 (ns com.nomistech.clojure-the-language.c-920-io.tailing
   (:require [clojure.core.async :as a]
+            [clojure.java.io :as io]
             [clojure.string :as str]
             [midje.sweet :refer :all])
   (:import (java.io File)

  (.stop tailer)
  (a/close! channel))

(fact (let [lines     ["a" "b" "c" "d" "e"]
            file      (File. "test/_work-dir/plop.log")
            t-and-c   (tailer-and-channel file 100)
            result-ch (a/thread (doall (tailer-and-channel->seq t-and-c)))]
        (Thread/sleep 1000)
        (spit file "")
        (spit file (str (str/join "\n" lines)
                        "\n"))
        (Thread/sleep 1000)
        (println "Stopping")
        (stop-tailer-and-channel t-and-c)
        (a/<!! result-ch)
        => lines))

;; TODO
;; Check that bug.

  (reify TailerListener
    (init [this tailer] ())
    (fileNotFound [this]
      ;; (println "File not found")
      )
    (fileRotated [this]
      ;; (println "Rotation detected")
      )
    (^void handle [this ^String line]
     (a/>!! c line))
    (^void handle [this ^Exception i]
