Skip to content

Commit

Permalink
Made file paths in config relative to config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
aroemers committed Nov 1, 2012
1 parent 381c817 commit 5cff9b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -177,7 +177,6 @@ verbose: false

## Future improvements

* Make 'glue' paths in the config relative to the configuration file.
* Generics support
* Plain, adapter-less injections
* Plug-in system
Expand Down
2 changes: 1 addition & 1 deletion src-java/test/bind.config
@@ -1,7 +1,7 @@
This is a test configuration file. Below, the gluer files are specified. The
paths to these files are relative to this configuration file.

glue: src-java/test/bind.gluer
glue: bind.gluer


Other options can be specified as well.
Expand Down
3 changes: 2 additions & 1 deletion src/gluer/agent.clj
Expand Up @@ -12,6 +12,7 @@
[gluer.resources :as r]
[gluer.runtime :as runtime]
[gluer.config :as c]
[gluer.core :as core]
[clojure.string :as s])
(:use [gluer.clauses]
[gluer.logging])
Expand Down Expand Up @@ -97,7 +98,7 @@
(with-redefs [*verbose* (:verbose config)]
(log-verbose "Parsing .gluer files and searching for Adapters...")
;; Parse the files and check for parse errors.
(let [parsed (r/parse-gluer-files (:glue config))
(let [parsed (r/parse-gluer-files (core/absolutise agent-args (:glue config)))
erroneous (filter (comp :error :parsed) parsed)]
(if (not (empty? erroneous))
(do (doseq [error erroneous]
Expand Down
12 changes: 11 additions & 1 deletion src/gluer/core.clj
Expand Up @@ -92,6 +92,16 @@
(catch InterruptedException ex
(println "Errors detected. Fix above errors and re-run the check."))))


;;; Helper functions.

(defn absolutise ;--- Move this to a utility namespace?
[root-file file-names]
(let [root-url (java.net.URL. (str "file:" root-file))]
(for [file-name file-names]
(.getFile (java.net.URL. root-url file-name)))))


;;; The main entry point.

(defn -main ;--- Maybe reading a JAR file containing .config, .gluer and Adapters is also nice?
Expand All @@ -104,6 +114,6 @@
(if-let [config (try (c/read-config (slurp config-file-name))
(catch java.io.IOException ioe))]
(with-redefs [*verbose* (or verbose (and (nil? verbose) (:verbose config)))]
(check (:glue config)))
(check (absolutise config-file-name (:glue config))))
(println "Could not find or open file:" config-file-name))
(display-help-text banner)))))

0 comments on commit 5cff9b6

Please sign in to comment.