@@ -19,7 +19,7 @@ __This project is in flux. Anything may change at any time.__
19
19
__ Leiningen ([ via Clojars] ( http://clojars.org/rewrite-clj ) )__
20
20
21
21
``` clojure
22
- [rewrite-clj " 0.1 .0" ]
22
+ [rewrite-clj " 0.2 .0" ]
23
23
```
24
24
25
25
__ Parsing Data__
@@ -62,7 +62,7 @@ operations, based on [fast-zip](https://github.com/akhudek/fast-zip).
62
62
" (defn my-function [a]
63
63
;; a comment
64
64
(* a 3))" )
65
- (def data (z/edn ( p/parse -string data-string) ))
65
+ (def data (z/of -string data-string))
66
66
67
67
(z/sexpr data) ; ; => (defn my-function [a] (* a 3))
68
68
(-> data z/down z/right z/node) ; ; => [:token my-function]
@@ -71,7 +71,7 @@ operations, based on [fast-zip](https://github.com/akhudek/fast-zip).
71
71
(-> data z/down z/right (z/edit (comp symbol str) " 2" ) z/up z/sexpr)
72
72
; ; => (defn my-function2 [a] (* a 3))
73
73
74
- (-> data z/down z/right (z/edit (comp symbol str) " 2" ) z/root prn/ print-edn )
74
+ (-> data z/down z/right (z/edit (comp symbol str) " 2" ) z/print-root )
75
75
; ; (defn my-function2 [a]
76
76
; ; ;; a comment
77
77
; ; (* a 3))
@@ -102,7 +102,7 @@ use `rewrite-clj.zip/next`, if you wanted to look for something on the same leve
102
102
Now, to enter the project map, you'd look for the symbol ` defproject ` in a depth-first way:
103
103
104
104
``` clojure
105
- (def data (z/edn ( p/parse -file " project.clj" ) ))
105
+ (def data (z/of -file " project.clj" ))
106
106
(def prj-map (z/find-value data z/next 'defproject))
107
107
```
108
108
@@ -116,7 +116,7 @@ The `:description` keyword should be on the same layer, the corresponding string
116
116
Replace it, zip up and print the result:
117
117
118
118
``` clojure
119
- (-> descr (z/replace " My first Project." ) z/root prn/ print-edn )
119
+ (-> descr (z/replace " My first Project." ) z/print-root )
120
120
; ; (defproject my-project "0.1.0-SNAPSHOT"
121
121
; ; :description "My first Project."
122
122
; ; ...)
@@ -144,14 +144,14 @@ rewrite-clj aims at providing easy ways to work with Clojure data structures. It
144
144
to the standard seq functions designed to work with zipper nodes containing said structures, e.g.:
145
145
146
146
``` clojure
147
- (def data (z/edn ( p/parse -string " [1\n 2\n 3]" ) ))
147
+ (def data (z/of -string " [1\n 2\n 3]" ))
148
148
149
149
(z/vector? data) ; ; => true
150
150
(z/sexpr data) ; ; => [1 2 3]
151
151
(-> data (z/get 1 ) z/node) ; ; => [:token 2]
152
152
(-> data (z/assoc 1 5 ) z/sexpr) ; ; => [1 5 3]
153
153
154
- (with-out-str ( - >> data (z/map #(z/edit % + 4 )) z/node prn/print-edn) )
154
+ (- >> data (z/map #(z/edit % + 4 )) z/->root-string )
155
155
; ; => "[5\n6\n7]"
156
156
```
157
157
0 commit comments