diff --git a/README.md b/README.md index 51f0dc0..c547ad8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ nested access or updates, like `get-in`, `assoc-in` and `update-in`: ```clojure (ns app - (:require [borge.by.clj-json-pointer :as json-pointer])) + (:require [clj-json-pointer.core :as jp])) (def org {"department" @@ -26,31 +26,31 @@ nested access or updates, like `get-in`, `assoc-in` and `update-in`: {"users" [{"name" "joe" "roles" ["reports-writer"]}]}}}) -(let [path (json-pointer/->vec org "/department/tech/users/1/roles") ; => ["department" "tech" 1 "users" "roles"] - roles (get-in org path)] ; => ["platform" "devops"] +(let [path (jp/->vec org "/department/tech/users/1/roles") ; => ["department" "tech" 1 "users" "roles"] + roles (get-in org path)] ; => ["platform" "devops"] (do (something (with roles)))) ``` These simple building blocks are used to implement the various operations of JSON `patch`: ```clojure -(json-pointer/patch {} ; => {} - [{"op" "add" "path" "/foo" "value" "bar"} ; => {"foo" "bar"} - {"op" "add" "path" "/bar" "value" "baz"} ; => {"foo" "bar" "bar" "baz} - {"op" "remove" "path" "/foo"} ; => {"bar" "baz"} - {"op" "replace" "path" "/bar" "value" "foo"} ; => {"bar" "foo"} - {"op" "copy" "from" "/bar" "path" "/baz"} ; => {"bar" "foo" "baz" "foo"} - {"op" "move" "from" "/baz" "path" "/foo"} ; => {"foo" "foo"} - {"op" "test" "path" "/foo" "value" "foo"}]) ; => {"foo" "foo"} +(jp/patch {} ; => {} + [{"op" "add" "path" "/foo" "value" "bar"} ; => {"foo" "bar"} + {"op" "add" "path" "/bar" "value" "baz"} ; => {"foo" "bar" "bar" "baz} + {"op" "remove" "path" "/foo"} ; => {"bar" "baz"} + {"op" "replace" "path" "/bar" "value" "foo"} ; => {"bar" "foo"} + {"op" "copy" "from" "/bar" "path" "/baz"} ; => {"bar" "foo" "baz" "foo"} + {"op" "move" "from" "/baz" "path" "/foo"} ; => {"foo" "foo"} + {"op" "test" "path" "/foo" "value" "foo"}]) ; => {"foo" "foo"} ``` Or if you so prefer, use the `apply-patch` function, which applies a single patch to the provided data structure: ```clojure -(json-pointer/apply-patch {} {"op" "add" "path" "/a" "value" 1}) ; => {"a" 1} +(jp/apply-patch {} {"op" "add" "path" "/a" "value" 1}) ; => {"a" 1} ; or, more likely: -(reduce json-pointer/apply-patch {} patches) +(reduce jp/apply-patch {} patches) ``` ## Development diff --git a/build.clj b/build.clj index a1d9b56..1d2efbc 100644 --- a/build.clj +++ b/build.clj @@ -2,9 +2,9 @@ (:refer-clojure :exclude [compile]) (:require [clojure.tools.build.api :as b])) -(def version "0.1.0") +(def version "1.0.0") -(def lib 'borge.by/clj-json-pointer) +(def lib 'by.borge/clj-json-pointer) (def basis (b/create-basis {:project "deps.edn"})) (def class-dir "target/classes") (def jar-file (format "target/%s-%s.jar" (name lib) version)) diff --git a/deps.edn b/deps.edn index 9f76380..97e2fcb 100644 --- a/deps.edn +++ b/deps.edn @@ -1,8 +1,14 @@ {:deps {org.clojure/clojure {:mvn/version "1.11.1"}} :paths ["src"] :aliases - {:build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.4" :git/sha "8c3cd69"}} + {:build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.4" :git/sha "8c3cd69"}} :ns-default build} + :deploy {:extra-deps {slipset/deps-deploy {:mvn/version "0.2.0"}} + :exec-fn deps-deploy.deps-deploy/deploy + :exec-args {:installer :remote + :sign-releases? true + :artifact "target/clj-json-pointer-1.0.0.jar" + :pom "target/classes/META-INF/maven/borge.by/clj-json-pointer/pom.xml"}} :test {:extra-paths ["test"] :extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}} :main-opts ["-m" "cognitect.test-runner"] @@ -16,5 +22,5 @@ :extra-deps {jonase/eastwood {:mvn/version "1.3.0"}} :main-opts ["-m" "eastwood.lint" {}]} :kibit {:extra-paths ["test"] - :extra-deps {tvaughan/kibit-runner {:mvn/version "1.0.1"}} - :main-opts ["-m" "kibit-runner.cmdline"]}}} + :extra-deps {tvaughan/kibit-runner {:mvn/version "1.0.1"}} + :main-opts ["-m" "kibit-runner.cmdline"]}}} diff --git a/package-lock.json b/package-lock.json index ffea340..3ea8bcd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "clj-json-pointer", - "version": "0.0.1", + "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "clj-json-pointer", - "version": "0.0.1", + "version": "0.1.0", "devDependencies": { "shadow-cljs": "2.20.7" } diff --git a/package.json b/package.json index 8cd8515..0102a08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clj-json-pointer", - "version": "0.0.1", + "version": "1.0.0", "private": false, "devDependencies": { "shadow-cljs": "2.20.7" diff --git a/pom.xml b/pom.xml index 82cab0d..42405c7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - borge.by + by.borge clj-json-pointer clj-json-pointer Simple Clojure(Script) library for working with JSON Pointer and JSON Patch, with no external dependencies. diff --git a/src/borge/by/clj_json_pointer.cljc b/src/clj_json_pointer/core.cljc similarity index 99% rename from src/borge/by/clj_json_pointer.cljc rename to src/clj_json_pointer/core.cljc index cbc8bc7..05ed039 100644 --- a/src/borge/by/clj_json_pointer.cljc +++ b/src/clj_json_pointer/core.cljc @@ -1,4 +1,4 @@ -(ns borge.by.clj-json-pointer +(ns clj-json-pointer.core (:require [clojure.set :as set] [clojure.string :as str])) diff --git a/test/borge/by/compliance_test.cljc b/test/clj_json_pointer/compliance_test.cljc similarity index 99% rename from test/borge/by/compliance_test.cljc rename to test/clj_json_pointer/compliance_test.cljc index 41b61d9..deedfc8 100644 --- a/test/borge/by/compliance_test.cljc +++ b/test/clj_json_pointer/compliance_test.cljc @@ -1,7 +1,7 @@ -(ns borge.by.compliance-test +(ns clj-json-pointer.compliance-test "Implementation of the JSON patch compliance test suite from https://github.com/json-patch/json-patch-tests" (:require [clojure.test :refer [deftest is testing]] - [borge.by.clj-json-pointer :as json-pointer]) + [clj-json-pointer.core :as json-pointer]) #?(:clj (:import (clojure.lang ExceptionInfo)))) (deftest json-patch-compliance-tests diff --git a/test/borge/by/clj_json_pointer_test.cljc b/test/clj_json_pointer/unit_test.cljc similarity index 98% rename from test/borge/by/clj_json_pointer_test.cljc rename to test/clj_json_pointer/unit_test.cljc index 6b5b970..6f4b416 100644 --- a/test/borge/by/clj_json_pointer_test.cljc +++ b/test/clj_json_pointer/unit_test.cljc @@ -1,6 +1,6 @@ -(ns borge.by.clj-json-pointer-test +(ns clj-json-pointer.unit-test (:require [clojure.test :refer [deftest is testing]] - [borge.by.clj-json-pointer :refer [patch]]) + [clj-json-pointer.core :refer [patch]]) #?(:clj (:import (clojure.lang ExceptionInfo)))) (deftest patch-add-test