prezzo 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: c64cce53d421e6df0292b032789f253f1f93732c
4
- data.tar.gz: 9917b148d77f183c414a476393bc24fe07325ac8
3
+ metadata.gz: 9b0833080b15f848d5af74f370de06f7b7e01f99
4
+ data.tar.gz: 84b4ba0a6ab9cde6acd3b712ea34a4454d0eb64d
5
5
  SHA512:
6
- metadata.gz: d971223483c2541472311df4e4ec4bb57d4bca8fd71d2ae160a4e6d1ced2e7eef2e5d5f7d26cce66c1a6b9bcf586a9a7531df607e917081769f0a5d01b226fd2
7
- data.tar.gz: 46d68027ad5acd62225a74821b53e768720f583d3af33e1b1e5f68f16c61e4527eb6861ff5ae0921d54bbfe666184ab42defc733a89a371d452761e8ddf4e5a2
6
+ metadata.gz: ccf84eb848f89a21583cffedccdf39964e8cc747d8a883d28001652467b9d4f476930d236610aac02cd753dd3ca935b59e1b6d7a9699eb878158cbff78298b10
7
+ data.tar.gz: a10f803a910e9f2b5a91eeddef07a98e269844f77a5bb06de1b60431caf9fffea04d071f60bcde3114e586ac6bff92eb8ffe1810b45158e29d98e3d52ed64e78
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .byebug_history
data/.rubocop.yml ADDED
@@ -0,0 +1,585 @@
1
+ Style/AccessorMethodName:
2
+ Description: Check the naming of accessor methods for get_/set_.
3
+ Enabled: false
4
+
5
+ Style/Alias:
6
+ Description: 'Use alias_method instead of alias.'
7
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
8
+ Enabled: false
9
+
10
+ Style/AlignParameters:
11
+ Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.'
12
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
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/AbcSize:
89
+ Description: >-
90
+ A calculated magnitude based on number of assignments,
91
+ branches, and conditions.
92
+ Enabled: false
93
+
94
+ Metrics/CyclomaticComplexity:
95
+ Description: >-
96
+ A complexity metric that is strongly correlated to the number
97
+ of test cases needed to validate a method.
98
+ Enabled: false
99
+
100
+ Rails/Delegate:
101
+ Description: 'Prefer delegate method for delegations.'
102
+ Enabled: false
103
+
104
+ Style/PreferredHashMethods:
105
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
106
+ StyleGuide: '#hash-key'
107
+ Enabled: false
108
+
109
+ Style/Documentation:
110
+ Description: 'Document classes and non-namespace modules.'
111
+ Enabled: false
112
+
113
+ Style/DotPosition:
114
+ Description: 'Checks the position of the dot in multi-line method calls.'
115
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
116
+ EnforcedStyle: trailing
117
+
118
+ Style/DoubleNegation:
119
+ Description: 'Checks for uses of double negation (!!).'
120
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
121
+ Enabled: false
122
+
123
+ Style/EachWithObject:
124
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
125
+ Enabled: false
126
+
127
+ Style/EmptyLiteral:
128
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
129
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
130
+ Enabled: false
131
+
132
+ # Checks whether the source file has a utf-8 encoding comment or not
133
+ # AutoCorrectEncodingComment must match the regex
134
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
135
+ Style/Encoding:
136
+ Enabled: false
137
+
138
+ Style/EvenOdd:
139
+ Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
140
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
141
+ Enabled: false
142
+
143
+ Style/ExtraSpacing:
144
+ Description: 'Do not use unnecessary spacing.'
145
+ Enabled: true
146
+
147
+ Style/FileName:
148
+ Description: 'Use snake_case for source file names.'
149
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
150
+ Enabled: false
151
+
152
+ Style/FrozenStringLiteralComment:
153
+ Description: >-
154
+ Add the frozen_string_literal comment to the top of files
155
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
156
+ Enabled: false
157
+
158
+ Style/FlipFlop:
159
+ Description: 'Checks for flip flops'
160
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
161
+ Enabled: false
162
+
163
+ Style/FormatString:
164
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
165
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
166
+ Enabled: false
167
+
168
+ Style/GlobalVars:
169
+ Description: 'Do not introduce global variables.'
170
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
171
+ Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
172
+ Enabled: false
173
+
174
+ Style/GuardClause:
175
+ Description: 'Check for conditionals that can be replaced with guard clauses'
176
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
177
+ Enabled: false
178
+
179
+ Style/IfUnlessModifier:
180
+ Description: >-
181
+ Favor modifier if/unless usage when you have a
182
+ single-line body.
183
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
184
+ Enabled: false
185
+
186
+ Style/IfWithSemicolon:
187
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
188
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
189
+ Enabled: false
190
+
191
+ Style/InlineComment:
192
+ Description: 'Avoid inline comments.'
193
+ Enabled: false
194
+
195
+ Style/Lambda:
196
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
197
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
198
+ Enabled: false
199
+
200
+ Style/LambdaCall:
201
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
202
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
203
+ Enabled: false
204
+
205
+ Style/LineEndConcatenation:
206
+ Description: >-
207
+ Use \ instead of + or << to concatenate two string literals at
208
+ line end.
209
+ Enabled: false
210
+
211
+ Metrics/LineLength:
212
+ Description: 'Limit lines to 100 characters.'
213
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
214
+ Max: 100
215
+
216
+ Metrics/MethodLength:
217
+ Description: 'Avoid methods longer than 10 lines of code.'
218
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
219
+ Enabled: false
220
+
221
+ Style/ModuleFunction:
222
+ Description: 'Checks for usage of `extend self` in modules.'
223
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
224
+ Enabled: false
225
+
226
+ Style/MultilineOperationIndentation:
227
+ Description: >-
228
+ Checks indentation of binary operations that span more than
229
+ one line.
230
+ Enabled: true
231
+ EnforcedStyle: indented
232
+
233
+ Style/MultilineBlockChain:
234
+ Description: 'Avoid multi-line chains of blocks.'
235
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
236
+ Enabled: false
237
+
238
+ Style/MultilineMethodCallIndentation:
239
+ Description: >-
240
+ Checks indentation of method calls with the dot operator
241
+ that span more than one line.
242
+ Enabled: true
243
+ EnforcedStyle: indented
244
+
245
+ Style/NegatedIf:
246
+ Description: >-
247
+ Favor unless over if for negative conditions
248
+ (or control flow or).
249
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
250
+ Enabled: false
251
+
252
+ Style/NegatedWhile:
253
+ Description: 'Favor until over while for negative conditions.'
254
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
255
+ Enabled: false
256
+
257
+ Style/Next:
258
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
259
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
260
+ Enabled: false
261
+
262
+ Style/NilComparison:
263
+ Description: 'Prefer x.nil? to x == nil.'
264
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
265
+ Enabled: false
266
+
267
+ Style/Not:
268
+ Description: 'Use ! instead of not.'
269
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
270
+ Enabled: false
271
+
272
+ Style/NumericLiterals:
273
+ Description: >-
274
+ Add underscores to large numeric literals to improve their
275
+ readability.
276
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
277
+ Enabled: false
278
+
279
+ Style/OneLineConditional:
280
+ Description: >-
281
+ Favor the ternary operator(?:) over
282
+ if/then/else/end constructs.
283
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
284
+ Enabled: false
285
+
286
+ Style/OpMethod:
287
+ Description: 'When defining binary operators, name the argument other.'
288
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
289
+ Enabled: false
290
+
291
+ Metrics/ParameterLists:
292
+ Description: 'Avoid parameter lists longer than three or four parameters.'
293
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
294
+ Enabled: false
295
+
296
+ Style/PercentLiteralDelimiters:
297
+ Description: 'Use `%`-literal delimiters consistently'
298
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
299
+ Enabled: false
300
+
301
+ Style/PerlBackrefs:
302
+ Description: 'Avoid Perl-style regex back references.'
303
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
304
+ Enabled: false
305
+
306
+ Style/PredicateName:
307
+ Description: 'Check the names of predicate methods.'
308
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
309
+ NamePrefixBlacklist:
310
+ - is_
311
+ Exclude:
312
+ - spec/**/*
313
+
314
+ Style/Proc:
315
+ Description: 'Use proc instead of Proc.new.'
316
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
317
+ Enabled: false
318
+
319
+ Style/RaiseArgs:
320
+ Description: 'Checks the arguments passed to raise/fail.'
321
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
322
+ Enabled: false
323
+
324
+ Style/RegexpLiteral:
325
+ Description: 'Use / or %r around regular expressions.'
326
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
327
+ Enabled: false
328
+
329
+ Style/SelfAssignment:
330
+ Description: >-
331
+ Checks for places where self-assignment shorthand should have
332
+ been used.
333
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
334
+ Enabled: false
335
+
336
+ Style/SingleLineBlockParams:
337
+ Description: 'Enforces the names of some block params.'
338
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
339
+ Enabled: false
340
+
341
+ Style/SingleLineMethods:
342
+ Description: 'Avoid single-line methods.'
343
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
344
+ Enabled: false
345
+
346
+ Style/SignalException:
347
+ Description: 'Checks for proper usage of fail and raise.'
348
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
349
+ Enabled: false
350
+
351
+ Style/SpecialGlobalVars:
352
+ Description: 'Avoid Perl-style global variables.'
353
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
354
+ Enabled: false
355
+
356
+ Style/StringLiterals:
357
+ Description: 'Checks if uses of quotes match the configured preference.'
358
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
359
+ EnforcedStyle: double_quotes
360
+ Enabled: true
361
+
362
+ Style/TrailingCommaInArguments:
363
+ Description: 'Checks for trailing comma in argument lists.'
364
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
365
+ EnforcedStyleForMultiline: comma
366
+ SupportedStyles:
367
+ - comma
368
+ - consistent_comma
369
+ - no_comma
370
+ Enabled: true
371
+
372
+ Style/TrailingCommaInLiteral:
373
+ Description: 'Checks for trailing comma in array and hash literals.'
374
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
375
+ EnforcedStyleForMultiline: comma
376
+ SupportedStyles:
377
+ - comma
378
+ - consistent_comma
379
+ - no_comma
380
+ Enabled: true
381
+
382
+ Style/TrivialAccessors:
383
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
384
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
385
+ Enabled: false
386
+
387
+ Style/VariableInterpolation:
388
+ Description: >-
389
+ Don't interpolate global, instance and class variables
390
+ directly in strings.
391
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
392
+ Enabled: false
393
+
394
+ Style/WhenThen:
395
+ Description: 'Use when x then ... for one-line cases.'
396
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
397
+ Enabled: false
398
+
399
+ Style/WhileUntilModifier:
400
+ Description: >-
401
+ Favor modifier while/until usage when you have a
402
+ single-line body.
403
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
404
+ Enabled: false
405
+
406
+ Style/WordArray:
407
+ Description: 'Use %w or %W for arrays of words.'
408
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
409
+ Enabled: false
410
+
411
+ # Lint
412
+
413
+ Lint/AmbiguousOperator:
414
+ Description: >-
415
+ Checks for ambiguous operators in the first argument of a
416
+ method invocation without parentheses.
417
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
418
+ Enabled: false
419
+
420
+ Lint/AmbiguousRegexpLiteral:
421
+ Description: >-
422
+ Checks for ambiguous regexp literals in the first argument of
423
+ a method invocation without parenthesis.
424
+ Enabled: false
425
+
426
+ Lint/AssignmentInCondition:
427
+ Description: "Don't use assignment in conditions."
428
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
429
+ Enabled: false
430
+
431
+ Lint/CircularArgumentReference:
432
+ Description: "Don't refer to the keyword argument in the default value."
433
+ Enabled: false
434
+
435
+ Lint/ConditionPosition:
436
+ Description: >-
437
+ Checks for condition placed in a confusing position relative to
438
+ the keyword.
439
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
440
+ Enabled: false
441
+
442
+ Lint/DeprecatedClassMethods:
443
+ Description: 'Check for deprecated class method calls.'
444
+ Enabled: false
445
+
446
+ Lint/DuplicatedKey:
447
+ Description: 'Check for duplicate keys in hash literals.'
448
+ Enabled: false
449
+
450
+ Lint/EachWithObjectArgument:
451
+ Description: 'Check for immutable argument given to each_with_object.'
452
+ Enabled: false
453
+
454
+ Lint/ElseLayout:
455
+ Description: 'Check for odd code arrangement in an else block.'
456
+ Enabled: false
457
+
458
+ Lint/FormatParameterMismatch:
459
+ Description: 'The number of parameters to format/sprint must match the fields.'
460
+ Enabled: false
461
+
462
+ Lint/HandleExceptions:
463
+ Description: "Don't suppress exception."
464
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
465
+ Enabled: false
466
+
467
+ Lint/InvalidCharacterLiteral:
468
+ Description: >-
469
+ Checks for invalid character literals with a non-escaped
470
+ whitespace character.
471
+ Enabled: false
472
+
473
+ Style/InitialIndentation:
474
+ Description: >-
475
+ Checks the indentation of the first non-blank non-comment line in a file.
476
+ Enabled: false
477
+
478
+ Lint/LiteralInCondition:
479
+ Description: 'Checks of literals used in conditions.'
480
+ Enabled: false
481
+
482
+ Lint/LiteralInInterpolation:
483
+ Description: 'Checks for literals used in interpolation.'
484
+ Enabled: false
485
+
486
+ Lint/Loop:
487
+ Description: >-
488
+ Use Kernel#loop with break rather than begin/end/until or
489
+ begin/end/while for post-loop tests.
490
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
491
+ Enabled: false
492
+
493
+ Lint/NestedMethodDefinition:
494
+ Description: 'Do not use nested method definitions.'
495
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
496
+ Enabled: false
497
+
498
+ Lint/NonLocalExitFromIterator:
499
+ Description: 'Do not use return in iterator to cause non-local exit.'
500
+ Enabled: false
501
+
502
+ Lint/ParenthesesAsGroupedExpression:
503
+ Description: >-
504
+ Checks for method calls with a space before the opening
505
+ parenthesis.
506
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
507
+ Enabled: false
508
+
509
+ Lint/RequireParentheses:
510
+ Description: >-
511
+ Use parentheses in the method call to avoid confusion
512
+ about precedence.
513
+ Enabled: false
514
+
515
+ Lint/UnderscorePrefixedVariableName:
516
+ Description: 'Do not use prefix `_` for a variable that is used.'
517
+ Enabled: false
518
+
519
+ Lint/UnneededDisable:
520
+ Description: >-
521
+ Checks for rubocop:disable comments that can be removed.
522
+ Note: this cop is not disabled when disabling all cops.
523
+ It must be explicitly disabled.
524
+ Enabled: false
525
+
526
+ Lint/Void:
527
+ Description: 'Possible use of operator/literal/variable in void context.'
528
+ Enabled: false
529
+
530
+ # Performance
531
+
532
+ Performance/CaseWhenSplat:
533
+ Description: >-
534
+ Place `when` conditions that use splat at the end
535
+ of the list of `when` branches.
536
+ Enabled: false
537
+
538
+ Performance/Count:
539
+ Description: >-
540
+ Use `count` instead of `select...size`, `reject...size`,
541
+ `select...count`, `reject...count`, `select...length`,
542
+ and `reject...length`.
543
+ Enabled: false
544
+
545
+ Performance/Detect:
546
+ Description: >-
547
+ Use `detect` instead of `select.first`, `find_all.first`,
548
+ `select.last`, and `find_all.last`.
549
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
550
+ Enabled: false
551
+
552
+ Performance/FlatMap:
553
+ Description: >-
554
+ Use `Enumerable#flat_map`
555
+ instead of `Enumerable#map...Array#flatten(1)`
556
+ or `Enumberable#collect..Array#flatten(1)`
557
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
558
+ Enabled: false
559
+
560
+ Performance/ReverseEach:
561
+ Description: 'Use `reverse_each` instead of `reverse.each`.'
562
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
563
+ Enabled: false
564
+
565
+ Performance/Sample:
566
+ Description: >-
567
+ Use `sample` instead of `shuffle.first`,
568
+ `shuffle.last`, and `shuffle[Fixnum]`.
569
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
570
+ Enabled: false
571
+
572
+ Performance/Size:
573
+ Description: >-
574
+ Use `size` instead of `count` for counting
575
+ the number of elements in `Array` and `Hash`.
576
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
577
+ Enabled: false
578
+
579
+ Performance/StringReplacement:
580
+ Description: >-
581
+ Use `tr` instead of `gsub` when you are replacing the same
582
+ number of characters. Use `delete` instead of `gsub` when
583
+ you are deleting characters.
584
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
585
+ Enabled: false
data/.travis.yml CHANGED
@@ -2,4 +2,19 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.3.1
5
- before_install: gem install bundler -v 1.13.7
5
+
6
+ addons:
7
+ code_climate:
8
+ repo_token: b05bb78bfd6dbb9fb7f55d520f63e7d981f13a69de06aa2ae5ebd69a1e01789e
9
+
10
+ before_install:
11
+ - gem install bundler -v 1.13.7
12
+
13
+ install:
14
+ - make
15
+
16
+ script:
17
+ - make test
18
+
19
+ after_success:
20
+ - make report_coverage
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,40 @@
1
+ # Contributing
2
+
3
+ 1. Star the project.
4
+ 2. Open or find an issue [here](https://github.com/marceloboeira/prezzo/issues).
5
+ 3. Fork it (https://github.com/marceloboeira/prezzo/fork)
6
+ 4. Create your feature branch (git checkout -b my-awesome-new-feature)
7
+ 5. Commit your changes (**follwing our [commit policy](#commit-policy) and [style guide](#style-guide)**)
8
+ 6. Push to the branch (git push origin my-new-feature)
9
+ 7. Create a new Pull Request
10
+
11
+ ---------
12
+
13
+ ## Style Guide
14
+
15
+ Currently, we are using [Thoughtbot's Style Guide](https://github.com/thoughtbot/guides/blob/master/style/ruby/README.md) for Ruby Code.
16
+
17
+ ## Commit Policy
18
+
19
+ We have a very rigid **commit policy**, to contribute please follow these rules:
20
+
21
+ ```
22
+ feature: Add hat wobble
23
+ ^--^ ^------------^
24
+ | |
25
+ | +-> Summary in present tense
26
+ |
27
+ +-------> Type: chore, doc, feature, fix, refactor, style, or test
28
+ ```
29
+
30
+ ### Available tags:
31
+
32
+ * **chore**: Add oyster build script
33
+ * **doc**: Explain hat wobble
34
+ * **feature**: Add beta sequence
35
+ * **fix**: Remove broken confirmation message
36
+ * **refactor**: Share logic between 4d3d3d3 and flarhgunnstow
37
+ * **style**: Convert tabs to spaces
38
+ * **test**: Ensure Tayne retains clothing
39
+
40
+ > Based on [this](http://seesparkbox.com/foundry/semantic_commit_messages).
data/Makefile ADDED
@@ -0,0 +1,33 @@
1
+ .PHONY: default
2
+ default: setup
3
+
4
+ .PHONY: setup
5
+ setup:
6
+ bin/setup
7
+
8
+ .PHONY: console
9
+ console:
10
+ bin/console
11
+
12
+ .PHONY: spec
13
+ spec:
14
+ bundle exec rspec
15
+
16
+ .PHONY: test
17
+ test: spec
18
+
19
+ .PHONY: report_coverage
20
+ report_coverage:
21
+ bundle exec codeclimate-test-reporter
22
+
23
+ .PHONY: guard
24
+ guard:
25
+ bundle exec guard
26
+
27
+ .PHONY: install
28
+ install:
29
+ bundle exec rake install
30
+
31
+ .PHONY: release
32
+ release:
33
+ bundle exec rake release
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Prezzo
1
+ # Prezzo [![Build Status](https://travis-ci.org/marceloboeira/prezzo.svg?branch=master)](https://travis-ci.org/marceloboeira/prezzo)
2
2
  > Toolbox to create complex pricing models
3
3
 
4
4
  ## Installation
@@ -11,37 +11,158 @@ gem "prezzo"
11
11
 
12
12
  And then execute:
13
13
 
14
- $ bundle
14
+ ```
15
+ $ bundle
16
+ ```
15
17
 
16
18
  Or install it yourself as:
17
19
 
18
- $ gem install prezzo
20
+ ```
21
+ $ gem install prezzo
22
+ ```
19
23
 
20
24
  ## Usage
21
25
 
22
- ### Basic:
26
+ ### Prezzo::Context
27
+
28
+
29
+ The `Prezzo::Context` is a source of data for your calculators. Basically, it receives a hash of params and it validates its content, in order to make the calculations safe.
30
+
31
+ e.g.:
32
+
33
+ ```ruby
34
+ module Uber
35
+ class Context
36
+ include Prezzo::Context
37
+ CATEGORIES = ["UberX", "UberXL", "UberBlack"].freeze
38
+
39
+ validations do
40
+ required(:category).filled(included_in?: CATEGORIES)
41
+ required(:distance).filled(:float?)
42
+ required(:total_cars).filled(:int?)
43
+ required(:available_cars).filled(:int?)
44
+ end
45
+ end
46
+ end
47
+
48
+ context = Uber::Context.new(category: "UberBlack", ...)
49
+
50
+ # when valid
51
+ context.valid?
52
+ #=> true
53
+
54
+ # when invalid
55
+ context.valid?
56
+ #=> false
57
+
58
+ context.errors
59
+ # { distance: ["must be a float"]}
60
+ ```
61
+
62
+ ### Prezzo::Calculator
63
+
64
+ The `Prezzo::Calculator` is a simple interface for injecting dependencies on your calculators and calculating the price. Basically, it makes it possible to receive the context, an Hash of parameters containing the necessary information to calculate your price or a Prezzo::Context.
65
+
66
+ e.g.:
23
67
 
24
68
  ```ruby
25
69
  require "prezzo"
26
70
 
27
- class MyCalculator < Prezzo::Calculator
28
- def calculate
29
- context.fetch(:foo) * 2
71
+ module Uber
72
+ class PricePerDistanceCalculator
73
+ include Prezzo::Calculator
74
+
75
+ def calculate
76
+ price_per_kilometer * distance
77
+ end
78
+
79
+ def price_per_kilometer
80
+ 1.30
81
+ end
82
+
83
+ def distance
84
+ context.fetch(:distance)
85
+ end
30
86
  end
31
87
  end
32
88
 
33
- MyCalculator.new(foo: 10).calculate
89
+ context = Uber::Context.new(distance: 10.0)
90
+ Uber::PricePerDistanceCalculator.new(context).calculate
34
91
  #=> 20.0
35
92
  ```
36
93
 
37
- Check the [Uber pricing](/spec/integration/uber_pricing_spec.rb) for more complete example with many calculators and factors.
94
+ **Context Validation**
95
+
96
+ If you initialize the context with a hash, it will skip the validation, however, any object that responds to `.valid?` will attempt a validation, and it will fail if valid? returns false.
97
+
98
+ ### Prezzo::Composed
99
+
100
+ The `Prezzo::Composed` module is an abstraction that provides a nice way of injecting other calculators define how the price will be composed with all of those calculators.
101
+
102
+ e.g.:
103
+
104
+ ```ruby
105
+ require "prezzo"
106
+
107
+ module Uber
108
+ class RidePriceCalculator
109
+ include Prezzo::Calculator
110
+ include Prezzo::Composed
111
+
112
+ composed_by base_fare: BaseFareCalculator,
113
+ price_per_distance: PricePerDistanceCalculator,
114
+
115
+ def calculate
116
+ base_fare + price_per_distance
117
+ end
118
+ end
119
+ end
120
+
121
+ context = Uber::Context.new(distance: 10.0)
122
+ Uber::RidePriceCalculator.new(context).calculate
123
+ #=> 47.3
124
+ ```
125
+
126
+ ### Prezzo::Explainable
127
+
128
+ The `Prezzo::Explainable` module is an abstraction that provides a nice way of representing how the price was composed.
129
+
130
+ e.g.:
131
+
132
+ ```ruby
133
+ require "prezzo"
134
+
135
+ module Uber
136
+ class RidePriceCalculator
137
+ include Prezzo::Calculator
138
+ include Prezzo::Composed
139
+ include Prezzo::Explainable
140
+
141
+ composed_by base_fare: BaseFareCalculator,
142
+ price_per_distance: PricePerDistanceCalculator,
143
+ explain_with :base_fare, :price_per_distance
144
+
145
+ def calculate
146
+ base_fare + price_per_distance
147
+ end
148
+ end
149
+ end
150
+
151
+ context = Uber::Context.new(distance: 10.0)
152
+ Uber::RidePriceCalculator.new(context).explain
153
+ #=> { base_fare: 4.3, price_per_distance: 21.3 }
154
+ ```
155
+
156
+ Check the full [Uber pricing](/spec/integration/uber_pricing_spec.rb) for more complete example with many calculators and factors.
38
157
 
39
158
  ## Development
40
159
 
41
- 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.
160
+ After checking out the repo, run `make` to install dependencies. Then, run `make spec` to run the tests. You can also run `make console` for an interactive prompt that will allow you to experiment.
42
161
 
43
- 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).
162
+ To install this gem onto your local machine, run `make install`. To release a new version, update the version number in `version.rb`, and then run `make 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).
44
163
 
45
164
  ## Contributing
46
165
 
47
- Bug reports and pull requests are welcome on GitHub at https://github.com/marceloboeira/prezzo. 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.
166
+ Please consider reading out [Contributing Guide](CONTRIBUTING.md).
167
+
168
+ 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.
@@ -1,15 +1,22 @@
1
1
  module Prezzo
2
- class Calculator
2
+ module Calculator
3
3
  def initialize(context = {})
4
- @context = context
4
+ @context = validated!(context)
5
5
  end
6
6
 
7
7
  def calculate
8
- 0
8
+ raise "Calculate not implemented"
9
9
  end
10
10
 
11
11
  private
12
12
 
13
+ def validated!(context)
14
+ raise "Empty Context" if context.nil?
15
+ raise "Invalid Context" if context.respond_to?(:valid?) && !context.valid?
16
+
17
+ context
18
+ end
19
+
13
20
  def context
14
21
  @context
15
22
  end
@@ -0,0 +1,23 @@
1
+ module Prezzo
2
+ module Composed
3
+ def self.included(base)
4
+ base.class_eval do
5
+ base.extend(ClassMethods)
6
+ end
7
+ end
8
+
9
+ module ClassMethods
10
+ def composed_by(options)
11
+ @@__calculators = {}
12
+
13
+ options.each do |name, klass|
14
+ @@__calculators[name] = klass
15
+
16
+ define_method(name) do
17
+ @@__calculators[name].new(context).calculate
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ require "hanami-validations"
2
+
3
+ module Prezzo
4
+ module Context
5
+ def self.included(base)
6
+ base.class_eval do
7
+ base.include(Hanami::Validations)
8
+ end
9
+ end
10
+
11
+ def valid?
12
+ validation.success?
13
+ end
14
+
15
+ def errors
16
+ validation.errors
17
+ end
18
+
19
+ def fetch(*args)
20
+ attributes.fetch(*args)
21
+ end
22
+
23
+ def attributes
24
+ validation.output
25
+ end
26
+
27
+ private
28
+
29
+ def validation
30
+ @_validation ||= validate
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ module Prezzo
2
+ module Explainable
3
+ def self.included(base)
4
+ base.class_eval do
5
+ base.extend(ClassMethods)
6
+ end
7
+ end
8
+
9
+ module ClassMethods
10
+ def explain_with(*options)
11
+ @@_methods = options
12
+
13
+ define_method(:explain) do
14
+ explanation = {}
15
+
16
+ @@_methods.each do |method|
17
+ explanation[method] = send(method)
18
+ end
19
+
20
+ explanation
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Prezzo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0".freeze
3
3
  end
data/lib/prezzo.rb CHANGED
@@ -2,4 +2,7 @@ require "prezzo/version"
2
2
 
3
3
  module Prezzo
4
4
  autoload :Calculator, "prezzo/calculator"
5
+ autoload :Composed, "prezzo/composed"
6
+ autoload :Context, "prezzo/context"
7
+ autoload :Explainable, "prezzo/explainable"
5
8
  end
data/prezzo.gemspec CHANGED
@@ -1,25 +1,28 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'prezzo/version'
4
+ require "prezzo/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "prezzo"
8
8
  spec.version = Prezzo::VERSION
9
9
  spec.authors = ["Marcelo Boeira"]
10
10
  spec.email = ["me@marceloboeira.com"]
11
- spec.summary = %q{Toolbox to create complex pricing models}
12
- spec.description = %q{Toolbox to create complex pricing models}
11
+ spec.summary = "Toolbox to create complex pricing models"
12
+ spec.description = "Toolbox to create complex pricing models"
13
13
  spec.homepage = "http://github.com/marceloboeira/prezzo"
14
14
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
15
  f.match(%r{^(test|spec|features)/})
16
16
  end
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.add_dependency "hanami-validations", "1.0.0.beta1"
19
20
  spec.add_development_dependency "bundler", "~> 1.13"
20
21
  spec.add_development_dependency "rake", "~> 10.0"
21
22
  spec.add_development_dependency "rspec", "~> 3.0"
22
23
  spec.add_development_dependency "rspec-nc"
23
24
  spec.add_development_dependency "guard", "~> 2.14"
24
25
  spec.add_development_dependency "guard-rspec", "~> 4.7"
26
+ spec.add_development_dependency "simplecov"
27
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
25
28
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prezzo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Boeira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-29 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hanami-validations
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0.beta1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0.beta1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,34 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '4.7'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: codeclimate-test-reporter
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.0.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.0.0
97
139
  description: Toolbox to create complex pricing models
98
140
  email:
99
141
  - me@marceloboeira.com
@@ -103,17 +145,23 @@ extra_rdoc_files: []
103
145
  files:
104
146
  - ".gitignore"
105
147
  - ".rspec"
148
+ - ".rubocop.yml"
106
149
  - ".travis.yml"
107
150
  - CODE_OF_CONDUCT.md
151
+ - CONTRIBUTING.md
108
152
  - Gemfile
109
153
  - Guardfile
110
154
  - LICENSE.md
155
+ - Makefile
111
156
  - README.md
112
157
  - Rakefile
113
158
  - bin/console
114
159
  - bin/setup
115
160
  - lib/prezzo.rb
116
161
  - lib/prezzo/calculator.rb
162
+ - lib/prezzo/composed.rb
163
+ - lib/prezzo/context.rb
164
+ - lib/prezzo/explainable.rb
117
165
  - lib/prezzo/version.rb
118
166
  - prezzo.gemspec
119
167
  homepage: http://github.com/marceloboeira/prezzo