Skip to content

Instantly share code, notes, and snippets.

@jcf
Created July 21, 2013 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcf/6049807 to your computer and use it in GitHub Desktop.
Save jcf/6049807 to your computer and use it in GitHub Desktop.
Download fixtures
(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