srl_ruby 0.4.5 → 0.4.9

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.
Files changed (58) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +298 -23
  3. data/CHANGELOG.md +41 -0
  4. data/Gemfile +2 -0
  5. data/LICENSE.txt +1 -1
  6. data/README.md +1 -1
  7. data/Rakefile +3 -0
  8. data/appveyor.yml +14 -12
  9. data/bin/srl2ruby +13 -9
  10. data/bin/srl2ruby_cli_parser.rb +3 -3
  11. data/features/lib/step_definitions/srl_testing_steps.rb +2 -0
  12. data/features/lib/support/env..rb +2 -0
  13. data/lib/regex/abstract_method.rb +2 -0
  14. data/lib/regex/alternation.rb +3 -3
  15. data/lib/regex/anchor.rb +3 -0
  16. data/lib/regex/atomic_expression.rb +2 -0
  17. data/lib/regex/capturing_group.rb +8 -3
  18. data/lib/regex/char_class.rb +4 -2
  19. data/lib/regex/char_range.rb +3 -3
  20. data/lib/regex/char_shorthand.rb +3 -0
  21. data/lib/regex/character.rb +5 -2
  22. data/lib/regex/compound_expression.rb +2 -0
  23. data/lib/regex/concatenation.rb +3 -1
  24. data/lib/regex/expression.rb +6 -1
  25. data/lib/regex/lookaround.rb +3 -1
  26. data/lib/regex/match_option.rb +2 -0
  27. data/lib/regex/monadic_expression.rb +2 -0
  28. data/lib/regex/multiplicity.rb +8 -9
  29. data/lib/regex/non_capturing_group.rb +3 -1
  30. data/lib/regex/polyadic_expression.rb +2 -0
  31. data/lib/regex/quantifiable.rb +3 -1
  32. data/lib/regex/raw_expression.rb +2 -0
  33. data/lib/regex/repetition.rb +2 -0
  34. data/lib/regex/wildcard.rb +2 -5
  35. data/lib/srl_ruby/ast_builder.rb +81 -121
  36. data/lib/srl_ruby/grammar.rb +80 -92
  37. data/lib/srl_ruby/regex_repr.rb +2 -0
  38. data/lib/srl_ruby/tokenizer.rb +10 -4
  39. data/lib/srl_ruby/version.rb +3 -1
  40. data/lib/srl_ruby.rb +2 -0
  41. data/spec/acceptance/srl_test_suite_spec.rb +2 -0
  42. data/spec/acceptance/support/rule_file_ast_builder.rb +2 -0
  43. data/spec/acceptance/support/rule_file_grammar.rb +7 -5
  44. data/spec/acceptance/support/rule_file_nodes.rb +2 -0
  45. data/spec/acceptance/support/rule_file_parser.rb +2 -0
  46. data/spec/acceptance/support/rule_file_tokenizer.rb +10 -3
  47. data/spec/regex/atomic_expression_spec.rb +2 -0
  48. data/spec/regex/character_spec.rb +16 -6
  49. data/spec/regex/match_option_spec.rb +2 -0
  50. data/spec/regex/monadic_expression_spec.rb +2 -0
  51. data/spec/regex/multiplicity_spec.rb +4 -0
  52. data/spec/regex/repetition_spec.rb +2 -0
  53. data/spec/spec_helper.rb +2 -0
  54. data/spec/srl_ruby/srl_ruby_spec.rb +2 -0
  55. data/spec/srl_ruby/tokenizer_spec.rb +2 -0
  56. data/spec/srl_ruby_spec.rb +8 -6
  57. data/srl_ruby.gemspec +6 -4
  58. metadata +13 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 09e2d0e45cb7094a048508eaf8af5e3d081a279b
4
- data.tar.gz: 50017e8623af0c0f034746541f430f21f4df7660
2
+ SHA256:
3
+ metadata.gz: 53f0b4c07147644a3298d66dd4db0b7108fc1cc630debc1be7dc5721bca244bf
4
+ data.tar.gz: 410029ea6b5ddc36c6161d50701500af1cb406e8b39bbfa2b6d6d60839db41eb
5
5
  SHA512:
6
- metadata.gz: 911f5c56ba1fcd7fcefa97b23ca8d3f76c228f84d21eeb742c40415fa81763a2ba0d296b045f38e727be94ea2bc0517141cf7e593493596e98c4f8a4e55a2e95
7
- data.tar.gz: e0b9b5e7a2a9a87520fe632f37e5ed89484be85d16f02519628ac44c0716dad669352cd86e465a46b225cc009d8e9eddc06328348e98243ad470c007cd0f2a8f
6
+ metadata.gz: 0e6124858fe023541f5fc291790251c2c87a2c36cbf28f9285d4b4ed6b87c3705ce381da3536c5e70627101f17c3b203673ea175fbb3fe58f7d193219ef959c0
7
+ data.tar.gz: a74fb973b4d74fe3546e10e9466654998f0f675ebaf9253932d8fb04b516feea767ab511c86fd11522df58084049a2b0f6455e1fd54ecde7920fd8f32550fc0b
data/.rubocop.yml CHANGED
@@ -1,10 +1,21 @@
1
1
  AllCops:
2
2
  Exclude:
3
3
  - 'exp/**/*'
4
+ - 'demo/**/*'
5
+
6
+ Gemspec/DateAssignment:
7
+ Enabled: true
8
+
9
+ Layout/ArgumentAlignment:
10
+ Enabled: false
11
+
12
+ Layout/ArrayAlignment:
13
+ Enabled: true
14
+ EnforcedStyle: with_fixed_indentation
4
15
 
5
16
  Layout/CaseIndentation:
6
17
  Enabled: false
7
-
18
+
8
19
  Layout/ClosingHeredocIndentation:
9
20
  Enabled: false
10
21
 
@@ -16,7 +27,7 @@ Layout/ElseAlignment:
16
27
 
17
28
  Layout/EmptyLines:
18
29
  Enabled: false
19
-
30
+
20
31
  Layout/EndAlignment:
21
32
  Enabled: false
22
33
 
@@ -24,39 +35,127 @@ Layout/EndOfLine:
24
35
  Enabled: true
25
36
  EnforcedStyle: lf
26
37
 
38
+ Layout/FirstArgumentIndentation:
39
+ Enabled: false
40
+
41
+ Layout/HashAlignment:
42
+ Enabled: false
43
+
27
44
  Layout/IndentationWidth:
28
45
  Enabled: false
29
46
 
30
47
  Layout/IndentationConsistency:
31
48
  Enabled: true
32
-
33
- Layout/IndentHeredoc:
49
+
50
+ Layout/HeredocIndentation:
34
51
  Enabled: false
35
-
52
+
53
+ Layout/LineEndStringConcatenationIndentation:
54
+ Enabled: true
55
+
36
56
  Layout/MultilineHashBraceLayout:
37
57
  Enabled: true
38
58
 
59
+ Layout/MultilineMethodCallBraceLayout:
60
+ Enabled: true
61
+ EnforcedStyle: same_line
62
+
39
63
  Layout/SpaceAroundOperators:
40
64
  Enabled: true
41
65
 
66
+ Layout/SpaceBeforeBrackets:
67
+ Enabled: true
68
+
42
69
  Layout/SpaceInsideParens:
43
70
  Enabled: true
44
-
45
- Layout/Tab:
71
+
72
+ Layout/IndentationStyle:
73
+ Enabled: true
74
+
75
+ Layout/SpaceAroundMethodCallOperator:
46
76
  Enabled: true
47
-
48
- Layout/TrailingBlankLines:
77
+
78
+ Layout/TrailingEmptyLines:
49
79
  Enabled: true
50
80
 
51
81
  Layout/TrailingWhitespace:
52
82
  Enabled: true
53
83
 
84
+ Lint/AmbiguousAssignment:
85
+ Enabled: true
86
+
87
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
88
+ Enabled: true
89
+
90
+ Lint/AmbiguousRange:
91
+ Enabled: true
92
+
93
+ Lint/DeprecatedConstants:
94
+ Enabled: true
95
+
96
+ Lint/DuplicateBranch:
97
+ Enabled: true
98
+
99
+ Lint/DuplicateRegexpCharacterClassElement:
100
+ Enabled: true
101
+
102
+ Lint/EmptyBlock:
103
+ Enabled: true
104
+
105
+ Lint/EmptyClass:
106
+ Enabled: false
107
+
108
+ Lint/EmptyInPattern:
109
+ Enabled: true
110
+
111
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
112
+ Enabled: true
113
+
114
+ Lint/LambdaWithoutLiteralBlock:
115
+ Enabled: true
116
+
54
117
  Lint/Loop:
55
118
  Enabled: true
56
119
 
120
+ Lint/NoReturnInBeginEndBlocks:
121
+ Enabled: true
122
+
123
+ Lint/NumberedParameterAssignment:
124
+ Enabled: true
125
+
126
+ Lint/OrAssignmentToConstant:
127
+ Enabled: true
128
+
129
+ Lint/RaiseException:
130
+ Enabled: true
131
+
132
+ Lint/RedundantDirGlobSort:
133
+ Enabled: true
134
+
135
+ Lint/RequireRelativeSelfPath: # new in 1.22
136
+ Enabled: true
137
+
57
138
  Lint/RescueException:
58
139
  Enabled: true
59
140
 
141
+ Lint/StructNewOverride:
142
+ Enabled: true
143
+
144
+ Lint/SymbolConversion:
145
+ Enabled: true
146
+
147
+ Lint/ToEnumArguments:
148
+ Enabled: true
149
+
150
+ Lint/TripleQuotes:
151
+ Enabled: true
152
+
153
+ Lint/UnexpectedBlockArity:
154
+ Enabled: true
155
+
156
+ Lint/UnmodifiedReduceAccumulator:
157
+ Enabled: true
158
+
60
159
  Lint/UnusedMethodArgument:
61
160
  Enabled: true
62
161
 
@@ -76,20 +175,24 @@ Metrics/BlockLength:
76
175
  Enabled: true
77
176
  Max: 350
78
177
 
178
+ Metrics/BlockNesting:
179
+ Enabled: true
180
+ Max: 5
181
+
79
182
  Metrics/ClassLength:
80
183
  Enabled: true
81
- Max: 350
184
+ Max: 450
82
185
 
83
186
  Metrics/CyclomaticComplexity:
84
187
  Enabled: false
85
188
 
86
- Metrics/LineLength:
189
+ Layout/LineLength:
87
190
  Enabled: false
88
191
  Max: 90
89
192
 
90
193
  Metrics/MethodLength:
91
194
  Enabled: true
92
- Max: 40
195
+ Max: 60
93
196
 
94
197
  Metrics/ModuleLength:
95
198
  Enabled: true
@@ -103,21 +206,30 @@ Naming/ConstantName:
103
206
 
104
207
  Naming/ClassAndModuleCamelCase:
105
208
  Enabled: false
106
-
107
- Naming/UncommunicativeBlockParamName:
209
+
210
+ Naming/BlockParameterName:
108
211
  Enabled: true
109
-
110
- Naming/UncommunicativeMethodParamName:
212
+
213
+ Naming/InclusiveLanguage:
214
+ Enabled: true
215
+
216
+ Naming/MethodParameterName:
217
+ Enabled: false
218
+
219
+ Naming/MethodName:
111
220
  Enabled: false
112
221
 
113
222
  Naming/VariableName:
114
223
  Enabled: false
115
224
 
225
+ Security/IoMethods: # new in 1.22
226
+ Enabled: true
227
+
116
228
  Style/Alias:
117
229
  Enabled: true
118
230
 
119
- Layout/AlignHash:
120
- Enabled: false
231
+ Style/ArgumentsForwarding:
232
+ Enabled: true
121
233
 
122
234
  Style/AsciiComments:
123
235
  Enabled: false
@@ -137,6 +249,9 @@ Style/ClassCheck:
137
249
  Style/ClassVars:
138
250
  Enabled: false
139
251
 
252
+ Style/CollectionCompact:
253
+ Enabled: true
254
+
140
255
  Style/ColonMethodCall:
141
256
  Enabled: false
142
257
 
@@ -155,44 +270,204 @@ Style/DefWithParentheses:
155
270
  Style/Documentation:
156
271
  Enabled: false
157
272
 
273
+ Style/DocumentDynamicEvalDefinition:
274
+ Enabled: true
275
+
158
276
  Style/ExpandPathArguments:
159
277
  Enabled: false
160
278
 
279
+ Style/ExponentialNotation:
280
+ Enabled: true
281
+
161
282
  Style/GuardClause:
162
283
  Enabled: false
163
284
 
285
+ Style/HashEachMethods:
286
+ Enabled: true
287
+
288
+ Style/HashExcept:
289
+ Enabled: true
290
+
291
+ Style/HashTransformKeys:
292
+ Enabled: true
293
+
294
+ Style/HashTransformValues:
295
+ Enabled: true
296
+
164
297
  Style/IfUnlessModifier:
165
298
  Enabled: false
166
299
 
300
+ Style/InPatternThen:
301
+ Enabled: true
302
+
167
303
  Style/InverseMethods:
304
+ Enabled: false
305
+
306
+ Style/MissingRespondToMissing:
307
+ Enabled: false
308
+
309
+ Style/MultilineInPatternThen:
310
+ Enabled: true
311
+
312
+ Style/NegatedIfElseCondition:
168
313
  Enabled: true
169
314
 
170
315
  Style/Next:
171
316
  Enabled: false
172
317
 
318
+ Style/NilLambda:
319
+ Enabled: true
320
+
321
+ Style/NumberedParameters: # new in 1.22
322
+ Enabled: true
323
+
324
+ Style/NumberedParametersLimit: # new in 1.22
325
+ Enabled: true
326
+
327
+ Style/NumericLiterals:
328
+ Enabled: false
329
+
330
+ Style/QuotedSymbols:
331
+ Enabled: true
332
+
173
333
  Style/RaiseArgs:
174
334
  Enabled: true
175
335
 
336
+ Style/RedundantArgument:
337
+ Enabled: true
338
+
176
339
  Style/RedundantReturn:
177
340
  Enabled: false
178
-
341
+
179
342
  Style/RedundantSelf:
180
343
  Enabled: true
181
344
 
345
+ Style/RedundantSelfAssignmentBranch:
346
+ Enabled: true
347
+
182
348
  Style/RegexpLiteral:
183
349
  Enabled: false
184
350
 
185
351
  Style/PercentLiteralDelimiters:
186
352
  Enabled: false
187
-
353
+
354
+ Style/SelectByRegexp: # new in 1.22
355
+ Enabled: true
356
+
188
357
  Style/StderrPuts:
189
- Enabled: false
358
+ Enabled: false
190
359
 
191
360
  Style/StringLiterals:
192
361
  Enabled: true
193
362
 
363
+ Style/SwapValues:
364
+ Enabled: true
365
+
194
366
  Style/TernaryParentheses:
195
367
  Enabled: false
196
-
368
+
197
369
  Style/UnlessElse:
198
- Enabled: false
370
+ Enabled: false
371
+
372
+ # Rubocop complains when it doesn't find an explicit setting for the following cops:
373
+ Layout/EmptyLinesAroundAttributeAccessor:
374
+ Enabled: true
375
+
376
+ Lint/BinaryOperatorWithIdenticalOperands:
377
+ Enabled: true
378
+
379
+ Lint/DeprecatedOpenSSLConstant:
380
+ Enabled: true
381
+
382
+ Lint/DuplicateElsifCondition:
383
+ Enabled: true
384
+
385
+ Lint/DuplicateRescueException:
386
+ Enabled: true
387
+
388
+ Lint/EmptyConditionalBody:
389
+ Enabled: true
390
+
391
+ Lint/FloatComparison:
392
+ Enabled: true
393
+
394
+ Lint/MissingSuper:
395
+ Enabled: true
396
+
397
+ Lint/MixedRegexpCaptureTypes:
398
+ Enabled: true
399
+
400
+ Lint/OutOfRangeRegexpRef:
401
+ Enabled: true
402
+
403
+ Lint/SelfAssignment:
404
+ Enabled: true
405
+
406
+ Lint/TopLevelReturnWithArgument:
407
+ Enabled: true
408
+
409
+ Lint/UnreachableLoop:
410
+ Enabled: true
411
+
412
+ Style/AccessorGrouping:
413
+ Enabled: true
414
+
415
+ Style/ArrayCoercion:
416
+ Enabled: true
417
+
418
+ Style/BisectedAttrAccessor:
419
+ Enabled: true
420
+
421
+ Style/CaseLikeIf:
422
+ Enabled: true
423
+
424
+ Style/EndlessMethod:
425
+ Enabled: true
426
+
427
+ Style/ExplicitBlockArgument:
428
+ Enabled: true
429
+
430
+ Style/GlobalStdStream:
431
+ Enabled: true
432
+
433
+ Style/HashAsLastArrayItem:
434
+ Enabled: true
435
+
436
+ Style/HashConversion:
437
+ Enabled: true
438
+
439
+ Style/HashLikeCase:
440
+ Enabled: true
441
+
442
+ Style/IfWithBooleanLiteralBranches:
443
+ Enabled: true
444
+
445
+ Style/OptionalBooleanParameter:
446
+ Enabled: true
447
+
448
+ Style/RedundantAssignment:
449
+ Enabled: true
450
+
451
+ Style/RedundantFetchBlock:
452
+ Enabled: true
453
+
454
+ Style/RedundantFileExtensionInRequire:
455
+ Enabled: true
456
+
457
+ Style/RedundantRegexpCharacterClass:
458
+ Enabled: true
459
+
460
+ Style/RedundantRegexpEscape:
461
+ Enabled: true
462
+
463
+ Style/SingleArgumentDig:
464
+ Enabled: true
465
+
466
+ Style/SlicingWithRange:
467
+ Enabled: true
468
+
469
+ Style/StringChars:
470
+ Enabled: true
471
+
472
+ Style/StringConcatenation:
473
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ ## [0.4.9] - 2021-11-01
2
+ - Code update to align with `Rley` v. 0.8.08
3
+
4
+ ### Changed
5
+ - File `ast_builder.rb` Updated some `reduce_...` methods to cope with ? quantifier change
6
+ - File `srl_ruby.gemspec` Updated the dependency towards Rley
7
+ - File `.rubocop.yml` Added newest cops from 1.21 and 1.22
8
+
9
+ ### Fixed
10
+ - File `grammar.rb` is now calling `Rley::grammar_builder` factory method.
11
+ - File `rule_file_grammar.rb` is now calling `Rley::grammar_builder` factory method.
12
+
13
+ ## [0.4.8] - 2021-08-27
14
+ - Updated dependencies (Bundler >~ 2.2), (Rley >~ 0.8.03)
15
+ - Grammar refactoring to take profit of new Rley rule syntax.
16
+
17
+ ### Changed
18
+ - File `srl_ruby.gemspec` Updated the dependencies
19
+ - File `grammar.rb` Grammar refactored (use ? * + modifiers in production rules)
20
+ - class `ASTBuilder` updated `reduce_` to reflect new refactored production rules.
21
+
22
+ ## [0.4.7] - 2021-08-24
23
+ - Updated dependencies (Ruby >= 2.5), (Rley >= 0.8.02)
24
+ - Code restyling to please rubocop 1.19.1.
25
+ ### Changed
26
+ - File `srl_ruby.gemspec` Updated the dependencies
27
+ - File `.rubocop.yml` Added configuration for newest cops
28
+
29
+ ## [0.4.6] - 2019-08-17
30
+ - Code refactoring to use string frozen magic comments (as a consequence, skeem runs only on Rubies 2.3 or newer).
31
+ - Code restyling to please rubocop 0.7.40.
32
+ ### Changed
33
+ - File `README.md` updated note on compatibility with Rubies
34
+
35
+
36
+ ## [0.4.5] - 2019-01-13
37
+ - Removed Ruby versions older than 2.3 in CI testing because of breaking changes by Bundler 2.0
38
+
39
+ ### Changed
40
+ * Files `.travis.yml`, `appveyor.yml` updated.
41
+
1
42
  ## [0.4.5] - 2019-01-02
2
43
  ### Changed
3
44
  - Minor code re-styling to please Rubocop 0.62.0.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
data/LICENSE.txt CHANGED
@@ -5,7 +5,7 @@ the 'srl_test' directory, which is subject to its own license.
5
5
 
6
6
  The MIT License (MIT)
7
7
 
8
- Copyright (c) 2018-2019 Dimitri Geshef
8
+ Copyright (c) 2018-2021 Dimitri Geshef
9
9
 
10
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
11
11
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -15,7 +15,7 @@ With **srl_ruby** you can easily design your patterns in SRL and let *srl_ruby*
15
15
  - Ruby API for integrating a SRL parser or compiler with your code.
16
16
  - 100% pure Ruby with clean design (_not a port from some other language_)
17
17
  - Minimal runtime dependency ([Rley](https://rubygems.org/gems/rley) gem). Won't drag a bunch of gems...
18
- - Compatibility: works with 2.x+ MRI, JRuby
18
+ - Compatibility: works with Ruby 2.3+ MRI, JRuby
19
19
  - Portability: tested on both Linux and Windows,...
20
20
 
21
21
  ## Installation
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task' # Rspec as testing tool
3
5
  require 'cucumber/rake/task' # Cucumber as testing tool
@@ -8,6 +10,7 @@ RSpec::Core::RakeTask.new do |spec|
8
10
  end
9
11
 
10
12
  Cucumber::Rake::Task.new do |_|
13
+ # Comment
11
14
  end
12
15
 
13
16
  # Combine RSpec and Cucumber tests
data/appveyor.yml CHANGED
@@ -1,26 +1,28 @@
1
1
  version: '{build}'
2
- max_jobs: 3
2
+ max_jobs: 5
3
3
  environment:
4
4
  matrix:
5
+ - Ruby_version: 26-x64
5
6
  - Ruby_version: 25-x64
6
- - Ruby_version: 24-x64
7
+ - Ruby_version: 24-x64
7
8
  - Ruby_version: 23-x64
8
- - Ruby_version: 22-x64
9
- - Ruby_version: 21-x64
10
- - Ruby_version: 25
11
- - Ruby_version: 24
12
- - Ruby_version: 23
13
- - Ruby_version: 22
14
- - Ruby_version: 21
15
- # These are failing
16
- # - Ruby_version: 26
17
- # - Ruby_version: 26-x64
9
+ - Ruby_version: 26
10
+ - Ruby_version: 25
11
+ - Ruby_version: 24
12
+ - Ruby_version: 23
18
13
 
19
14
  install:
20
15
  - set PATH=C:\Ruby%Ruby_version%\bin;%PATH%
16
+ - gem update --system
17
+ - gem install bundler
21
18
  - bundle install --retry=3 --clean --force
22
19
 
23
20
  build: off
24
21
 
22
+ before_test:
23
+ - ruby -v
24
+ - gem -v
25
+ - bundle -v
26
+
25
27
  test_script:
26
28
  - bundle exec rake
data/bin/srl2ruby CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require 'erb'
3
5
  require 'rubygems'
4
6
  require 'pathname'
@@ -7,10 +9,14 @@ require_relative '../lib/srl_ruby'
7
9
  require_relative 'srl2ruby_cli_parser'
8
10
 
9
11
  class Srl2RubyProg
10
- DefaultSRLExtension = 'srl'.freeze
11
- DefDirname = '/templates'.freeze
12
- DefTemplate = 'base.erb'.freeze
12
+ DefaultSRLExtension = 'srl'
13
+ DefDirname = '/templates'
14
+ DefTemplate = 'base.erb'
15
+
16
+ # @return [Hash]
13
17
  attr_reader(:cli_options)
18
+
19
+ # @return [ERB]
14
20
  attr_reader(:template)
15
21
 
16
22
  def initialize(prog_name, args)
@@ -47,18 +53,16 @@ class Srl2RubyProg
47
53
  fname = cli_options[:template]
48
54
  exists = File.exist?(fname)
49
55
  if exists
50
- t_filepath = Dir.getwd + '/' + fname
56
+ t_filepath = "#{Dir.getwd}/#{fname}"
51
57
  else
52
- t_filepath = def_template_dir + '/' + fname
58
+ t_filepath = "#{def_template_dir}/#{fname}"
53
59
  exit(1) unless file_exist?(t_filepath)
54
60
  end
55
61
  else
56
- t_filepath = def_template_dir + '/' + DefTemplate
62
+ t_filepath = "#{def_template_dir}/#{DefTemplate}"
57
63
  end
58
64
  path = Pathname.new(t_filepath)
59
- erb_template = ERB.new(path.read, nil, '<>')
60
-
61
- erb_template
65
+ ERB.new(path.read, nil, '<>')
62
66
  end
63
67
 
64
68
  def validate_filename(raw_fname)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'optparse' # Use standard OptionParser class for command-line parsing
2
4
 
3
5
  # A command-line option parser for the srl2ruby compiler.
@@ -35,7 +37,7 @@ class Srl2RubyCLIParser < OptionParser
35
37
  end
36
38
 
37
39
  def description
38
- descr = <<-DESCR
40
+ <<-DESCR
39
41
  Description:
40
42
  Parses a SRL file and compiles it into a Ruby Regexp literal.
41
43
  Simple Regex Language (SRL) website: https://simple-regex.com
@@ -45,8 +47,6 @@ Examples:
45
47
  #{program_name} -p 'begin with literally "Hello world!"'
46
48
  #{program_name} example.srl -o example_re.rb -t srl_and_ruby.erb
47
49
  DESCR
48
-
49
- descr
50
50
  end
51
51
 
52
52
  def heading
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  When('I define the following SRL expression:') do |srl_source|
2
4
  @regex = SrlRuby::parse(srl_source)
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec'
2
4
  require 'cucumber'
3
5
  require 'srl_ruby'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # File: abstract_method.rb
2
4
 
3
5
  # Mix-in module. Provides the method 'abstract_method' that raises an exception
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # File: alternation.rb
2
4
 
3
5
  require_relative 'polyadic_expression' # Access the superclass
@@ -17,9 +19,7 @@ module Regex # This module is used as a namespace
17
19
  # Purpose: Return the String representation of the concatented expressions.
18
20
  def text_repr
19
21
  result_children = children.map(&:to_str)
20
- result = '(?:' + result_children.join('|') + ')'
21
-
22
- return result
22
+ "(?:#{result_children.join('|')})"
23
23
  end
24
24
  end # class
25
25
  end # module