null_record 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11b8b4bb2118c132a0bb7f101739166e4143819f
4
+ data.tar.gz: ceb39071c1e9eedf0452b1271af71a74148c0715
5
+ SHA512:
6
+ metadata.gz: 74647b4e25bbef6989edcdb5a5de9c3c155aaa31ead129d8673317a654e8165a1a5e5e9bca53cab4dc536ade8334d41a394fcbe83f060ea47aa6319786e3c060
7
+ data.tar.gz: 087eae24ba20ccb52a0392a00e825a78e1f3d7e4765bb75e77a0b88ba44ca82135ae3a18bbc3445ddada00eca270648efa2ad53fe3f7b07894dbcc6c52c2e977
data/.codeclimate.yml ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ engines:
3
+ duplication:
4
+ enabled: true
5
+ config:
6
+ languages:
7
+ - ruby
8
+ fixme:
9
+ enabled: true
10
+ rubocop:
11
+ enabled: true
12
+ ratings:
13
+ paths:
14
+ - "**.rb"
15
+ exclude_paths:
16
+ - spec/
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /test.sqlite3
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,609 @@
1
+ AllCops:
2
+ Exclude:
3
+ - db/schema.rb
4
+ - bin/**/*
5
+
6
+ Style/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
+ Style/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/CyclomaticComplexity:
89
+ Description: >-
90
+ A complexity metric that is strongly correlated to the number
91
+ of test cases needed to validate a method.
92
+ Enabled: false
93
+
94
+ Rails/Delegate:
95
+ Description: 'Prefer delegate method for delegations.'
96
+ Enabled: false
97
+
98
+ Style/DeprecatedHashMethods:
99
+ Description: 'Checks for use of deprecated Hash methods.'
100
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key'
101
+ Enabled: false
102
+
103
+ Style/Documentation:
104
+ Description: 'Document classes and non-namespace modules.'
105
+ Enabled: false
106
+
107
+ Style/DotPosition:
108
+ Description: 'Checks the position of the dot in multi-line method calls.'
109
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
110
+ EnforcedStyle: trailing
111
+
112
+ Style/DoubleNegation:
113
+ Description: 'Checks for uses of double negation (!!).'
114
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
115
+ Enabled: false
116
+
117
+ Style/EachWithObject:
118
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
119
+ Enabled: false
120
+
121
+ Style/EmptyLiteral:
122
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
123
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
124
+ Enabled: false
125
+
126
+ # Checks whether the source file has a utf-8 encoding comment or not
127
+ # AutoCorrectEncodingComment must match the regex
128
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
129
+ Style/Encoding:
130
+ Enabled: false
131
+
132
+ Style/EvenOdd:
133
+ Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
134
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
135
+ Enabled: false
136
+
137
+ Style/ExtraSpacing:
138
+ Description: 'Do not use unnecessary spacing.'
139
+ Enabled: true
140
+
141
+ Style/FileName:
142
+ Description: 'Use snake_case for source file names.'
143
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
144
+ Enabled: false
145
+
146
+ Style/FlipFlop:
147
+ Description: 'Checks for flip flops'
148
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
149
+ Enabled: false
150
+
151
+ Style/FormatString:
152
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
153
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
154
+ Enabled: false
155
+
156
+ Style/GlobalVars:
157
+ Description: 'Do not introduce global variables.'
158
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
159
+ Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
160
+ Enabled: false
161
+
162
+ Style/GuardClause:
163
+ Description: 'Check for conditionals that can be replaced with guard clauses'
164
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
165
+ Enabled: false
166
+
167
+ Style/IfUnlessModifier:
168
+ Description: >-
169
+ Favor modifier if/unless usage when you have a
170
+ single-line body.
171
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
172
+ Enabled: false
173
+
174
+ Style/IfWithSemicolon:
175
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
176
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
177
+ Enabled: false
178
+
179
+ Style/InlineComment:
180
+ Description: 'Avoid inline comments.'
181
+ Enabled: false
182
+
183
+ Style/Lambda:
184
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
185
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
186
+ Enabled: false
187
+
188
+ Style/LambdaCall:
189
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
190
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
191
+ Enabled: false
192
+
193
+ Style/LineEndConcatenation:
194
+ Description: >-
195
+ Use \ instead of + or << to concatenate two string literals at
196
+ line end.
197
+ Enabled: false
198
+
199
+ Metrics/LineLength:
200
+ Description: 'Limit lines to 80 characters.'
201
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
202
+ Max: 80
203
+
204
+ Metrics/MethodLength:
205
+ Description: 'Avoid methods longer than 10 lines of code.'
206
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
207
+ Enabled: false
208
+
209
+ Style/ModuleFunction:
210
+ Description: 'Checks for usage of `extend self` in modules.'
211
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
212
+ Enabled: false
213
+
214
+ Style/MultilineOperationIndentation:
215
+ Description: >-
216
+ Checks indentation of binary operations that span more than
217
+ one line.
218
+ Enabled: true
219
+ EnforcedStyle: indented
220
+
221
+ Style/NegatedIf:
222
+ Description: >-
223
+ Favor unless over if for negative conditions
224
+ (or control flow or).
225
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
226
+ Enabled: false
227
+
228
+ Style/NegatedWhile:
229
+ Description: 'Favor until over while for negative conditions.'
230
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
231
+ Enabled: false
232
+
233
+ Style/Next:
234
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
235
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
236
+ Enabled: false
237
+
238
+ Style/NilComparison:
239
+ Description: 'Prefer x.nil? to x == nil.'
240
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
241
+ Enabled: false
242
+
243
+ Style/Not:
244
+ Description: 'Use ! instead of not.'
245
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
246
+ Enabled: false
247
+
248
+ Style/NumericLiterals:
249
+ Description: >-
250
+ Add underscores to large numeric literals to improve their
251
+ readability.
252
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
253
+ Enabled: false
254
+
255
+ Style/OneLineConditional:
256
+ Description: >-
257
+ Favor the ternary operator(?:) over
258
+ if/then/else/end constructs.
259
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
260
+ Enabled: false
261
+
262
+ Style/OpMethod:
263
+ Description: 'When defining binary operators, name the argument other.'
264
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
265
+ Enabled: false
266
+
267
+ Metrics/ParameterLists:
268
+ Description: 'Avoid parameter lists longer than three or four parameters.'
269
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
270
+ Enabled: false
271
+
272
+ Style/PercentLiteralDelimiters:
273
+ Description: 'Use `%`-literal delimiters consistently'
274
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
275
+ Enabled: false
276
+
277
+ Style/PerlBackrefs:
278
+ Description: 'Avoid Perl-style regex back references.'
279
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
280
+ Enabled: false
281
+
282
+ Style/PredicateName:
283
+ Description: 'Check the names of predicate methods.'
284
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
285
+ NamePrefixBlacklist:
286
+ - is_
287
+ Exclude:
288
+ - spec/**/*
289
+
290
+ Style/Proc:
291
+ Description: 'Use proc instead of Proc.new.'
292
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
293
+ Enabled: false
294
+
295
+ Style/RaiseArgs:
296
+ Description: 'Checks the arguments passed to raise/fail.'
297
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
298
+ Enabled: false
299
+
300
+ Style/RegexpLiteral:
301
+ Description: 'Use / or %r around regular expressions.'
302
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
303
+ Enabled: false
304
+
305
+ Style/SelfAssignment:
306
+ Description: >-
307
+ Checks for places where self-assignment shorthand should have
308
+ been used.
309
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
310
+ Enabled: false
311
+
312
+ Style/SingleLineBlockParams:
313
+ Description: 'Enforces the names of some block params.'
314
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
315
+ Enabled: false
316
+
317
+ Style/SingleLineMethods:
318
+ Description: 'Avoid single-line methods.'
319
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
320
+ Enabled: false
321
+
322
+ Style/SignalException:
323
+ Description: 'Checks for proper usage of fail and raise.'
324
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
325
+ Enabled: false
326
+
327
+ Style/SpecialGlobalVars:
328
+ Description: 'Avoid Perl-style global variables.'
329
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
330
+ Enabled: false
331
+
332
+ Style/StringLiterals:
333
+ Description: 'Checks if uses of quotes match the configured preference.'
334
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
335
+ EnforcedStyle: double_quotes
336
+ Enabled: true
337
+
338
+ Style/TrailingCommaInArguments:
339
+ Description: 'Checks for trailing comma in argument lists.'
340
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
341
+ EnforcedStyleForMultiline: comma
342
+ SupportedStyles:
343
+ - comma
344
+ - consistent_comma
345
+ - no_comma
346
+ Enabled: true
347
+
348
+ Style/TrailingCommaInLiteral:
349
+ Description: 'Checks for trailing comma in array and hash literals.'
350
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
351
+ EnforcedStyleForMultiline: comma
352
+ SupportedStyles:
353
+ - comma
354
+ - consistent_comma
355
+ - no_comma
356
+ Enabled: true
357
+
358
+ Style/TrivialAccessors:
359
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
360
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
361
+ Enabled: false
362
+
363
+ Style/VariableInterpolation:
364
+ Description: >-
365
+ Don't interpolate global, instance and class variables
366
+ directly in strings.
367
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
368
+ Enabled: false
369
+
370
+ Style/WhenThen:
371
+ Description: 'Use when x then ... for one-line cases.'
372
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
373
+ Enabled: false
374
+
375
+ Style/WhileUntilModifier:
376
+ Description: >-
377
+ Favor modifier while/until usage when you have a
378
+ single-line body.
379
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
380
+ Enabled: false
381
+
382
+ Style/WordArray:
383
+ Description: 'Use %w or %W for arrays of words.'
384
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
385
+ Enabled: false
386
+
387
+ # Lint
388
+
389
+ Lint/AmbiguousOperator:
390
+ Description: >-
391
+ Checks for ambiguous operators in the first argument of a
392
+ method invocation without parentheses.
393
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
394
+ Enabled: false
395
+
396
+ Lint/AmbiguousRegexpLiteral:
397
+ Description: >-
398
+ Checks for ambiguous regexp literals in the first argument of
399
+ a method invocation without parenthesis.
400
+ Enabled: false
401
+
402
+ Lint/AssignmentInCondition:
403
+ Description: "Don't use assignment in conditions."
404
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
405
+ Enabled: false
406
+
407
+ Lint/CircularArgumentReference:
408
+ Description: "Don't refer to the keyword argument in the default value."
409
+ Enabled: false
410
+
411
+ Lint/ConditionPosition:
412
+ Description: >-
413
+ Checks for condition placed in a confusing position relative to
414
+ the keyword.
415
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
416
+ Enabled: false
417
+
418
+ Lint/DeprecatedClassMethods:
419
+ Description: 'Check for deprecated class method calls.'
420
+ Enabled: false
421
+
422
+ Lint/DuplicatedKey:
423
+ Description: 'Check for duplicate keys in hash literals.'
424
+ Enabled: false
425
+
426
+ Lint/EachWithObjectArgument:
427
+ Description: 'Check for immutable argument given to each_with_object.'
428
+ Enabled: false
429
+
430
+ Lint/ElseLayout:
431
+ Description: 'Check for odd code arrangement in an else block.'
432
+ Enabled: false
433
+
434
+ Lint/FormatParameterMismatch:
435
+ Description: 'The number of parameters to format/sprint must match the fields.'
436
+ Enabled: false
437
+
438
+ Lint/HandleExceptions:
439
+ Description: "Don't suppress exception."
440
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
441
+ Enabled: false
442
+
443
+ Lint/InvalidCharacterLiteral:
444
+ Description: >-
445
+ Checks for invalid character literals with a non-escaped
446
+ whitespace character.
447
+ Enabled: false
448
+
449
+ Style/InitialIndentation:
450
+ Description: >-
451
+ Checks the indentation of the first non-blank non-comment line in a file.
452
+ Enabled: false
453
+
454
+ Lint/LiteralInCondition:
455
+ Description: 'Checks of literals used in conditions.'
456
+ Enabled: false
457
+
458
+ Lint/LiteralInInterpolation:
459
+ Description: 'Checks for literals used in interpolation.'
460
+ Enabled: false
461
+
462
+ Lint/Loop:
463
+ Description: >-
464
+ Use Kernel#loop with break rather than begin/end/until or
465
+ begin/end/while for post-loop tests.
466
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
467
+ Enabled: false
468
+
469
+ Lint/NestedMethodDefinition:
470
+ Description: 'Do not use nested method definitions.'
471
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
472
+ Enabled: false
473
+
474
+ Lint/NonLocalExitFromIterator:
475
+ Description: 'Do not use return in iterator to cause non-local exit.'
476
+ Enabled: false
477
+
478
+ Lint/ParenthesesAsGroupedExpression:
479
+ Description: >-
480
+ Checks for method calls with a space before the opening
481
+ parenthesis.
482
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
483
+ Enabled: false
484
+
485
+ Lint/RequireParentheses:
486
+ Description: >-
487
+ Use parentheses in the method call to avoid confusion
488
+ about precedence.
489
+ Enabled: false
490
+
491
+ Lint/UnderscorePrefixedVariableName:
492
+ Description: 'Do not use prefix `_` for a variable that is used.'
493
+ Enabled: false
494
+
495
+ Lint/UnneededDisable:
496
+ Description: >-
497
+ Checks for rubocop:disable comments that can be removed.
498
+ Note: this cop is not disabled when disabling all cops.
499
+ It must be explicitly disabled.
500
+ Enabled: false
501
+
502
+ Lint/Void:
503
+ Description: 'Possible use of operator/literal/variable in void context.'
504
+ Enabled: false
505
+
506
+ # Performance
507
+
508
+ Performance/CaseWhenSplat:
509
+ Description: >-
510
+ Place `when` conditions that use splat at the end
511
+ of the list of `when` branches.
512
+ Enabled: false
513
+
514
+ Performance/Count:
515
+ Description: >-
516
+ Use `count` instead of `select...size`, `reject...size`,
517
+ `select...count`, `reject...count`, `select...length`,
518
+ and `reject...length`.
519
+ Enabled: false
520
+
521
+ Performance/Detect:
522
+ Description: >-
523
+ Use `detect` instead of `select.first`, `find_all.first`,
524
+ `select.last`, and `find_all.last`.
525
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
526
+ Enabled: false
527
+
528
+ Performance/FlatMap:
529
+ Description: >-
530
+ Use `Enumerable#flat_map`
531
+ instead of `Enumerable#map...Array#flatten(1)`
532
+ or `Enumberable#collect..Array#flatten(1)`
533
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
534
+ Enabled: false
535
+
536
+ Performance/ReverseEach:
537
+ Description: 'Use `reverse_each` instead of `reverse.each`.'
538
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
539
+ Enabled: false
540
+
541
+ Performance/Sample:
542
+ Description: >-
543
+ Use `sample` instead of `shuffle.first`,
544
+ `shuffle.last`, and `shuffle[Fixnum]`.
545
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
546
+ Enabled: false
547
+
548
+ Performance/Size:
549
+ Description: >-
550
+ Use `size` instead of `count` for counting
551
+ the number of elements in `Array` and `Hash`.
552
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
553
+ Enabled: false
554
+
555
+ Performance/StringReplacement:
556
+ Description: >-
557
+ Use `tr` instead of `gsub` when you are replacing the same
558
+ number of characters. Use `delete` instead of `gsub` when
559
+ you are deleting characters.
560
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
561
+ Enabled: false
562
+
563
+ # Rails
564
+
565
+ Rails/ActionFilter:
566
+ Description: 'Enforces consistent use of action filter methods.'
567
+ Enabled: false
568
+
569
+ Rails/Date:
570
+ Description: >-
571
+ Checks the correct usage of date aware methods,
572
+ such as Date.today, Date.current etc.
573
+ Enabled: false
574
+
575
+ Rails/FindBy:
576
+ Description: 'Prefer find_by over where.first.'
577
+ Enabled: false
578
+
579
+ Rails/FindEach:
580
+ Description: 'Prefer all.find_each over all.find.'
581
+ Enabled: false
582
+
583
+ Rails/HasAndBelongsToMany:
584
+ Description: 'Prefer has_many :through to has_and_belongs_to_many.'
585
+ Enabled: false
586
+
587
+ Rails/Output:
588
+ Description: 'Checks for calls to puts, print, etc.'
589
+ Enabled: false
590
+
591
+ Rails/ReadWriteAttribute:
592
+ Description: >-
593
+ Checks for read_attribute(:attr) and
594
+ write_attribute(:attr, val).
595
+ Enabled: false
596
+
597
+ Rails/ScopeArgs:
598
+ Description: 'Checks the arguments of ActiveRecord scopes.'
599
+ Enabled: false
600
+
601
+ Rails/TimeZone:
602
+ Description: 'Checks the correct usage of time zone aware methods.'
603
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
604
+ Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
605
+ Enabled: false
606
+
607
+ Rails/Validation:
608
+ Description: 'Use validates :attribute, hash of validations.'
609
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.3
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at alexstophel@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in null_record.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Alex Stophel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ [![Code Climate](https://codeclimate.com/github/alexstophel/null_record/badges/gpa.svg)](https://codeclimate.com/github/alexstophel/null_record)
2
+ [![Test Coverage](https://codeclimate.com/github/alexstophel/null_record/badges/coverage.svg)](https://codeclimate.com/github/alexstophel/null_record/coverage)
3
+ [![Build Status](https://travis-ci.org/alexstophel/null_record.svg?branch=master)](https://travis-ci.org/alexstophel/null_record)
4
+
5
+ # NullRecord
6
+
7
+ NullRecord is intended to make using the [Null
8
+ Object](https://en.wikipedia.org/wiki/Null_Object_pattern) pattern with
9
+ ActiveRecord easier. This gem is fairly simple, and you could likely implement
10
+ all of the functionality without this gem relatively easy. I initially had all
11
+ of this logic in a project and decided to rip it out to make it easier to share
12
+ among projects and other AR objects.
13
+
14
+ Not sure what the Null Object pattern is all about? Here's some resources to get
15
+ you started:
16
+
17
+ [Suspicions of nil](http://www.sandimetz.com/blog/2014/12/19/suspicions-of-nil)
18
+ by Sandi Metz
19
+
20
+ [Null Objects and
21
+ Falsiness](http://devblog.avdi.org/2011/05/30/null-objects-and-falsiness/) by
22
+ Advi Grimm
23
+
24
+ Is there a resource that you find helpful? Submit a Pull Request to add it to
25
+ this list!
26
+
27
+ ## Installation
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ ```ruby
32
+ gem 'null_record'
33
+ ```
34
+
35
+ And then execute:
36
+
37
+ $ bundle
38
+
39
+ Or install it yourself as:
40
+
41
+ $ gem install null_record
42
+
43
+ If you're including this in a Rails application, create an initializer to
44
+ include NullRecord in ActiveRecord::Base:
45
+
46
+ ```ruby
47
+ # config/initializers/null_record.rb
48
+
49
+ ActiveSupport.on_load(:active_record) do
50
+ ActiveRecord::Base.send(:include, NullRecord)
51
+ end
52
+ ```
53
+
54
+ ## Usage
55
+
56
+ NullRecord patches ActiveRecord finder methods to return a Null Object instead
57
+ of nil. How neat! Check it out:
58
+
59
+ Standard ActiveRecord:
60
+
61
+ ```ruby
62
+ User.find(1)
63
+ => nil
64
+ ```
65
+
66
+ ActiveRecord w/ NullRecord:
67
+
68
+ ```ruby
69
+ User.find(1)
70
+ => <null:User>
71
+ ```
72
+
73
+ ## Development
74
+
75
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
76
+
77
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
78
+
79
+ ## Contributing
80
+
81
+ Bug reports and pull requests are welcome on GitHub at https://github.com/alexstophel/null_record. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
82
+
83
+ ## License
84
+
85
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
86
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "null_record"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ require "active_support"
2
+ require "naught"
3
+ require "null_record/finder_methods"
4
+ require "null_record/has_null_record"
5
+ require "null_record/null_object"
6
+ require "null_record/version"
7
+
8
+ module NullRecord
9
+ extend ActiveSupport::Concern
10
+
11
+ module ClassMethods
12
+ # rubocop:disable Style/PredicateName
13
+ def has_null_record
14
+ NullRecord::HasNullRecord.define_on(self)
15
+ end
16
+ # rubocop:enable Style/PredicateName
17
+ end
18
+ end
@@ -0,0 +1,54 @@
1
+ module NullRecord
2
+ module FinderMethods
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def fifth
7
+ super || null_object
8
+ end
9
+
10
+ def find(id)
11
+ super(id)
12
+ rescue ActiveRecord::RecordNotFound
13
+ null_object
14
+ end
15
+
16
+ def find_by(attributes)
17
+ super(attributes) || null_object
18
+ end
19
+
20
+ def first
21
+ super || null_object
22
+ end
23
+
24
+ def forty_two
25
+ super || null_object
26
+ end
27
+
28
+ def fourth
29
+ super || null_object
30
+ end
31
+
32
+ def last
33
+ super || null_object
34
+ end
35
+
36
+ def second
37
+ super || null_object
38
+ end
39
+
40
+ def take(limit = nil)
41
+ if limit && limit > 1
42
+ result = super(limit)
43
+ result.size > 1 ? result : Array.new(limit) { null_object }
44
+ else
45
+ super(limit) || null_object
46
+ end
47
+ end
48
+
49
+ def third
50
+ super || null_object
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ module NullRecord
2
+ module HasNullRecord
3
+ class << self
4
+ def define_on(model)
5
+ build_null_object(model, default_naught_config(model))
6
+ model.send(:include, NullRecord::FinderMethods)
7
+ model.send(:include, NullRecord::NullObject)
8
+ end
9
+
10
+ private
11
+
12
+ def build_null_object(model, config)
13
+ model.instance_eval do
14
+ null_object = Naught.build(&config)
15
+ const_set "Null#{self}", null_object
16
+ end
17
+ end
18
+
19
+ def default_naught_config(model)
20
+ proc do |config|
21
+ config.mimic model.to_s.constantize
22
+ config.predicates_return false
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ module NullRecord
2
+ module NullObject
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def null_object
7
+ Object.const_get("#{self}::Null#{self}").new
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module NullRecord
2
+ VERSION = "0.1.0".freeze
3
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "null_record/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "null_record"
8
+ spec.version = NullRecord::VERSION
9
+ spec.authors = ["Alex Stophel"]
10
+ spec.email = ["alexstophel@gmail.com"]
11
+ spec.summary = "Enables ActiveRecord FinderMethods to return Null Objects."
12
+ spec.homepage = "https://github.com/alexstophel/null_record"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "activerecord"
24
+ spec.add_dependency "activesupport"
25
+ spec.add_dependency "naught", "~> 1.1"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.12"
28
+ spec.add_development_dependency "codeclimate-test-reporter"
29
+ spec.add_development_dependency "pry", "~> 0.10.3"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "sqlite3", "~> 1.3", ">= 1.3.11"
33
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: null_record
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex Stophel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: naught
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.10.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: sqlite3
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.3'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.3.11
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '1.3'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 1.3.11
145
+ description:
146
+ email:
147
+ - alexstophel@gmail.com
148
+ executables: []
149
+ extensions: []
150
+ extra_rdoc_files: []
151
+ files:
152
+ - ".codeclimate.yml"
153
+ - ".gitignore"
154
+ - ".rspec"
155
+ - ".rubocop.yml"
156
+ - ".travis.yml"
157
+ - CODE_OF_CONDUCT.md
158
+ - Gemfile
159
+ - LICENSE.txt
160
+ - README.md
161
+ - Rakefile
162
+ - bin/console
163
+ - bin/rspec
164
+ - bin/setup
165
+ - lib/null_record.rb
166
+ - lib/null_record/finder_methods.rb
167
+ - lib/null_record/has_null_record.rb
168
+ - lib/null_record/null_object.rb
169
+ - lib/null_record/version.rb
170
+ - null_record.gemspec
171
+ homepage: https://github.com/alexstophel/null_record
172
+ licenses:
173
+ - MIT
174
+ metadata: {}
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubyforge_project:
191
+ rubygems_version: 2.5.1
192
+ signing_key:
193
+ specification_version: 4
194
+ summary: Enables ActiveRecord FinderMethods to return Null Objects.
195
+ test_files: []