srl_ruby 0.4.6 → 0.4.10

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.
@@ -5,7 +5,7 @@ require 'rley' # Load the gem
5
5
  module SrlRuby
6
6
  ########################################
7
7
  # SRL grammar
8
- builder = Rley::Syntax::GrammarBuilder.new do
8
+ builder = Rley::grammar_builder do
9
9
  # Separators...
10
10
  add_terminals('LPAREN', 'RPAREN', 'COMMA')
11
11
 
@@ -31,97 +31,83 @@ module SrlRuby
31
31
  add_terminals('LAZY')
32
32
 
33
33
  # Grammar rules...
34
- rule('srl' => 'expression').as 'start_rule'
35
- rule('expression' => %w[pattern flags]).as 'flagged_expr'
36
- rule('expression' => 'pattern').as 'simple_expr'
37
- rule('pattern' => %w[pattern separator sub_pattern]).as 'pattern_sequence'
38
- rule('pattern' => 'sub_pattern').as 'basic_pattern'
39
- rule('sub_pattern' => 'quantifiable').as 'quantifiable_sub_pattern'
40
- rule('sub_pattern' => 'assertion').as 'assertion_sub_pattern'
41
- rule('separator' => 'COMMA').as 'comma_separator'
42
- rule('separator' => []).as 'void_separator'
43
- rule('flags' => %w[flags separator single_flag]).as 'flag_sequence'
44
- rule('flags' => %w[separator single_flag]).as 'flag_simple'
45
- rule('single_flag' => %w[CASE INSENSITIVE]).as 'case_insensitive'
46
- rule('single_flag' => %w[MULTI LINE]).as 'multi_line'
47
- rule('single_flag' => %w[ALL LAZY]).as 'all_lazy'
48
- rule('quantifiable' => %w[begin_anchor anchorable end_anchor]).as 'pinned_quantifiable'
49
- rule('quantifiable' => %w[begin_anchor anchorable]).as 'begin_anchor_quantifiable'
50
- rule('quantifiable' => %w[anchorable end_anchor]).as 'end_anchor_quantifiable'
51
- rule('quantifiable' => 'anchorable').as 'simple_quantifiable'
52
- rule('begin_anchor' => %w[STARTS WITH]).as 'starts_with'
53
- rule('begin_anchor' => %w[BEGIN WITH]).as 'begin_with'
54
- rule('end_anchor' => %w[separator MUST END]).as 'end_anchor'
55
- rule('anchorable' => 'assertable').as 'simple_anchorable'
56
- rule('assertion' => %w[IF FOLLOWED BY assertable]).as 'if_followed'
57
- rule('assertion' => %w[IF NOT FOLLOWED BY assertable]).as 'if_not_followed'
58
- rule('assertion' => %w[IF ALREADY HAD assertable]).as 'if_had'
59
- rule('assertion' => %w[IF NOT ALREADY HAD assertable]).as 'if_not_had'
60
- rule('assertable' => 'term').as 'simple_assertable'
61
- rule('assertable' => %w[term quantifier]).as 'quantified_assertable'
62
- rule('term' => 'atom').as 'atom_term'
63
- rule('term' => 'alternation').as 'alternation_term'
64
- rule('term' => 'grouping').as 'grouping_term'
65
- rule('term' => 'capturing_group').as 'capturing_group_atom'
66
- rule('atom' => 'letter_range').as 'letter_range_atom'
67
- rule('atom' => 'digit_range').as 'digit_range_atom'
68
- rule('atom' => 'character_class').as 'character_class_atom'
69
- rule('atom' => 'special_char').as 'special_char_atom'
70
- rule('atom' => 'literal').as 'literal_atom'
71
- rule('atom' => 'raw').as 'raw_atom'
72
- rule('letter_range' => %w[LETTER FROM LETTER_LIT TO LETTER_LIT]).as 'lowercase_from_to'
73
- rule('letter_range' => %w[UPPERCASE LETTER FROM LETTER_LIT TO LETTER_LIT]).as 'uppercase_from_to'
74
- rule('letter_range' => 'LETTER').as 'any_lowercase'
75
- rule('letter_range' => %w[UPPERCASE LETTER]).as 'any_uppercase'
76
- rule('digit_range' => %w[digit_or_number FROM DIGIT_LIT TO DIGIT_LIT]).as 'digits_from_to'
77
- rule('character_class' => %w[ANY CHARACTER]).as 'any_character'
78
- rule('character_class' => %w[NO CHARACTER]).as 'no_character'
79
- rule('character_class' => 'digit_or_number').as 'digit'
80
- rule('character_class' => %w[NO DIGIT]).as 'non_digit'
81
- rule('character_class' => 'WHITESPACE').as 'whitespace'
82
- rule('character_class' => %w[NO WHITESPACE]).as 'no_whitespace'
83
- rule('character_class' => 'ANYTHING').as 'anything'
84
- rule('character_class' => %w[ONE OF cclass]).as 'one_of'
85
- rule('character_class' => %w[NONE OF cclass]).as 'none_of'
86
- rule('cclass' => 'STRING_LIT').as 'quoted_cclass' # Preferred syntax
87
- rule('cclass' => 'INTEGER').as 'digits_cclass'
88
- rule('cclass' => 'IDENTIFIER').as 'identifier_cclass'
89
- rule('cclass' => 'CHAR_CLASS').as 'unquoted_cclass'
90
- rule('special_char' => 'TAB').as 'tab'
91
- rule('special_char' => 'VERTICAL TAB').as 'vtab'
92
- rule('special_char' => 'BACKSLASH').as 'backslash'
93
- rule('special_char' => %w[NEW LINE]).as 'new_line'
94
- rule('special_char' => %w[CARRIAGE RETURN]).as 'carriage_return'
95
- rule('special_char' => %w[WORD]).as 'word'
96
- rule('special_char' => %w[NO WORD]).as 'no_word'
97
- rule('literal' => %w[LITERALLY STRING_LIT]).as 'literally'
98
- rule('raw' => 'RAW STRING_LIT').as 'raw_literal'
99
- rule('alternation' => %w[any_or_either OF LPAREN alternatives RPAREN]).as 'any_of'
100
- rule('alternatives' => %w[alternatives separator quantifiable]).as 'alternative_list'
101
- rule('alternatives' => 'quantifiable').as 'simple_alternative'
102
- rule('any_or_either' => 'ANY').as 'any_keyword'
103
- rule('any_or_either' => 'EITHER').as 'either_keyword'
104
- rule('grouping' => %w[LPAREN pattern RPAREN]).as 'grouping_parenthenses'
105
- rule('capturing_group' => %w[CAPTURE assertable]).as 'capture'
106
- rule('capturing_group' => %w[CAPTURE assertable UNTIL assertable]).as 'capture_until'
107
- rule('capturing_group' => %w[CAPTURE assertable AS var_name]).as 'named_capture'
108
- rule('capturing_group' => %w[CAPTURE assertable AS var_name UNTIL assertable]).as 'named_capture_until'
109
- rule('var_name' => 'STRING_LIT').as 'var_name'
110
- rule('var_name' => 'IDENTIFIER').as 'var_ident' # capture name not enclosed between quotes
111
- rule('quantifier' => 'ONCE').as 'once'
112
- rule('quantifier' => 'TWICE').as 'twice'
113
- rule('quantifier' => %w[EXACTLY count TIMES]).as 'exactly'
114
- rule('quantifier' => %w[BETWEEN count AND count times_suffix]).as 'between_and'
115
- rule('quantifier' => 'OPTIONAL').as 'optional'
116
- rule('quantifier' => %w[ONCE OR MORE]).as 'once_or_more'
117
- rule('quantifier' => %w[NEVER OR MORE]).as 'never_or_more'
118
- rule('quantifier' => %w[AT LEAST count TIMES]).as 'at_least'
119
- rule('digit_or_number' => 'DIGIT').as 'digit_keyword'
120
- rule('digit_or_number' => 'NUMBER').as 'number_keyword'
121
- rule('count' => 'DIGIT_LIT').as 'single_digit'
122
- rule('count' => 'INTEGER').as 'integer_count'
123
- rule('times_suffix' => 'TIMES').as 'times_keyword'
124
- rule('times_suffix' => []).as 'times_dropped'
34
+ rule('srl' => 'expression').tag 'start_rule'
35
+ rule('expression' => 'pattern flags?').tag 'flagged_expr'
36
+ rule('pattern' => 'sub_pattern (separator sub_pattern)*').tag 'pattern_sequence'
37
+ rule('sub_pattern' => 'quantifiable').tag 'quantifiable_sub_pattern'
38
+ rule('sub_pattern' => 'assertion').tag 'assertion_sub_pattern'
39
+ rule('separator' => 'COMMA?')
40
+ rule('flags' => '(separator single_flag)+').tag 'flag_sequence'
41
+ rule('single_flag' => 'CASE INSENSITIVE').tag 'case_insensitive'
42
+ rule('single_flag' => 'MULTI LINE').tag 'multi_line'
43
+ rule('single_flag' => 'ALL LAZY').tag 'all_lazy'
44
+ rule('quantifiable' => 'begin_anchor? anchorable end_anchor?').tag 'quantifiable'
45
+ rule('begin_anchor' => 'STARTS WITH').tag 'starts_with'
46
+ rule('begin_anchor' => 'BEGIN WITH').tag 'begin_with'
47
+ rule('end_anchor' => 'separator MUST END').tag 'end_anchor'
48
+ rule('anchorable' => 'assertable').tag 'simple_anchorable'
49
+ rule('assertion' => 'IF NOT? FOLLOWED BY assertable').tag 'if_followed'
50
+ rule('assertion' => 'IF NOT? ALREADY HAD assertable').tag 'if_had'
51
+ rule('assertable' => 'term quantifier?').tag 'assertable'
52
+ rule('term' => 'atom').tag 'atom_term'
53
+ rule('term' => 'alternation').tag 'alternation_term'
54
+ rule('term' => 'grouping').tag 'grouping_term'
55
+ rule('term' => 'capturing_group').tag 'capturing_group_atom'
56
+ rule('atom' => 'letter_range').tag 'letter_range_atom'
57
+ rule('atom' => 'digit_range').tag 'digit_range_atom'
58
+ rule('atom' => 'character_class').tag 'character_class_atom'
59
+ rule('atom' => 'special_char').tag 'special_char_atom'
60
+ rule('atom' => 'literal').tag 'literal_atom'
61
+ rule('atom' => 'raw').tag 'raw_atom'
62
+ rule('letter_range' => 'LETTER FROM LETTER_LIT TO LETTER_LIT').tag 'lowercase_from_to'
63
+ rule('letter_range' => 'UPPERCASE LETTER FROM LETTER_LIT TO LETTER_LIT').tag 'uppercase_from_to'
64
+ rule('letter_range' => 'LETTER').tag 'any_lowercase'
65
+ rule('letter_range' => 'UPPERCASE LETTER').tag 'any_uppercase'
66
+ rule('digit_range' => 'digit_or_number FROM DIGIT_LIT TO DIGIT_LIT').tag 'digits_from_to'
67
+ rule('character_class' => 'ANY CHARACTER').tag 'any_character'
68
+ rule('character_class' => 'NO CHARACTER').tag 'no_character'
69
+ rule('character_class' => 'digit_or_number').tag 'digit'
70
+ rule('character_class' => 'NO DIGIT').tag 'non_digit'
71
+ rule('character_class' => 'WHITESPACE').tag 'whitespace'
72
+ rule('character_class' => 'NO WHITESPACE').tag 'no_whitespace'
73
+ rule('character_class' => 'ANYTHING').tag 'anything'
74
+ rule('character_class' => 'ONE OF cclass').tag 'one_of'
75
+ rule('character_class' => 'NONE OF cclass').tag 'none_of'
76
+ rule('cclass' => 'STRING_LIT').tag 'quoted_cclass' # Preferred syntax
77
+ rule('cclass' => 'INTEGER').tag 'digits_cclass'
78
+ rule('cclass' => 'IDENTIFIER').tag 'identifier_cclass'
79
+ rule('cclass' => 'CHAR_CLASS').tag 'unquoted_cclass'
80
+ rule('special_char' => 'TAB').tag 'tab'
81
+ rule('special_char' => 'VERTICAL TAB').tag 'vtab'
82
+ rule('special_char' => 'BACKSLASH').tag 'backslash'
83
+ rule('special_char' => 'NEW LINE').tag 'new_line'
84
+ rule('special_char' => 'CARRIAGE RETURN').tag 'carriage_return'
85
+ rule('special_char' => 'WORD').tag 'word'
86
+ rule('special_char' => 'NO WORD').tag 'no_word'
87
+ rule('literal' => 'LITERALLY STRING_LIT').tag 'literally'
88
+ rule('raw' => 'RAW STRING_LIT').tag 'raw_literal'
89
+ rule('alternation' => 'any_or_either OF LPAREN alternatives RPAREN').tag 'any_of'
90
+ rule('alternatives' => 'alternatives separator quantifiable').tag 'alternative_list'
91
+ rule('alternatives' => 'quantifiable').tag 'simple_alternative'
92
+ rule('any_or_either' => 'ANY').tag 'any_keyword'
93
+ rule('any_or_either' => 'EITHER').tag 'either_keyword'
94
+ rule('grouping' => 'LPAREN pattern RPAREN').tag 'grouping_parenthenses'
95
+ rule('capturing_group' => 'CAPTURE assertable (UNTIL assertable)?').tag 'capture'
96
+ rule('capturing_group' => 'CAPTURE assertable AS var_name (UNTIL assertable)?').tag 'named_capture'
97
+ rule('var_name' => 'STRING_LIT').tag 'var_name'
98
+ rule('var_name' => 'IDENTIFIER').tag 'var_ident' # capture name not enclosed between quotes
99
+ rule('quantifier' => 'ONCE').tag 'once'
100
+ rule('quantifier' => 'TWICE').tag 'twice'
101
+ rule('quantifier' => 'EXACTLY count TIMES').tag 'exactly'
102
+ rule('quantifier' => 'BETWEEN count AND count TIMES?').tag 'between_and'
103
+ rule('quantifier' => 'OPTIONAL').tag 'optional'
104
+ rule('quantifier' => 'ONCE OR MORE').tag 'once_or_more'
105
+ rule('quantifier' => 'NEVER OR MORE').tag 'never_or_more'
106
+ rule('quantifier' => 'AT LEAST count TIMES').tag 'at_least'
107
+ rule('digit_or_number' => 'DIGIT').tag 'digit_keyword'
108
+ rule('digit_or_number' => 'NUMBER').tag 'number_keyword'
109
+ rule('count' => 'DIGIT_LIT').tag 'single_digit'
110
+ rule('count' => 'INTEGER').tag 'integer_count'
125
111
  end
126
112
 
127
113
  # And now build the grammar and make it accessible via a global constant
@@ -17,10 +17,14 @@ module SrlRuby
17
17
  # Delimiters: parentheses '(' and ')'
18
18
  # Separators: comma (optional)
19
19
  class Tokenizer
20
+ # @return [StringScanner]
20
21
  attr_reader(:scanner)
22
+
23
+ # @return [Integer] current line number
21
24
  attr_reader(:lineno)
25
+
26
+ # @return [Integer] offset of start of current line within input
22
27
  attr_reader(:line_start)
23
- # attr_reader(:column)
24
28
 
25
29
  @@lexeme2name = {
26
30
  '(' => 'LPAREN',
@@ -86,7 +90,7 @@ module SrlRuby
86
90
  WHITESPACE
87
91
  WITH
88
92
  WORD
89
- ].map { |x| [x, x] } .to_h
93
+ ].map { |x| [x, x] }.to_h
90
94
 
91
95
  class ScanError < StandardError; end
92
96
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SrlRuby
4
- VERSION = '0.4.6'
4
+ VERSION = '0.4.10'
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,37 +6,32 @@ 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::Syntax::GrammarBuilder.new do
9
+ builder = Rley::grammar_builder do
11
10
  # Punctuation
12
11
  add_terminals('COLON', 'DASH')
13
12
 
14
13
  # Keywords
15
14
  add_terminals('CAPTURE', 'FOR')
16
- add_terminals('MATCH:', 'NO', 'SRL:')
15
+ add_terminals('MATCH', 'NO', 'SRL')
17
16
 
18
17
  # Literals
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...
@@ -16,8 +16,13 @@ module Acceptance
16
16
  # Delimiters: parentheses '(' and ')'
17
17
  # Separators: comma (optional)
18
18
  class RuleFileTokenizer
19
+ # @return [StringScanner]
19
20
  attr_reader(:scanner)
21
+
22
+ # @return [Integer] current line number
20
23
  attr_reader(:lineno)
24
+
25
+ # @return [Integer] offset of start of current line within input
21
26
  attr_reader(:line_start)
22
27
 
23
28
  # Can be :default, :expecting_srl
@@ -82,7 +87,7 @@ module Acceptance
82
87
  elsif (lexeme = scanner.scan(/[0-9]+/))
83
88
  token = build_token('INTEGER', lexeme)
84
89
  elsif (lexeme = scanner.scan(/srl:|match:/))
85
- token = build_token(@@keywords[lexeme], lexeme)
90
+ token = build_token(@@keywords[lexeme].chop, lexeme.chop)
86
91
  @state = :expecting_srl if lexeme == 'srl:'
87
92
  elsif (lexeme = scanner.scan(/[a-zA-Z_][a-zA-Z0-9_]*/))
88
93
  keyw = @@keywords[lexeme]
@@ -6,6 +6,8 @@ require_relative '../../lib/regex/character'
6
6
 
7
7
  module Regex # Open this namespace, to get rid of scope qualifiers
8
8
  describe Character do
9
+ # rubocop: disable Lint/ConstantDefinitionInBlock
10
+
9
11
  # This constant holds an arbitrary selection of characters
10
12
  SampleChars = [?a, ?\0, ?\u0107].freeze
11
13
 
@@ -87,6 +89,8 @@ module Regex # Open this namespace, to get rid of scope qualifiers
87
89
 
88
90
  # Try with our escape sequence samples
89
91
  (SampleDigrams + SampleNumEscs).each do |escape_seq|
92
+
93
+ # Build a string from escape sequence literal
90
94
  expectation = String.class_eval(%Q|"#{escape_seq}"|, __FILE__, __LINE__)
91
95
  new_ch = Character.new(escape_seq).to_str
92
96
  new_ch == expectation
@@ -111,11 +115,20 @@ module Regex # Open this namespace, to get rid of scope qualifiers
111
115
 
112
116
  # Try with our escape sequence samples
113
117
  (SampleDigrams + SampleNumEscs).each do |escape_seq|
118
+
119
+ # Get ordinal value of given escape sequence
114
120
  expectation = String.class_eval(%Q|"#{escape_seq}".ord()|, __FILE__, __LINE__)
115
121
  expect(Character.new(escape_seq).codepoint).to eq(expectation)
116
122
  end
117
123
  end
118
124
 
125
+ # Create a module that re-defines the existing to_s method
126
+ module Tweak_to_s
127
+ def to_s # Overwrite the existing to_s method
128
+ ?\u03a3
129
+ end
130
+ end # module
131
+
119
132
  it 'should known whether it is equal to another Object' do
120
133
  newOne = Character.new(?\u03a3)
121
134
 
@@ -147,12 +160,6 @@ module Regex # Open this namespace, to get rid of scope qualifiers
147
160
  expect(simulator).to receive(:to_s).and_return(?\u03a3)
148
161
  expect(newOne).to eq(simulator)
149
162
 
150
- # Create a module that re-defines the existing to_s method
151
- module Tweak_to_s
152
- def to_s # Overwrite the existing to_s method
153
- ?\u03a3
154
- end
155
- end # module
156
163
  weird = Object.new
157
164
  weird.extend(Tweak_to_s)
158
165
  expect(newOne).to eq(weird)
@@ -166,6 +173,7 @@ module Regex # Open this namespace, to get rid of scope qualifiers
166
173
  expect(ch2.explain).to eq("the character '\u03a3'")
167
174
  end
168
175
  end # context
176
+ # rubocop: enable Lint/ConstantDefinitionInBlock
169
177
  end # describe
170
178
  end # module
171
179
 
@@ -23,6 +23,7 @@ module Regex # This module is used as a namespace
23
23
  end
24
24
 
25
25
  context 'Provided services' do
26
+ # rubocop: disable Style/CombinableLoops
26
27
  it 'should know its text representation' do
27
28
  policy2text = { greedy: '', lazy: '?', possessive: '+' }
28
29
 
@@ -73,6 +74,7 @@ module Regex # This module is used as a namespace
73
74
  end
74
75
  end
75
76
  end
77
+ # rubocop: enable Style/CombinableLoops
76
78
  end
77
79
  end
78
80
  end # module
@@ -226,7 +226,7 @@ SRL
226
226
  let(:prefix) { 'letter from p to t ' }
227
227
 
228
228
  it "should parse 'once' syntax" do
229
- regexp = SrlRuby.parse(prefix + 'once')
229
+ regexp = SrlRuby.parse("#{prefix}once")
230
230
  expect(regexp.source).to eq('[p-t]{1}')
231
231
  end
232
232
 
@@ -246,26 +246,26 @@ SRL
246
246
  end
247
247
 
248
248
  it "should parse 'between ... and ... times' syntax" do
249
- regexp = SrlRuby.parse(prefix + 'between 2 and 4 times')
249
+ regexp = SrlRuby.parse("#{prefix}between 2 and 4 times")
250
250
  expect(regexp.source).to eq('[p-t]{2,4}')
251
251
 
252
252
  # Dropping 'times' keyword is a shorter alternative syntax
253
- regexp = SrlRuby.parse(prefix + 'between 2 and 4')
253
+ regexp = SrlRuby.parse("#{prefix}between 2 and 4")
254
254
  expect(regexp.source).to eq('[p-t]{2,4}')
255
255
  end
256
256
 
257
257
  it "should parse 'once or more' syntax" do
258
- regexp = SrlRuby.parse(prefix + 'once or more')
258
+ regexp = SrlRuby.parse("#{prefix}once or more")
259
259
  expect(regexp.source).to eq('[p-t]+')
260
260
  end
261
261
 
262
262
  it "should parse 'never or more' syntax" do
263
- regexp = SrlRuby.parse(prefix + 'never or more')
263
+ regexp = SrlRuby.parse("#{prefix}never or more")
264
264
  expect(regexp.source).to eq('[p-t]*')
265
265
  end
266
266
 
267
267
  it "should parse 'at least ... times' syntax" do
268
- regexp = SrlRuby.parse(prefix + 'at least 10 times')
268
+ regexp = SrlRuby.parse("#{prefix}at least 10 times")
269
269
  expect(regexp.source).to eq('[p-t]{10,}')
270
270
  end
271
271
  end # context
data/srl_ruby.gemspec CHANGED
@@ -65,13 +65,13 @@ SUMMARY
65
65
  spec.require_paths = ['lib']
66
66
  PkgExtending.pkg_files(spec)
67
67
  PkgExtending.pkg_documentation(spec)
68
- spec.required_ruby_version = '>= 2.3.0'
68
+ spec.required_ruby_version = '>= 2.5.0'
69
69
 
70
70
  # Runtime dependencies
71
- spec.add_dependency 'rley', '~> 0.7.00'
71
+ spec.add_dependency 'rley', '~> 0.8.08'
72
72
 
73
73
  # Development dependencies
74
- spec.add_development_dependency 'bundler', '~> 2.0.0'
74
+ spec.add_development_dependency 'bundler', '~> 2.2.0'
75
75
  spec.add_development_dependency 'cucumber', '>= 2.2.0'
76
76
  spec.add_development_dependency 'rake', '~> 12.0'
77
77
  spec.add_development_dependency 'rspec', '~> 3.0'
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.6
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-17 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.7.00
19
+ version: 0.8.08
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.7.00
26
+ version: 0.8.08
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
- version: 2.0.0
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
- version: 2.0.0
40
+ version: 2.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cucumber
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +190,7 @@ homepage: https://github.com/famished-tiger/SRL-Ruby
190
190
  licenses:
191
191
  - MIT
192
192
  metadata: {}
193
- post_install_message:
193
+ post_install_message:
194
194
  rdoc_options:
195
195
  - --charset=UTF-8 --exclude="examples|spec"
196
196
  require_paths:
@@ -199,15 +199,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - ">="
201
201
  - !ruby/object:Gem::Version
202
- version: 2.3.0
202
+ version: 2.5.0
203
203
  required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  requirements:
205
205
  - - ">="
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
208
  requirements: []
209
- rubygems_version: 3.0.3
210
- signing_key:
209
+ rubygems_version: 3.1.4
210
+ signing_key:
211
211
  specification_version: 4
212
212
  summary: A parser for the [Simple Regex Language](https://simple-regex.com/). It translates
213
213
  patterns expressed in SRL into plain Ruby Regexp objects or in regex literals. Use