Remove implicit regex functionality.
This commit is contained in:
parent
efaeff4fc5
commit
98c7510d1c
3 changed files with 12 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
## 1.0.5-SNAPSHOT
|
## 1.0.5-SNAPSHOT
|
||||||
|
|
||||||
* Add implicit navigator for regexes, which navigate to every match in a string and support replacement with a new substring.
|
* Add `regex-nav` navigator for regexes, which navigate to every match in a string and support replacement with a new substring.
|
||||||
|
|
||||||
## 1.0.4
|
## 1.0.4
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1177,10 +1177,6 @@
|
||||||
ImplicitNav
|
ImplicitNav
|
||||||
(implicit-nav [this] (pred this)))
|
(implicit-nav [this] (pred this)))
|
||||||
|
|
||||||
(extend-type #?(:clj java.util.regex.Pattern :cljs js/RegExp)
|
|
||||||
ImplicitNav
|
|
||||||
(implicit-nav [this] (regex-nav this)))
|
|
||||||
|
|
||||||
(defnav
|
(defnav
|
||||||
^{:doc "Navigates to the provided val if the structure is nil. Otherwise it stays
|
^{:doc "Navigates to the provided val if the structure is nil. Otherwise it stays
|
||||||
navigated at the structure."}
|
navigated at the structure."}
|
||||||
|
|
|
||||||
|
|
@ -1435,17 +1435,17 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(deftest regex-navigation-test
|
(deftest regex-navigation-test
|
||||||
(is (= (select #"t" "test") ["t" "t"]))
|
(is (= (select (s/regex-nav #"t") "test") ["t" "t"]))
|
||||||
(is (= (select [:a #"t"] {:a "test"}) ["t" "t"]))
|
(is (= (select [:a (s/regex-nav #"t")] {:a "test"}) ["t" "t"]))
|
||||||
(is (= (transform #"t" clojure.string/capitalize "test") "TesT"))
|
(is (= (transform (s/regex-nav #"t") clojure.string/capitalize "test") "TesT"))
|
||||||
(is (= (transform [:a #"t"] clojure.string/capitalize {:a "test"}) {:a "TesT"}))
|
(is (= (transform [:a (s/regex-nav #"t")] clojure.string/capitalize {:a "test"}) {:a "TesT"}))
|
||||||
(is (= (transform #"\s+\w" clojure.string/triml "Hello World!") "HelloWorld!"))
|
(is (= (transform (s/regex-nav #"\s+\w") clojure.string/triml "Hello World!") "HelloWorld!"))
|
||||||
(is (= (setval #"t" "z" "test") "zesz"))
|
(is (= (setval (s/regex-nav #"t") "z" "test") "zesz"))
|
||||||
(is (= (setval [:a #"t"] "z" {:a "test"}) {:a "zesz"}))
|
(is (= (setval [:a (s/regex-nav #"t")] "z" {:a "test"}) {:a "zesz"}))
|
||||||
(is (= (transform #"aa*" (fn [s] (-> s count str)) "aadt") "2dt"))
|
(is (= (transform (s/regex-nav #"aa*") (fn [s] (-> s count str)) "aadt") "2dt"))
|
||||||
(is (= (transform #"[Aa]+" (fn [s] (apply str (take (count s) (repeat "@")))) "Amsterdam Aardvarks") "@msterd@m @@rdv@rks"))
|
(is (= (transform (s/regex-nav #"[Aa]+") (fn [s] (apply str (take (count s) (repeat "@")))) "Amsterdam Aardvarks") "@msterd@m @@rdv@rks"))
|
||||||
(is (= (select [#"(\S+):\ (\d+)" (s/nthpath 2)] "Mary: 1st George: 2nd Arthur: 3rd") ["1" "2" "3"]))
|
(is (= (select [(s/regex-nav #"(\S+):\ (\d+)") (s/nthpath 2)] "Mary: 1st George: 2nd Arthur: 3rd") ["1" "2" "3"]))
|
||||||
(is (= (transform (s/subselect #"\d\w+") reverse "Mary: 1st George: 2nd Arthur: 3rd") "Mary: 3rd George: 2nd Arthur: 1st"))
|
(is (= (transform (s/subselect (s/regex-nav #"\d\w+")) reverse "Mary: 1st George: 2nd Arthur: 3rd") "Mary: 3rd George: 2nd Arthur: 1st"))
|
||||||
)
|
)
|
||||||
|
|
||||||
(deftest single-value-none-navigators-test
|
(deftest single-value-none-navigators-test
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue