Sosueme (pronounced "So, sue me!") is a collection of Clojure functions for things we like to do.
The jar is available on Clojars at http://clojars.org/factual/sosueme .
Include it in your project.clj :dependencies:
[factual/sosueme "0.0.14"]
Sosueme provides the following functionalily, organized by namesapce:
Simple convenience functions for loading in file and resource based configuration data.
Takes a path to a file on the classpath, interprets the contents of the file as Clojure data, and returns the result. Example:
(println (:host (load-when "myconf.clj")))
Loads and merges configuration from a specified path into current configuration data. This allows you to conveniently build up configuration data and refer to it from anywhere in your application.
Returns the value of a specific key, from current configuration data.
Returns all configuration data that was loaded via load-file!.
Say you have a file called myconf.clj with this content...
{:host "my.server.com"
:port 8081}
...then your app could do this:
(conf/load-file! "myconf.clj")
(let [host (conf/get-key :host)]
... )
Hawaiian style functions!
Example:
> (repeatedly 6 newname)
("kiwihei" "nehe" "naimaiku" "lahehei" "wenani" "haikimi")
I/O stuff, e.g. load content from the classpath.
Slurps content from the classpath. Example:
(slurp-cp "somefile.txt")
Nnetworking stuff, e.g. get local hostname.
Returns your local host name.
System stuff, e.g. get current process id.
Returns the current process's PID, as a String.
Time stuff, e.g. get Unix epoch value for "25 minutes ago".
Returns the Unix epoch value for the current time.
Returns the Unix epoch value for N minutes ago. Example:
(minutes-ago 25)
Text handling stuff.
Uses Clojure's pprint to return a prettily formatted String representation of data, including line breaks for readability.
Example use:
(println (pretty {:a "b" :b "this is b it is a long thing" :c {:x "X" :y '(this is a long list of things)}}))
Returns, as a String, the formatted stack trace from a throwable. Example use:
;; Assuming you have an Exception instance, e
(let [msg (stack-trace-str e)]
;; do something with msg, such as put it in a log
)
The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file LICENSE.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.