shiny_json_logic 0.3.1 → 0.3.2

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: 4f62f75b8b9279af811dddcc9a97049550d16f711d33bda0e727e5b4adb36d2d
4
- data.tar.gz: 596cc8713677361a03805ee566c6684b406526b43c3ad9ba23748283753519f2
3
+ metadata.gz: 47eab10babd10e80ceeda0d5f5dc857c73a69ae7f36c5a8b09c71984e02c4243
4
+ data.tar.gz: 21adb41b87070e1ca2438d83fd351f3bf785ad60ce7842f889beea21d2fa7624
5
5
  SHA512:
6
- metadata.gz: 34871c34a9999116eaca7af2d1aacf7a41f7527f5181d17bff57aa85d358b44a327a4c8ec03a7c0b2990dc3f3c5c70efd12cc4935e9d72bd0a8d435d2677ba8f
7
- data.tar.gz: 4156b07eefc2419d34a080d5d1f1d3e570a6536d9a0ca3d16f20fe490e0126c843b10303089336ba3b8132628d71527ec7ef94ec2adc2b7a5acd180d7dc7a1c5
6
+ metadata.gz: 10f5c5bb5bca496e4f2f0957f304658181cec45277fea2bb91f9cd6c8d4901aaa937113a433821c2e728560e84fda5149d88ac5a27b18059452d8156e55b767b
7
+ data.tar.gz: a4b7d20d5fbcedd32fe347d418a5efddba8adb77fb11ac6caf9dcfb06ff4e7b3585035db905ccb1242c0b1581a2a5957d83b43d76f0fec89f01524d11351e704
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
+ ## [0.3.2] - 2026-02-28
5
+ ### Changed
6
+ - Refactors scope stack as an array of arrays in order to improve performance
7
+
4
8
  ## [0.3.1] - 2026-02-23
5
9
  ### Changed
6
10
  - Removes operations validation pass for optimization purposes.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shiny_json_logic (0.3.1)
4
+ shiny_json_logic (0.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -21,12 +21,12 @@ module ShinyJsonLogic
21
21
 
22
22
  def initialize(root_data)
23
23
  @root_data = root_data
24
- @stack = [{ data: @root_data, index: 0 }]
24
+ @stack = [[@root_data, 0]]
25
25
  end
26
26
 
27
27
  # Push a new scope onto the stack (when entering an iteration)
28
28
  def push(data, index: 0)
29
- stack.push({ data: data, index: index })
29
+ stack.push([data, index])
30
30
  end
31
31
 
32
32
  # Pop the top scope (when exiting an iteration)
@@ -36,7 +36,7 @@ module ShinyJsonLogic
36
36
 
37
37
  # Returns the current scope's data (top of stack)
38
38
  def current
39
- stack.last[:data]
39
+ stack.last[0]
40
40
  end
41
41
 
42
42
  # Resolve a value by going up n levels and then accessing keys
@@ -51,7 +51,7 @@ module ShinyJsonLogic
51
51
  scope = stack[target_index]
52
52
  return nil unless scope
53
53
 
54
- data = scope[:data]
54
+ data = scope[0]
55
55
 
56
56
  if keys.empty?
57
57
  data
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShinyJsonLogic
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
@@ -16,10 +16,12 @@ module ShinyJsonLogic
16
16
  Engine.call(rule, scope_stack)
17
17
  end
18
18
 
19
- # Recursively converts all hash keys to strings
19
+ # Recursively converts all hash keys to strings.
20
+ # Fast path: if all keys are already strings, skip the copy.
20
21
  def self.deep_stringify_keys(obj)
21
22
  case obj
22
23
  when Hash
24
+ return obj if obj.keys.all? { |k| k.is_a?(String) }
23
25
  obj.each_with_object({}) do |(key, value), result|
24
26
  result[key.to_s] = deep_stringify_keys(value)
25
27
  end
@@ -29,31 +31,6 @@ module ShinyJsonLogic
29
31
  obj
30
32
  end
31
33
  end
32
-
33
- # Validates that all operations in the rule tree use known operators
34
- def self.validate_operators!(rule)
35
- case rule
36
- when Hash
37
- return if rule.empty?
38
-
39
- # Multi-key hashes are invalid
40
- if rule.size > 1
41
- raise Errors::UnknownOperator
42
- end
43
-
44
- operation, args = rule.first
45
-
46
- # Check if operation is known
47
- unless OperatorSolver::SOLVERS.key?(operation.to_s)
48
- raise Errors::UnknownOperator
49
- end
50
-
51
- # Recursively validate args
52
- validate_operators!(args)
53
- when Array
54
- rule.each { |item| validate_operators!(item) }
55
- end
56
- end
57
34
  end
58
35
 
59
36
  JsonLogic = ShinyJsonLogic
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.3.1
4
+ version: 0.3.2
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-23 00:00:00.000000000 Z
11
+ date: 2026-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler