jmespath 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jmespath might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 802d17af3f269cfbd38879ff753082257effba66f383f415667b1018d9d68c5c
4
- data.tar.gz: 3b9ec8bf65b3dbcf00273667510385a406fa2c23cd64890557a76263944a8b0f
3
+ metadata.gz: '09a128a1330ef64e0a59ae48084fa404aa705184bdf2cf2a74d477dda596aa25'
4
+ data.tar.gz: 50ecb149f81b2a468a24de16ce5b91b0ec5300e1d1b3a16022138b0fb4a50374
5
5
  SHA512:
6
- metadata.gz: c95fe346be9e1e36a67869cad050a03e74ae414ceedb09049210419a9d4c5455df38e49403bcedf1434b56e8b45d6142527bdb3d2af86919cc833da021251e16
7
- data.tar.gz: 73e3c073ccf6b57c65c2246d12fd4a3c5d5f3beb603772966c4ec92371f9ed10f4e1a10b66a1619f50fdd78137a1a6b0998f65b4e7f966a928e5fc2a8d7393be
6
+ metadata.gz: a66052e2a8b1cb4d9bbbb5b8e7e40b5f6cf8df91cf260e27d7ed4d32e129003c4a20bd92cd39afa168d4959400b450bb36876f6e23c4b0a440cb8e8a99d9e0d6
7
+ data.tar.gz: 25fc0eec3d98c4722e1792771cab62b59b5ebe1e740c6556e5d76ad23d6f248b636816eaa2c3613e523b15e5cd95917e8dad1627dfcb3abd61c4e25b716b068e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.0
1
+ 1.6.0
@@ -2,6 +2,8 @@ module JMESPath
2
2
  # @api private
3
3
  module Nodes
4
4
  class Comparator < Node
5
+ COMPARABLE_TYPES = [Numeric, String].freeze
6
+
5
7
  attr_reader :left, :right
6
8
 
7
9
  def initialize(left, right)
@@ -36,6 +38,12 @@ module JMESPath
36
38
  def check(left_value, right_value)
37
39
  nil
38
40
  end
41
+
42
+ def comparable?(left_value, right_value)
43
+ COMPARABLE_TYPES.any? do |type|
44
+ left_value.is_a?(type) && right_value.is_a?(type)
45
+ end
46
+ end
39
47
  end
40
48
 
41
49
  module Comparators
@@ -54,7 +62,7 @@ module JMESPath
54
62
 
55
63
  class Gt < Comparator
56
64
  def check(left_value, right_value)
57
- if left_value.is_a?(Numeric) && right_value.is_a?(Numeric)
65
+ if comparable?(left_value, right_value)
58
66
  left_value > right_value
59
67
  else
60
68
  nil
@@ -64,7 +72,7 @@ module JMESPath
64
72
 
65
73
  class Gte < Comparator
66
74
  def check(left_value, right_value)
67
- if left_value.is_a?(Numeric) && right_value.is_a?(Numeric)
75
+ if comparable?(left_value, right_value)
68
76
  left_value >= right_value
69
77
  else
70
78
  nil
@@ -74,7 +82,7 @@ module JMESPath
74
82
 
75
83
  class Lt < Comparator
76
84
  def check(left_value, right_value)
77
- if left_value.is_a?(Numeric) && right_value.is_a?(Numeric)
85
+ if comparable?(left_value, right_value)
78
86
  left_value < right_value
79
87
  else
80
88
  nil
@@ -84,7 +92,7 @@ module JMESPath
84
92
 
85
93
  class Lte < Comparator
86
94
  def check(left_value, right_value)
87
- if left_value.is_a?(Numeric) && right_value.is_a?(Numeric)
95
+ if comparable?(left_value, right_value)
88
96
  left_value <= right_value
89
97
  else
90
98
  nil
@@ -27,6 +27,7 @@ module JMESPath
27
27
 
28
28
  class ComparatorCondition < Node
29
29
  COMPARATOR_TO_CONDITION = {}
30
+ COMPARABLE_TYPES = [Integer, String].freeze
30
31
 
31
32
  def initialize(left, right, child)
32
33
  @left = left
@@ -37,6 +38,14 @@ module JMESPath
37
38
  def visit(value)
38
39
  nil
39
40
  end
41
+
42
+ private
43
+
44
+ def comparable?(left_value, right_value)
45
+ COMPARABLE_TYPES.any? do |type|
46
+ left_value.is_a?(type) && right_value.is_a?(type)
47
+ end
48
+ end
40
49
  end
41
50
 
42
51
  class EqCondition < ComparatorCondition
@@ -99,7 +108,7 @@ module JMESPath
99
108
  def visit(value)
100
109
  left_value = @left.visit(value)
101
110
  right_value = @right.visit(value)
102
- left_value.is_a?(Integer) && right_value.is_a?(Integer) && left_value > right_value ? @child.visit(value) : nil
111
+ comparable?(left_value, right_value) && left_value > right_value ? @child.visit(value) : nil
103
112
  end
104
113
  end
105
114
 
@@ -109,7 +118,7 @@ module JMESPath
109
118
  def visit(value)
110
119
  left_value = @left.visit(value)
111
120
  right_value = @right.visit(value)
112
- left_value.is_a?(Integer) && right_value.is_a?(Integer) && left_value >= right_value ? @child.visit(value) : nil
121
+ comparable?(left_value, right_value) && left_value >= right_value ? @child.visit(value) : nil
113
122
  end
114
123
  end
115
124
 
@@ -119,7 +128,7 @@ module JMESPath
119
128
  def visit(value)
120
129
  left_value = @left.visit(value)
121
130
  right_value = @right.visit(value)
122
- left_value.is_a?(Integer) && right_value.is_a?(Integer) && left_value < right_value ? @child.visit(value) : nil
131
+ comparable?(left_value, right_value) && left_value < right_value ? @child.visit(value) : nil
123
132
  end
124
133
  end
125
134
 
@@ -129,7 +138,7 @@ module JMESPath
129
138
  def visit(value)
130
139
  left_value = @left.visit(value)
131
140
  right_value = @right.visit(value)
132
- left_value.is_a?(Integer) && right_value.is_a?(Integer) && left_value <= right_value ? @child.visit(value) : nil
141
+ comparable?(left_value, right_value) && left_value <= right_value ? @child.visit(value) : nil
133
142
  end
134
143
  end
135
144
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jmespath
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Rowe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Implements JMESPath for Ruby
14
14
  email: trevorrowe@gmail.com
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.2.7
69
+ rubygems_version: 3.2.3
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: JMESPath - Ruby Edition