Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b22d3a150d
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (41 sloc) 1.562 kb
(ns leiningen.utils
(:require [clojure.string])
(:use [clojure.java.io]))
;;From the maginalia source: http://fogus.me/fun/marginalia/
(defn slurp-resource
[resource-name]
(try
(-> (.getContextClassLoader (Thread/currentThread))
(.getResourceAsStream resource-name)
(java.io.InputStreamReader.)
(slurp))
(catch java.lang.NullPointerException npe
(println (str "Could not locate resources at " resource-name))
(println " ... attempting to fix.")
(let [resource-name (str "./resources/" resource-name)]
(try
(-> (.getContextClassLoader (Thread/currentThread))
(.getResourceAsStream resource-name)
(java.io.InputStreamReader.)
(slurp))
(catch java.lang.NullPointerException npe
(println (str " STILL could not locate resources at " resource-name ". Giving up!"))))))))
(defn ->file [path-to-file content]
"Quick create new file with directory structure"
(let [path (clojure.string/replace path-to-file "-" "_")]
(.mkdirs (.getParentFile (file path)))
(spit
(file path) content)))
(defn make-path [entity]
(-> (str entity)
(clojure.string/replace "." "/")
(clojure.string/replace "-" "_")))
(defn make-form-name [entity]
(-> (str entity)
(clojure.string/replace "-" "_")
(clojure.string/replace "." "-")))
(defn make-title [entity]
(-> (str entity)
(clojure.string/replace "." " >> ")
(clojure.string/replace "-" " > ")
(clojure.string/capitalize)))
Jump to Line
Something went wrong with that request. Please try again.