cucumber-tag-expressions 6.1.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0f706cda9810598cd7d38933b862a0e50e2870be4525012e64e4b0b6596b3b3
4
- data.tar.gz: 40b6af7268af69b1af1406d567cf0e536bd00d6d28dd3a6693a29c822b4e4876
3
+ metadata.gz: 47563b3d91bae578ee83c3f510081724ba64d4322cb6196beaf0da543d4b21c0
4
+ data.tar.gz: 5bcf02d2e8b2e0aa0b7b2906ba9aecde5224f967b12fc7deb7f013e6defa5614
5
5
  SHA512:
6
- metadata.gz: 838196e211cb93599402f1ae4f928ca91f039a2a3ae5cdf7b1245e1ad8dc5609edf5ca1ce6f6e56d722a642c37a3afa6a7d8c89ce8a0baf3de8f2ee551631287
7
- data.tar.gz: 3ab907243a1fa9a2ab3330829650f6fdf8769dcc532b7fddb04bc70bf8acaaa51e5fa74426840975d1bfcf15fd32084a2fcccab0f950d374dd10775457d5d665
6
+ metadata.gz: 724e4dc685894201c18998973edd45866ebe13a75799119c847c19209c0f9b6b8c9042d81001d8faf2e6f922b926a5d14053b0672457394f5f6b8096cb2ccf9b
7
+ data.tar.gz: 64044f10e31c417e6348c02d7f21043e8f0aa223b6a0b892cbfe4a74b266007d85140c66c4b6528075d4cce1340a7292453810ecebfc28142e87df319d2edc16
@@ -8,14 +8,6 @@ module Cucumber
8
8
  def initialize
9
9
  @expressions = []
10
10
  @operators = []
11
-
12
- @operator_types = {
13
- 'or' => { type: :binary_operator, precedence: 0, assoc: :left },
14
- 'and' => { type: :binary_operator, precedence: 1, assoc: :left },
15
- 'not' => { type: :unary_operator, precedence: 2, assoc: :right },
16
- ')' => { type: :close_paren, precedence: -1 },
17
- '(' => { type: :open_paren, precedence: 1 }
18
- }
19
11
  end
20
12
 
21
13
  def parse(infix_expression)
@@ -24,11 +16,7 @@ module Cucumber
24
16
  return True.new if tokens.empty?
25
17
 
26
18
  tokens.each do |token|
27
- if @operator_types[token]
28
- expected_token_type = send("handle_#{@operator_types.dig(token, :type)}", infix_expression, token, expected_token_type)
29
- else
30
- expected_token_type = handle_literal(infix_expression, token, expected_token_type)
31
- end
19
+ expected_token_type = handle_sequential_tokens(token, infix_expression, expected_token_type)
32
20
  end
33
21
 
34
22
  while @operators.any?
@@ -43,7 +31,7 @@ module Cucumber
43
31
  private
44
32
 
45
33
  def assoc_of(token, value)
46
- @operator_types.dig(token, :assoc) == value
34
+ operator_types.dig(token, :assoc) == value
47
35
  end
48
36
 
49
37
  def lower_precedence?(operation)
@@ -52,11 +40,11 @@ module Cucumber
52
40
  end
53
41
 
54
42
  def operator?(token)
55
- [:unary_operator, :binary_operator].include?(@operator_types.dig(token, :type))
43
+ %i[unary_operator binary_operator].include?(operator_types.dig(token, :type))
56
44
  end
57
45
 
58
46
  def precedence(token)
59
- @operator_types.dig(token, :precedence)
47
+ operator_types.dig(token, :precedence)
60
48
  end
61
49
 
62
50
  def tokenize(infix_expression)
@@ -89,10 +77,18 @@ module Cucumber
89
77
 
90
78
  def push_expression(token)
91
79
  case token
92
- when 'and'; @expressions.push(And.new(*pop(@expressions, 2)))
93
- when 'or'; @expressions.push(Or.new(*pop(@expressions, 2)))
94
- when 'not'; @expressions.push(Not.new(pop(@expressions)))
95
- else @expressions.push(Literal.new(token))
80
+ when 'and' then @expressions.push(And.new(*pop(@expressions, 2)))
81
+ when 'or' then @expressions.push(Or.new(*pop(@expressions, 2)))
82
+ when 'not' then @expressions.push(Not.new(pop(@expressions)))
83
+ else @expressions.push(Literal.new(token))
84
+ end
85
+ end
86
+
87
+ def handle_sequential_tokens(token, infix_expression, expected_token_type)
88
+ if operator_types[token]
89
+ send("handle_#{operator_types.dig(token, :type)}", infix_expression, token, expected_token_type)
90
+ else
91
+ handle_literal(infix_expression, token, expected_token_type)
96
92
  end
97
93
  end
98
94
 
@@ -143,6 +139,16 @@ module Cucumber
143
139
  amount == 1 ? result.first : result
144
140
  end
145
141
 
142
+ def operator_types
143
+ {
144
+ 'or' => { type: :binary_operator, precedence: 0, assoc: :left },
145
+ 'and' => { type: :binary_operator, precedence: 1, assoc: :left },
146
+ 'not' => { type: :unary_operator, precedence: 2, assoc: :right },
147
+ ')' => { type: :close_paren, precedence: -1 },
148
+ '(' => { type: :open_paren, precedence: 1 }
149
+ }
150
+ end
151
+
146
152
  def whitespace?(char)
147
153
  char.match(/\s/)
148
154
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-tag-expressions
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Nodari
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-10 00:00:00.000000000 Z
12
+ date: 2024-10-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -98,10 +98,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: 3.0.8
100
100
  requirements: []
101
- rubygems_version: 3.4.10
101
+ rubygems_version: 3.4.19
102
102
  signing_key:
103
103
  specification_version: 4
104
- summary: cucumber-tag-expressions-6.1.0
104
+ summary: cucumber-tag-expressions-6.1.1
105
105
  test_files:
106
106
  - spec/errors_spec.rb
107
107
  - spec/evaluations_spec.rb