Created
July 21, 2013 20:15
-
-
Save jcf/6049807 to your computer and use it in GitHub Desktop.
Download fixtures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns leiningen.company-fixtures | |
(:require [leiningen.core.project :as project] | |
[me.raynes.fs :as fs] | |
[me.raynes.fs.compression :as compress] | |
[clojure.java.io :as io])) | |
(def ^:const url | |
"http://example-company.com/url.zip") | |
(defn- expand-path [path] | |
(str (fs/normalized-path path))) | |
(def fixture-path | |
(expand-path (io/file "./test/fixtures" (fs/base-name url)))) | |
(defn- unzip [path] | |
(compress/unzip path)) | |
(defn- download [from to] | |
(io/copy (io/input-stream from) (io/output-stream to))) | |
(defn- download-if-missing [from to] | |
(if-not (fs/exists? to) (download from to))) | |
(defn company-fixtures [_] | |
(download-if-missing url fixture-path) | |
(unzip fixture-path)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment