shiny_json_logic 0.1.3 β†’ 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c4b549a75d02aacd916417297fcdfc3b3a208ed1327bb176522aaa396155f70
4
- data.tar.gz: fc868171df7caee20cae4c04f60ecb2e7db1a85b23e2ac4a4dfc097085e15fa5
3
+ metadata.gz: 5af5c24c121a66a702066d61036b7febb6230cf93d89e738f91f5b610e68eb5e
4
+ data.tar.gz: 3f9e425f25edabe05fcbe8bca95302c465feb5c00f72e465694bd0195ee7e515
5
5
  SHA512:
6
- metadata.gz: dcbf8a820eea98dc973874e500670a60d41366053103bf4ef6030500d7e9aa9fb6e4963b2730ea40122b8e96530ff5706b055ddd5fc42722b01f11c0f5b50c8f
7
- data.tar.gz: '038d39b60d79d5f691f50ac326de84560181c16518bda086d12c4a32950156ad08a80db6097cb3e856caf24152e1e7b0c58f272a664905f01007f30a86132e8d'
6
+ metadata.gz: bc18bd78dfa7f000e9000856415288b095e0092a06feb54cd1817a9cf976976bc219e90ad39ede919cbfdd7396bcb393349a890cb7347daa31c8258862eb3346
7
+ data.tar.gz: 4d5f7885741001b33fe4da2f143354637a940b5d442fe402447c006a6acd9518cec4e65ceb0094de50442c0a5e100eb9e555e19fc097b501b6d1c551040fabc3
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [0.1.5] - 2026-01-25
6
+ ### Changed
7
+ - Improve RubyGems gem description (no runtime changes).
8
+
9
+ ## [0.1.4] - 2026-01-25
10
+ ### Changed
11
+ - Improve RubyGems metadata and gem description (no runtime changes).
12
+ - Improves README md
13
+
14
+ ## [0.1.3]
15
+ ### Added
16
+ - Adds Support for `val`, `exists` and `??` operators.
17
+
18
+ ## [0.1.0]
19
+ - Initial release with support for legacy JSON Logic operators.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shiny_json_logic (0.1.2)
4
+ shiny_json_logic (0.1.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -35,7 +35,7 @@ DEPENDENCIES
35
35
  bundler
36
36
  byebug
37
37
  pry
38
- rake (~> 10.0)
38
+ rake
39
39
  rspec (~> 3.0)
40
40
  shiny_json_logic!
41
41
 
data/README.md CHANGED
@@ -1,12 +1,26 @@
1
1
  # ShinyJsonLogic ✨
2
2
 
3
- > Shine bright like a Ruby πŸ’Ž
3
+ > Shine bright like a Ruby πŸ’Ž
4
+ > **A boring, correct, and production-ready JSON Logic implementation for Ruby.**
4
5
 
5
- A **working** JSON Logic implementation in Ruby.
6
+ **ShinyJsonLogic** is a **pure Ruby**, **zero-dependency** implementation of the JSON Logic specification.
6
7
 
7
- This gem exists because the official JSONLogic Ruby implementation has been incomplete and unmaintained for quite a while.
8
+ We exist because the original Ruby implementation has been neglected for years.
8
9
 
9
- `ShinyJsonLogic` aims to be predictable, aligned with specs, test-driven and ready to use in Ruby's production code.
10
+ This gem focuses on predictable behavior, strict spec alignment, high compatibility and long-term maintainability.
11
+
12
+ ---
13
+
14
+ ## Why ShinyJsonLogic?
15
+
16
+ - βœ… **Zero runtime dependencies** (stdlib-only). Just plug & play!
17
+ - βœ… **Ruby 2.7+ compatible, one of the lowest among other Ruby implementations**
18
+ - βœ… **Actively maintained**
19
+ - βœ… **High JSON Logic spec coverage**
20
+ - βœ… **Iterative approach:** Stop worrying about long statements breaking your app.
21
+ - ⭐ **Only Ruby implementation supporting the new standard operations up to date.**
22
+
23
+ If you want JSON Logic to *just work* in Ruby, this is the safe default.
10
24
 
11
25
  ---
12
26
 
@@ -23,17 +37,26 @@ Then run:
23
37
  ```bash
24
38
  bundle install
25
39
  ```
26
- Or install it yourself:
40
+
41
+ Or install it directly:
27
42
 
28
43
  ```bash
29
44
  gem install shiny_json_logic
30
45
  ```
31
46
 
47
+ and require it in your project:
48
+
49
+ ```rubyruby
50
+ require "shiny_json_logic"
51
+ ```
52
+
53
+ ---
54
+
32
55
  ## Usage
33
56
 
34
57
  Basic usage is intentionally simple:
35
58
 
36
- ``` ruby
59
+ ```ruby
37
60
  require "shiny_json_logic"
38
61
 
39
62
  rule = {
@@ -49,10 +72,11 @@ ShinyJsonLogic.apply(rule, data)
49
72
  # => true
50
73
  ```
51
74
 
52
- ### Nested Logic
53
- You can nest rules as deeply as needed:
75
+ ### Nested logic
76
+
77
+ Rules can be nested arbitrarily:
54
78
 
55
- ``` ruby
79
+ ```ruby
56
80
  rule = {
57
81
  "if" => [
58
82
  { "var" => "financing" },
@@ -65,76 +89,92 @@ data = { "financing" => true }
65
89
 
66
90
  ShinyJsonLogic.apply(rule, data)
67
91
  # => ["apr"]
68
-
69
92
  ```
70
93
 
71
- ### Supported operators
94
+ ---
72
95
 
73
- The goal is full JSON Logic coverage. Currently supported:
96
+ ## Supported operators
74
97
 
75
- #### Logic
98
+ Our goal is **full JSON Logic coverage**.
99
+ Currently implemented operators include:
76
100
 
77
- `if, and, or, !, !!`
101
+ ### Logic
102
+ `if`, `and`, `or`, `!`, `!!`
78
103
 
79
- #### Comparison
104
+ ### Comparison
105
+ `==`, `===`, `!=`, `!==`, `>`, `>=`, `<`, `<=`
80
106
 
81
- `==, ===, !=, !==, >, >=, <, <=`
107
+ ### Data access
108
+ `var`, `missing`, `missing_some`, `val`✨, `exists`✨
82
109
 
83
- #### Data access
110
+ ### Math
111
+ `+`, `-`, `*`, `/`, `%`, `min`, `max`
84
112
 
85
- `var, missing, missing_some, val, exists`
113
+ ### Strings
114
+ `cat`, `substr`
86
115
 
87
- #### Math
116
+ ### Arrays
117
+ `merge`, `in`, `??`✨ *(coalesce operator)*
88
118
 
89
- `+, -, *, /, %`
90
- `min, max`
119
+ ### Iterable operations
120
+ `map, reduce, filter, some, all, none`
91
121
 
92
- #### Strings
122
+ πŸ“Œ **Note:**
123
+ `val`, `exists` and `??` are **only supported by ShinyJsonLogic** at the moment.
93
124
 
94
- `cat, substr`
125
+ (See `lib/shiny_json_logic/operations` for the authoritative list.)
95
126
 
96
- #### Arrays
127
+ ---
97
128
 
98
- `merge, in, ?? (Coalesce operator)`
129
+ ## Compatibility
99
130
 
100
- #### Iterable operations
101
- `map, reduce, filter, some, all, none`
131
+ ShinyJsonLogic is designed to track the official JSON Logic specification as closely as possible.
132
+
133
+ A compatibility PR against the JSON Logic test tables is currently in progress and will be linked here once merged.
102
134
 
103
- (See lib/shiny_json_logic/operations for the authoritative list.)
135
+ ---
104
136
 
105
137
  ## Development
106
138
 
107
139
  After checking out the repo:
108
140
 
109
- ``` bash
141
+ ```bash
110
142
  bin/setup
111
143
  bundle exec rspec
112
144
  ```
113
145
 
114
- You can also open a console with:
146
+ Open a console:
115
147
 
116
- ``` bash
148
+ ```bash
117
149
  bin/console
118
150
  ```
119
151
 
120
- To install the gem locally:
152
+ Install locally:
121
153
 
122
- ``` bash
154
+ ```bash
123
155
  bundle exec rake install
124
156
  ```
125
157
 
158
+ ---
159
+
126
160
  ## Contributing
127
161
 
128
162
  Contributions are welcome β€” especially:
129
163
 
130
- spec alignment improvements, missing operators, edge-case tests or performance improvements
164
+ - spec alignment improvements
165
+ - missing operators
166
+ - edge-case tests
167
+ - performance improvements
131
168
 
132
169
  Please include tests with any change.
133
170
 
134
- Repository: https://github.com/luismoyano/shiny_json_logic
171
+ Repository:
172
+ https://github.com/luismoyano/shiny_json_logic
173
+
174
+ ---
135
175
 
136
176
  ## License
137
177
 
138
178
  MIT License.
139
179
 
140
- Use it, fork it, ship it (:
180
+ Use it. Fork it. Ship it. (:
@@ -11,7 +11,7 @@ module ShinyJsonLogic
11
11
  @data = data
12
12
  end
13
13
 
14
- def call(rule = self.rule, data = self.data)
14
+ def call
15
15
  stack = [[rule, data, :enter]]
16
16
  results = []
17
17
 
@@ -31,21 +31,10 @@ module ShinyJsonLogic
31
31
  args = results.pop(argc)
32
32
  results << solvers.fetch(op).new(args, ctx).call
33
33
  else
34
- child = results.pop
35
-
36
- args =
37
- if child.nil?
38
- []
39
- elsif child.is_a?(Array)
40
- child
41
- else
42
- [child]
43
- end
44
-
34
+ args = Array.wrap(results.pop)
45
35
  results << solvers.fetch(op).new(args, ctx).call
46
36
  end
47
37
  end
48
-
49
38
  elsif node.is_a?(Array)
50
39
  results << results.pop(node.size)
51
40
  end
@@ -86,48 +75,48 @@ module ShinyJsonLogic
86
75
 
87
76
  def solvers
88
77
  @@solvers ||= {
89
- "var" => ::ShinyJsonLogic::Operations::Var,
90
- "missing" => ::ShinyJsonLogic::Operations::Missing,
91
- "missing_some" => ::ShinyJsonLogic::Operations::MissingSome,
92
- "if" => ::ShinyJsonLogic::Operations::If,
93
- "==" => ::ShinyJsonLogic::Operations::Equal,
94
- "===" => ::ShinyJsonLogic::Operations::StrictEqual,
95
- "!=" => ::ShinyJsonLogic::Operations::Different,
96
- "!==" => ::ShinyJsonLogic::Operations::StrictDifferent,
97
- ">" => ::ShinyJsonLogic::Operations::Greater,
98
- ">=" => ::ShinyJsonLogic::Operations::GreaterEqual,
99
- "<" => ::ShinyJsonLogic::Operations::Smaller,
100
- "<=" => ::ShinyJsonLogic::Operations::SmallerEqual,
101
- "!" => ::ShinyJsonLogic::Operations::Not,
102
- "or" => ::ShinyJsonLogic::Operations::Or,
103
- "and" => ::ShinyJsonLogic::Operations::And,
104
- "?:" => ::ShinyJsonLogic::Operations::If,
105
- "in" => ::ShinyJsonLogic::Operations::Inclusion,
106
- "cat" => ::ShinyJsonLogic::Operations::Concatenation,
107
- "%" => ::ShinyJsonLogic::Operations::Modulo,
108
- "max" => ::ShinyJsonLogic::Operations::Max,
109
- "min" => ::ShinyJsonLogic::Operations::Min,
110
- "+" => ::ShinyJsonLogic::Operations::Addition,
111
- "*" => ::ShinyJsonLogic::Operations::Product,
112
- "-" => ::ShinyJsonLogic::Operations::Subtraction,
113
- "/" => ::ShinyJsonLogic::Operations::Division,
114
- "substr" => ::ShinyJsonLogic::Operations::Substring,
115
- "merge" => ::ShinyJsonLogic::Operations::Merge,
116
- "!!" => ::ShinyJsonLogic::Operations::DoubleNot,
117
- "val" => ::ShinyJsonLogic::Operations::Val,
118
- "??" => ::ShinyJsonLogic::Operations::Coalesce,
119
- "exists" => ::ShinyJsonLogic::Operations::Exists,
78
+ "var" => Operations::Var,
79
+ "missing" => Operations::Missing,
80
+ "missing_some" => Operations::MissingSome,
81
+ "if" => Operations::If,
82
+ "==" => Operations::Equal,
83
+ "===" => Operations::StrictEqual,
84
+ "!=" => Operations::Different,
85
+ "!==" => Operations::StrictDifferent,
86
+ ">" => Operations::Greater,
87
+ ">=" => Operations::GreaterEqual,
88
+ "<" => Operations::Smaller,
89
+ "<=" => Operations::SmallerEqual,
90
+ "!" => Operations::Not,
91
+ "or" => Operations::Or,
92
+ "and" => Operations::And,
93
+ "?:" => Operations::If,
94
+ "in" => Operations::Inclusion,
95
+ "cat" => Operations::Concatenation,
96
+ "%" => Operations::Modulo,
97
+ "max" => Operations::Max,
98
+ "min" => Operations::Min,
99
+ "+" => Operations::Addition,
100
+ "*" => Operations::Product,
101
+ "-" => Operations::Subtraction,
102
+ "/" => Operations::Division,
103
+ "substr" => Operations::Substring,
104
+ "merge" => Operations::Merge,
105
+ "!!" => Operations::DoubleNot,
106
+ "val" => Operations::Val,
107
+ "??" => Operations::Coalesce,
108
+ "exists" => Operations::Exists,
120
109
  }
121
110
  end
122
111
 
123
112
  def collection_solvers
124
113
  @@collection_solvers ||= {
125
- "filter" => ::ShinyJsonLogic::Operations::Filter,
126
- "map" => ::ShinyJsonLogic::Operations::Map,
127
- "reduce" => ::ShinyJsonLogic::Operations::Reduce,
128
- "all" => ::ShinyJsonLogic::Operations::All,
129
- "none" => ::ShinyJsonLogic::Operations::None,
130
- "some" => ::ShinyJsonLogic::Operations::Some,
114
+ "filter" => Operations::Filter,
115
+ "map" => Operations::Map,
116
+ "reduce" => Operations::Reduce,
117
+ "all" => Operations::All,
118
+ "none" => Operations::None,
119
+ "some" => Operations::Some,
131
120
  }
132
121
  end
133
122
  end
@@ -1,3 +1,3 @@
1
1
  module ShinyJsonLogic
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -9,24 +9,36 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Luis Moyano"]
10
10
  spec.email = ["moyano@hey.com"]
11
11
 
12
- spec.summary = %q{An implementation of JSON Logic in Ruby that works.}
13
- spec.description = %q{JsonLogic isn’t a full programming language. It’s a small, safe way to delegate one decision. You could store a rule in a database to decide later. You could send that rule from back-end to front-end so the decision is made immediately from user input. Because the rule is data, you can even build it dynamically from user actions or GUI input. See http://jsonlogic.com}
12
+ spec.summary = "Production-ready JSON Logic for Ruby that just works: zero deps, Ruby 2.7+, high spec alignment."
13
+ spec.description = %q{
14
+ ShinyJsonLogic is a pure-Ruby, zero-runtime-dependency implementation of the JSON Logic specification. Ruby 2.7+ compatible, actively maintained, test-driven, and designed for strict spec alignment and predictable behavior. It currently offers the highest support for JSON Logic operations in the Ruby ecosystem.
15
+ }
16
+
14
17
  spec.homepage = "https://github.com/luismoyano/shiny-json-logic-ruby"
15
18
  spec.license = "MIT"
16
19
 
20
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
21
+
22
+ spec.metadata = {
23
+ "homepage_uri" => spec.homepage,
24
+ "source_code_uri" => spec.homepage,
25
+ "documentation_uri" => "#{spec.homepage}#readme",
26
+ "changelog_uri" => "#{spec.homepage}/blob/master/CHANGELOG.md",
27
+ "rubygems_mfa_required" => "true"
28
+ }
29
+
17
30
  # Specify which files should be added to the gem when it is released.
18
31
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
32
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
33
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
34
  end
22
35
 
23
- spec.add_runtime_dependency 'backport_dig' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
24
36
  spec.bindir = "exe"
25
37
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
38
  spec.require_paths = ["lib"]
27
39
 
28
40
  spec.add_development_dependency "bundler"
29
- spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rake"
30
42
  spec.add_development_dependency "rspec", "~> 3.0"
31
43
  spec.add_development_dependency 'byebug'
32
44
  spec.add_development_dependency 'pry'
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shiny_json_logic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Moyano
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-01-25 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: bundler
@@ -27,16 +28,16 @@ dependencies:
27
28
  name: rake
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - "~>"
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
- version: '10.0'
33
+ version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
36
  version_requirements: !ruby/object:Gem::Requirement
36
37
  requirements:
37
- - - "~>"
38
+ - - ">="
38
39
  - !ruby/object:Gem::Version
39
- version: '10.0'
40
+ version: '0'
40
41
  - !ruby/object:Gem::Dependency
41
42
  name: rspec
42
43
  requirement: !ruby/object:Gem::Requirement
@@ -79,11 +80,10 @@ dependencies:
79
80
  - - ">="
80
81
  - !ruby/object:Gem::Version
81
82
  version: '0'
82
- description: JsonLogic isn’t a full programming language. It’s a small, safe way to
83
- delegate one decision. You could store a rule in a database to decide later. You
84
- could send that rule from back-end to front-end so the decision is made immediately
85
- from user input. Because the rule is data, you can even build it dynamically from
86
- user actions or GUI input. See http://jsonlogic.com
83
+ description: "\n ShinyJsonLogic is a pure-Ruby, zero-runtime-dependency implementation
84
+ of the JSON Logic specification. Ruby 2.7+ compatible, actively maintained, test-driven,
85
+ and designed for strict spec alignment and predictable behavior. It currently offers
86
+ the highest support for JSON Logic operations in the Ruby ecosystem.\n "
87
87
  email:
88
88
  - moyano@hey.com
89
89
  executables: []
@@ -97,6 +97,7 @@ files:
97
97
  - ".idea/vcs.xml"
98
98
  - ".rspec"
99
99
  - ".travis.yml"
100
+ - CHANGELOG.md
100
101
  - Gemfile
101
102
  - Gemfile.lock
102
103
  - LICENSE.txt
@@ -152,7 +153,13 @@ files:
152
153
  homepage: https://github.com/luismoyano/shiny-json-logic-ruby
153
154
  licenses:
154
155
  - MIT
155
- metadata: {}
156
+ metadata:
157
+ homepage_uri: https://github.com/luismoyano/shiny-json-logic-ruby
158
+ source_code_uri: https://github.com/luismoyano/shiny-json-logic-ruby
159
+ documentation_uri: https://github.com/luismoyano/shiny-json-logic-ruby#readme
160
+ changelog_uri: https://github.com/luismoyano/shiny-json-logic-ruby/blob/master/CHANGELOG.md
161
+ rubygems_mfa_required: 'true'
162
+ post_install_message:
156
163
  rdoc_options: []
157
164
  require_paths:
158
165
  - lib
@@ -160,14 +167,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
167
  requirements:
161
168
  - - ">="
162
169
  - !ruby/object:Gem::Version
163
- version: '0'
170
+ version: 2.7.0
164
171
  required_rubygems_version: !ruby/object:Gem::Requirement
165
172
  requirements:
166
173
  - - ">="
167
174
  - !ruby/object:Gem::Version
168
175
  version: '0'
169
176
  requirements: []
170
- rubygems_version: 3.6.9
177
+ rubygems_version: 3.1.6
178
+ signing_key:
171
179
  specification_version: 4
172
- summary: An implementation of JSON Logic in Ruby that works.
180
+ summary: 'Production-ready JSON Logic for Ruby that just works: zero deps, Ruby 2.7+,
181
+ high spec alignment.'
173
182
  test_files: []