Skip to content

Commit

Permalink
Merge branch 'release-0.6.4'
Browse files Browse the repository at this point in the history
Conflicts:
	project.clj
  • Loading branch information
greglook committed Sep 24, 2014
2 parents fde6432 + b6a50cf commit 36d49b1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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.3)
[![Dependency Status](https://www.versioneye.com/user/projects/53718bfb14c1589a89000144/badge.png)](https://www.versioneye.com/clojure/mvxcvi:puget/0.6.4)

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 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.3"
(defproject mvxcvi/puget "0.6.4"
:description "Colorizing canonical Clojure printer for EDN values."
:url "https://github.com/greglook/puget"
:license {:name "Public Domain"
Expand Down
32 changes: 32 additions & 0 deletions src/puget/printer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@
(color-doc :symbol (subs (str value) 2))])


(defmethod canonize clojure.lang.IDeref
[value]
(illegal-when-strict value)
[:span
(color-doc :class-delimiter "#<")
(color-doc :class-name (.getName (class value)))
(color-doc :class-delimiter "@")
(system-id value) " "
(canonize @value)
(color-doc :class-delimiter ">")])


(defmethod canonize clojure.lang.Atom
[value]
(illegal-when-strict value)
Expand All @@ -289,6 +301,20 @@
(color-doc :class-delimiter ">")])


(defmethod canonize clojure.lang.IPending
[value]
(illegal-when-strict value)
[:span
(color-doc :class-delimiter "#<")
(color-doc :class-name (.getName (class value)))
(color-doc :class-delimiter "@")
(system-id value) " "
(if (realized? value)
(canonize @value)
(color-doc :nil "pending"))
(color-doc :class-delimiter ">")])


(defmethod canonize clojure.lang.Delay
[value]
(illegal-when-strict value)
Expand Down Expand Up @@ -317,6 +343,12 @@
(color-doc :class-delimiter ">")])


(prefer-method canonize clojure.lang.ISeq clojure.lang.IPending)
(prefer-method canonize clojure.lang.IPending clojure.lang.IDeref)
(prefer-method canonize java.util.concurrent.Future clojure.lang.IDeref)
(prefer-method canonize java.util.concurrent.Future clojure.lang.IPending)



;;;;; OTHER TYPES ;;;;;

Expand Down
22 changes: 21 additions & 1 deletion test/puget/printer_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@
(is (= "#puget.printer_test.TestRecord{:bar \\y, :foo \\x}\n"
(with-out-str (pprint r)))))))

(deftype ADeref []
clojure.lang.IDeref
(deref [this] 123))

(deftype APending []
clojure.lang.IPending
(isRealized [this] false))

(deftest clojure-types
(testing "seq"
(is (= "()" (pprint-str (lazy-seq)))))
(testing "regex"
(let [v #"\d+"]
(should-fail-when-strict v)
Expand All @@ -89,7 +98,18 @@
(should-fail-when-strict v)
(is (re-seq #"#<Future@[0-9a-f]+ pending>" (pprint-str v)))
(is (= :done @v))
(is (re-seq #"#<Future@[0-9a-f]+ :done>" (pprint-str v))))))
(is (re-seq #"#<Future@[0-9a-f]+ :done>" (pprint-str v)))))
(testing "custom IDeref"
(let [v (ADeref.)]
(should-fail-when-strict v)
(is (re-seq #"#<puget.printer_test.ADeref@[0-9a-f]+ 123>"
(pprint-str v)))))
(testing "custom IPending"
(let [v (APending.)]
(should-fail-when-strict v)
(is (re-seq #"#<puget.printer_test.APending@[0-9a-f]+ pending"
(pprint-str v)))))
)


(deftest canonical-tagged-value
Expand Down

0 comments on commit 36d49b1

Please sign in to comment.