Liking cljdoc? Tell your friends :D

hara.config.base.resolve


*current*clj


*path*clj


+config+clj


+hara-dir+clj


+project-dir+clj


+user-dir+clj


directive?clj

(directive? form)

checks if a form is a directive

(directive? "hello") => false

(directive? [:eval '(+ 1 2 3)]) => true

checks if a form is a directive

(directive? "hello") => false

(directive? [:eval '(+ 1 2 3)]) => true
raw docstring

ex-configclj

(ex-config msg)
(ex-config msg data)
(ex-config msg data e)

helper function for creating config exceptions

(ex-config "error" {})

helper function for creating config exceptions

(ex-config "error" {})
raw docstring

loadclj

(load)
(load file)

helper function for file resolvers

(load "dev/test/hara.config/config.edn") => map?

helper function for file resolvers

(load "dev/test/hara.config/config.edn")
=> map?
raw docstring

prewalkclj

(prewalk f form)

modified clojure.walk/prewalk function for config

modified clojure.walk/prewalk function for config
raw docstring

resolveclj

(resolve form)
(resolve form key)

helper function for resolve

(resolve 1) => 1

(resolve [:str ["hello" " " "there"]]) => "hello there"

helper function for resolve

(resolve 1) => 1

(resolve [:str ["hello" " " "there"]])
=> "hello there"
raw docstring

resolve-contentclj

(resolve-content
  content
  {:keys [secured key default format type] :as opts :or {type :text}})

resolves directive into content

(resolve-content "hello" {}) => "hello"

(resolve-content "hello" {:type :edn}) => 'hello

(resolve-content "yzRQQ+R5tWYeg7DNp9wvvA==" {:type :edn :secured true :key "Bz6i3dhp912F8+P82v1tvA=="}) => {:a 1, :b 2}

resolves directive into content

(resolve-content "hello" {}) => "hello"

(resolve-content "hello" {:type :edn}) => 'hello

(resolve-content "yzRQQ+R5tWYeg7DNp9wvvA=="
                 {:type :edn
                  :secured true
                  :key "Bz6i3dhp912F8+P82v1tvA=="})
=> {:a 1, :b 2}
raw docstring

resolve-directiveclj

(resolve-directive form)

resolves directives with error handling

(resolve-directive [:merge {:a 1} {:b 2}]) => {:a 1, :b 2}

resolves directives with error handling

(resolve-directive [:merge {:a 1} {:b 2}])
=> {:a 1, :b 2}
raw docstring

resolve-directive-caseclj

(resolve-directive-case [_ sel & pairs])

switches from the selected element

(System/setProperty "hara.config.profile" "dev")

(resolve-directive-case [:case [:properties "hara.config.profile"] "public" "public-profile" "dev" "dev-profile"]) => "dev-profile"

switches from the selected element

(System/setProperty "hara.config.profile" "dev")

(resolve-directive-case
 [:case [:properties "hara.config.profile"]
    "public" "public-profile"
    "dev"    "dev-profile"])
=> "dev-profile"
raw docstring

resolve-directive-envclj

(resolve-directive-env [_ env opts])

reads from system env

(resolve-directive-env [:env "HOME"]) ;; "/Users/chris" => string?

reads from system env

(resolve-directive-env [:env "HOME"])
;; "/Users/chris"
=> string?
raw docstring

resolve-directive-errorclj

(resolve-directive-error [_ msg error])

throws an error with message

(resolve-directive-error [:error "errored" {}]) => throws

throws an error with message

(resolve-directive-error [:error "errored" {}])
=> throws
raw docstring

resolve-directive-evalclj

(resolve-directive-eval [_ form])

evaluates a config form

(System/setProperty "hara.config.items" "3")

(resolve-directive-eval [:eval '(+ 1 2 [:properties "hara.config.items" {:type :edn}])]) => 6

evaluates a config form

(System/setProperty "hara.config.items" "3")

(resolve-directive-eval [:eval '(+ 1 2 
                                   [:properties "hara.config.items"
                                    {:type :edn}])])
=> 6
raw docstring

resolve-directive-fileclj

(resolve-directive-file [_ path opts])

resolves to file content

(resolve-directive-file [:file "dev/test/hara.config/hello.clear"]) => "hello"

resolves to file content

(resolve-directive-file
 [:file "dev/test/hara.config/hello.clear"])
=> "hello"
raw docstring

resolve-directive-formatclj

(resolve-directive-format [_ args opts])

formats values to form a string

(resolve-directive-format [:format ["http://%s:%s" "localhost" "8080"]]) => "http://localhost:8080"

formats values to form a string

(resolve-directive-format [:format ["http://%s:%s" "localhost" "8080"]])
=> "http://localhost:8080"
raw docstring

resolve-directive-globalclj

(resolve-directive-global [_ val opts])

resolves a directive form the global map

(resolve-directive-global [:global :user.name]) => string?

resolves a directive form the global map

(resolve-directive-global [:global :user.name])
=> string?
raw docstring

resolve-directive-includeclj

(resolve-directive-include [_ path opts])

resolves to either current project or config directory

(resolve-directive-include [:include "dev/test/hara.config/hello.clear" {:type :edn}]) => 'hello

resolves to either current project or config directory

(resolve-directive-include
 [:include "dev/test/hara.config/hello.clear" {:type :edn}])
=> 'hello
raw docstring

resolve-directive-mergeclj

(resolve-directive-merge [_ & args])

merges two entries together

(resolve-directive-merge [:merge {:a {:b 1}} {:a {:c 2}}]) => {:a {:c 2}}

merges two entries together

(resolve-directive-merge [:merge
                          {:a {:b 1}}
                          {:a {:c 2}}])
=> {:a {:c 2}}
raw docstring

resolve-directive-orclj

(resolve-directive-or [_ & args])

reads from the first non-nil value

(resolve-directive-or [:or [:env "SERVER"] "<server>"]) => "<server>"

reads from the first non-nil value

(resolve-directive-or [:or [:env "SERVER"] "<server>"])
=> "<server>"
raw docstring

resolve-directive-parentclj

(resolve-directive-parent [_ val opts])

resolves a directive from the map parent

(binding [current [{:a {:b [:eval "hello"]}} {:b [:eval "hello"]}]] (resolve-directive-parent [:parent :b])) => "hello"

resolves a directive from the map parent

(binding [*current* [{:a {:b [:eval "hello"]}}
                     {:b [:eval "hello"]}]]
  (resolve-directive-parent [:parent :b]))
=> "hello"
raw docstring

resolve-directive-projectclj

(resolve-directive-project [_ proj opts])

reads form the project

(resolve-directive-project [:project :name] ) => 'hara

reads form the project

(resolve-directive-project [:project :name] )
=> 'hara
raw docstring

resolve-directive-propertiesclj

(resolve-directive-properties [_ property opts])

reads from system properties

(resolve-directive-properties [:properties "user.name"]) ;; "chris" => string?

reads from system properties

(resolve-directive-properties [:properties "user.name"])
;; "chris"
=> string?
raw docstring

resolve-directive-resourceclj

(resolve-directive-resource [_ path opts])

resolves to resource content

(resolve-directive-resource [:resource "dev/test/hara.config/hello.clear"]) => "hello"

resolves to resource content

(resolve-directive-resource
 [:resource "dev/test/hara.config/hello.clear"])
=> "hello"
raw docstring

resolve-directive-rootclj

(resolve-directive-root [_ val opts])

resolves a directive from the config root

(binding [current [{:a {:b [:eval "hello"]}}]] (resolve-directive-root [:root [:a :b]])) => "hello"

resolves a directive from the config root

(binding [*current* [{:a {:b [:eval "hello"]}}]]
  (resolve-directive-root [:root [:a :b]]))
=> "hello"
raw docstring

resolve-directive-strclj

(resolve-directive-str [_ args opts])

joins values to form a string

(resolve-directive-str [:str ["hello" [:env "SPACE" {:default " "}] "world"]]) => "hello world"

joins values to form a string

(resolve-directive-str [:str ["hello"
                              [:env "SPACE" {:default " "}]
                             "world"]])
=> "hello world"
raw docstring

resolve-mapclj

(resolve-map input form)

resolves a map

(resolve-map {:a {:b [:eval "hello"]}} [:a :b]) => "hello"

resolves a map

(resolve-map {:a {:b [:eval "hello"]}}
             [:a :b])
=> "hello"
raw docstring

resolve-pathclj

(resolve-path path)

helper function for file resolvers

(resolve-path ["config/" [:eval "hello"]]) => "config/hello"

helper function for file resolvers

(resolve-path ["config/" [:eval "hello"]])
=> "config/hello"
raw docstring

resolve-typeclj

(resolve-type type content)

converts a string to a type

(resolve-type :text "3") => "3"

(resolve-type :edn "3") => 3

converts a string to a type

(resolve-type :text "3")
=> "3"  

(resolve-type :edn "3")
=> 3
raw docstring

walkclj

(walk inner outer form)

modified clojure.walk/walk function for config

modified clojure.walk/walk function for config
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close