Skip to content
Browse files

Add Drinkable impl for Readers, tests for it and Files.

  • Loading branch information...
1 parent 924c38c commit ae1a75f22f8ace5498dd1c7abb8a131b4cce558b @Raynes committed Oct 1, 2012
Showing with 12 additions and 3 deletions.
  1. +7 −2 src/conch/sh.clj
  2. +5 −1 test/conch/sh_test.clj
View
9 src/conch/sh.clj
@@ -34,11 +34,16 @@
(println x))))
(conch/done proc)))
+(extend-type java.io.Reader
+ Drinkable
+ (drink [r proc]
+ (conch/feed-from proc r)
+ (conch/done proc)))
+
(extend-type java.io.File
Drinkable
(drink [f proc]
- (conch/feed-from proc (io/reader f))
- (conch/done proc)))
+ (drink (io/reader f) proc)))
(extend-type java.lang.String
Drinkable
View
6 test/conch/sh_test.clj
@@ -52,4 +52,8 @@
(testing "Can input from string"
(is (= "hi" (cat {:in "hi"}))))
(testing "Can input a seq"
- (is (= "hi\nthere\n" (cat {:in ["hi" "there"]}))))))
+ (is (= "hi\nthere\n" (cat {:in ["hi" "there"]}))))
+ (testing "Can input a file"
+ (is (= "we\nwear\nshort\nshorts" (cat {:in (java.io.File. "test/testfiles/inputdata")}))))
+ (testing "Can input a reader"
+ (is (= "we\nwear\nshort\nshorts" (cat {:in (java.io.FileReader. "test/testfiles/inputdata")}))))))

0 comments on commit ae1a75f

Please sign in to comment.
Something went wrong with that request. Please try again.