shiny_json_logic 0.1.3 β†’ 0.1.4

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: a0344634b8f6d210b6968b38d5353c7890df29d927481d23686bc720b8680aab
4
+ data.tar.gz: 8d7e436d54cf970a720415c9bba2af1ab7fe5677718072b42bd756bbba901300
5
5
  SHA512:
6
- metadata.gz: dcbf8a820eea98dc973874e500670a60d41366053103bf4ef6030500d7e9aa9fb6e4963b2730ea40122b8e96530ff5706b055ddd5fc42722b01f11c0f5b50c8f
7
- data.tar.gz: '038d39b60d79d5f691f50ac326de84560181c16518bda086d12c4a32950156ad08a80db6097cb3e856caf24152e1e7b0c58f272a664905f01007f30a86132e8d'
6
+ metadata.gz: dcaf78915b3198bdc3da54b9ca0e12e8118105bcea515cd09e1fc83815d3b2d4c63d715c0849e2b7e6348f36754f7a25d2a50221c5e5cb41fc96a26832b085c7
7
+ data.tar.gz: a6e3414cdf9db71cc870e15357fd62e726ac1eba25b134424cc882ea84a33b0af45dc391e16aec6c10ccbfd8ec9b201dc0679d8c5b3f9b8dd03305693cf4d21b
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [0.1.4] - 2026-01-25
6
+ ### Changed
7
+ - Improve RubyGems metadata and gem description (no runtime changes).
8
+ - Improves README md
9
+
10
+ ## [0.1.3]
11
+ ### Added
12
+ - Adds Support for `val`, `exists` and `??` operators.
13
+
14
+ ## [0.1.0]
15
+ - 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.4)
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.4"
3
3
  end
@@ -9,24 +9,42 @@ 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 = <<~DESC
14
+ ShinyJsonLogic is a pure-Ruby, zero-runtime-dependency implementation of the JSON Logic specification.
15
+
16
+ - Ruby 2.7+ compatible
17
+ - Actively maintained and test-driven
18
+ - Designed for spec alignment and predictable behavior
19
+ - Highest support for JSON Logic operations within the Ruby ecosystem
20
+
21
+ JSON Logic lets you represent decisions as data, so rules can be stored, transmitted, and evaluated safely.
22
+ DESC
14
23
  spec.homepage = "https://github.com/luismoyano/shiny-json-logic-ruby"
15
24
  spec.license = "MIT"
16
25
 
26
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
27
+
28
+ spec.metadata = {
29
+ "homepage_uri" => spec.homepage,
30
+ "source_code_uri" => spec.homepage,
31
+ "documentation_uri" => "#{spec.homepage}#readme",
32
+ "changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md",
33
+ "rubygems_mfa_required" => "true"
34
+ }
35
+
17
36
  # Specify which files should be added to the gem when it is released.
18
37
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
38
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
39
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
40
  end
22
41
 
23
- spec.add_runtime_dependency 'backport_dig' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
24
42
  spec.bindir = "exe"
25
43
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
44
  spec.require_paths = ["lib"]
27
45
 
28
46
  spec.add_development_dependency "bundler"
29
- spec.add_development_dependency "rake", "~> 10.0"
47
+ spec.add_development_dependency "rake"
30
48
  spec.add_development_dependency "rspec", "~> 3.0"
31
49
  spec.add_development_dependency 'byebug'
32
50
  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.4
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,15 @@ 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: |
84
+ ShinyJsonLogic is a pure-Ruby, zero-runtime-dependency implementation of the JSON Logic specification.
85
+
86
+ - Ruby 2.7+ compatible
87
+ - Actively maintained and test-driven
88
+ - Designed for spec alignment and predictable behavior
89
+ - Highest support for JSON Logic operations within the Ruby ecosystem
90
+
91
+ JSON Logic lets you represent decisions as data, so rules can be stored, transmitted, and evaluated safely.
87
92
  email:
88
93
  - moyano@hey.com
89
94
  executables: []
@@ -97,6 +102,7 @@ files:
97
102
  - ".idea/vcs.xml"
98
103
  - ".rspec"
99
104
  - ".travis.yml"
105
+ - CHANGELOG.md
100
106
  - Gemfile
101
107
  - Gemfile.lock
102
108
  - LICENSE.txt
@@ -152,7 +158,13 @@ files:
152
158
  homepage: https://github.com/luismoyano/shiny-json-logic-ruby
153
159
  licenses:
154
160
  - MIT
155
- metadata: {}
161
+ metadata:
162
+ homepage_uri: https://github.com/luismoyano/shiny-json-logic-ruby
163
+ source_code_uri: https://github.com/luismoyano/shiny-json-logic-ruby
164
+ documentation_uri: https://github.com/luismoyano/shiny-json-logic-ruby#readme
165
+ changelog_uri: https://github.com/luismoyano/shiny-json-logic-ruby/blob/main/CHANGELOG.md
166
+ rubygems_mfa_required: 'true'
167
+ post_install_message:
156
168
  rdoc_options: []
157
169
  require_paths:
158
170
  - lib
@@ -160,14 +172,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
172
  requirements:
161
173
  - - ">="
162
174
  - !ruby/object:Gem::Version
163
- version: '0'
175
+ version: 2.7.0
164
176
  required_rubygems_version: !ruby/object:Gem::Requirement
165
177
  requirements:
166
178
  - - ">="
167
179
  - !ruby/object:Gem::Version
168
180
  version: '0'
169
181
  requirements: []
170
- rubygems_version: 3.6.9
182
+ rubygems_version: 3.1.6
183
+ signing_key:
171
184
  specification_version: 4
172
- summary: An implementation of JSON Logic in Ruby that works.
185
+ summary: 'Production-ready JSON Logic for Ruby that just works: zero deps, Ruby 2.7+,
186
+ high spec alignment.'
173
187
  test_files: []