Skip to content

Commit

Permalink
Merge branch 'release-0.6.1'
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
	project.clj
  • Loading branch information
greglook committed Jun 25, 2014
2 parents a98585d + c9cb805 commit eafc760
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Puget

[![Build Status](https://travis-ci.org/greglook/puget.svg?branch=master)](https://travis-ci.org/greglook/puget)
[![Coverage Status](https://coveralls.io/repos/greglook/puget/badge.png?branch=master)](https://coveralls.io/r/greglook/puget?branch=master)
[![Dependency Status](https://www.versioneye.com/user/projects/53718bfb14c1589a89000144/badge.png)](https://www.versioneye.com/clojure/mvxcvi:puget/0.6.0)
[![Dependency Status](https://www.versioneye.com/user/projects/53718bfb14c1589a89000144/badge.png)](https://www.versioneye.com/clojure/mvxcvi:puget/0.6.1)

Puget is a Clojure library for printing [EDN](https://github.com/edn-format/edn)
values. Under the hood, Puget formats data into a _print document_ and uses the
Expand All @@ -20,7 +20,7 @@ To use this version with Leiningen, add the following dependency to your project
definition:

```clojure
[mvxcvi/puget "0.6.0"]
[mvxcvi/puget "0.6.1"]
```

## Syntax Coloring
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject mvxcvi/puget "0.6.0"
(defproject mvxcvi/puget "0.6.1"
:description "Colorizing canonical Clojure printer for EDN values."
:url "https://github.com/greglook/puget"
:license {:name "Public Domain"
Expand Down
23 changes: 21 additions & 2 deletions src/puget/printer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,36 @@
:class-name [:bold :blue]}})


(defn merge-options
"Merges a map of options into the current option map, taking care to combine
the color scheme correctly."
[opts]
(let [colors (merge (:color-scheme *options*)
(:color-scheme opts))]
(-> *options*
(merge opts)
(assoc :color-scheme colors))))


(defmacro with-options
"Executes the given expressions with a set of options merged into the current
option map."
[opts & body]
`(binding [*options* (merge-options ~opts)]
~@body))


(defmacro with-color
"Executes the given expressions with colored output enabled."
[& body]
`(binding [*options* (assoc *options* :print-color true)]
`(with-options {:print-color true}
~@body))


(defmacro with-strict-mode
"Executes the given expressions with strict mode enabled."
[& body]
`(binding [*options* (assoc *options* :strict true)]
`(with-options {:strict true}
~@body))


Expand Down

0 comments on commit eafc760

Please sign in to comment.