Skip to content

Commit

Permalink
Encapsulate the io/file within a new app-relative fn
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrossley3 committed Jul 4, 2012
1 parent 9546c30 commit 4dce537
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions integration-tests/apps/ring/noir-app/immutant.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(ns noir-app.init
(:require [immutant.web :as web]
[immutant.utilities :as util]
[clojure.java.io :as io]
[noir.server :as server]))

(server/load-views (io/file (util/app-root) "src/noir_app/views"))
(server/load-views (util/app-relative "src/noir_app/views"))
(web/start "/" (server/gen-handler {:mode :dev :ns 'noir-app}))


5 changes: 2 additions & 3 deletions modules/core/src/main/clojure/immutant/runtime.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
(ns immutant.runtime
"This namespace is solely for use during the application runtime
bootstrapping process. Applications shouldn't use anything here."
(:require [clojure.java.io :as io]
[clojure.string :as str]
(:require [clojure.string :as str]
[clojure.tools.logging :as log]
[immutant.repl :as repl]
[immutant.utilities :as util]
Expand All @@ -41,7 +40,7 @@ bootstrapping process. Applications shouldn't use anything here."
tries to load an immutant.clj from the app-root. In either case, post-initialize is called
to finalize initialization."
[init-fn config-hash]
(let [init-file (io/file (util/app-root) "immutant.clj")
(let [init-file (util/app-relative "immutant.clj")
init-file-exists (.exists init-file)]
(if init-fn
(do
Expand Down
7 changes: 6 additions & 1 deletion modules/core/src/main/clojure/immutant/utilities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
(ns immutant.utilities
"Various utility functions."
(:require [immutant.registry :as lookup]
[clojure.string :as str])
[clojure.string :as str]
[clojure.java.io :as io])
(:import org.immutant.core.Closer))

(defn app-root
Expand All @@ -31,6 +32,10 @@
[]
(lookup/fetch "app-name"))

(defn app-relative
"Returns a file relative to app-root"
[& path]
(apply io/file (app-root) path))

(defn at-exit
"Registers a function to be called when the application is undeployed.
Expand Down

0 comments on commit 4dce537

Please sign in to comment.