GithubHelp home page GithubHelp logo

lotuc / clojurewerkz_propertied Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michaelklishin/propertied

0.0 1.0 0.0 47 KB

Tiny Clojure library for working with Java property lists (java.util.Properties)

Clojure 100.00%

clojurewerkz_propertied's Introduction

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:

<repository>
  <id>clojars.org</id>
  <url>http://clojars.org/repo</url>
</repository>

The Most Recent Release

With Leiningen:

Clojars Project

With Maven:

<dependency>
  <groupId>clojurewerkz</groupId>
  <artifactId>propertied</artifactId>
  <version>1.3.0</version>
</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.

(require '[clojurewerkz.propertied.properties :as p])

(p/load-from {"a key" "a value"})
;= {"a key" "a value"}
(class (p/load-from {"a key" "a value"}))
;= java.util.Properties
(let [pl (p/load-from {"a key" "a value"})]
  (p/properties->map pl))
;= {"a key" "a value"}

;; converting keys to keywords
(let [pl (p/load-from {"key" "a value"})]
  (p/properties->map pl true))
;= {:key "a value"}

;; loading from files and InputStreams
(require '[clojure.java.io :as io])

(p/load-from (io/resource "resource/on/classpath.properties"))
(p/load-from (io/file "resource/on/classpath.properties"))

;; storing to property files (.properties)
(p/store-to {"name" "Michael" "age" "28"} "/tmp/michael.properties")
(p/store-to {"name" "Michael" "age" "28"} (io/file "/tmp/michael.properties"))
(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

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.

clojurewerkz_propertied's People

Contributors

agarciasc avatar aisamu avatar alvarogarcia7 avatar lotuc avatar michaelklishin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.