nerd_dice 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/main.yml +67 -0
  4. data/.rubocop.yml +114 -0
  5. data/CHANGELOG.md +76 -2
  6. data/Gemfile +2 -2
  7. data/Gemfile.lock +54 -32
  8. data/README.md +372 -5
  9. data/bin/generate_checksums +13 -0
  10. data/bin/nerd_dice_benchmark +322 -0
  11. data/certs/msducheminjr.pem +26 -0
  12. data/checksum/nerd_dice-0.1.0.gem.sha256 +1 -0
  13. data/checksum/nerd_dice-0.1.0.gem.sha512 +1 -0
  14. data/checksum/nerd_dice-0.1.1.gem.sha256 +1 -0
  15. data/checksum/nerd_dice-0.1.1.gem.sha512 +1 -0
  16. data/checksum/nerd_dice-0.2.0.gem.sha256 +1 -0
  17. data/checksum/nerd_dice-0.2.0.gem.sha512 +1 -0
  18. data/checksum/nerd_dice-0.3.0.gem.sha256 +1 -0
  19. data/checksum/nerd_dice-0.3.0.gem.sha512 +1 -0
  20. data/lib/nerd_dice/class_methods/configure.rb +50 -0
  21. data/lib/nerd_dice/class_methods/execute_die_roll.rb +47 -0
  22. data/lib/nerd_dice/class_methods/harvest_totals.rb +40 -0
  23. data/lib/nerd_dice/class_methods/refresh_seed.rb +83 -0
  24. data/lib/nerd_dice/class_methods/roll_ability_scores.rb +73 -0
  25. data/lib/nerd_dice/class_methods/roll_dice.rb +45 -0
  26. data/lib/nerd_dice/class_methods/total_ability_scores.rb +52 -0
  27. data/lib/nerd_dice/class_methods/total_dice.rb +44 -0
  28. data/lib/nerd_dice/class_methods.rb +30 -0
  29. data/lib/nerd_dice/configuration.rb +91 -0
  30. data/lib/nerd_dice/convenience_methods.rb +279 -0
  31. data/lib/nerd_dice/dice_set.rb +166 -0
  32. data/lib/nerd_dice/die.rb +51 -0
  33. data/lib/nerd_dice/sets_randomization_technique.rb +19 -0
  34. data/lib/nerd_dice/version.rb +1 -1
  35. data/lib/nerd_dice.rb +15 -33
  36. data/nerd_dice.gemspec +12 -7
  37. data.tar.gz.sig +0 -0
  38. metadata +97 -21
  39. metadata.gz.sig +0 -0
  40. data/.travis.yml +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9829d6b43a9548f57a3c8ed8d9bb37955b7d78c3a96216b337184fc56271c6e7
4
- data.tar.gz: 42143651b8e4feb48321f088de10adae1e2b16fcf5c945421017d81d8824e353
3
+ metadata.gz: 8f64389429514a7d0c2a8410b2e27575e5c11b316b50cee41b37c58d8f8af953
4
+ data.tar.gz: 4d2365e3ce8139d4675695dfe47edf9ef5d52b9cc873beb5c7c314b8955aaa33
5
5
  SHA512:
6
- metadata.gz: 87fd79c32d6b160705ab428273553e4d805bdfdd537f5b9695425701f1db281e6cd557c3266fc49148b1567126c1ef741178d42be0a64e08750db773cc25edd8
7
- data.tar.gz: 891670ff69791edb4c72008e112c4a11eb681bad56b1d914571466c94630ad4c1b3cafeb17811f1d75c81c7969e221e3b6b9ff5d2baf52521617008b7c9d8059
6
+ metadata.gz: d8bf0ea2c85e3aedf952d82d0f511463accedcad5122b14a7d6769a94100902887ca0e52cf85a6d8b69a75a6cd750858852ad71e34980e61624d39666bedff5b
7
+ data.tar.gz: ee2e8117b3071872a3d07353dabd4685c4a20e188591e80cbcb93609ba9f134ab22082ae01bee152c34c9cdd1a81a6a40aec2b1521d3e2a106d10f0c8fa313ae
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,67 @@
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: Nerd Dice CI
4
+
5
+ # Controls when the action will run.
6
+ on: [push, pull_request]
7
+
8
+ # Allows you to run this workflow manually from the Actions tab
9
+ # workflow_dispatch:
10
+
11
+ jobs:
12
+ test_rspec:
13
+
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ ruby-version: ['2.7', '3.0']
18
+
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby-version }}
25
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
26
+ - name: Run tests
27
+ run: bundle exec rake
28
+ - name: Coveralls Parallel
29
+ uses: coverallsapp/github-action@master
30
+ with:
31
+ github-token: ${{ secrets.github_token }}
32
+ flag-name: run-${{ matrix.test_number }}
33
+ parallel: true
34
+
35
+ rubocop:
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: actions/checkout@v2
39
+ - name: Set up Ruby
40
+ uses: ruby/setup-ruby@v1
41
+ with:
42
+ ruby-version: '3.0'
43
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
44
+ - name: Run rubocop
45
+ run: bundle exec rubocop --parallel
46
+
47
+ benchmark:
48
+ runs-on: ubuntu-latest
49
+ steps:
50
+ - uses: actions/checkout@v2
51
+ - name: Set up Ruby
52
+ uses: ruby/setup-ruby@v1
53
+ with:
54
+ ruby-version: '3.0'
55
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
56
+ - name: Run benchmark script
57
+ run: bin/nerd_dice_benchmark
58
+
59
+ finish:
60
+ needs: test_rspec
61
+ runs-on: ubuntu-latest
62
+ steps:
63
+ - name: Coveralls Finished
64
+ uses: coverallsapp/github-action@master
65
+ with:
66
+ github-token: ${{ secrets.github_token }}
67
+ parallel-finished: true
data/.rubocop.yml CHANGED
@@ -161,6 +161,14 @@ Layout/TrailingWhitespace:
161
161
  Style/RedundantPercentQ:
162
162
  Enabled: true
163
163
 
164
+ # exclude spec from block length
165
+ Metrics/BlockLength:
166
+ Exclude:
167
+ - 'Rakefile'
168
+ - '**/*.rake'
169
+ - 'spec/**/*.rb'
170
+ - 'nerd_dice.gemspec'
171
+
164
172
  Lint/ErbNewArguments:
165
173
  Enabled: true
166
174
 
@@ -305,3 +313,109 @@ Performance/StringInclude: # (new in 1.7)
305
313
 
306
314
  Performance/Sum: # (new in 1.8)
307
315
  Enabled: true
316
+
317
+ Layout/SpaceBeforeBrackets: # (new in 1.7)
318
+ Enabled: true
319
+
320
+ Lint/AmbiguousAssignment: # (new in 1.7)
321
+ Enabled: true
322
+
323
+ Lint/DeprecatedConstants: # (new in 1.8)
324
+ Enabled: true
325
+
326
+ Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
327
+ Enabled: true
328
+
329
+ Lint/RedundantDirGlobSort: # (new in 1.8)
330
+ Enabled: true
331
+
332
+ Style/EndlessMethod: # (new in 1.8)
333
+ Enabled: true
334
+
335
+ Style/HashExcept: # (new in 1.7)
336
+ Enabled: true
337
+
338
+ # Added 2021-08-14
339
+ Gemspec/DateAssignment: # (new in 1.10)
340
+ Enabled: true
341
+
342
+ Layout/LineEndStringConcatenationIndentation: # (new in 1.18)
343
+ Enabled: true
344
+
345
+ Lint/EmptyInPattern: # (new in 1.16)
346
+ Enabled: true
347
+
348
+ Lint/NumberedParameterAssignment: # (new in 1.9)
349
+ Enabled: true
350
+
351
+ Lint/OrAssignmentToConstant: # (new in 1.9)
352
+ Enabled: true
353
+
354
+ Lint/SymbolConversion: # (new in 1.9)
355
+ Enabled: true
356
+
357
+ Lint/TripleQuotes: # (new in 1.9)
358
+ Enabled: true
359
+
360
+ Naming/InclusiveLanguage: # (new in 1.18)
361
+ Enabled: false
362
+
363
+ Style/HashConversion: # (new in 1.10)
364
+ Enabled: true
365
+
366
+ Style/IfWithBooleanLiteralBranches: # (new in 1.9)
367
+ Enabled: true
368
+
369
+ Style/InPatternThen: # (new in 1.16)
370
+ Enabled: true
371
+
372
+ Style/MultilineInPatternThen: # (new in 1.16)
373
+ Enabled: true
374
+
375
+ Style/QuotedSymbols: # (new in 1.16)
376
+ Enabled: true
377
+
378
+ Style/StringChars: # (new in 1.12)
379
+ Enabled: true
380
+
381
+ Performance/MapCompact: # (new in 1.11)
382
+ Enabled: true
383
+
384
+ Performance/RedundantEqualityComparisonBlock: # (new in 1.10)
385
+ Enabled: true
386
+
387
+ Performance/RedundantSplitRegexpArgument: # (new in 1.10)
388
+ Enabled: true
389
+
390
+ RSpec/IdenticalEqualityAssertion: # (new in 2.4)
391
+ Enabled: true
392
+
393
+ RSpec/Rails/AvoidSetupHook: # (new in 2.4)
394
+ Enabled: true
395
+
396
+ RSpec/MessageSpies:
397
+ EnforcedStyle: receive
398
+
399
+ Lint/AmbiguousRange: # new in 1.19
400
+ Enabled: true
401
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
402
+ Enabled: true
403
+
404
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
405
+ Enabled: true
406
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
407
+ Enabled: true
408
+ Lint/RequireRelativeSelfPath: # new in 1.22
409
+ Enabled: true
410
+ Security/IoMethods: # new in 1.22
411
+ Enabled: true
412
+ Style/NumberedParameters: # new in 1.22
413
+ Enabled: true
414
+ Style/NumberedParametersLimit: # new in 1.22
415
+ Enabled: true
416
+ Style/SelectByRegexp: # new in 1.22
417
+ Enabled: true
418
+ RSpec/ExcessiveDocstringSpacing: # new in 2.5
419
+ Enabled: true
420
+ RSpec/SubjectDeclaration: # new in 2.5
421
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,8 +1,82 @@
1
1
  # Nerd Dice Changelog
2
2
 
3
3
  ## master \(unreleased\)
4
+ ### Added
5
+ ### Changed
6
+ ### Fixed
4
7
 
5
- ## 0.1.0 \(2020-12-06\)
8
+ ## 0.4.0 \(2021-10-23\)
9
+ ### Added
10
+ * Add `NerdDice::ConvenienceMethods` method_missing mixin module that allows for dynamic invocation of patterns in the method name that get converted into calls to `NerdDice.roll_dice` or `NerdDice.total_dice` along with allowing the advantage/disadvantage mechanic or bonuses to be parsed from the method name. Full documentation of the module can be found in the [Convenience Methods Mixin](README.md#convenience-methods-mixin) section of the README.
11
+ * Add exensive specs to support the ConvenienceMethods module
12
+ ### Changed
13
+ * Replace `Benchmark.bmbm` with `Benchmark.bm` in the nerd_dice_benchmark
14
+ * Add convenience_methods to nerd_dice_benchmark
15
+ * Extend `NerdDice::ConvenienceMethods` into top-level module as class methods
16
+ ### Fixed
17
+ * Fix typos and horizontal scrolling in README
18
+ * Fix CodeClimate Code Smell on harvest_totals
6
19
 
7
- ### New Features
20
+ ## 0.3.0 \(2021-09-11\)
21
+ ### Added
22
+ * Add new options to `NerdDice::Configuration`
23
+ - `ability_score_number_of_sides`
24
+ - `ability_score_dice_rolled`
25
+ - `ability_score_dice_kept`
26
+ * Add `NerdDice.harvest_totals` method that takes in a collection and returns the results of calling `total` on each element
27
+ * Add `NerdDice.roll_ability_scores` convenience method that returns an array of `DiceSet` objects based on options and/or configuration
28
+ * Add `NerdDice.total_ability_scores` convenience method that returns an array of integers based on options and/or configuration
29
+ * Add `NerdDice::Die` class that represents a single die object and mixes in the `Comparable` module
30
+ * Add `NerdDice::DiceSet` class that represents a collection of `Die` objects and mixes in the `Enumerable` module
31
+ * Add `NerdDice::SetsRandomizationTechnique` mixin module and include in the `DiceSet` and `Die` classes
32
+ * Add `die_background_color` and `die_foreground_color` to `Configuration` class with defaults defined as constants
33
+ * Add `NerdDice.roll_dice` method that behaves in a similar fashion to `total_dice` but returns a `DiceSet` object instead of an `Integer` and has additional optional arguments relating to the non-numeric attributes of the dice
34
+ * Add `coveralls_reborn` to RSpec and GitHub actions
35
+ * Add build badge to README
36
+ * Add Code Climate maintainability integration and badge to README
37
+ * Add `nerd_dice_benchmark` script to bin directory
38
+ * Add GitHub Action CI build
39
+ - Run RSpec test suite, fail if specs fail, report coverage via Coveralls
40
+ - Run RuboCop and fail if violations
41
+ - Run benchmark suite and fail if outside of allowed ratios
42
+ ### Changed
43
+ * Update RuboCop version and configuration
44
+ * Break up the NerdDice source code file into several smaller files that are included by the module
45
+ * Enforce that `NerdDice.configuration.ability_score_array_size` must be a positive duck-type integer
46
+ ### Fixed
47
+
48
+ ## 0.2.0 \(2021-01-28\)
49
+ ### Added
50
+ * Add ability to configure with `NerdDice.configure` block or `NerdDice.configuration`
51
+ - Configure `randomization_technique` as `:random_rand`, `:securerandom`, `:random_object`, or `randomized`
52
+ - Configure `refresh_seed_interval` to allow a periodic refresh of the seed
53
+ * Add `randomization_technique` option to `NerdDice.total_dice` method keyword arguments
54
+ * Add a lower-level `execute_die_roll` method that allows you to roll a single die with a generator specified
55
+ * Add ability to manually refresh or specify seed with `:refresh_seed!` method
56
+ ### Changed
57
+ * Change `opts = {}` final argument to use keyword args `**opts` in the `NerdDice.total_dice` method. Now the method can be called as follows:
58
+ ```ruby
59
+ # old
60
+ NerdDice.total_dice(20, 1, {bonus: 5})
61
+ NerdDice.total_dice(6, 3, {bonus: 1})
62
+
63
+ # new
64
+ NerdDice.total_dice(20, bonus: 5)
65
+ NerdDice.total_dice(6, 3, bonus: 1)
66
+ ```
67
+ * Call `:to_i` on bonus instead of using `:is_a?` and raise ArgumentError in the `NerdDice.total_dice` method if it doesn't respond to `:to_i`
68
+ * Added `securerandom` as an explicit dependency due to Ruby 3.x change to bundled gem
69
+ * `total_dice` no longer calls unqualified `.rand` which improves performance on all generators except for `:securerandom`
70
+ ### Fixed
71
+
72
+ ## 0.1.1 \(2020-12-12\)
73
+ ### Added
74
+ ### Changed
75
+ ### Fixed
76
+ * Fix broken link to CHANGELOG in gemspec
77
+ * Fix rubocop offenses from 0.1.0 and refactor specs
78
+
79
+ ## 0.1.0 \(2020-12-07\)
80
+
81
+ ### Added
8
82
  * Add NerdDice.total_dice class method with the ability to roll multiple polyhedral dice and add a bonus
data/Gemfile CHANGED
@@ -5,5 +5,5 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in nerd_dice.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 12.0"
9
- gem "rspec", "~> 3.0"
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec", "~> 3.10"
data/Gemfile.lock CHANGED
@@ -1,66 +1,88 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nerd_dice (0.1.0)
4
+ nerd_dice (0.4.0)
5
+ securerandom (~> 0.1, >= 0.1.1)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
- ast (2.4.1)
10
+ ast (2.4.2)
11
+ coveralls_reborn (0.23.0)
12
+ simplecov (>= 0.18.1, < 0.22.0)
13
+ term-ansicolor (~> 1.6)
14
+ thor (>= 0.20.3, < 2.0)
15
+ tins (~> 1.16)
10
16
  diff-lcs (1.4.4)
11
- parallel (1.20.1)
12
- parser (2.7.2.0)
17
+ docile (1.4.0)
18
+ parallel (1.21.0)
19
+ parser (3.0.2.0)
13
20
  ast (~> 2.4.1)
14
21
  rainbow (3.0.0)
15
- rake (12.3.3)
16
- regexp_parser (1.8.2)
17
- rexml (3.2.3)
22
+ rake (13.0.6)
23
+ regexp_parser (2.1.1)
24
+ rexml (3.2.5)
18
25
  rspec (3.10.0)
19
26
  rspec-core (~> 3.10.0)
20
27
  rspec-expectations (~> 3.10.0)
21
28
  rspec-mocks (~> 3.10.0)
22
- rspec-core (3.10.0)
29
+ rspec-core (3.10.1)
23
30
  rspec-support (~> 3.10.0)
24
- rspec-expectations (3.10.0)
31
+ rspec-expectations (3.10.1)
25
32
  diff-lcs (>= 1.2.0, < 2.0)
26
33
  rspec-support (~> 3.10.0)
27
- rspec-mocks (3.10.0)
34
+ rspec-mocks (3.10.2)
28
35
  diff-lcs (>= 1.2.0, < 2.0)
29
36
  rspec-support (~> 3.10.0)
30
- rspec-support (3.10.0)
31
- rubocop (1.5.2)
37
+ rspec-support (3.10.2)
38
+ rubocop (1.22.2)
32
39
  parallel (~> 1.10)
33
- parser (>= 2.7.1.5)
40
+ parser (>= 3.0.0.0)
34
41
  rainbow (>= 2.2.2, < 4.0)
35
42
  regexp_parser (>= 1.8, < 3.0)
36
43
  rexml
37
- rubocop-ast (>= 1.2.0, < 2.0)
44
+ rubocop-ast (>= 1.12.0, < 2.0)
38
45
  ruby-progressbar (~> 1.7)
39
- unicode-display_width (>= 1.4.0, < 2.0)
40
- rubocop-ast (1.3.0)
41
- parser (>= 2.7.1.5)
42
- rubocop-performance (1.9.1)
43
- rubocop (>= 0.90.0, < 2.0)
46
+ unicode-display_width (>= 1.4.0, < 3.0)
47
+ rubocop-ast (1.12.0)
48
+ parser (>= 3.0.1.1)
49
+ rubocop-performance (1.11.5)
50
+ rubocop (>= 1.7.0, < 2.0)
44
51
  rubocop-ast (>= 0.4.0)
45
- rubocop-rake (0.5.1)
46
- rubocop
47
- rubocop-rspec (2.0.1)
52
+ rubocop-rake (0.6.0)
48
53
  rubocop (~> 1.0)
49
- rubocop-ast (>= 1.1.0)
50
- ruby-progressbar (1.10.1)
51
- unicode-display_width (1.7.0)
54
+ rubocop-rspec (2.5.0)
55
+ rubocop (~> 1.19)
56
+ ruby-progressbar (1.11.0)
57
+ securerandom (0.1.1)
58
+ simplecov (0.21.2)
59
+ docile (~> 1.1)
60
+ simplecov-html (~> 0.11)
61
+ simplecov_json_formatter (~> 0.1)
62
+ simplecov-html (0.12.3)
63
+ simplecov-lcov (0.8.0)
64
+ simplecov_json_formatter (0.1.3)
65
+ sync (0.5.0)
66
+ term-ansicolor (1.7.1)
67
+ tins (~> 1.0)
68
+ thor (1.1.0)
69
+ tins (1.29.1)
70
+ sync
71
+ unicode-display_width (2.1.0)
52
72
 
53
73
  PLATFORMS
54
74
  ruby
55
75
 
56
76
  DEPENDENCIES
77
+ coveralls_reborn (~> 0.23.0)
57
78
  nerd_dice!
58
- rake (~> 12.0)
59
- rspec (~> 3.0)
60
- rubocop (~> 1.5, >= 1.5.2)
61
- rubocop-performance (~> 1.9, >= 1.9.1)
62
- rubocop-rake (~> 0.5, >= 0.5.1)
63
- rubocop-rspec (~> 2.0, >= 2.0.1)
79
+ rake (~> 13.0)
80
+ rspec (~> 3.10)
81
+ rubocop (~> 1.22, >= 1.22.2)
82
+ rubocop-performance (~> 1.11, >= 1.11.5)
83
+ rubocop-rake (~> 0.6, >= 0.6.0)
84
+ rubocop-rspec (~> 2.5, >= 2.5.0)
85
+ simplecov-lcov (~> 0.8.0)
64
86
 
65
87
  BUNDLED WITH
66
- 2.1.4
88
+ 2.2.22