Permalink
Browse files

Allow for a solution directory to be specified.

  • Loading branch information...
1 parent f974d1e commit 703b03b0e6cb213f6ec3d2aff497cdd580e3980b @mudge committed Mar 29, 2013
Showing with 17 additions and 13 deletions.
  1. +3 −2 README.md
  2. +7 −4 src/foreclojure_downloader/core.clj
  3. +7 −7 src/foreclojure_downloader/writer.clj
View
@@ -5,8 +5,8 @@ tests using [Midje](https://github.com/marick/Midje).
## Usage
-Currently, the downloader will store all downloaded problem files under
-`src/foreclojure_solutions`.
+Use `lein run` to create tests under `src/foreclojure_solutions` by default.
+This can be overridden by passing a path to `run`, e.g. `lein run solutions`.
```console
$ git clone git://github.com/mudge/foreclojure-downloader.git
@@ -20,3 +20,4 @@ $ lein run
Copyright © 2013 Paul Mucur
Distributed under the Eclipse Public License, the same as Clojure.
+
@@ -7,7 +7,10 @@
[]
(filter identity (pmap api/problem (range 1 200))))
-(defn -main []
- (doseq [problem (problems)]
- (println "Writing problem" (:number problem) (:title problem))
- (writer/write-problem problem)))
+(defn -main
+ ([] (-main "src/foreclojure_solutions"))
+ ([path]
+ (doseq [problem (problems)]
+ (println "Writing problem" (:number problem) (:title problem))
+ (writer/write-problem problem path))))
+
@@ -2,15 +2,15 @@
(:require [foreclojure-downloader.translator :as translator]))
(defn- file-name
- "Return the file name for the given problem."
- [problem]
- (str "src/foreclojure_solutions/p" (:number problem) ".clj"))
+ "Return the file name for the given problem and path."
+ [problem path]
+ (java.io.File. path (str "p" (:number problem) ".clj")))
(defn write-problem
- "Write the given problem to disk."
- [problem]
- (let [dir (java.io.File. "src/foreclojure_solutions")]
+ "Write the given problem to the given path"
+ [problem path]
+ (let [dir (java.io.File. path)]
(when-not (.exists dir) (.mkdirs dir))
- (spit (file-name problem) (translator/problem-test problem))
+ (spit (file-name problem path) (translator/problem-test problem))
problem))

0 comments on commit 703b03b

Please sign in to comment.