fix strings in key map portability
This commit is contained in:
parent
8a33982450
commit
08f3f69909
2 changed files with 6 additions and 9 deletions
|
@ -2,16 +2,13 @@
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as str]))
|
[clojure.string :as str]))
|
||||||
|
|
||||||
(defn write-key
|
(def write-key name)
|
||||||
[x]
|
|
||||||
(cond
|
|
||||||
(string? x) (str "\"" x "\"")
|
|
||||||
:else (name x)))
|
|
||||||
|
|
||||||
(defn read-key
|
(defn read-key
|
||||||
|
"don't keywordize keys with / or ."
|
||||||
[x]
|
[x]
|
||||||
(if-let [y (re-seq #"^\"(.*)\"$" x)]
|
(if (re-matches #".*[/.].*" x)
|
||||||
(-> y first second)
|
x
|
||||||
(keyword x)))
|
(keyword x)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
(fact "write-key should work fine."
|
(fact "write-key should work fine."
|
||||||
(write-key :foo) => "foo"
|
(write-key :foo) => "foo"
|
||||||
(write-key "foo") => "\"foo\"")
|
(write-key "foo") => "foo")
|
||||||
|
|
||||||
(fact "read-key should work fine."
|
(fact "read-key should work fine."
|
||||||
(read-key "foo") => :foo
|
(read-key "foo") => :foo
|
||||||
(read-key "\"foo\"") => "foo")
|
(read-key "foo/bar") => "foo/bar")
|
||||||
|
|
Loading…
Reference in a new issue