Skip to content

Commit

Permalink
Remove tagged-literal functions.
Browse files Browse the repository at this point in the history
These clash with clojure 1.7 built-ins, and aren't actually used by the
rest of the code. Fixes #20.
  • Loading branch information
greglook committed Apr 25, 2015
1 parent f07ff16 commit f830588
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 64 deletions.
47 changes: 2 additions & 45 deletions src/puget/data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,7 @@
(->edn
[value]
"Converts the given value into a tagged value representation for EDN
serialization. Returns a `TaggedLiteral` record."))


; TODO: remove this when CLJ-1424 merges
; http://dev.clojure.org/jira/browse/CLJ-1424
(defrecord TaggedLiteral
[tag form]

ExtendedNotation

(->edn
[this]
this)


Object

(toString
[this]
(str \# tag \space (pr-str form))))


;; Remove automatic constructor functions.
(ns-unmap *ns* '->TaggedLiteral)
(ns-unmap *ns* 'map->TaggedLiteral)


(defmethod print-method TaggedLiteral
[v ^java.io.Writer w]
(.write w (str v)))


(defn tagged-literal
"Creates a generic tagged value record to represent some EDN value. This is
suitable for use as a default-data-reader function."
[tag value]
{:pre [(symbol? tag)]}
(TaggedLiteral. tag value))


(defn tagged-literal?
"Returns true if the given value is a tagged-literal form."
[value]
(instance? TaggedLiteral value))
serialization. Should return a value with a `:tag` and a `:form`."))



Expand All @@ -70,7 +27,7 @@
ExtendedNotation
(->edn
[this#]
(tagged-literal ~tag (value-fn# this#))))))
(array-map :tag ~tag :form (value-fn# this#))))))


(defmacro extend-tagged-str
Expand Down
12 changes: 0 additions & 12 deletions test/puget/data_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@
'uuid "96d91316-53b9-4800-81c1-97ae9f4b86b0"))


(deftest generic-tagged-literal
(let [data (data/tagged-literal 'foo :bar)
{:keys [tag form]} (data/->edn data)
string (str data)]
(is (data/tagged-literal? data))
(is (= 'foo tag))
(is (= :bar form))
(is (= "#foo :bar" string))
(is (= "#foo :bar" (pr-str data)))
(is (= data (edn/read-string {:default data/tagged-literal} string)))))


(defrecord TestRecord [x y])
(data/extend-tagged-map TestRecord 'test/record)
(deftest tagged-literal-extension
Expand Down
7 changes: 0 additions & 7 deletions test/puget/printer_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@
(pprint-str v))))))


(deftest formatting-tagged-literals
(let [tv (data/tagged-literal 'foo :bar/baz)]
(is (= "#foo :bar/baz" (pprint-str tv))))
(let [tv (data/tagged-literal 'frobble/biznar [:foo :bar :baz])]
(is (= "#frobble/biznar\n[:foo :bar :baz]" (pprint-str tv)))))


(deftype ComplexValue []
Object
(toString [_] "to-string"))
Expand Down

0 comments on commit f830588

Please sign in to comment.