项目作者: michaelklishin

项目描述 :
Tiny Clojure library for working with Java property lists (java.util.Properties)
高级语言: Clojure
项目地址: git://github.com/michaelklishin/propertied.git
创建时间: 2013-08-31T23:24:14Z
项目社区:https://github.com/michaelklishin/propertied

开源协议:

下载


What is Propertied

Propertied is a tiny Clojure library that deals with Java property
lists.

Project Maturity

Propertied is not a young project and unlikely to radically change
(it is too small in scope).

Artifacts

Propertied artifacts are released to
Clojars
. If you are
using Maven, add the following repository definition to your
pom.xml:

  1. <repository>
  2. <id>clojars.org</id>
  3. <url>http://clojars.org/repo</url>
  4. </repository>

The Most Recent Release

With Leiningen:

Clojars Project

With Maven:

  1. <dependency>
  2. <groupId>clojurewerkz</groupId>
  3. <artifactId>propertied</artifactId>
  4. <version>1.3.0</version>
  5. </dependency>

Documentation & Examples

Propertied makes it easy to convert property lists
(java.util.Properties) into Clojure maps and vice versa. Thus
working with property lists is generally as straightforward as working
with maps.

clojurewerkz.propertied.properties/load-from is a polymorphic
function that instantiates a property list from an input (e.g. a map
or property file).

clojurewerkz.propertied.properties/store-to takes a map and stores
it into a .properties file (an output stream or anything else that
can be coerced to java.io.Writer).

clojurewerkz.propertied.properties/properties->map is a function
that converts a java.util.Properties to an immutable
map. clojurewerkz.propertied.properties/map->properties converts the
opposite way.

  1. (require '[clojurewerkz.propertied.properties :as p])
  2. (p/load-from {"a key" "a value"})
  3. ;= {"a key" "a value"}
  4. (class (p/load-from {"a key" "a value"}))
  5. ;= java.util.Properties
  6. (let [pl (p/load-from {"a key" "a value"})]
  7. (p/properties->map pl))
  8. ;= {"a key" "a value"}
  9. ;; converting keys to keywords
  10. (let [pl (p/load-from {"key" "a value"})]
  11. (p/properties->map pl true))
  12. ;= {:key "a value"}
  13. ;; loading from files and InputStreams
  14. (require '[clojure.java.io :as io])
  15. (p/load-from (io/resource "resource/on/classpath.properties"))
  16. (p/load-from (io/file "resource/on/classpath.properties"))
  17. ;; storing to property files (.properties)
  18. (p/store-to {"name" "Michael" "age" "28"} "/tmp/michael.properties")
  19. (p/store-to {"name" "Michael" "age" "28"} (io/file "/tmp/michael.properties"))
  20. (p/store-to {"name" "Michael" "age" "28"} (java.io.File/createTempFile "michael" ".properties"))

Community

To subscribe for announcements of releases, important changes and so
on, please follow @ClojureWerkz
on Twitter.

Supported Clojure Versions

Propertied requires Clojure 1.6.

Continuous Integration Status

Continuous Integration
status

Propertied Is a ClojureWerkz Project

Propertied is part of the group of Clojure libraries known as ClojureWerkz, together with

and several others.

Development

propertied uses Leiningen
2
. Make
sure you have it installed and then run tests against supported
Clojure versions using

  1. lein all test

Then create a branch and make your changes on it. Once you are done
with your changes and all tests pass, submit a pull request on GitHub.

License

Copyright (C) 2013-2017 Michael S. Klishin, Alex Petrov, and the ClojureWerkz team.

Double licensed under the Eclipse Public License (the same as Clojure) or
the Apache Public License 2.0.