sequitur 0.1.23 → 0.1.24

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: 281bd27d3f94acef7567bebbf56099c56a1dbc3c7df02d763ffd7793ff463b84
4
- data.tar.gz: ea7881682da31b7de732d4160951bf1591cb26ecc8008f14603a55e8c8620bbe
3
+ metadata.gz: a1ba8348f20a1e800b1c7001090916dbe05159177471452fdcfa8925bc975431
4
+ data.tar.gz: a8002cab5a1f7ae7b20b347f4a5f79e92a2f979dca1fad2dad83e153f5969d22
5
5
  SHA512:
6
- metadata.gz: 553904778b8d61a96486e6f32ae0719d3a8b9f6ef99fb3b962f088f55097e6e23a5d75ca65c0ba916027a46d221deb5d7c9aed5a2927754d456c6f9e54658398
7
- data.tar.gz: 2c67d893f9ec2d1ffc2523261f170a76de8e15dcf75f6069efe716ff3f48a8314c39a10ee53edd2938db71933a931a356258c694acd1c4b516fb1ec6fabcecce
6
+ metadata.gz: 2a116b242f218d0c08740a0432b641f88dbaa7f65dd67b02a5339be208927c835db4965d6e3ede344d7d93a4bbea6d4468692c4b237f1f18a8bbd3f6ffb54037
7
+ data.tar.gz: 2b7ea3e4acf58cb45ed3c0b7081a35201c2a8aa5285e163e9845fd82f082e7dcfb563a063d566c2561bb81944cefec6a67d0d2203b2080cb12fd73f6ace3c53e
data/.rubocop.yml CHANGED
@@ -1,456 +1,30 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - 'exp/**/*'
4
3
  - 'lab/**/*'
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
15
-
16
- Layout/CaseIndentation:
17
- Enabled: false
18
-
19
- Layout/ClosingHeredocIndentation:
20
- Enabled: false
21
-
22
- Layout/CommentIndentation:
23
- Enabled: false
24
-
25
- Layout/ElseAlignment:
26
- Enabled: false
27
-
28
- Layout/EmptyLines:
29
- Enabled: false
30
-
31
- Layout/EndAlignment:
32
- Enabled: false
33
-
4
+
34
5
  Layout/EndOfLine:
35
- Enabled: true
36
- EnforcedStyle: lf
37
-
38
- Layout/FirstArgumentIndentation:
39
- Enabled: false
40
-
41
- Layout/HashAlignment:
42
- Enabled: false
43
-
44
- Layout/IndentationWidth:
45
- Enabled: false
46
-
47
- Layout/IndentationConsistency:
48
- Enabled: true
49
-
50
- Layout/HeredocIndentation:
51
- Enabled: false
52
-
53
- Layout/LineEndStringConcatenationIndentation:
54
- Enabled: true
55
-
56
- Layout/MultilineHashBraceLayout:
57
- Enabled: true
58
-
59
- Layout/MultilineMethodCallBraceLayout:
60
- Enabled: true
61
- EnforcedStyle: same_line
62
-
63
- Layout/SpaceAroundOperators:
64
- Enabled: true
65
-
66
- Layout/SpaceBeforeBrackets:
67
- Enabled: true
68
-
69
- Layout/SpaceInsideParens:
70
- Enabled: true
71
-
72
- Layout/IndentationStyle:
73
- Enabled: true
74
-
75
- Layout/SpaceAroundMethodCallOperator:
76
- Enabled: true
77
-
78
- Layout/TrailingEmptyLines:
79
- Enabled: true
80
-
81
- Layout/TrailingWhitespace:
82
- Enabled: true
83
-
84
- Lint/AmbiguousAssignment:
85
- Enabled: true
86
-
87
- Lint/AmbiguousRange:
88
- Enabled: true
89
-
90
- Lint/DeprecatedConstants:
91
- Enabled: true
92
-
93
- Lint/DuplicateBranch:
94
- Enabled: true
95
-
96
- Lint/DuplicateRegexpCharacterClassElement:
97
- Enabled: true
98
-
99
- Lint/EmptyBlock:
100
- Enabled: true
101
-
102
- Lint/EmptyClass:
103
- Enabled: false
104
-
105
- Lint/EmptyInPattern:
106
- Enabled: true
107
-
108
- Lint/LambdaWithoutLiteralBlock:
109
- Enabled: true
110
-
111
- Lint/Loop:
112
- Enabled: true
113
-
114
- Lint/NoReturnInBeginEndBlocks:
115
- Enabled: true
116
-
117
- Lint/NumberedParameterAssignment:
118
- Enabled: true
119
-
120
- Lint/OrAssignmentToConstant:
121
- Enabled: true
122
-
123
- Lint/RaiseException:
124
- Enabled: true
125
-
126
- Lint/RedundantDirGlobSort:
127
- Enabled: true
128
-
129
- Lint/RescueException:
130
- Enabled: true
131
-
132
- Lint/StructNewOverride:
133
- Enabled: true
134
-
135
- Lint/SymbolConversion:
136
- Enabled: true
137
-
138
- Lint/ToEnumArguments:
139
- Enabled: true
140
-
141
- Lint/TripleQuotes:
142
- Enabled: true
143
-
144
- Lint/UnexpectedBlockArity:
145
- Enabled: true
146
-
147
- Lint/UnmodifiedReduceAccumulator:
148
- Enabled: true
149
-
150
- Lint/UnusedMethodArgument:
151
- Enabled: true
152
-
153
- Lint/UselessAccessModifier:
154
- Enabled: true
155
-
156
- Lint/Void:
157
- Enabled: false
158
-
159
- Lint/UselessAssignment:
160
- Enabled: true
6
+ Enabled: false # Make source portable!
161
7
 
162
8
  Metrics/AbcSize:
163
- Enabled: false
164
-
165
- Metrics/BlockLength:
166
- Enabled: true
167
- Max: 350
168
-
169
- Metrics/BlockNesting:
170
- Enabled: true
171
- Max: 5
9
+ Max: 22
172
10
 
173
11
  Metrics/ClassLength:
174
- Enabled: true
175
- Max: 450
176
-
12
+ Max: 150
13
+
177
14
  Metrics/CyclomaticComplexity:
178
- Enabled: false
179
-
180
- Layout/LineLength:
181
- Enabled: false
182
- Max: 90
15
+ Max: 10
183
16
 
184
17
  Metrics/MethodLength:
185
- Enabled: true
186
- Max: 60
187
-
188
- Metrics/ModuleLength:
189
- Enabled: true
190
- Max: 500
191
-
18
+ Max: 50
19
+
192
20
  Metrics/PerceivedComplexity:
193
- Enabled: false
194
-
195
- Naming/ConstantName:
196
- Enabled: false
197
-
198
- Naming/ClassAndModuleCamelCase:
199
- Enabled: false
200
-
201
- Naming/BlockParameterName:
202
- Enabled: true
203
-
204
- Naming/InclusiveLanguage:
205
- Enabled: true
21
+ Max: 10
206
22
 
207
23
  Naming/MethodParameterName:
208
24
  Enabled: false
209
-
210
- Naming/MethodName:
211
- Enabled: false
212
-
25
+
213
26
  Naming/VariableName:
214
27
  Enabled: false
215
28
 
216
- Style/AccessorGrouping:
217
- Enabled: false
218
-
219
- Style/Alias:
220
- Enabled: true
221
-
222
- Style/ArgumentsForwarding:
223
- Enabled: true
224
-
225
- Style/AsciiComments:
226
- Enabled: false
227
-
228
- Style/BarePercentLiterals:
229
- Enabled: false
230
-
231
- Style/BlockComments:
232
- Enabled: false
233
-
234
- Style/CharacterLiteral:
235
- Enabled: false
236
-
237
- Style/ClassCheck:
238
- Enabled: false
239
-
240
- Style/ClassVars:
241
- Enabled: false
242
-
243
- Style/CollectionCompact:
244
- Enabled: true
245
-
246
- Style/ColonMethodCall:
247
- Enabled: false
248
-
249
- Style/CommentAnnotation:
250
- Enabled: false
251
-
252
29
  Style/CommentedKeyword:
253
- Enabled: false
254
-
255
- Style/ConditionalAssignment:
256
- Enabled: false
257
-
258
- Style/DefWithParentheses:
259
- Enabled: true
260
-
261
- Style/Documentation:
262
- Enabled: false
263
-
264
- Style/DocumentDynamicEvalDefinition:
265
- Enabled: false
266
-
267
- Style/EmptyElse:
268
- Enabled: true
269
- EnforcedStyle: empty
270
-
271
- Style/ExpandPathArguments:
272
- Enabled: false
273
-
274
- Style/ExponentialNotation:
275
- Enabled: true
276
-
277
- Style/GuardClause:
278
- Enabled: false
279
-
280
- Style/HashEachMethods:
281
- Enabled: true
282
-
283
- Style/HashExcept:
284
- Enabled: true
285
-
286
- Style/HashTransformKeys:
287
- Enabled: true
288
-
289
- Style/HashTransformValues:
290
- Enabled: true
291
-
292
- Style/IfUnlessModifier:
293
- Enabled: false
294
-
295
- Style/InPatternThen:
296
- Enabled: true
297
-
298
- Style/InverseMethods:
299
- Enabled: false
300
-
301
- Style/MissingRespondToMissing:
302
- Enabled: false
303
-
304
- Style/MultilineInPatternThen:
305
- Enabled: true
306
-
307
- Style/NegatedIfElseCondition:
308
- Enabled: true
309
-
310
- Style/Next:
311
- Enabled: false
312
-
313
- Style/NilLambda:
314
- Enabled: true
315
-
316
- Style/NumericLiterals:
317
- Enabled: false
318
-
319
- Style/QuotedSymbols:
320
- Enabled: true
321
-
322
- Style/RaiseArgs:
323
- Enabled: true
324
-
325
- Style/RedundantArgument:
326
- Enabled: true
327
-
328
- Style/RedundantReturn:
329
- Enabled: false
330
-
331
- Style/RedundantSelf:
332
- Enabled: true
333
-
334
- Style/RedundantSelfAssignmentBranch:
335
- Enabled: true
336
-
337
- Style/RegexpLiteral:
338
- Enabled: false
339
-
340
- Style/PercentLiteralDelimiters:
341
- Enabled: false
342
-
343
- Style/StderrPuts:
344
- Enabled: false
345
-
346
- Style/StringLiterals:
347
- Enabled: true
348
-
349
- Style/SwapValues:
350
- Enabled: true
351
-
352
- Style/TernaryParentheses:
353
- Enabled: false
354
-
355
- Style/UnlessElse:
356
- Enabled: false
357
-
358
- # Rubocop complains when it doesn't find an explicit setting for the following cops:
359
- Layout/EmptyLinesAroundAttributeAccessor:
360
- Enabled: true
361
-
362
- Lint/BinaryOperatorWithIdenticalOperands:
363
- Enabled: true
364
-
365
- Lint/DeprecatedOpenSSLConstant:
366
- Enabled: true
367
-
368
- Lint/DuplicateElsifCondition:
369
- Enabled: true
370
-
371
- Lint/DuplicateRescueException:
372
- Enabled: true
373
-
374
- Lint/EmptyConditionalBody:
375
- Enabled: true
376
-
377
- Lint/FloatComparison:
378
- Enabled: true
379
-
380
- Lint/MissingSuper:
381
- Enabled: true
382
-
383
- Lint/MixedRegexpCaptureTypes:
384
- Enabled: true
385
-
386
- Lint/OutOfRangeRegexpRef:
387
- Enabled: true
388
-
389
- Lint/SelfAssignment:
390
- Enabled: true
391
-
392
- Lint/TopLevelReturnWithArgument:
393
- Enabled: true
394
-
395
- Lint/UnreachableLoop:
396
- Enabled: true
397
-
398
- Style/ArrayCoercion:
399
- Enabled: true
400
-
401
- Style/BisectedAttrAccessor:
402
- Enabled: true
403
-
404
- Style/CaseLikeIf:
405
- Enabled: true
406
-
407
- Style/EndlessMethod:
408
- Enabled: true
409
-
410
- Style/ExplicitBlockArgument:
411
- Enabled: true
412
-
413
- Style/GlobalStdStream:
414
- Enabled: true
415
-
416
- Style/HashAsLastArrayItem:
417
- Enabled: true
418
-
419
- Style/HashConversion:
420
- Enabled: true
421
-
422
- Style/HashLikeCase:
423
- Enabled: true
424
-
425
- Style/IfWithBooleanLiteralBranches:
426
- Enabled: true
427
-
428
- Style/OptionalBooleanParameter:
429
- Enabled: true
430
-
431
- Style/RedundantAssignment:
432
- Enabled: true
433
-
434
- Style/RedundantFetchBlock:
435
- Enabled: true
436
-
437
- Style/RedundantFileExtensionInRequire:
438
- Enabled: true
439
-
440
- Style/RedundantRegexpCharacterClass:
441
- Enabled: true
442
-
443
- Style/RedundantRegexpEscape:
444
- Enabled: true
445
-
446
- Style/SingleArgumentDig:
447
- Enabled: true
448
-
449
- Style/SlicingWithRange:
450
- Enabled: true
451
-
452
- Style/StringChars:
453
- Enabled: true
454
-
455
- Style/StringConcatenation:
456
- Enabled: true
30
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.1.24] - 2021-07-01
2
+ - Code restyling to please rubocop 1.53.1
3
+
1
4
  ## [0.1.23] - 2021-09-04
2
5
  - Remove dependencies towards `coverall`, `simplecov`
3
6
  - Code restyling to please rubocop 1.19.1
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2019 Dimitri Geshef
1
+ Copyright (c) 2014-2023 Dimitri Geshef
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -19,12 +19,10 @@ RSpec::Core::RakeTask.new do |spec|
19
19
  spec.pattern = 'spec/**/*_spec.rb'
20
20
  end
21
21
 
22
-
23
22
  # Run RSpec tests
24
23
  desc 'Run tests, with RSpec'
25
24
  task test: [:spec]
26
25
 
27
-
28
26
  # Default rake task
29
27
  task default: :test
30
28
 
@@ -10,7 +10,6 @@ input_sequence = [1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5]
10
10
  # Generate the grammar from the sequence
11
11
  grammar = Sequitur.build_from(input_sequence)
12
12
 
13
-
14
13
  # Use a formatter to display the grammar rules on the console output
15
14
  formatter = Sequitur::Formatter::BaseText.new($stdout)
16
15
 
data/examples/porridge.rb CHANGED
@@ -3,16 +3,16 @@
3
3
  require 'sequitur' # Load the Sequitur library
4
4
 
5
5
  # Purpose: demo to show that sequitur gem works on example from sequitur.info website
6
- input_sequence = <<-SNIPPET
7
- pease porridge hot,
8
- pease porridge cold,
9
- pease porridge in the pot,
10
- nine days old.
6
+ input_sequence = <<~SNIPPET
7
+ pease porridge hot,
8
+ pease porridge cold,
9
+ pease porridge in the pot,
10
+ nine days old.
11
11
 
12
- some like it hot,
13
- some like it cold,
14
- some like it in the pot,
15
- nine days old.
12
+ some like it hot,
13
+ some like it cold,
14
+ some like it in the pot,
15
+ nine days old.
16
16
  SNIPPET
17
17
 
18
18
  grammar = Sequitur.build_from(input_sequence)
@@ -7,10 +7,10 @@ require 'sequitur' # Load the Sequitur library
7
7
  #
8
8
 
9
9
  # Raw input is one String containing repeated sentences...
10
- raw_input = <<-SNIPPET
11
- Error: unknown character '?' at position 6
12
- Error: illegal character '%' at position 20
13
- Error: unknown character '/' at position 9
10
+ raw_input = <<~SNIPPET
11
+ Error: unknown character '?' at position 6
12
+ Error: illegal character '%' at position 20
13
+ Error: unknown character '/' at position 9
14
14
  SNIPPET
15
15
 
16
16
  # Convert into a sequence of words
@@ -18,7 +18,6 @@ input_sequence = raw_input.scan(/\w+/)
18
18
  # Generate the grammar from the sequence
19
19
  grammar = Sequitur.build_from(input_sequence)
20
20
 
21
-
22
21
  # Use a formatter to display the grammar rules on the console output
23
22
  formatter = Sequitur::Formatter::BaseText.new($stdout)
24
23
 
@@ -4,8 +4,10 @@
4
4
  # Purpose: definition of Sequitur constants.
5
5
 
6
6
  module Sequitur # Module used as a namespace
7
+ # rubocop:disable Naming/ConstantName
8
+
7
9
  # The version number of the gem.
8
- Version = '0.1.23'
10
+ Version = '0.1.24'
9
11
 
10
12
  # Brief description of the gem.
11
13
  Description = 'Ruby implementation of the Sequitur algorithm'
@@ -23,6 +25,7 @@ module Sequitur # Module used as a namespace
23
25
  "#{startdir}/" # Append trailing slash character to it
24
26
  end
25
27
  end
28
+ # rubocop:enable Naming/ConstantName
26
29
  end # module
27
30
 
28
31
  # End of file
@@ -37,13 +37,13 @@ module Sequitur # Module for classes implementing the Sequitur algorithm
37
37
  # @param other [Digram] another to compare with
38
38
  # @return [true/false]
39
39
  def ==(other)
40
- return key == other.key
40
+ key == other.key
41
41
  end
42
42
 
43
43
  # Does the digram consists of twice the same symbols?
44
44
  # @return [true/false] true when symbols.first == symbols.last
45
45
  def repeating?
46
- return symbols[0] == symbols[1]
46
+ symbols[0] == symbols[1]
47
47
  end
48
48
  end # class
49
49
  end # module
@@ -34,8 +34,7 @@ module Sequitur # Module for classes implementing the Sequitur algorithm
34
34
  # Each production rule is emitted per line.
35
35
  # @return [String]
36
36
  def to_string
37
- rule_text = productions.map(&:to_string).join("\n")
38
- return rule_text
37
+ productions.map(&:to_string).join("\n")
39
38
  end
40
39
 
41
40
  # Add a given production to the grammar.
@@ -58,7 +57,7 @@ module Sequitur # Module for classes implementing the Sequitur algorithm
58
57
  puts("Removed: #{prod.to_string}") if trace
59
58
  prod.clear_rhs
60
59
 
61
- return prod
60
+ prod
62
61
  end
63
62
 
64
63
  # Add the given token to the grammar.
@@ -83,7 +82,7 @@ module Sequitur # Module for classes implementing the Sequitur algorithm
83
82
  # Factory method. Returns a visitor for this grammar.
84
83
  # @return [GrammarVisitor]
85
84
  def visitor
86
- return GrammarVisitor.new(self)
85
+ GrammarVisitor.new(self)
87
86
  end
88
87
 
89
88
  protected
@@ -19,7 +19,7 @@ module Sequitur
19
19
  # and render the visit events in the output stream.
20
20
  # @param aGrmOrVisitor [DynamicGrammar or GrammarVisitor]
21
21
  def render(aGrmOrVisitor)
22
- a_visitor = if aGrmOrVisitor.kind_of?(GrammarVisitor)
22
+ a_visitor = if aGrmOrVisitor.is_a?(GrammarVisitor)
23
23
  aGrmOrVisitor
24
24
  else
25
25
  aGrmOrVisitor.visitor
@@ -12,6 +12,8 @@ module Sequitur
12
12
  # # Render the grammar (through a visitor)
13
13
  # formatter.run(some_grammar.visitor)
14
14
  class BaseText < BaseFormatter
15
+ attr_reader :prod_lookup
16
+
15
17
  # Constructor.
16
18
  # @param anIO [IO] The output stream to which the rendered grammar
17
19
  # is written.
@@ -73,17 +75,11 @@ module Sequitur
73
75
 
74
76
  private
75
77
 
76
- # Read accessor of the production lookup
77
- def prod_lookup
78
- return @prod_lookup
79
- end
80
-
81
78
  # Generate a name of a given production.
82
79
  # @param aProduction [Production]
83
80
  def prod_name(aProduction)
84
81
  prod_index = prod_lookup[aProduction]
85
- name = prod_index.zero? ? 'start' : "P#{prod_index}"
86
- return name
82
+ prod_index.zero? ? 'start' : "P#{prod_index}"
87
83
  end
88
84
  end # class
89
85
  end # module
@@ -2,7 +2,6 @@
2
2
 
3
3
  require_relative 'base_formatter'
4
4
 
5
-
6
5
  module Sequitur
7
6
  module Formatter
8
7
  # A formatter class that can render the notification events
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sequitur # Module for classes implementing the Sequitur algorithm
4
- # A visitor class dedicated in the visit of Grammar.
4
+ # A visitor class dedicated in the visit of Grammar.
5
5
  class GrammarVisitor
6
6
  # Link to the grammar to visit
7
7
  attr_reader(:grammar)