cucumber-tag-expressions 6.1.0 → 6.1.2

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: bddf0d042650b79fc5886aed9537224e09c014fcdf858606cf71a78ed3a039c1
4
+ data.tar.gz: 6f22aa0faeb10909fed7db9af1f4b7dff6e040d46a10da31681edb55df4376f9
5
5
  SHA512:
6
- metadata.gz: 838196e211cb93599402f1ae4f928ca91f039a2a3ae5cdf7b1245e1ad8dc5609edf5ca1ce6f6e56d722a642c37a3afa6a7d8c89ce8a0baf3de8f2ee551631287
7
- data.tar.gz: 3ab907243a1fa9a2ab3330829650f6fdf8769dcc532b7fddb04bc70bf8acaaa51e5fa74426840975d1bfcf15fd32084a2fcccab0f950d374dd10775457d5d665
6
+ metadata.gz: a0b216d933ee4aca4eae8e1114b75acff19565f179931c3b61c531b94eb4d233af2ec16ac954513121d06d35d352ade10e730949314b137adf7bf114612309b6
7
+ data.tar.gz: d1f799fa7b759c0c6be6a7cd2d49e89924880b5a1aa708659755448ccec974fecfaad43f6945bd3f3dd5c3c4afff4c850c74637631b3f8991d9b24035ac1892f
@@ -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,15 +1,14 @@
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Nodari
8
8
  - Aslak Hellesøy
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-01-10 00:00:00.000000000 Z
11
+ date: 2025-01-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
@@ -17,20 +16,14 @@ dependencies:
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: '13.0'
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 13.0.6
19
+ version: '13.1'
24
20
  type: :development
25
21
  prerelease: false
26
22
  version_requirements: !ruby/object:Gem::Requirement
27
23
  requirements:
28
24
  - - "~>"
29
25
  - !ruby/object:Gem::Version
30
- version: '13.0'
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 13.0.6
26
+ version: '13.1'
34
27
  - !ruby/object:Gem::Dependency
35
28
  name: rspec
36
29
  requirement: !ruby/object:Gem::Requirement
@@ -69,10 +62,6 @@ files:
69
62
  - lib/cucumber/tag_expressions.rb
70
63
  - lib/cucumber/tag_expressions/expressions.rb
71
64
  - lib/cucumber/tag_expressions/parser.rb
72
- - spec/errors_spec.rb
73
- - spec/evaluations_spec.rb
74
- - spec/parsing_spec.rb
75
- - spec/spec_helper.rb
76
65
  homepage: https://cucumber.io/docs/cucumber/api/#tag-expressions
77
66
  licenses:
78
67
  - MIT
@@ -82,7 +71,6 @@ metadata:
82
71
  documentation_uri: https://cucumber.io/docs/cucumber/api/#tag-expressions
83
72
  mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
84
73
  source_code_uri: https://github.com/cucumber/tag-expressions/tree/main/ruby
85
- post_install_message:
86
74
  rdoc_options:
87
75
  - "--charset=UTF-8"
88
76
  require_paths:
@@ -98,12 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
86
  - !ruby/object:Gem::Version
99
87
  version: 3.0.8
100
88
  requirements: []
101
- rubygems_version: 3.4.10
102
- signing_key:
89
+ rubygems_version: 3.6.2
103
90
  specification_version: 4
104
- summary: cucumber-tag-expressions-6.1.0
105
- test_files:
106
- - spec/errors_spec.rb
107
- - spec/evaluations_spec.rb
108
- - spec/parsing_spec.rb
109
- - spec/spec_helper.rb
91
+ summary: cucumber-tag-expressions-6.1.2
92
+ test_files: []
data/spec/errors_spec.rb DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- tests = YAML.load_file('../testdata/errors.yml')
4
-
5
- describe 'Errors' do
6
- tests.each do |test|
7
- let(:parser) { Cucumber::TagExpressions::Parser.new }
8
-
9
- it "fails to parse '#{test['expression']}' with '#{test['error']}'" do
10
- expect { parser.parse(test['expression']) }.to raise_error(test['error'])
11
- end
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- evaluations = YAML.load_file('../testdata/evaluations.yml')
4
-
5
- describe 'Evaluations' do
6
- evaluations.each do |evaluation|
7
- context evaluation['expression'] do
8
- let(:parser) { Cucumber::TagExpressions::Parser.new }
9
-
10
- evaluation['tests'].each do |test|
11
- it "evaluates [#{test['variables'].join(', ')}] to #{test['result']}" do
12
- expect(parser.parse(evaluation['expression']).evaluate(test['variables'])).to eq(test['result'])
13
- end
14
- end
15
- end
16
- end
17
- end
data/spec/parsing_spec.rb DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- tests = YAML.load_file('../testdata/parsing.yml')
4
-
5
- describe 'Parsing' do
6
- let(:parser) { Cucumber::TagExpressions::Parser.new }
7
-
8
- tests.each do |test|
9
- it "parses '#{test['expression']}' into '#{test['formatted']}'" do
10
- expect(parser.parse(test['expression']).to_s).to eq(test['formatted'])
11
- end
12
- end
13
- end
data/spec/spec_helper.rb DELETED
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'cucumber/tag_expressions/parser'
4
- require 'yaml'