Skip to content

Commit

Permalink
Merge pull request #9 from odogono/chore/8-clean-and-update
Browse files Browse the repository at this point in the history
chore/8 clean and update
  • Loading branch information
odogono authored Sep 11, 2024
2 parents 651aada + 363c8ce commit a6ae868
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 180 deletions.
5 changes: 3 additions & 2 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Used by "mix format"
[
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
37 changes: 32 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
/_build
/deps
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
elixir_jason_test-*.tar

# Temporary files, for example, from tests.
/tmp/
*~

# Ignore macOS files
.DS_Store
node_modules
doc
.elixir_ls

# Ignore editor files
.elixir_ls

# Ignore vscode files
.vscode
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: elixir
elixir:
- 1.8
- 1.9
- 1.17
otp_release:
- 22.0
- 26.0
sudo: false
40 changes: 24 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
## Changelog
# Changelog

Written with guidance from [Keep a CHANGELOG](http://keepachangelog.com/).
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## v3.0.1

## v3.1.0 (2024-09-11)
### Changed
- updated package dependencies
- error handling for get on invalid containers
- error message format changed to be more consistent

## v3.0.1 (2019-07-31)
### Fixed
- crash when retrieving a path which contains a null value


## v3.0.0
## v3.0.0 (2019-02-27)
### Added
- add/add! - adds values indicated by pointers
- options can be passed to operations. only option so far is :strict which affects set/add behaviour
Expand All @@ -25,23 +33,23 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- corrected parsing of /~01


## v2.5.0
## v2.5.0 (2019-02-22)
### Added
- support for special array rules - /01 is not evaluated to an integer
- the /- pointer when used with set either appends the value to the end of a list, or
- the /- pointer when used with set either appends the value to the end of a list, or
creates a new list with the value


## v2.4.0
## v2.4.0 (2019-04-01)
### Fixed
- pointers are no longer uri decoded, so the rfc example of "/c%d" now works correctly


## v2.3.0
## v2.3.0 (2018-05-09)
### Changed
- JSONPointer.apply changed to JSONPointer.transform

## v2.2.0
## v2.2.0 (2018-04-12)
### Added
- hydrate and dehydrate functions added
- apply added - a utility to transform a source container
Expand All @@ -50,32 +58,32 @@ creates a new list with the value
- extract - renamed to dehydrate


## v2.1.0
## v2.1.0 (2018-04-12)
### Added
- set!, extract!, merge!


## v2.0.0
## v2.0.0 (2018-01-19)
### Changed
- passing a string to get/set will raise an argument error
- new elixir formatter applied to code
- code refactored to use defguard - which means this package is > 1.6 only

## v1.3.0
## v1.3.0 (2017-12-21)
### Fixed
- deprecation warning for String.ltrim
- Unsafe variable warnings

## v1.2.0
## v1.2.0 (2016-04-11)
### Added
- parse will take a list of strings
- JSONPointer.extract returns a list of paths that make up an object
- JSONPointer.extract returns a list of paths that make up an object
- JSONPointer.merge combines dst into src

## v1.1.0
## Added
## v1.1.0 (2016-03-04)
### Added
- pointers can be passed as lists as well as strings


## v1.0.0
## v1.0.0 (2016-03-03)
* Initial Release
4 changes: 2 additions & 2 deletions LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
# The MIT License (MIT)

Copyright (c) [2019] [Alexander Veenendaal]
Copyright (c) 2024 Alexander Veenendaal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
44 changes: 20 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,75 @@
ODGN JSONPointer
=================
# ODGN JSONPointer

[![Build Status](https://travis-ci.org/odogono/elixir-jsonpointer.svg?branch=master)](https://travis-ci.org/odogono/elixir-jsonpointer)
[![Hex.pm](https://img.shields.io/hexpm/v/odgn_json_pointer.svg?style=flat-square)](https://hex.pm/packages/odgn_json_pointer)

[![Module Version](https://img.shields.io/hexpm/v/odgn_json_pointer.svg)](https://hex.pm/packages/odgn_json_pointer)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/odgn_json_pointer/)
[![Total Download](https://img.shields.io/hexpm/dt/odgn_json_pointer.svg)](https://hex.pm/packages/odgn_json_pointer)
[![License](https://img.shields.io/hexpm/l/odgn_json_pointer.svg)](https://github.com/odogono/elixir-jsonpointer/blob/master/LICENSE.md)
[![Last Updated](https://img.shields.io/github/last-commit/odogono/elixir-jsonpointer.svg)](https://github.com/odogono/elixir-jsonpointer/commits/master)

An implementation of [JSON Pointer (RFC 6901)](http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-08) for Elixir.


## Installation

Add a dependency to your project `mix.exs`:

```Elixir
```elixir
def deps do
[{:odgn_json_pointer, "~> 3.0.1"}]
[
{:odgn_json_pointer, "~> 3.1.0"}
]
end
```

## Basic Usage

```Elixir
```elixir
iex> JSONPointer.get( %{ "fridge" => %{ "door" => "milk" } }, "/fridge/door" )
{:ok, "milk"}


iex> JSONPointer.set( %{}, "/example/msg", "hello")
{:ok, %{ "example" => %{ "msg" => "hello" }}, nil }


iex> JSONPointer.add( %{ "fridge" => [ "milk", "cheese" ]}, "/fridge/1", "salad")
{:ok, %{ "fridge" => [ "milk", "salad", "cheese" ]}, [ "milk", "cheese" ] }


iex> JSONPointer.has?( %{ "milk" => true, "butter" => false}, "/butter" )
true


iex> JSONPointer.test( %{ "milk" => "skimmed", "butter" => false}, "/milk", "skimmed" )
{:ok, %{ "milk" => "skimmed", "butter" => false} }


iex> JSONPointer.remove( %{"fridge" => %{ "milk" => true, "butter" => true}}, "/fridge/butter" )
{:ok, %{"fridge" => %{"milk"=>true}}, true }


iex> JSONPointer.dehydrate( %{"a"=>%{"b"=>["c","d"]}} )
{:ok, [{"/a/b/0", "c"}, {"/a/b/1", "d"}] }


iex> iex> JSONPointer.hydrate( [ {"/a/1/b", "single"} ] )
{:ok, %{"a" => %{"1" => %{"b" => "single"}}}}


iex> JSONPointer.merge( %{"a"=>1}, %{"b"=>2} )
{:ok, %{"a"=>1,"b"=>2} }


iex> JSONPointer.transform( %{ "a"=>4, "b"=>%{ "c" => true }}, [ {"/b/c", "/valid"}, {"/a","/count", fn val -> val*2 end} ] )
{:ok, %{"count" => 8, "valid" => true}}

```

Full documentation can be found at https://hexdocs.pm/odgn_json_pointer.

## Acknowledgement

Inspiration from https://github.com/manuelstofer/json-pointer

## Ack

inspiration from https://github.com/manuelstofer/json-pointer

made without peeking (much) at the source of https://github.com/xavier/json_pointer
Made without peeking (much) at the source of https://github.com/xavier/json_pointer

Made in Exeter, UK.


## License
## Copyright and License

Copyright (c) 2024 Alexander Veenendaal

This software is licensed under [the MIT license](LICENSE.md).
This work is free. You can redistribute it and/or modify it under the
terms of the MIT License. See the [LICENSE.md](./LICENSE.md) file for more details.
24 changes: 0 additions & 24 deletions config/config.exs

This file was deleted.

Loading

0 comments on commit a6ae868

Please sign in to comment.