srl_ruby 0.4.8 → 0.4.11

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: 4142454106f1b3b0a0e1e9b7c382ba6c5088f34a7b4d2e4c9437164537bb766a
4
- data.tar.gz: 2ded972212dc2db8b037aba56aec6f79917a90a945f56c8f9f72b1bd88cd8b69
3
+ metadata.gz: 3a2509164bd980bf2145d41c15281608694674f633b2a6f2b482b6298db7d36a
4
+ data.tar.gz: 3112162a2a27268dd4d0c1e8cf4b0af25b98a158152e7ceca9e9d5f34c347c96
5
5
  SHA512:
6
- metadata.gz: d7da9074cd772c28dc7eeaa8072d39fb5a91a08dba1665982fbf08303582c84742cf72ca6785ed18f1944cb11fcfd25fb011a37f93055c552011543235799669
7
- data.tar.gz: '070724971995e366a27232732d5accf62c3e2141807ae80a7548d0ae98a28004bf811c50119001e581648c3e262cba7295ee6117bab5f1bddea3110e692d9c94'
6
+ metadata.gz: 51099a1c625930c9e139079f73647524caf6db7ed23ccdcdee475a720dcdb238d4e48ad0632f6ec7b0cee8e57785a25ce7b5f4232c605811f382a95d11b31afa
7
+ data.tar.gz: a4a7383ce66944d5b5c834200a8e5b2367660912a93daaca13dc27eb95fd56f0b655317c575a4013dd5e69b22af804a4dcbfb5ce5a5804249bf78d7495d5a4e9
data/.rubocop.yml CHANGED
@@ -1,9 +1,13 @@
1
1
  AllCops:
2
2
  Exclude:
3
3
  - 'exp/**/*'
4
+ - 'demo/**/*'
4
5
 
5
6
  Gemspec/DateAssignment:
6
7
  Enabled: true
8
+
9
+ Gemspec/RequireMFA: # new in 1.23
10
+ Enabled: false
7
11
 
8
12
  Layout/ArgumentAlignment:
9
13
  Enabled: false
@@ -83,6 +87,9 @@ Layout/TrailingWhitespace:
83
87
  Lint/AmbiguousAssignment:
84
88
  Enabled: true
85
89
 
90
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
91
+ Enabled: true
92
+
86
93
  Lint/AmbiguousRange:
87
94
  Enabled: true
88
95
 
@@ -104,6 +111,9 @@ Lint/EmptyClass:
104
111
  Lint/EmptyInPattern:
105
112
  Enabled: true
106
113
 
114
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
115
+ Enabled: true
116
+
107
117
  Lint/LambdaWithoutLiteralBlock:
108
118
  Enabled: true
109
119
 
@@ -124,6 +134,12 @@ Lint/RaiseException:
124
134
 
125
135
  Lint/RedundantDirGlobSort:
126
136
  Enabled: true
137
+
138
+ Lint/RefinementImportMethods: # new in 1.27
139
+ Enabled: true
140
+
141
+ Lint/RequireRelativeSelfPath: # new in 1.22
142
+ Enabled: true
127
143
 
128
144
  Lint/RescueException:
129
145
  Enabled: true
@@ -151,6 +167,9 @@ Lint/UnusedMethodArgument:
151
167
 
152
168
  Lint/UselessAccessModifier:
153
169
  Enabled: true
170
+
171
+ Lint/UselessRuby2Keywords: # new in 1.23
172
+ Enabled: true
154
173
 
155
174
  Lint/Void:
156
175
  Enabled: false
@@ -196,6 +215,9 @@ Naming/ConstantName:
196
215
 
197
216
  Naming/ClassAndModuleCamelCase:
198
217
  Enabled: false
218
+
219
+ Naming/BlockForwarding: # new in 1.24
220
+ Enabled: true
199
221
 
200
222
  Naming/BlockParameterName:
201
223
  Enabled: true
@@ -212,6 +234,9 @@ Naming/MethodName:
212
234
  Naming/VariableName:
213
235
  Enabled: false
214
236
 
237
+ Security/IoMethods: # new in 1.22
238
+ Enabled: true
239
+
215
240
  Style/Alias:
216
241
  Enabled: true
217
242
 
@@ -258,13 +283,19 @@ Style/Documentation:
258
283
  Enabled: false
259
284
 
260
285
  Style/DocumentDynamicEvalDefinition:
261
- Enabled: false
286
+ Enabled: true
262
287
 
263
288
  Style/ExpandPathArguments:
264
289
  Enabled: false
265
290
 
266
291
  Style/ExponentialNotation:
267
292
  Enabled: true
293
+
294
+ Style/FileRead: # new in 1.24
295
+ Enabled: true
296
+
297
+ Style/FileWrite: # new in 1.24
298
+ Enabled: true
268
299
 
269
300
  Style/GuardClause:
270
301
  Enabled: false
@@ -289,6 +320,9 @@ Style/InPatternThen:
289
320
 
290
321
  Style/InverseMethods:
291
322
  Enabled: false
323
+
324
+ Style/MapToHash: # new in 1.24
325
+ Enabled: true
292
326
 
293
327
  Style/MissingRespondToMissing:
294
328
  Enabled: false
@@ -299,14 +333,26 @@ Style/MultilineInPatternThen:
299
333
  Style/NegatedIfElseCondition:
300
334
  Enabled: true
301
335
 
336
+ Style/NestedFileDirname: # new in 1.26
337
+ Enabled: true
338
+
302
339
  Style/Next:
303
340
  Enabled: false
304
341
 
305
342
  Style/NilLambda:
306
343
  Enabled: true
307
344
 
345
+ Style/NumberedParameters: # new in 1.22
346
+ Enabled: true
347
+
348
+ Style/NumberedParametersLimit: # new in 1.22
349
+ Enabled: true
350
+
308
351
  Style/NumericLiterals:
309
352
  Enabled: false
353
+
354
+ Style/OpenStructUse: # new in 1.23
355
+ Enabled: true
310
356
 
311
357
  Style/QuotedSymbols:
312
358
  Enabled: true
@@ -316,6 +362,9 @@ Style/RaiseArgs:
316
362
 
317
363
  Style/RedundantArgument:
318
364
  Enabled: true
365
+
366
+ Style/RedundantInitialize: # new in 1.27
367
+ Enabled: true
319
368
 
320
369
  Style/RedundantReturn:
321
370
  Enabled: false
@@ -332,6 +381,9 @@ Style/RegexpLiteral:
332
381
  Style/PercentLiteralDelimiters:
333
382
  Enabled: false
334
383
 
384
+ Style/SelectByRegexp: # new in 1.22
385
+ Enabled: true
386
+
335
387
  Style/StderrPuts:
336
388
  Enabled: false
337
389
 
@@ -448,4 +500,4 @@ Style/StringChars:
448
500
  Enabled: true
449
501
 
450
502
  Style/StringConcatenation:
451
- Enabled: true
503
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [0.4.11] - 2022-04-17
2
+ - Fixed code breaking change in Ruby 3.1+: prime library is no longer part of stdlib.
3
+
4
+ ### Fixed
5
+ - File `srl-ruby.gemspec` has a dependency to `Rley 0.8.11`. Necessary to fix change in CRuby 3.1: `prime` library is no more part of stdlib.
6
+
7
+ ### Changed
8
+ - Minor style refactoring to please Runocop 1.27
9
+
10
+ ## [0.4.9] - 2021-11-01
11
+ - Code update to align with `Rley` v. 0.8.08
12
+
13
+ ### Changed
14
+ - File `ast_builder.rb` Updated some `reduce_...` methods to cope with ? quantifier change
15
+ - File `srl_ruby.gemspec` Updated the dependency towards Rley
16
+ - File `.rubocop.yml` Added newest cops from 1.21 and 1.22
17
+
18
+ ### Fixed
19
+ - File `grammar.rb` is now calling `Rley::grammar_builder` factory method.
20
+ - File `rule_file_grammar.rb` is now calling `Rley::grammar_builder` factory method.
21
+
1
22
  ## [0.4.8] - 2021-08-27
2
23
  - Updated dependencies (Bundler >~ 2.2), (Rley >~ 0.8.03)
3
24
  - Grammar refactoring to take profit of new Rley rule syntax.
data/Rakefile CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task' # Rspec as testing tool
5
- require 'cucumber/rake/task' # Cucumber as testing tool
5
+ # require 'cucumber/rake/task' # Cucumber as testing tool
6
6
 
7
- desc 'Run RSpec'
8
- RSpec::Core::RakeTask.new do |spec|
9
- spec.pattern = 'spec/**/*_spec.rb'
10
- end
7
+ # desc 'Run RSpec'
8
+ RSpec::Core::RakeTask.new(:spec)
11
9
 
12
- Cucumber::Rake::Task.new do |_|
13
- # Comment
14
- end
10
+ # Cucumber::Rake::Task.new do |_|
11
+ # # Comment
12
+ # end
15
13
 
16
14
  # Combine RSpec and Cucumber tests
17
15
  desc 'Run tests, with RSpec and Cucumber'
18
- task test: %i[spec cucumber]
16
+ task test: :spec
17
+ # task test: %i[spec cucumber]
18
+
19
19
 
20
20
  # Default rake task
21
21
  task default: :test
@@ -13,9 +13,6 @@ module Regex # This module is used as a namespace
13
13
  # @return [NilClass, Anchor]
14
14
  attr_accessor :end_anchor
15
15
 
16
- # Constructor
17
- def initialize(); end
18
-
19
16
  # Abstract method. Return true iff the expression is atomic
20
17
  # (= doesn't not have any child).
21
18
  # @return [Boolean]
@@ -120,7 +120,7 @@ module SrlRuby
120
120
 
121
121
  # rule('expression' => 'pattern (flags)?').tag 'flagged_expr'
122
122
  def reduce_flagged_expr(_production, aRange, theTokens, theChildren)
123
- @options = theChildren[1] if theChildren[1]
123
+ @options = theChildren[1].first if theChildren[1]
124
124
  return_first_child(aRange, theTokens, theChildren)
125
125
  end
126
126
 
@@ -163,7 +163,7 @@ module SrlRuby
163
163
 
164
164
  # rule('quantifiable' => 'begin_anchor? anchorable end_anchor?')
165
165
  def reduce_quantifiable(_production, _range, _tokens, theChildren)
166
- Regex::Concatenation.new(*theChildren.compact)
166
+ Regex::Concatenation.new(*theChildren.flatten.compact)
167
167
  end
168
168
 
169
169
  # rule 'begin_anchor' => %w[STARTS WITH]
@@ -195,7 +195,7 @@ module SrlRuby
195
195
 
196
196
  # rule('assertable' => 'term quantifier?').tag 'assertable'
197
197
  def reduce_assertable(_production, _range, _tokens, theChildren)
198
- (term, quantifier) = theChildren
198
+ (term, quantifier) = theChildren.flatten
199
199
  quantifier ? repetition(term, quantifier) : term
200
200
  end
201
201
 
@@ -5,7 +5,7 @@ require 'rley' # Load the gem
5
5
  module SrlRuby
6
6
  ########################################
7
7
  # SRL grammar
8
- builder = Rley::Notation::GrammarBuilder.new do
8
+ builder = Rley::grammar_builder do
9
9
  # Separators...
10
10
  add_terminals('LPAREN', 'RPAREN', 'COMMA')
11
11
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SrlRuby
4
- VERSION = '0.4.8'
4
+ VERSION = '0.4.11'
5
5
  end
@@ -32,7 +32,7 @@ module Acceptance
32
32
  Terminal2NodeClass
33
33
  end
34
34
 
35
- # rule('rule_file' => %w[srl_heading srl_tests]).as 'start_rule'
35
+ # rule('rule_file' => 'srl_heading tests').as 'start_rule'
36
36
  def reduce_start_rule(_production, _range, _tokens, theChildren)
37
37
  rule_file = RuleFileTests.new(theChildren[0])
38
38
  tests = theChildren.last.flatten
@@ -54,16 +54,6 @@ module Acceptance
54
54
  theChildren.last
55
55
  end
56
56
 
57
- # rule('srl_tests' => %w[srl_tests single_test]).as 'test_list'
58
- def reduce_test_list(_production, _range, _tokens, theChildren)
59
- theChildren[0] << theChildren[1]
60
- end
61
-
62
- # rule('srl_tests' => 'single_test').as 'one_test'
63
- def reduce_one_test(_production, _range, _tokens, theChildren)
64
- [theChildren.last]
65
- end
66
-
67
57
  # rule('match_test' => %w[MATCH: STRING_LIT]).as 'match_string'
68
58
  def reduce_match_string(_production, _range, _tokens, theChildren)
69
59
  MatchTest.new(theChildren.last)
@@ -85,17 +75,6 @@ module Acceptance
85
75
  theChildren[2]
86
76
  end
87
77
 
88
- # rule('capture_expectations' => %w[capture_expectations
89
- # single_expectation]).as 'assertion_list'
90
- def reduce_assertion_list(_production, _range, _tokens, theChildren)
91
- theChildren[0] << theChildren[1]
92
- end
93
-
94
- # rule('capture_expectations' => 'single_expectation').as 'one_expectation'
95
- def reduce_one_expectation(_production, _range, _tokens, theChildren)
96
- [theChildren.last]
97
- end
98
-
99
78
  # rule('single_expectation' => %w[DASH INTEGER COLON capture_variable
100
79
  # COLON STRING_LIT]).as 'capture_expectation'
101
80
  def reduce_capture_expectation(_production, _range, _tokens, theChildren)
@@ -6,8 +6,7 @@ require 'rley' # Load the Rley gem
6
6
  # Grammar for Test-Rule files
7
7
  # [File format](https://github.com/SimpleRegex/Test-Rules/blob/master/README.md)
8
8
  ########################################
9
- # Define a grammar for basic arithmetical expressions
10
- builder = Rley::Notation::GrammarBuilder.new do
9
+ builder = Rley::grammar_builder do
11
10
  # Punctuation
12
11
  add_terminals('COLON', 'DASH')
13
12
 
@@ -19,24 +18,20 @@ builder = Rley::Notation::GrammarBuilder.new do
19
18
  add_terminals('INTEGER', 'STRING_LIT')
20
19
  add_terminals('IDENTIFIER', 'SRL_SOURCE')
21
20
 
22
- rule('rule_file' => 'srl_heading srl_tests').as 'start_rule'
23
- rule('srl_heading' => 'SRL SRL_SOURCE').as 'srl_source'
24
- rule('srl_tests' => 'srl_tests single_test').as 'test_list'
25
- rule('srl_tests' => 'single_test').as 'one_test'
26
- rule('single_test' => 'atomic_test').as 'single_atomic_test'
27
- rule('single_test' => 'compound_test').as 'single_compound_test'
28
- rule('atomic_test' => 'match_test').as 'atomic_match'
29
- rule('atomic_test' => 'no_match_test').as 'atomic_no_match'
30
- rule('compound_test' => 'capture_test').as 'compound_capture'
31
- rule('match_test' => 'MATCH STRING_LIT').as 'match_string'
32
- rule('no_match_test' => 'NO MATCH STRING_LIT').as 'no_match_string'
33
- rule('capture_test' => 'capture_heading capture_expectations').as 'capture_test'
34
- rule('capture_heading' => 'CAPTURE FOR STRING_LIT COLON').as 'capture_string'
35
- rule('capture_expectations' => 'capture_expectations single_expectation').as 'assertion_list'
36
- rule('capture_expectations' => 'single_expectation').as 'one_expectation'
37
- rule('single_expectation' => 'DASH INTEGER COLON capture_variable COLON STRING_LIT').as 'capture_expectation'
38
- rule('capture_variable' => 'INTEGER').as 'var_integer'
39
- rule('capture_variable' => 'IDENTIFIER').as 'var_identifier'
21
+ rule('rule_file' => 'srl_heading srl_test+').tag 'start_rule'
22
+ rule('srl_heading' => 'SRL SRL_SOURCE').tag 'srl_source'
23
+ rule('srl_test' => 'atomic_test').tag 'single_atomic_test'
24
+ rule('srl_test' => 'compound_test').tag 'single_compound_test'
25
+ rule('atomic_test' => 'match_test').tag 'atomic_match'
26
+ rule('atomic_test' => 'no_match_test').tag 'atomic_no_match'
27
+ rule('compound_test' => 'capture_test').tag 'compound_capture'
28
+ rule('match_test' => 'MATCH STRING_LIT').tag 'match_string'
29
+ rule('no_match_test' => 'NO MATCH STRING_LIT').tag 'no_match_string'
30
+ rule('capture_test' => 'capture_heading capture_expectation+').tag 'capture_test'
31
+ rule('capture_heading' => 'CAPTURE FOR STRING_LIT COLON').tag 'capture_string'
32
+ rule('capture_expectation' => 'DASH INTEGER COLON capture_variable COLON STRING_LIT').tag 'capture_expectation'
33
+ rule('capture_variable' => 'INTEGER').tag 'var_integer'
34
+ rule('capture_variable' => 'IDENTIFIER').tag 'var_identifier'
40
35
  end
41
36
 
42
37
  # And now build the grammar...
@@ -53,6 +53,7 @@ module Regex # Open this namespace, to get rid of scope qualifiers
53
53
  end
54
54
  end # context
55
55
 
56
+ # rubocop: disable Style/DocumentDynamicEvalDefinition
56
57
  context 'Provided services' do
57
58
  it 'Should know its lexeme if created from a string' do
58
59
  # Lexeme is defined when the character was initialised from a text
@@ -89,6 +90,7 @@ module Regex # Open this namespace, to get rid of scope qualifiers
89
90
 
90
91
  # Try with our escape sequence samples
91
92
  (SampleDigrams + SampleNumEscs).each do |escape_seq|
93
+ # Build a string from escape sequence literal
92
94
  expectation = String.class_eval(%Q|"#{escape_seq}"|, __FILE__, __LINE__)
93
95
  new_ch = Character.new(escape_seq).to_str
94
96
  new_ch == expectation
@@ -113,6 +115,7 @@ module Regex # Open this namespace, to get rid of scope qualifiers
113
115
 
114
116
  # Try with our escape sequence samples
115
117
  (SampleDigrams + SampleNumEscs).each do |escape_seq|
118
+ # Get ordinal value of given escape sequence
116
119
  expectation = String.class_eval(%Q|"#{escape_seq}".ord()|, __FILE__, __LINE__)
117
120
  expect(Character.new(escape_seq).codepoint).to eq(expectation)
118
121
  end
@@ -147,7 +150,7 @@ module Regex # Open this namespace, to get rid of scope qualifiers
147
150
  # Case 5: test fails with multiple character strings
148
151
  expect(newOne).not_to eq('03a3')
149
152
 
150
- # Case 6: equality testing with arbitray object
153
+ # Case 6: equality testing with arbitrary object
151
154
  expect(newOne).not_to eq(nil)
152
155
  expect(newOne).not_to eq(Object.new)
153
156
 
@@ -169,6 +172,7 @@ module Regex # Open this namespace, to get rid of scope qualifiers
169
172
  expect(ch2.explain).to eq("the character '\u03a3'")
170
173
  end
171
174
  end # context
175
+ # rubocop: enable Style/DocumentDynamicEvalDefinition
172
176
  # rubocop: enable Lint/ConstantDefinitionInBlock
173
177
  end # describe
174
178
  end # module
data/srl_ruby.gemspec CHANGED
@@ -68,11 +68,11 @@ SUMMARY
68
68
  spec.required_ruby_version = '>= 2.5.0'
69
69
 
70
70
  # Runtime dependencies
71
- spec.add_dependency 'rley', '~> 0.8.02'
71
+ spec.add_dependency 'rley', '~> 0.8.11'
72
72
 
73
73
  # Development dependencies
74
- spec.add_development_dependency 'bundler', '~> 2.2.0'
75
- spec.add_development_dependency 'cucumber', '>= 2.2.0'
76
- spec.add_development_dependency 'rake', '~> 12.0'
74
+ spec.add_development_dependency 'bundler', '>= 2.2.0'
75
+ spec.add_development_dependency 'cucumber', '>= 3.1.2'
76
+ spec.add_development_dependency 'rake', '>= 12.0'
77
77
  spec.add_development_dependency 'rspec', '~> 3.0'
78
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: srl_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2022-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley
@@ -16,26 +16,26 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.02
19
+ version: 0.8.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.02
26
+ version: 0.8.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.2.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.2.0
41
41
  - !ruby/object:Gem::Dependency
@@ -44,26 +44,26 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.2.0
47
+ version: 3.1.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.2.0
54
+ version: 3.1.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '12.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '12.0'
69
69
  - !ruby/object:Gem::Dependency
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
208
  requirements: []
209
- rubygems_version: 3.1.4
209
+ rubygems_version: 3.3.7
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: A parser for the [Simple Regex Language](https://simple-regex.com/). It translates