All Projects → borkdude → rewrite-edn

borkdude / rewrite-edn

Licence: EPL-1.0 license
Utility lib on top of rewrite-clj with common operations to update EDN while preserving whitespace and comments.

Programming Languages

clojure
4091 projects

Labels

Projects that are alternatives of or similar to rewrite-edn

Datalevin
A simple, fast and durable Datalog database
Stars: ✭ 360 (+453.85%)
Mutual labels:  edn
Fif
Stack-based Programming in Clojure(script)
Stars: ✭ 71 (+9.23%)
Mutual labels:  edn
Honeyeql
HoneyEQL is a Clojure library enables you to query database using the EDN Query Language.
Stars: ✭ 111 (+70.77%)
Mutual labels:  edn
Coast
The fullest full stack clojure web framework
Stars: ✭ 442 (+580%)
Mutual labels:  edn
Edn Data
EDN parser and generator that works with plain JS data, with support for TS and node streams
Stars: ✭ 44 (-32.31%)
Mutual labels:  edn
Dyn Edn
Dynamic properties in EDN content
Stars: ✭ 88 (+35.38%)
Mutual labels:  edn
Muuntaja
Clojure library for fast http api format negotiation, encoding and decoding.
Stars: ✭ 304 (+367.69%)
Mutual labels:  edn
clj-rn
A utility for building ClojureScript-based React Native apps
Stars: ✭ 56 (-13.85%)
Mutual labels:  edn
Cause
An EDN-like CRDT (Causal Tree) for Clojure & ClojureScript that automatically tracks history and resolves conflicts.
Stars: ✭ 68 (+4.62%)
Mutual labels:  edn
Eden Smart Contracts
EDEN - EDN Smart Token & Smart Contracts
Stars: ✭ 109 (+67.69%)
Mutual labels:  edn
Fipp
Fast Idiomatic Pretty Printer for Clojure
Stars: ✭ 454 (+598.46%)
Mutual labels:  edn
Mpedn
EDN I/O library for Objective-C (MacOS and iOS)
Stars: ✭ 28 (-56.92%)
Mutual labels:  edn
Edn format
EDN reader and writer implementation in Python, using PLY (lex, yacc)
Stars: ✭ 92 (+41.54%)
Mutual labels:  edn
Walkable
A Clojure(script) SQL library for building APIs: Datomic® (GraphQL-ish) pull syntax, data driven configuration, dynamic filtering with relations in mind
Stars: ✭ 384 (+490.77%)
Mutual labels:  edn
Sente
Realtime web comms for Clojure/Script
Stars: ✭ 1,626 (+2401.54%)
Mutual labels:  edn
Jet
CLI to transform between JSON, EDN and Transit, powered with a minimal query language.
Stars: ✭ 331 (+409.23%)
Mutual labels:  edn
Edn
Go implementation of EDN (Extensible Data Notation)
Stars: ✭ 76 (+16.92%)
Mutual labels:  edn
protean
Evolve your RESTful API's and Web Services
Stars: ✭ 31 (-52.31%)
Mutual labels:  edn
Eden
edn (extensible data notation) encoder/decoder for Elixir
Stars: ✭ 32 (-50.77%)
Mutual labels:  edn
Wernicke
Redaction for structured data
Stars: ✭ 100 (+53.85%)
Mutual labels:  edn

rewrite-edn

Clojars Project

Utility lib on top of rewrite-clj with common operations to update EDN while preserving whitespace and comments.

API

See docstrings in the borkdude.rewrite-edn namespace for details.

Currently implemented:

  • parse-string
  • sexpr
  • get
  • keys
  • assoc
  • assoc-in
  • update
  • update-in
  • dissoc
  • map-keys

Examples

Given deps.edn:

{:deps {foo {:mvn/version "0.1.0"}
        bar {:mvn/version "0.2.0"}
        ;; here's a comment and the next dep is ignored:
        #_baz #_{:mvn/version "0.3.0"}}}

and this script:

(require '[borkdude.rewrite-edn :as r])

(def edn-string (slurp "deps.edn"))

(def nodes (r/parse-string edn-string))

Add dependency

(println (str (r/assoc-in nodes [:deps 'my-other-dep] {:mvn/version "0.1.2"})))
{:deps {foo {:mvn/version "0.1.0"}
        bar {:mvn/version "0.2.0"}
        ;; here's a comment and the next dep is ignored:
        #_baz #_{:mvn/version "0.3.0"}
        my-other-dep {:mvn/version "0.1.2"}}}

Fully qualify dep symbols

(defn qualify-sym-node [sym-node]
  (let [sym (r/sexpr sym-node)]
    (if (or (not (symbol? sym))
            (qualified-symbol? sym))
      sym-node
      (symbol (str sym) (str sym)))))

(def updated-nodes (r/update nodes :deps #(r/map-keys qualify-sym-node %)))
(println (str updated-nodes))
{:deps {foo/foo {:mvn/version "0.1.0"}
        bar/bar {:mvn/version "0.2.0"}
        ;; here's a comment and the next dep is ignored:
        #_baz #_{:mvn/version "0.3.0"}}}

Also see examples.

License

Copyright © 2021 Michiel Borkent

Distributed under the EPL License, same as Clojure. See LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].