shiny_json_logic 0.2.13 → 0.2.14
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +39 -2
- data/badges/compat.json +1 -1
- data/lib/shiny_json_logic/numericals/min_max_collection.rb +11 -8
- data/lib/shiny_json_logic/version.rb +1 -1
- data/results/ruby.json +2 -2
- metadata +2 -7
- data/.idea/.gitignore +0 -8
- data/.idea/modules.xml +0 -8
- data/.idea/shiny_json_logic.iml +0 -55
- data/.idea/vcs.xml +0 -6
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed2816fd55214567b67e38255450feb26751c3eda3961e4a6a3e5f7bb6bb31ab
|
|
4
|
+
data.tar.gz: b6e61b87234e065c9ff973ec010ad9ea0404178617efd13915d196007798dc10
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b285e0401752e36ad8d0bd29d6b39611c68799dda1de5aa97d1aa5659f7137d8dde81b67684a9dff5f4808d2cbe692adfd19b50cafa92c993c6aea9bcf53caa
|
|
7
|
+
data.tar.gz: e8455bd077e2ef3e37e995448a78ed1b5de7c8400d3bc1f69cdecd1ec81ebd0bbdd58c93285b5f8f7a898d0223ee27381cf89bb6d0179ef00aa5dcfb3ff7d214
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.2.14] - 2026-02-14
|
|
6
|
+
### Fixed
|
|
7
|
+
- `max`/`min` operators no longer incorrectly expand arrays from operations inside array wrapper.
|
|
8
|
+
|
|
5
9
|
## [0.2.13] - 2026-02-09
|
|
6
10
|
### Changed
|
|
7
11
|
- Empty objects `{}` are now falsy (previously truthy). This aligns with the official JSONLogic spec.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -161,13 +161,50 @@ Currently implemented operators include:
|
|
|
161
161
|
📌 **Note:**
|
|
162
162
|
`val`, `exists`, `??`, `try`, `throw` and `preserve` are **only supported by ShinyJsonLogic** among Ruby implementations.
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
See the [spec](https://jsonlogicruby.com/docs) for the full list of operators and their behavior.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Error Handling
|
|
169
|
+
|
|
170
|
+
ShinyJsonLogic uses native Ruby exceptions for error handling:
|
|
171
|
+
|
|
172
|
+
```ruby
|
|
173
|
+
# Unknown operators raise an error
|
|
174
|
+
ShinyJsonLogic.apply({ "unknown_op" => [1, 2] }, {})
|
|
175
|
+
# => raises ShinyJsonLogic::Errors::UnknownOperator
|
|
176
|
+
|
|
177
|
+
# Invalid arguments raise an error
|
|
178
|
+
ShinyJsonLogic.apply({ "+" => ["not", "numbers"] }, {})
|
|
179
|
+
# => raises ShinyJsonLogic::Errors::InvalidArguments
|
|
180
|
+
|
|
181
|
+
# You can use try/throw for controlled error handling within rules
|
|
182
|
+
rule = {
|
|
183
|
+
"try" => [
|
|
184
|
+
{ "throw" => "Something went wrong" },
|
|
185
|
+
{ "cat" => ["Error: ", { "var" => "type" }] }
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
ShinyJsonLogic.apply(rule, {})
|
|
189
|
+
# => "Error: Something went wrong"
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Error classes:
|
|
193
|
+
- `ShinyJsonLogic::Errors::UnknownOperator` - Unknown operator in rule
|
|
194
|
+
- `ShinyJsonLogic::Errors::InvalidArguments` - Invalid arguments to operator
|
|
195
|
+
- `ShinyJsonLogic::Errors::NotANumber` - NaN result in numeric operation
|
|
165
196
|
|
|
166
197
|
---
|
|
167
198
|
|
|
168
199
|
## Compatibility
|
|
169
200
|
|
|
170
|
-
Compatibility is measured
|
|
201
|
+
Compatibility is measured against two external test suites:
|
|
202
|
+
|
|
203
|
+
| Test Suite | Status | Description |
|
|
204
|
+
|------------|--------|-------------|
|
|
205
|
+
| **compat-tables** (`json-logic/compat-tables`) | 99.6% (1121/1126) | Main compatibility suite |
|
|
206
|
+
| **official tests** (`json-logic/.github/tests`) | 100% (601/601) | Official spec tests |
|
|
207
|
+
|
|
171
208
|
See `badges/compat.json` for the exact numbers behind the badge.
|
|
172
209
|
|
|
173
210
|
---
|
data/badges/compat.json
CHANGED
|
@@ -13,16 +13,19 @@ module ShinyJsonLogic
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def collect_values
|
|
16
|
+
# Logic chaining: if rules is a single operation, expand the result
|
|
17
|
+
# e.g., {"max": {"val": "data"}} where data is [1,2,3] -> max of 1,2,3
|
|
18
|
+
if operation?(rules)
|
|
19
|
+
evaluated = evaluate(rules)
|
|
20
|
+
return wrap_nil(evaluated)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Otherwise, rules is an array of arguments - evaluate each without expanding
|
|
24
|
+
# e.g., {"max": [1, 2, 3]} or {"max": [1, {"val": "x"}]}
|
|
25
|
+
# Note: {"max": [{"val": "data"}]} where data is [1,2,3] -> invalid (array is one element)
|
|
16
26
|
result = []
|
|
17
27
|
wrap_nil(rules).each do |rule|
|
|
18
|
-
|
|
19
|
-
# If rule was an operation (Hash), expand the result array
|
|
20
|
-
# If rule was a literal array, it's invalid (will fail numeric check)
|
|
21
|
-
if operation?(rule)
|
|
22
|
-
wrap_nil(evaluated).each { |val| result << val }
|
|
23
|
-
else
|
|
24
|
-
result << evaluated
|
|
25
|
-
end
|
|
28
|
+
result << evaluate(rule)
|
|
26
29
|
end
|
|
27
30
|
result
|
|
28
31
|
end
|
data/results/ruby.json
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shiny_json_logic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Luis Moyano
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -109,12 +109,7 @@ files:
|
|
|
109
109
|
- ".github/workflows/ci.yml"
|
|
110
110
|
- ".github/workflows/compat.yml"
|
|
111
111
|
- ".gitignore"
|
|
112
|
-
- ".idea/.gitignore"
|
|
113
|
-
- ".idea/modules.xml"
|
|
114
|
-
- ".idea/shiny_json_logic.iml"
|
|
115
|
-
- ".idea/vcs.xml"
|
|
116
112
|
- ".rspec"
|
|
117
|
-
- ".travis.yml"
|
|
118
113
|
- CHANGELOG.md
|
|
119
114
|
- CONTRIBUTING.md
|
|
120
115
|
- Gemfile
|
data/.idea/.gitignore
DELETED
data/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/shiny_json_logic.iml" filepath="$PROJECT_DIR$/.idea/shiny_json_logic.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
data/.idea/shiny_json_logic.iml
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
|
4
|
-
<shared />
|
|
5
|
-
</component>
|
|
6
|
-
<component name="NewModuleRootManager">
|
|
7
|
-
<content url="file://$MODULE_DIR$">
|
|
8
|
-
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
|
9
|
-
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
|
10
|
-
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
|
11
|
-
</content>
|
|
12
|
-
<orderEntry type="jdk" jdkName="ruby-2.6.8-p205" jdkType="RUBY_SDK" />
|
|
13
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.2, ruby-2.6.8-p205) [gem]" level="application" />
|
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="byebug (v11.1.3, ruby-2.6.8-p205) [gem]" level="application" />
|
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.3, ruby-2.6.8-p205) [gem]" level="application" />
|
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, ruby-2.6.8-p205) [gem]" level="application" />
|
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, ruby-2.6.8-p205) [gem]" level="application" />
|
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="pry (v0.14.1, ruby-2.6.8-p205) [gem]" level="application" />
|
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, ruby-2.6.8-p205) [gem]" level="application" />
|
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, ruby-2.6.8-p205) [gem]" level="application" />
|
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.12.0, ruby-2.6.8-p205) [gem]" level="application" />
|
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.2, ruby-2.6.8-p205) [gem]" level="application" />
|
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.2, ruby-2.6.8-p205) [gem]" level="application" />
|
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.12.0, ruby-2.6.8-p205) [gem]" level="application" />
|
|
26
|
-
</component>
|
|
27
|
-
<component name="RakeTasksCache">
|
|
28
|
-
<option name="myRootTask">
|
|
29
|
-
<RakeTaskImpl id="rake">
|
|
30
|
-
<subtasks>
|
|
31
|
-
<RakeTaskImpl description="Build shiny_json_logic-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
|
32
|
-
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
|
33
|
-
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
|
34
|
-
<RakeTaskImpl description="Build and install shiny_json_logic-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
|
35
|
-
<RakeTaskImpl id="install">
|
|
36
|
-
<subtasks>
|
|
37
|
-
<RakeTaskImpl description="Build and install shiny_json_logic-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
|
38
|
-
</subtasks>
|
|
39
|
-
</RakeTaskImpl>
|
|
40
|
-
<RakeTaskImpl description="Create tag v0.1.0 and build and push shiny_json_logic-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
|
41
|
-
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
|
42
|
-
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
|
43
|
-
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
|
44
|
-
<RakeTaskImpl id="release">
|
|
45
|
-
<subtasks>
|
|
46
|
-
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
|
47
|
-
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
|
48
|
-
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
|
49
|
-
</subtasks>
|
|
50
|
-
</RakeTaskImpl>
|
|
51
|
-
</subtasks>
|
|
52
|
-
</RakeTaskImpl>
|
|
53
|
-
</option>
|
|
54
|
-
</component>
|
|
55
|
-
</module>
|
data/.idea/vcs.xml
DELETED