slugtastic 1.3.1 → 2.0.0

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
- SHA1:
3
- metadata.gz: fedfdd70757c326282c3afa06061ff5219db0ad2
4
- data.tar.gz: c6c87146a76046a04381be4c0b4552262a131065
2
+ SHA256:
3
+ metadata.gz: a19e6d22559b2445e715c6ff4fc8900e67ada4c3e9870e2f266319c6d1ffa1a5
4
+ data.tar.gz: d4492f22987062a08ffac0bdbae34bff43e81b15d381d506b91bc20ca2481793
5
5
  SHA512:
6
- metadata.gz: e6817d70b75343f27d0cb41ec3c1b795b07deb31c5b3446ac2971aceb7533e808b17d9f98ffa5a1670f9619b8646ac568f7b94dfb6474eca820d1f7b88acd449
7
- data.tar.gz: c6e05d16648c4b4bd631cc560541ab7eb100c0888d8617fcc6435a651c808b75aa5c0d191e59fd5c793eeb40dabbe8dacce508b6362afcdf0ae527aeb05b4cc1
6
+ metadata.gz: d5684e335c190b8814e0d92d49bc9b3ae91df22cea19c18cfed5936a7d27978047e58a2a93b5bc969e33e6acbafa8aa9ed4f5feea60df36251a76c116fe50988
7
+ data.tar.gz: 9dc1caf83db1ae4fe1309a5377a5be8188c8909a5391c09c85d57394c718e2b6f5ceba1b172e797a5bacbaa472a5165a7a8a558acb3545ad4bda5911d1d1451c
@@ -1,16 +1,651 @@
1
+ AllCops:
2
+ Exclude:
3
+ - db/schema.rb
4
+ TargetRubyVersion: 2.3
5
+
6
+ Naming/AccessorMethodName:
7
+ Description: Check the naming of accessor methods for get_/set_.
8
+ Enabled: false
9
+
10
+ Style/Alias:
11
+ Description: 'Use alias_method instead of alias.'
12
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
13
+ Enabled: false
14
+
15
+ Style/ArrayJoin:
16
+ Description: 'Use Array#join instead of Array#*.'
17
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join'
18
+ Enabled: false
19
+
20
+ Style/AsciiComments:
21
+ Description: 'Use only ascii symbols in comments.'
22
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
23
+ Enabled: false
24
+
25
+ Naming/AsciiIdentifiers:
26
+ Description: 'Use only ascii symbols in identifiers.'
27
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers'
28
+ Enabled: false
29
+
30
+ Style/Attr:
31
+ Description: 'Checks for uses of Module#attr.'
32
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr'
33
+ Enabled: false
34
+
35
+ Metrics/BlockNesting:
36
+ Description: 'Avoid excessive block nesting'
37
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
38
+ Enabled: false
39
+
40
+ Style/CaseEquality:
41
+ Description: 'Avoid explicit use of the case equality operator(===).'
42
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
43
+ Enabled: false
44
+
45
+ Style/CharacterLiteral:
46
+ Description: 'Checks for uses of character literals.'
47
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals'
48
+ Enabled: false
49
+
50
+ Style/ClassAndModuleChildren:
51
+ Description: 'Checks style of children classes and modules.'
52
+ Enabled: true
53
+ EnforcedStyle: nested
54
+
55
+ Metrics/ClassLength:
56
+ Description: 'Avoid classes longer than 100 lines of code.'
57
+ Enabled: false
58
+
59
+ Metrics/ModuleLength:
60
+ Description: 'Avoid modules longer than 100 lines of code.'
61
+ Enabled: false
62
+
63
+ Style/ClassVars:
64
+ Description: 'Avoid the use of class variables.'
65
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
66
+ Enabled: false
67
+
68
+ Style/CollectionMethods:
69
+ Enabled: true
70
+ PreferredMethods:
71
+ find: detect
72
+ inject: reduce
73
+ collect: map
74
+ find_all: select
75
+
76
+ Style/ColonMethodCall:
77
+ Description: 'Do not use :: for method call.'
78
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
79
+ Enabled: false
80
+
81
+ Style/CommentAnnotation:
82
+ Description: >-
83
+ Checks formatting of special comments
84
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
85
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
86
+ Enabled: false
87
+
88
+ Metrics/AbcSize:
89
+ Description: >-
90
+ A calculated magnitude based on number of assignments,
91
+ branches, and conditions.
92
+ Enabled: false
93
+
94
+ Metrics/BlockLength:
95
+ CountComments: true # count full line comments?
96
+ Max: 25
97
+ ExcludedMethods: []
98
+ Exclude:
99
+ - "spec/**/*"
100
+
101
+ Metrics/CyclomaticComplexity:
102
+ Description: >-
103
+ A complexity metric that is strongly correlated to the number
104
+ of test cases needed to validate a method.
105
+ Enabled: false
106
+
107
+ Rails/Delegate:
108
+ Description: 'Prefer delegate method for delegations.'
109
+ Enabled: false
110
+
111
+ Style/PreferredHashMethods:
112
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
113
+ StyleGuide: '#hash-key'
114
+ Enabled: false
115
+
116
+ Style/Documentation:
117
+ Description: 'Document classes and non-namespace modules.'
118
+ Enabled: false
119
+
120
+ Style/DoubleNegation:
121
+ Description: 'Checks for uses of double negation (!!).'
122
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
123
+ Enabled: false
124
+
125
+ Style/EachWithObject:
126
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
127
+ Enabled: false
128
+
129
+ Style/EmptyLiteral:
130
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
131
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
132
+ Enabled: false
133
+
134
+ # Checks whether the source file has a utf-8 encoding comment or not
135
+ # AutoCorrectEncodingComment must match the regex
136
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
137
+ Style/Encoding:
138
+ Enabled: false
139
+
140
+ Style/EvenOdd:
141
+ Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
142
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
143
+ Enabled: false
144
+
145
+ Naming/FileName:
146
+ Description: 'Use snake_case for source file names.'
147
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
148
+ Enabled: false
149
+
150
+ Style/FrozenStringLiteralComment:
151
+ Description: >-
152
+ Add the frozen_string_literal comment to the top of files
153
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
154
+ Enabled: false
155
+
156
+ Style/FlipFlop:
157
+ Description: 'Checks for flip flops'
158
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
159
+ Enabled: false
160
+
161
+ Style/FormatString:
162
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
163
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
164
+ Enabled: false
165
+
166
+ Style/GlobalVars:
167
+ Description: 'Do not introduce global variables.'
168
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
169
+ Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
170
+ Enabled: false
171
+
172
+ Style/GuardClause:
173
+ Description: 'Check for conditionals that can be replaced with guard clauses'
174
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
175
+ Enabled: false
176
+
177
+ Style/IfUnlessModifier:
178
+ Description: >-
179
+ Favor modifier if/unless usage when you have a
180
+ single-line body.
181
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
182
+ Enabled: false
183
+
184
+ Style/IfWithSemicolon:
185
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
186
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
187
+ Enabled: false
188
+
189
+ Style/InlineComment:
190
+ Description: 'Avoid inline comments.'
191
+ Enabled: false
192
+
193
+ Style/Lambda:
194
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
195
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
196
+ Enabled: false
197
+
198
+ Style/LambdaCall:
199
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
200
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
201
+ Enabled: false
202
+
203
+ Style/LineEndConcatenation:
204
+ Description: >-
205
+ Use \ instead of + or << to concatenate two string literals at
206
+ line end.
207
+ Enabled: false
208
+
1
209
  Metrics/LineLength:
2
- Max: 120
210
+ Description: 'Limit lines to 80 characters.'
211
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
212
+ Max: 80
3
213
 
4
- Documentation:
214
+ Metrics/MethodLength:
215
+ Description: 'Avoid methods longer than 10 lines of code.'
216
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
5
217
  Enabled: false
6
218
 
7
- AllCops:
8
- Include:
9
- - '**/Rakefile'
10
- - '**/config.ru'
219
+ Style/ModuleFunction:
220
+ Description: 'Checks for usage of `extend self` in modules.'
221
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
222
+ Enabled: false
223
+
224
+ Style/MultilineBlockChain:
225
+ Description: 'Avoid multi-line chains of blocks.'
226
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
227
+ Enabled: false
228
+
229
+ Style/NegatedIf:
230
+ Description: >-
231
+ Favor unless over if for negative conditions
232
+ (or control flow or).
233
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
234
+ Enabled: false
235
+
236
+ Style/NegatedWhile:
237
+ Description: 'Favor until over while for negative conditions.'
238
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
239
+ Enabled: false
240
+
241
+ Style/Next:
242
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
243
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
244
+ Enabled: false
245
+
246
+ Style/NilComparison:
247
+ Description: 'Prefer x.nil? to x == nil.'
248
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
249
+ Enabled: false
250
+
251
+ Style/Not:
252
+ Description: 'Use ! instead of not.'
253
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
254
+ Enabled: false
255
+
256
+ Style/NumericLiterals:
257
+ Description: >-
258
+ Add underscores to large numeric literals to improve their
259
+ readability.
260
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
261
+ Enabled: false
262
+
263
+ Style/OneLineConditional:
264
+ Description: >-
265
+ Favor the ternary operator(?:) over
266
+ if/then/else/end constructs.
267
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
268
+ Enabled: false
269
+
270
+ Naming/BinaryOperatorParameterName:
271
+ Description: 'When defining binary operators, name the argument other.'
272
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
273
+ Enabled: false
274
+
275
+ Metrics/ParameterLists:
276
+ Description: 'Avoid parameter lists longer than three or four parameters.'
277
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
278
+ Enabled: false
279
+
280
+ Style/PercentLiteralDelimiters:
281
+ Description: 'Use `%`-literal delimiters consistently'
282
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
283
+ Enabled: false
284
+
285
+ Style/PerlBackrefs:
286
+ Description: 'Avoid Perl-style regex back references.'
287
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
288
+ Enabled: false
289
+
290
+ Naming/PredicateName:
291
+ Description: 'Check the names of predicate methods.'
292
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
293
+ NamePrefixBlacklist:
294
+ - is_
11
295
  Exclude:
12
- - 'db/**/*'
13
- - 'config/**/*'
14
- - 'script/**/*'
15
- - 'bin/**/*'
16
- - !ruby/regexp /old_and_unused\.rb$/
296
+ - spec/**/*
297
+
298
+ Style/Proc:
299
+ Description: 'Use proc instead of Proc.new.'
300
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
301
+ Enabled: false
302
+
303
+ Style/RaiseArgs:
304
+ Description: 'Checks the arguments passed to raise/fail.'
305
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
306
+ Enabled: false
307
+
308
+ Style/RegexpLiteral:
309
+ Description: 'Use / or %r around regular expressions.'
310
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
311
+ Enabled: false
312
+
313
+ Style/SelfAssignment:
314
+ Description: >-
315
+ Checks for places where self-assignment shorthand should have
316
+ been used.
317
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
318
+ Enabled: false
319
+
320
+ Style/SingleLineBlockParams:
321
+ Description: 'Enforces the names of some block params.'
322
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
323
+ Enabled: false
324
+
325
+ Style/SingleLineMethods:
326
+ Description: 'Avoid single-line methods.'
327
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
328
+ Enabled: false
329
+
330
+ Style/SignalException:
331
+ Description: 'Checks for proper usage of fail and raise.'
332
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
333
+ Enabled: false
334
+
335
+ Style/SpecialGlobalVars:
336
+ Description: 'Avoid Perl-style global variables.'
337
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
338
+ Enabled: false
339
+
340
+ Style/StringLiterals:
341
+ Description: 'Checks if uses of quotes match the configured preference.'
342
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
343
+ EnforcedStyle: double_quotes
344
+ Enabled: true
345
+
346
+ Style/TrailingCommaInArguments:
347
+ Description: 'Checks for trailing comma in argument lists.'
348
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
349
+ EnforcedStyleForMultiline: comma
350
+ SupportedStylesForMultiline:
351
+ - comma
352
+ - consistent_comma
353
+ - no_comma
354
+ Enabled: true
355
+
356
+ Style/TrailingCommaInArrayLiteral:
357
+ Description: 'Checks for trailing comma in array literals.'
358
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
359
+ EnforcedStyleForMultiline: comma
360
+ SupportedStylesForMultiline:
361
+ - comma
362
+ - consistent_comma
363
+ - no_comma
364
+ Enabled: true
365
+
366
+ Style/TrailingCommaInHashLiteral:
367
+ Description: 'Checks for trailing comma in hash literals.'
368
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
369
+ EnforcedStyleForMultiline: comma
370
+ SupportedStylesForMultiline:
371
+ - comma
372
+ - consistent_comma
373
+ - no_comma
374
+ Enabled: true
375
+
376
+ Style/TrivialAccessors:
377
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
378
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
379
+ Enabled: false
380
+
381
+ Style/VariableInterpolation:
382
+ Description: >-
383
+ Don't interpolate global, instance and class variables
384
+ directly in strings.
385
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
386
+ Enabled: false
387
+
388
+ Style/WhenThen:
389
+ Description: 'Use when x then ... for one-line cases.'
390
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
391
+ Enabled: false
392
+
393
+ Style/WhileUntilModifier:
394
+ Description: >-
395
+ Favor modifier while/until usage when you have a
396
+ single-line body.
397
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
398
+ Enabled: false
399
+
400
+ Style/WordArray:
401
+ Description: 'Use %w or %W for arrays of words.'
402
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
403
+ Enabled: false
404
+
405
+ # Layout
406
+
407
+ Layout/AlignParameters:
408
+ Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.'
409
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
410
+ Enabled: false
411
+
412
+ Layout/ConditionPosition:
413
+ Description: >-
414
+ Checks for condition placed in a confusing position relative to
415
+ the keyword.
416
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
417
+ Enabled: false
418
+
419
+ Layout/DotPosition:
420
+ Description: 'Checks the position of the dot in multi-line method calls.'
421
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
422
+ EnforcedStyle: leading
423
+
424
+ Layout/ExtraSpacing:
425
+ Description: 'Do not use unnecessary spacing.'
426
+ Enabled: true
427
+
428
+ Layout/MultilineOperationIndentation:
429
+ Description: >-
430
+ Checks indentation of binary operations that span more than
431
+ one line.
432
+ Enabled: true
433
+ EnforcedStyle: indented
434
+
435
+ Layout/MultilineMethodCallIndentation:
436
+ Description: >-
437
+ Checks indentation of method calls with the dot operator
438
+ that span more than one line.
439
+ Enabled: true
440
+ EnforcedStyle: indented
441
+
442
+ Layout/InitialIndentation:
443
+ Description: >-
444
+ Checks the indentation of the first non-blank non-comment line in a file.
445
+ Enabled: false
446
+
447
+ # Lint
448
+
449
+ Lint/AmbiguousOperator:
450
+ Description: >-
451
+ Checks for ambiguous operators in the first argument of a
452
+ method invocation without parentheses.
453
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
454
+ Enabled: false
455
+
456
+ Lint/AmbiguousRegexpLiteral:
457
+ Description: >-
458
+ Checks for ambiguous regexp literals in the first argument of
459
+ a method invocation without parenthesis.
460
+ Enabled: false
461
+
462
+ Lint/AssignmentInCondition:
463
+ Description: "Don't use assignment in conditions."
464
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
465
+ Enabled: false
466
+
467
+ Lint/CircularArgumentReference:
468
+ Description: "Don't refer to the keyword argument in the default value."
469
+ Enabled: false
470
+
471
+ Lint/DeprecatedClassMethods:
472
+ Description: 'Check for deprecated class method calls.'
473
+ Enabled: false
474
+
475
+ Lint/DuplicatedKey:
476
+ Description: 'Check for duplicate keys in hash literals.'
477
+ Enabled: false
478
+
479
+ Lint/EachWithObjectArgument:
480
+ Description: 'Check for immutable argument given to each_with_object.'
481
+ Enabled: false
482
+
483
+ Lint/ElseLayout:
484
+ Description: 'Check for odd code arrangement in an else block.'
485
+ Enabled: false
486
+
487
+ Lint/FormatParameterMismatch:
488
+ Description: 'The number of parameters to format/sprint must match the fields.'
489
+ Enabled: false
490
+
491
+ Lint/HandleExceptions:
492
+ Description: "Don't suppress exception."
493
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
494
+ Enabled: false
495
+
496
+ Lint/LiteralAsCondition:
497
+ Description: 'Checks of literals used in conditions.'
498
+ Enabled: false
499
+
500
+ Lint/LiteralInInterpolation:
501
+ Description: 'Checks for literals used in interpolation.'
502
+ Enabled: false
503
+
504
+ Lint/Loop:
505
+ Description: >-
506
+ Use Kernel#loop with break rather than begin/end/until or
507
+ begin/end/while for post-loop tests.
508
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
509
+ Enabled: false
510
+
511
+ Lint/NestedMethodDefinition:
512
+ Description: 'Do not use nested method definitions.'
513
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
514
+ Enabled: false
515
+
516
+ Lint/NonLocalExitFromIterator:
517
+ Description: 'Do not use return in iterator to cause non-local exit.'
518
+ Enabled: false
519
+
520
+ Lint/ParenthesesAsGroupedExpression:
521
+ Description: >-
522
+ Checks for method calls with a space before the opening
523
+ parenthesis.
524
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
525
+ Enabled: false
526
+
527
+ Lint/RequireParentheses:
528
+ Description: >-
529
+ Use parentheses in the method call to avoid confusion
530
+ about precedence.
531
+ Enabled: false
532
+
533
+ Lint/UnderscorePrefixedVariableName:
534
+ Description: 'Do not use prefix `_` for a variable that is used.'
535
+ Enabled: false
536
+
537
+ Lint/UnneededCopDisableDirective:
538
+ Description: >-
539
+ Checks for rubocop:disable comments that can be removed.
540
+ Note: this cop is not disabled when disabling all cops.
541
+ It must be explicitly disabled.
542
+ Enabled: false
543
+
544
+ Lint/Void:
545
+ Description: 'Possible use of operator/literal/variable in void context.'
546
+ Enabled: false
547
+
548
+ # Performance
549
+
550
+ Performance/CaseWhenSplat:
551
+ Description: >-
552
+ Place `when` conditions that use splat at the end
553
+ of the list of `when` branches.
554
+ Enabled: false
555
+
556
+ Performance/Count:
557
+ Description: >-
558
+ Use `count` instead of `select...size`, `reject...size`,
559
+ `select...count`, `reject...count`, `select...length`,
560
+ and `reject...length`.
561
+ Enabled: false
562
+
563
+ Performance/Detect:
564
+ Description: >-
565
+ Use `detect` instead of `select.first`, `find_all.first`,
566
+ `select.last`, and `find_all.last`.
567
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
568
+ Enabled: false
569
+
570
+ Performance/FlatMap:
571
+ Description: >-
572
+ Use `Enumerable#flat_map`
573
+ instead of `Enumerable#map...Array#flatten(1)`
574
+ or `Enumberable#collect..Array#flatten(1)`
575
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
576
+ Enabled: false
577
+
578
+ Performance/ReverseEach:
579
+ Description: 'Use `reverse_each` instead of `reverse.each`.'
580
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
581
+ Enabled: false
582
+
583
+ Performance/Sample:
584
+ Description: >-
585
+ Use `sample` instead of `shuffle.first`,
586
+ `shuffle.last`, and `shuffle[Fixnum]`.
587
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
588
+ Enabled: false
589
+
590
+ Performance/Size:
591
+ Description: >-
592
+ Use `size` instead of `count` for counting
593
+ the number of elements in `Array` and `Hash`.
594
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
595
+ Enabled: false
596
+
597
+ Performance/StringReplacement:
598
+ Description: >-
599
+ Use `tr` instead of `gsub` when you are replacing the same
600
+ number of characters. Use `delete` instead of `gsub` when
601
+ you are deleting characters.
602
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
603
+ Enabled: false
604
+
605
+ # Rails
606
+
607
+ Rails/ActionFilter:
608
+ Description: 'Enforces consistent use of action filter methods.'
609
+ Enabled: false
610
+
611
+ Rails/Date:
612
+ Description: >-
613
+ Checks the correct usage of date aware methods,
614
+ such as Date.today, Date.current etc.
615
+ Enabled: false
616
+
617
+ Rails/FindBy:
618
+ Description: 'Prefer find_by over where.first.'
619
+ Enabled: false
620
+
621
+ Rails/FindEach:
622
+ Description: 'Prefer all.find_each over all.find.'
623
+ Enabled: false
624
+
625
+ Rails/HasAndBelongsToMany:
626
+ Description: 'Prefer has_many :through to has_and_belongs_to_many.'
627
+ Enabled: false
628
+
629
+ Rails/Output:
630
+ Description: 'Checks for calls to puts, print, etc.'
631
+ Enabled: false
632
+
633
+ Rails/ReadWriteAttribute:
634
+ Description: >-
635
+ Checks for read_attribute(:attr) and
636
+ write_attribute(:attr, val).
637
+ Enabled: false
638
+
639
+ Rails/ScopeArgs:
640
+ Description: 'Checks the arguments of ActiveRecord scopes.'
641
+ Enabled: false
642
+
643
+ Rails/TimeZone:
644
+ Description: 'Checks the correct usage of time zone aware methods.'
645
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
646
+ Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
647
+ Enabled: false
648
+
649
+ Rails/Validation:
650
+ Description: 'Use validates :attribute, hash of validations.'
651
+ Enabled: false
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in slugtastic.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -9,14 +9,16 @@ models.
9
9
 
10
10
  ## Requirements
11
11
 
12
- * Ruby 2.0.0+
13
- * Rails 3.1 or higher.
12
+ * Ruby 2.2.0+
13
+ * Rails 5 or higher.
14
+
15
+ It will probably work just find with earlier versions--down to Rails 3.1 and Ruby 1.9.3--but it's not tested.
14
16
 
15
17
  ## Installation
16
18
 
17
19
  Add this line to your application's Gemfile:
18
20
 
19
- gem 'slugtastic'
21
+ gem "slugtastic"
20
22
 
21
23
  And then execute:
22
24
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
@@ -1,12 +1,12 @@
1
- require 'slugtastic/version'
2
- require 'slugtastic/model_additions'
3
- require 'slugtastic/railtie' if defined? Rails
1
+ require "slugtastic/version"
2
+ require "slugtastic/model_additions"
3
+ require "slugtastic/railtie" if defined? Rails
4
4
 
5
5
  module Slugtastic
6
6
  def self.generate_slug(string, delimiter = nil)
7
7
  return if string.nil?
8
8
  slug = string.parameterize
9
- slug.gsub!('-', delimiter) if delimiter
9
+ slug.gsub!("-", delimiter) if delimiter
10
10
  slug
11
11
  end
12
12
  end
@@ -2,8 +2,8 @@ module Slugtastic
2
2
  module ModelAdditions
3
3
  # To generate a slug from another value, call <tt>has_slug</tt> in any
4
4
  # ActiveRecord model and pass in the name of the slug attribute.
5
- # By default the slug will be generated from the <tt>title</tt> attribute, but
6
- # you can specify by adding <tt>:from => {attribute}</tt>.
5
+ # By default the slug will be generated from the <tt>title</tt> attribute,
6
+ # but you can specify by adding <tt>:from => {attribute}</tt>.
7
7
  #
8
8
  # class Article < ActiveRecord::Base
9
9
  # has_slug :slug, :from => :title
@@ -11,17 +11,15 @@ module Slugtastic
11
11
  #
12
12
  def slug(name, options = {})
13
13
  options.reverse_merge!(from: :title)
14
+
14
15
  before_validation do
15
16
  if send(name).nil? || send(name).blank?
16
- send("#{name}=", Slugtastic.generate_slug(send(options[:from]), options[:delimiter]))
17
+ send(
18
+ "#{name}=",
19
+ Slugtastic.generate_slug(send(options[:from]), options[:delimiter]),
20
+ )
17
21
  end
18
22
  end
19
23
  end
20
-
21
- def has_slug(name, options = {})
22
- $stderr.puts '[deprecated] Slugtastic: `has_slug` has been renamed `slug` and will likely '\
23
- 'be removed in a future version.'
24
- slug(name, options)
25
- end
26
24
  end
27
25
  end
@@ -1,6 +1,6 @@
1
1
  module Slugtastic
2
2
  class Railtie < Rails::Railtie
3
- initializer 'slugtastic.model_additions' do
3
+ initializer "slugtastic.model_additions" do
4
4
  ActiveSupport.on_load :active_record do
5
5
  extend ModelAdditions
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module Slugtastic
2
- VERSION = '1.3.1'.freeze
2
+ VERSION = "2.0.0".freeze
3
3
  end
@@ -1,22 +1,24 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/slugtastic/version', __FILE__)
2
+
3
+ require File.expand_path("lib/slugtastic/version", __dir__)
3
4
 
4
5
  Gem::Specification.new do |gem|
5
6
  gem.authors = ["Dan Barber"]
6
7
  gem.email = ["danbee@gmail.com"]
7
- gem.licenses = ['MIT']
8
- gem.description = %q{A simple slug string generator for ActiveRecord. Will populate a slug attribute from another attribute.}
9
- gem.summary = %q{A simple slug string generator for ActiveRecord.}
8
+ gem.licenses = ["MIT"]
9
+ gem.description = "A simple slug string generator for ActiveRecord. " \
10
+ "Will populate a slug attribute from another attribute."
11
+ gem.summary = "A simple slug string generator for ActiveRecord."
10
12
  gem.homepage = "http://danbarber.me/slugtastic"
11
13
 
12
14
  gem.files = `git ls-files`.split($\)
13
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
14
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
17
  gem.name = "slugtastic"
16
18
  gem.require_paths = ["lib"]
17
19
  gem.version = Slugtastic::VERSION
18
20
 
19
- gem.add_development_dependency "rake", "~> 11.1"
20
- gem.add_development_dependency "rspec", "~> 3.4"
21
- gem.add_development_dependency "supermodel", "~> 0"
21
+ gem.add_development_dependency "activemodel", "~> 5"
22
+ gem.add_development_dependency "rake", "~> 12.3"
23
+ gem.add_development_dependency "rspec", "~> 3.7"
22
24
  end
@@ -1,8 +1,9 @@
1
1
  # encoding: utf-8
2
- require 'spec_helper'
3
2
 
4
- class BaseModel < SuperModel::Base
5
- include ActiveModel::Validations::Callbacks
3
+ require "spec_helper"
4
+ require "support/fake_model"
5
+
6
+ class BaseModel < FakeModel
6
7
  extend Slugtastic::ModelAdditions
7
8
  end
8
9
 
@@ -18,37 +19,30 @@ end
18
19
 
19
20
  class ModelDelimiter < BaseModel
20
21
  attr_accessor :slug, :title
21
- slug :slug, delimiter: '_'
22
- end
23
-
24
- class ModelAlias < BaseModel
25
- attr_accessor :slug, :title
26
- has_slug :slug
22
+ slug :slug, delimiter: "_"
27
23
  end
28
24
 
29
25
  describe Slugtastic::ModelAdditions do
30
- it 'generates a slug from the name' do
31
- expect(Model.create!(name: 'A Simple Name').slug).to eq 'a-simple-name'
26
+ it "generates a slug from the name" do
27
+ expect(Model.create!(name: "A Simple Name").slug).to eq "a-simple-name"
32
28
  end
33
29
 
34
- it 'defaults to generating the slug from title' do
35
- expect(ModelDefault.create!(title: 'A Simple Title').slug).to eq 'a-simple-title'
30
+ it "defaults to generating the slug from title" do
31
+ expect(ModelDefault.create!(title: "A Simple Title").slug)
32
+ .to eq "a-simple-title"
36
33
  end
37
34
 
38
- it 'generates a slug from the title with delimiter substitutions' do
39
- expect(ModelDelimiter.create!(title: 'A Simple Title').slug).to eq 'a_simple_title'
35
+ it "generates a slug from the title with delimiter substitutions" do
36
+ expect(ModelDelimiter.create!(title: "A Simple Title").slug)
37
+ .to eq "a_simple_title"
40
38
  end
41
39
 
42
40
  it "doesn't regenerate the slug if it already exists" do
43
- model = Model.create!(name: 'A Simple Name')
44
- expect(model.slug).to eq 'a-simple-name'
41
+ model = Model.create!(name: "A Simple Name")
42
+ expect(model.slug).to eq "a-simple-name"
45
43
 
46
- model.title = 'A new title'
44
+ model.name = "A new title"
47
45
  model.save
48
- expect(model.slug).to eq 'a-simple-name'
49
- end
50
-
51
- it 'aliases slug to has_slug for backwards compatibility' do
52
- expect(ModelAlias.create!(title: 'A Simple Title').slug).to eq 'a-simple-title'
46
+ expect(model.slug).to eq "a-simple-name"
53
47
  end
54
48
  end
@@ -1,35 +1,43 @@
1
1
  # encoding: utf-8
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  describe Slugtastic do
5
- describe '.generate_slug' do
6
- it 'returns empty if the input string is empty' do
7
- expect(Slugtastic.generate_slug('')).to eq ''
6
+ describe ".generate_slug" do
7
+ it "returns empty if the input string is empty" do
8
+ expect(Slugtastic.generate_slug("")).to eq ""
8
9
  end
9
10
 
10
- it 'generates a slug from a simple string' do
11
- expect(Slugtastic.generate_slug('A simple string.')).to eq 'a-simple-string'
11
+ it "generates a slug from a simple string" do
12
+ expect(Slugtastic.generate_slug("A simple string."))
13
+ .to eq "a-simple-string"
12
14
  end
13
15
 
14
- it 'substitutes hyphens for delimiter if specified' do
15
- expect(Slugtastic.generate_slug('A simple string.', '_')).to eq 'a_simple_string'
16
+ it "substitutes hyphens for delimiter if specified" do
17
+ expect(Slugtastic.generate_slug("A simple string.", "_"))
18
+ .to eq "a_simple_string"
16
19
  end
17
20
 
18
- it 'generates a slug from a string with numbers' do
19
- expect(Slugtastic.generate_slug('Slugtastic was built in 2012.')).to eq 'slugtastic-was-built-in-2012'
21
+ it "generates a slug from a string with numbers" do
22
+ expect(Slugtastic.generate_slug("Slugtastic was built in 2012."))
23
+ .to eq "slugtastic-was-built-in-2012"
20
24
  end
21
25
 
22
- it 'handles strings with hypens in them' do
23
- expect(Slugtastic.generate_slug('A string - with Hyphens')).to eq 'a-string-with-hyphens'
26
+ it "handles strings with hypens in them" do
27
+ expect(Slugtastic.generate_slug("A string - with Hyphens"))
28
+ .to eq "a-string-with-hyphens"
24
29
  end
25
30
 
26
- it 'handles strings with other characters in them' do
27
- expect(Slugtastic.generate_slug('A string, with /All sorts!')).to eq 'a-string-with-all-sorts'
31
+ it "handles strings with other characters in them" do
32
+ expect(Slugtastic.generate_slug("A string, with /All sorts!"))
33
+ .to eq "a-string-with-all-sorts"
28
34
  end
29
35
 
30
- it 'handles basic transliteration' do
31
- expect(Slugtastic.generate_slug('Un été À la maison.')).to eq 'un-ete-a-la-maison'
32
- expect(Slugtastic.generate_slug('Ātri brūna lapsa')).to eq 'atri-bruna-lapsa'
36
+ it "handles basic transliteration" do
37
+ expect(Slugtastic.generate_slug("Un été À la maison."))
38
+ .to eq "un-ete-a-la-maison"
39
+ expect(Slugtastic.generate_slug("Ātri brūna lapsa"))
40
+ .to eq "atri-bruna-lapsa"
33
41
  end
34
42
  end
35
43
  end
@@ -1,2 +1 @@
1
- require 'slugtastic'
2
- require 'supermodel'
1
+ require "slugtastic"
@@ -0,0 +1,21 @@
1
+ require "active_support/core_ext/hash/reverse_merge"
2
+ require "active_model"
3
+
4
+ class FakeModel
5
+ include ActiveModel::Validations::Callbacks
6
+
7
+ def initialize(attrs = {})
8
+ attrs.each do |key, value|
9
+ instance_variable_set(:"@#{key}", value)
10
+ end
11
+ end
12
+
13
+ def self.create!(attrs)
14
+ new(attrs).save
15
+ end
16
+
17
+ def save
18
+ _run_validation_callbacks
19
+ self
20
+ end
21
+ end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slugtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Barber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-26 00:00:00.000000000 Z
11
+ date: 2018-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '11.1'
19
+ version: '5'
20
20
  type: :development
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: '11.1'
26
+ version: '5'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.4'
33
+ version: '12.3'
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: '3.4'
40
+ version: '12.3'
41
41
  - !ruby/object:Gem::Dependency
42
- name: supermodel
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.7'
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: '0'
54
+ version: '3.7'
55
55
  description: A simple slug string generator for ActiveRecord. Will populate a slug
56
56
  attribute from another attribute.
57
57
  email:
@@ -63,7 +63,6 @@ files:
63
63
  - ".gitignore"
64
64
  - ".rspec"
65
65
  - ".rubocop.yml"
66
- - ".travis.yml"
67
66
  - CHANGELOG.md
68
67
  - Gemfile
69
68
  - Gemfile.lock
@@ -78,6 +77,7 @@ files:
78
77
  - spec/slugtastic/model_additions_spec.rb
79
78
  - spec/slugtastic_spec.rb
80
79
  - spec/spec_helper.rb
80
+ - spec/support/fake_model.rb
81
81
  homepage: http://danbarber.me/slugtastic
82
82
  licenses:
83
83
  - MIT
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.5.1
101
+ rubygems_version: 2.7.3
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: A simple slug string generator for ActiveRecord.
@@ -106,3 +106,4 @@ test_files:
106
106
  - spec/slugtastic/model_additions_spec.rb
107
107
  - spec/slugtastic_spec.rb
108
108
  - spec/spec_helper.rb
109
+ - spec/support/fake_model.rb
@@ -1,3 +0,0 @@
1
- rvm:
2
- - 1.9.2
3
- - 1.9.3