nerd_dice 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9829d6b43a9548f57a3c8ed8d9bb37955b7d78c3a96216b337184fc56271c6e7
4
+ data.tar.gz: 42143651b8e4feb48321f088de10adae1e2b16fcf5c945421017d81d8824e353
5
+ SHA512:
6
+ metadata.gz: 87fd79c32d6b160705ab428273553e4d805bdfdd537f5b9695425701f1db281e6cd557c3266fc49148b1567126c1ef741178d42be0a64e08750db773cc25edd8
7
+ data.tar.gz: 891670ff69791edb4c72008e112c4a11eb681bad56b1d914571466c94630ad4c1b3cafeb17811f1d75c81c7969e221e3b6b9ff5d2baf52521617008b7c9d8059
Binary file
Binary file
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,307 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.7
8
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
9
+ # to ignore them, so only the ones explicitly set in this file are enabled.
10
+ #DisabledByDefault: true
11
+ Exclude:
12
+ - '**/templates/**/*'
13
+ - '**/vendor/**/*'
14
+ - 'node_modules/**/*'
15
+
16
+ Performance:
17
+ Exclude:
18
+ - '**/test/**/*'
19
+
20
+ # Prefer &&/|| over and/or.
21
+ Style/AndOr:
22
+ Enabled: true
23
+
24
+ # Align `when` with `case`.
25
+ Layout/CaseIndentation:
26
+ Enabled: true
27
+
28
+ # Align comments with method definitions.
29
+ Layout/CommentIndentation:
30
+ Enabled: true
31
+
32
+ Layout/ElseAlignment:
33
+ Enabled: true
34
+
35
+ # Align `end` with the matching keyword or starting expression except for
36
+ # assignments, where it should be aligned with the LHS.
37
+ Layout/EndAlignment:
38
+ Enabled: true
39
+ EnforcedStyleAlignWith: variable
40
+ AutoCorrect: true
41
+
42
+ Layout/EmptyLineAfterMagicComment:
43
+ Enabled: true
44
+
45
+ Layout/EmptyLinesAroundBlockBody:
46
+ Enabled: true
47
+
48
+ # In a regular class definition, no empty lines around the body.
49
+ Layout/EmptyLinesAroundClassBody:
50
+ Enabled: true
51
+
52
+ # In a regular method definition, no empty lines around the body.
53
+ Layout/EmptyLinesAroundMethodBody:
54
+ Enabled: true
55
+
56
+ # In a regular module definition, no empty lines around the body.
57
+ Layout/EmptyLinesAroundModuleBody:
58
+ Enabled: true
59
+
60
+ Layout/FirstArgumentIndentation:
61
+ Enabled: true
62
+
63
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
64
+ Style/HashSyntax:
65
+ Enabled: true
66
+
67
+ # Method definitions after `private` or `protected` isolated calls need one
68
+ # extra level of indentation.
69
+ Layout/IndentationConsistency:
70
+ Enabled: true
71
+ EnforcedStyle: indented_internal_methods
72
+
73
+ # Two spaces, no tabs (for indentation).
74
+ Layout/IndentationWidth:
75
+ Enabled: true
76
+
77
+ Layout/LeadingCommentSpace:
78
+ Enabled: true
79
+
80
+ Layout/SpaceAfterColon:
81
+ Enabled: true
82
+
83
+ Layout/SpaceAfterComma:
84
+ Enabled: true
85
+
86
+ Layout/SpaceAfterSemicolon:
87
+ Enabled: true
88
+
89
+ Layout/SpaceAroundEqualsInParameterDefault:
90
+ Enabled: true
91
+
92
+ Layout/SpaceAroundKeyword:
93
+ Enabled: true
94
+
95
+ Layout/SpaceAroundOperators:
96
+ Enabled: true
97
+
98
+ Layout/SpaceBeforeComma:
99
+ Enabled: true
100
+
101
+ Layout/SpaceBeforeFirstArg:
102
+ Enabled: true
103
+
104
+ Style/DefWithParentheses:
105
+ Enabled: true
106
+
107
+ # Defining a method with parameters needs parentheses.
108
+ Style/MethodDefParentheses:
109
+ Enabled: true
110
+
111
+ Style/FrozenStringLiteralComment:
112
+ Enabled: true
113
+ EnforcedStyle: always
114
+ Exclude:
115
+ - 'actionview/test/**/*.builder'
116
+ - 'actionview/test/**/*.ruby'
117
+ - 'actionpack/test/**/*.builder'
118
+ - 'actionpack/test/**/*.ruby'
119
+ - 'activestorage/db/migrate/**/*.rb'
120
+ - 'activestorage/db/update_migrate/**/*.rb'
121
+ - 'actionmailbox/db/migrate/**/*.rb'
122
+ - 'actiontext/db/migrate/**/*.rb'
123
+
124
+ Style/RedundantFreeze:
125
+ Enabled: true
126
+
127
+ # Use `foo {}` not `foo{}`.
128
+ Layout/SpaceBeforeBlockBraces:
129
+ Enabled: true
130
+
131
+ # Use `foo { bar }` not `foo {bar}`.
132
+ Layout/SpaceInsideBlockBraces:
133
+ Enabled: true
134
+ EnforcedStyleForEmptyBraces: space
135
+
136
+ # Use `{ a: 1 }` not `{a:1}`.
137
+ Layout/SpaceInsideHashLiteralBraces:
138
+ Enabled: true
139
+
140
+ Layout/SpaceInsideParens:
141
+ Enabled: true
142
+
143
+ # Check quotes usage according to lint rule below.
144
+ Style/StringLiterals:
145
+ Enabled: true
146
+ EnforcedStyle: double_quotes
147
+
148
+ # Detect hard tabs, no hard tabs.
149
+ Layout/IndentationStyle:
150
+ Enabled: true
151
+
152
+ # Blank lines should not have any spaces.
153
+ Layout/TrailingEmptyLines:
154
+ Enabled: true
155
+
156
+ # No trailing whitespace.
157
+ Layout/TrailingWhitespace:
158
+ Enabled: true
159
+
160
+ # Use quotes for string literals when they are enough.
161
+ Style/RedundantPercentQ:
162
+ Enabled: true
163
+
164
+ Lint/ErbNewArguments:
165
+ Enabled: true
166
+
167
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
168
+ Lint/RequireParentheses:
169
+ Enabled: true
170
+
171
+ Lint/ShadowingOuterLocalVariable:
172
+ Enabled: true
173
+
174
+ Lint/RedundantStringCoercion:
175
+ Enabled: true
176
+
177
+ Lint/UriEscapeUnescape:
178
+ Enabled: true
179
+
180
+ Lint/UselessAssignment:
181
+ Enabled: true
182
+
183
+ Lint/DeprecatedClassMethods:
184
+ Enabled: true
185
+
186
+ Lint/DuplicateBranch: # (new in 1.3)
187
+ Enabled: true
188
+
189
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
190
+ Enabled: true
191
+
192
+ Lint/EmptyBlock: # (new in 1.1)
193
+ Enabled: true
194
+
195
+ Lint/EmptyClass: # (new in 1.3)
196
+ Enabled: true
197
+
198
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
199
+ Enabled: true
200
+
201
+ Lint/ToEnumArguments: # (new in 1.1)
202
+ Enabled: true
203
+
204
+ Lint/UnexpectedBlockArity: # (new in 1.5)
205
+ Enabled: true
206
+
207
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
208
+ Enabled: true
209
+
210
+ Style/ParenthesesAroundCondition:
211
+ Enabled: true
212
+
213
+ Style/RedundantBegin:
214
+ Enabled: true
215
+
216
+ Style/RedundantReturn:
217
+ Enabled: true
218
+ AllowMultipleReturnValues: true
219
+
220
+ Style/Semicolon:
221
+ Enabled: true
222
+ AllowAsExpressionSeparator: true
223
+
224
+ # Prefer Foo.method over Foo::method
225
+ Style/ColonMethodCall:
226
+ Enabled: true
227
+
228
+ Style/TrivialAccessors:
229
+ Enabled: true
230
+
231
+ Style/ArgumentsForwarding: # (new in 1.1)
232
+ Enabled: true
233
+
234
+ Style/CollectionCompact: # (new in 1.2)
235
+ Enabled: true
236
+
237
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
238
+ Enabled: true
239
+
240
+ Style/NegatedIfElseCondition: # (new in 1.2)
241
+ Enabled: true
242
+
243
+ Style/NilLambda: # (new in 1.3)
244
+ Enabled: true
245
+
246
+ Style/RedundantArgument: # (new in 1.4)
247
+ Enabled: true
248
+
249
+ Style/SwapValues: # (new in 1.1)
250
+ Enabled: true
251
+
252
+ Performance/FlatMap:
253
+ Enabled: true
254
+
255
+ Performance/RedundantMerge:
256
+ Enabled: true
257
+
258
+ Performance/StartWith:
259
+ Enabled: true
260
+
261
+ Performance/EndWith:
262
+ Enabled: true
263
+
264
+ Performance/RegexpMatch:
265
+ Enabled: true
266
+
267
+ Performance/UnfreezeString:
268
+ Enabled: true
269
+
270
+ Performance/AncestorsInclude: # (new in 1.7)
271
+ Enabled: true
272
+
273
+ Performance/BigDecimalWithNumericArgument: # (new in 1.7)
274
+ Enabled: true
275
+
276
+ Performance/BlockGivenWithExplicitBlock: # (new in 1.9)
277
+ Enabled: true
278
+
279
+ Performance/CollectionLiteralInLoop: # (new in 1.8)
280
+ Enabled: true
281
+
282
+ Performance/ConstantRegexp: # (new in 1.9)
283
+ Enabled: true
284
+
285
+ Performance/MethodObjectAsBlock: # (new in 1.9)
286
+ Enabled: true
287
+
288
+ Performance/RedundantSortBlock: # (new in 1.7)
289
+ Enabled: true
290
+
291
+ Performance/RedundantStringChars: # (new in 1.7)
292
+ Enabled: true
293
+
294
+ Performance/ReverseFirst: # (new in 1.7)
295
+ Enabled: true
296
+
297
+ Performance/SortReverse: # (new in 1.7)
298
+ Enabled: true
299
+
300
+ Performance/Squeeze: # (new in 1.7)
301
+ Enabled: true
302
+
303
+ Performance/StringInclude: # (new in 1.7)
304
+ Enabled: true
305
+
306
+ Performance/Sum: # (new in 1.8)
307
+ Enabled: true
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,57 @@
1
+ # BURN THE CONTRIBUTOR COVENANT WITH FIRE!
2
+
3
+ ## This is not an incitement to violence and\/or property damage
4
+ This should go without saying, but we live in unhinged and delusional times\. \"Burn the Contributor Covenant with Fire\" is not in any way an incitement toward violence or property damage\. The item in question is digital\. It is merely a metaphor expressing intense disapproval of the Contributor Covenant and unwillingness to use it on my own projects\.
5
+
6
+ ## Introduction
7
+ The [Contributor Covenant](https://www.contributor-covenant.org/) is the most prevalent Code of Conduct on Github. It is the default Code of Conduct included in the generators for many open source frameworks. While to the casual reader, it may seem benign, the actual use of the Contributor Covenant by those who were instrumental in its creation and adoption has been to weaponize it and use it as a mechanism to silence those whose ideas do not conform to the radical political left, even to the point of getting project founders kicked off of their projects.
8
+
9
+ ## Statement on Diversity and Inclusion
10
+ I'm all for actual diversity and actual inclusion\. The vast majority of those who are the most vocal about \"Diversity and Inclusion\" and get the HR enforcer jobs tend to be deeply offended by actual diversity or any inclusion of those with whom they might disagree\. If you replace \"Diversity and Inclusion\" with \"Conformity and Exclusion\" you'll get a pretty good idea of what the actual goals are\.
11
+
12
+ ### People are Unique Individuals
13
+ People are unique individuals\. Each human being is truly unique in all of human history\. Each human being has a unique background, set of beliefs, and perspective on life\. These differences enrich us\.
14
+
15
+ ### Reducing people to a set of classes and attributes is demeaning
16
+ As a method of enforcing conformity to political correctness, the Contributor Covenant is all about categorizing people according to \(but not limited to\) the classic government protected classes\. This collectivist mindset is used to pressure people to conform to the expectations that progressives have for that class\. \"You're not \[insert protected class here\] enough\" is used exclusively by the political left as a method of social manipulation to bully people into thinking and acting alike based on attributes they may possess\.
17
+
18
+ ### Inclusion also means including people with whom you disagree
19
+ As somebody who holds minority views on a great many subjects, I could not function if I limited my interactions to only those who agreed with me\. There is not one human being alive that I cannot learn something from or teach something to\. If I were to write off people who disagree with me \(even on things that I care about most\) with the non-person dismissal labels that the progressives use to try to destroy people, it would impoverish me\.
20
+
21
+ ### For all the talk of \"empathy\" the enforcers have little empathy for people who have trouble complying through no fault of their own
22
+ The enforcers love to jump on people for violations related to tone and wording\. This displays little empathy for contributors who are participating in a second \(or nth\) language\. Even among native speakers, much is lost in translation from speaking in person to audio to digital\. How inclusive are you truly being if everybody who is a non-native speaker or those who have disabilities or mental illnesses that make it difficult for them to comply with arbitrary and one\-sided enforcement of a code of conduct\? If you are a non-native speaker of a language, you had better learn some politically correct platitudes because you\'re going to need them lest you get devoured and kicked off the project by the champions of Diversity and Inclusion\.
23
+
24
+ ## The Contributor Covenant was designed by Code of Conduct Trolls for Code of Conduct Trolls
25
+ As much as the original Contributor Covenant docs and [FAQ](https://www.contributor-covenant.org/faq/) claimed that they were not intending to ruin people\'s lives for conduct outside of their project, it quickly became clear that the primary creator of the CC is [Code of Conduct Troll Prime](https://github.com/opal/opal/issues/941). You look to the conduct of the writers of a document to see how it is likely to be used and enforced\. The U.S. Constitution may have looked good to some on paper, but seeing how Alexander Hamilton used the document after he convinced people to adopt it, it's pretty clear that he intended it as a malicious Trojan Horse document\. In the same way, the Prime Mover of the CC was just itching to get people who have unapproved thoughts to adopt the Contributor Covenant in order to use it to remove them from their own projects\.
26
+
27
+ ### The enforcement is intentionally asymmetrical
28
+ Like Orwell's Animal Farm, some protected attributes are more equal than others. If, for example, you actually believe the sacred text(s) of your ancient religion and they are not in line with 21st century political leftism, there is a **zero percent chance** that a progressive founder of a project will get kicked off of their project for offending a religious conservative\. If a religious conservative said something 10 years ago that is now deemed offensive, the Code of Conduct Trolls will be out for blood\.
29
+
30
+ ### The Contributor Covenant is Calvinball
31
+ The Contributor Covenant proudly proclaims on its homepage that it is a \"living document\.\" Given the history of other \"living documents\" that means that whoever gets the enforcement power on a project has the ability to arbitrarily change the interpretation of the rules and take retroactive disciplinary action on anybody who at any time in the past had behavior that is now not in compliance with the living document\. At least if you play real [Calvinball](https://calvinandhobbes.fandom.com/wiki/Calvinball), you know in advance that the rules are subject to change on a whim and there isn't a Trojan Horse generator that turns every new game into Calvinball\.
32
+
33
+ ## I'm not agreeing to set up an enforcement bureaucracy on my project
34
+ Part of adopting the Contributor Covenant is agreeing to set up an enforcement bureaucracy\. On small projects, committing to this level of overhead is impractical and unrealistic\. Most open source projects are small projects and having a default for your framework where you need an enforcement committee is overkill\. Even if there were not all of the other problems with the Contributor Covenant above, this should be enough to disqualify it as a default\.
35
+
36
+ ### The project maintainer(s) reserve the right to moderate content but are under no obligation to do so
37
+ If you act like a jerk on the project, the maintainers reserve the right to moderate your content, but are under no obligation to do so and make no warranty express or implied that action will be taken\.
38
+
39
+ ### If you enthusiastically embrace the Contributor Covenant, you are welcome to contribute
40
+ Contributing to this project doesn't mean that you endorse or agree to this document\. You can be all about the Contributor Covenant everywhere else, but _you have no power to enforce it here_\. You are free to criticize my lack of adoption and this document to your heart's content\.
41
+
42
+ ## I will not reject or revert commits based on what somebody said outside of the code itself
43
+ This is a software project\. The purpose of it is to write working software\. If you are a jerk in the way that you bring an issue to our attention, we might moderate the issue, but we're not going to reject the idea or the pull request because it came from somebody who is not behaving properly\. Contributions to the project will be judged on the merit of those contributions themselves, not the virtue of the individual submitting them\.
44
+
45
+ ## If you don't like it, you can fork it
46
+ This is an open source project\. If you don't like how the project maintainers run the show, you are free to fork it and have your own project\. There is nothing stopping you\.
47
+
48
+ ## It\'s okay to disagree
49
+ In fact, it\'s encouraged. How boring life would be if we all thought alike\! I realize that publishing this document is going to make me some enemies, but somebody needs to stand up to the bullies who are actively working to exclude anybody with the slightest deviation from the ever\-moving target of politically correct speech.
50
+
51
+ *Michael Duchemin*
52
+ December 4, 2020
53
+
54
+ Home repo: [msducheminjr/burn_the_contributor_covenant_with_fire
55
+ ](https://github.com/msducheminjr/burn_the_contributor_covenant_with_fire.git)
56
+
57
+ This document is dual-licensed under the [MIT](https://opensource.org/licenses/MIT) license and the [UNLICENSE](https://unlicense.org/) \(with strong preference toward the UNLICENSE\)\. The content is released under [CC0](https://creativecommons.org/share-your-work/public-domain/cc0/) \(no rights reserved\)
@@ -0,0 +1,8 @@
1
+ # Nerd Dice Changelog
2
+
3
+ ## master \(unreleased\)
4
+
5
+ ## 0.1.0 \(2020-12-06\)
6
+
7
+ ### New Features
8
+ * Add NerdDice.total_dice class method with the ability to roll multiple polyhedral dice and add a bonus
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in nerd_dice.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 12.0"
9
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,66 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nerd_dice (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.1)
10
+ diff-lcs (1.4.4)
11
+ parallel (1.20.1)
12
+ parser (2.7.2.0)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.0.0)
15
+ rake (12.3.3)
16
+ regexp_parser (1.8.2)
17
+ rexml (3.2.3)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.0)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.0)
31
+ rubocop (1.5.2)
32
+ parallel (~> 1.10)
33
+ parser (>= 2.7.1.5)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ regexp_parser (>= 1.8, < 3.0)
36
+ rexml
37
+ rubocop-ast (>= 1.2.0, < 2.0)
38
+ 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)
44
+ rubocop-ast (>= 0.4.0)
45
+ rubocop-rake (0.5.1)
46
+ rubocop
47
+ rubocop-rspec (2.0.1)
48
+ rubocop (~> 1.0)
49
+ rubocop-ast (>= 1.1.0)
50
+ ruby-progressbar (1.10.1)
51
+ unicode-display_width (1.7.0)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ 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)
64
+
65
+ BUNDLED WITH
66
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Michael Duchemin
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.
@@ -0,0 +1,47 @@
1
+ # NerdDice
2
+ Nerd dice allows you to roll polyhedral dice and add bonuses as you would in a tabletop roleplaying game. You can choose to roll multiple dice and keep a specified number of dice such as rolling 4d6 and dropping the lowest for ability scores or rolling with advantage and disadvantage if those mechanics exist in your game.
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'nerd_dice'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle install
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install nerd_dice
19
+
20
+ ## Usage
21
+ ### Rolling a number of dice and adding a bonus
22
+ ```ruby
23
+ # roll a single d4
24
+ NerdDice.total_dice(4) # => return random Integer between 1-4
25
+
26
+ # roll 3d6
27
+ NerdDice.total_dice(6, 3) => return Integer total of three 6-sided dice
28
+
29
+ # roll a d20 and add 5 to the value
30
+ NerdDice.total_dice(20, 1, { bonus: 5 })
31
+ ```
32
+ __NOTE:__ If provided, the bonus must be an ```Integer``` or it will be ignored
33
+
34
+ ## Development
35
+
36
+ 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.
37
+
38
+ 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).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/statelesscode/nerd_dice/issues. We welcome and encourage your participation in this open-source project. We welcome those of all backgrounds and abilities, but we refuse to adopt the Contributor Covenant for reasons outlined in [BURN_THE_CONTRIBUTOR_COVENANT_WITH_FIRE.md](https://github.com/statelesscode/nerd_dice/blob/master/BURN_THE_CONTRIBUTOR_COVENANT_WITH_FIRE.md)
43
+
44
+
45
+ ## Unlicense, License, and Copyright
46
+
47
+ The document is dual-licensed under the [MIT](https://opensource.org/licenses/MIT) license and the [UNLICENSE](https://unlicense.org/) \(with strong preference toward the UNLICENSE\)\. The content is released under [CC0](https://creativecommons.org/share-your-work/public-domain/cc0/) \(no rights reserved\). You are free to include it in its original form or modified with or without modification in your own project\.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org>
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "nerd_dice"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -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,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "nerd_dice/version"
4
+ # Nerd dice allows you to roll polyhedral dice and add bonuses as you would in
5
+ # a tabletop roleplaying game. You can choose to roll multiple dice and keep a
6
+ # specified number of dice such as rolling 4d6 and dropping the lowest for
7
+ # ability scores or rolling with advantage and disadvantage if those mechanics
8
+ # exist in your game.
9
+ #
10
+ # Usage:
11
+ # Right now there is only a single class method :total_dice
12
+ #
13
+ # If you wanted to roll a single d4, you would execute:
14
+ # <tt>NerdDice.total_dice(4)</tt>
15
+ #
16
+ # If you wanted to roll 3d6, you would execute
17
+ # <tt>NerdDice.total_dice(6, 3)</tt>
18
+ #
19
+ # If you wanted to roll a d20 and add 5 to the value, you would execute
20
+ # <tt>NerdDice.total_dice(20, 1, { bonus: 5 })</tt>
21
+ #
22
+ # The bonus in the options hash must be an Integer or it will be ignored
23
+ module NerdDice
24
+ class Error < StandardError; end
25
+
26
+ ############################
27
+ # total_dice class method
28
+ ############################
29
+ # Arguments:
30
+ # number_of_sides (Integer) => the number of sides of the dice to roll
31
+ # number_of_dice (Integer, DEFAULT: 1) => the quantity to roll of the type
32
+ # of die specified in the number_of_sides argument.
33
+ # options (Hash, DEFAULT: {}) any additional options you wish to include
34
+ # :bonus (Integer) => The total bonus (positive integer) or penalty
35
+ # (negative integer) to modify the total by. Is added to the total of
36
+ # all dice after they are totaled, not to each die rolled
37
+ #
38
+ # Return (Integer) => Total of the dice rolled, plus modifier if applicable
39
+ def self.total_dice(number_of_sides, number_of_dice = 1, opts = {})
40
+ total = 0
41
+ number_of_dice.times do
42
+ total += rand(number_of_sides) + 1
43
+ end
44
+ total += opts[:bonus] if opts[:bonus].is_a?(Integer)
45
+ total
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NerdDice
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/nerd_dice/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "nerd_dice"
7
+ spec.version = NerdDice::VERSION
8
+ spec.authors = ["Michael Duchemin"]
9
+ spec.email = ["statelesscode@gmail.com"]
10
+
11
+ spec.summary = "A Ruby Gem for rolling polyhedral dice."
12
+ spec.description = <<-GEM_DESCRIPTION
13
+ Nerd dice allows you to roll polyhedral dice and add bonuses as you would in
14
+ a tabletop roleplaying game. You can choose to roll multiple dice and keep a
15
+ specified number of dice such as rolling 4d6 and dropping the lowest for
16
+ ability scores or rolling with advantage and disadvantage if those mechanics
17
+ exist in your game.
18
+ GEM_DESCRIPTION
19
+ spec.homepage = "https://github.com/statelesscode/nerd_dice"
20
+ spec.licenses = %w[Unlicense MIT]
21
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
22
+
23
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
24
+
25
+ spec.metadata["homepage_uri"] = spec.homepage
26
+ spec.metadata["source_code_uri"] = "https://github.com/statelesscode/nerd_dice"
27
+ spec.metadata["changelog_uri"] = "https://github.com/statelesscode/nerd_dice/CHANGELOG.md"
28
+ spec.metadata["bug_tracker_uri"] = "https://github.com/statelesscode/nerd_dice/issues"
29
+ spec.metadata["documentation_uri"] = "https://github.com/statelesscode/nerd_dice/README.md"
30
+ spec.metadata["documentation_uri"] = "https://github.com/statelesscode/nerd_dice/README.md"
31
+
32
+ # Specify which files should be added to the gem when it is released.
33
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
34
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
35
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
36
+ end
37
+ spec.bindir = "bin"
38
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
39
+ spec.require_paths = ["lib"]
40
+
41
+ # Certs and signing
42
+ spec.cert_chain = ["certs/msducheminjr.pem"]
43
+ spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $PROGRAM_NAME.match?(/gem\z/)
44
+
45
+ # Dependencies
46
+ spec.add_development_dependency "rubocop", "~> 1.5", ">= 1.5.2"
47
+ spec.add_development_dependency "rubocop-performance", "~> 1.9", ">= 1.9.1"
48
+ spec.add_development_dependency "rubocop-rake", "~> 0.5", ">= 0.5.1"
49
+ spec.add_development_dependency "rubocop-rspec", "~> 2.0", ">= 2.0.1"
50
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nerd_dice
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Duchemin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIETTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1zdGF0
14
+ ZWxlc3Njb2RlL0RDPWdtYWlsL0RDPWNvbTAeFw0yMDEyMDYyMzQ1NTZaFw0yMTEy
15
+ MDYyMzQ1NTZaMCgxJjAkBgNVBAMMHXN0YXRlbGVzc2NvZGUvREM9Z21haWwvREM9
16
+ Y29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAyHIMJi0o3bwBZsx5
17
+ TQ35XByFsdDRsro3T+0NY7EAILtOiU04o9C2NPOp/RQE7BXQgMjGebwp6bT6QvzN
18
+ 6noV4jPL7Fi5pWw08QygG7f+73YUBb+8d8o+3xGrC+UO5h1PZEtVcZwUWUG18QBE
19
+ fbDinQT6P4IDQoZwhfrPCB+aBfUyQp4Ok7oD7MEWqsq9SjrSxqxfk4+oZdXUySe7
20
+ Vi5vnzVQ5uFf56NHwWnNKCzJzmH84mBO5MzHaQpHNzKGJPoUmzLU5RBlCH6YXqBG
21
+ KhXTMUDBWKJmJ3RDry/FpGgJLKu4wzFRYjXla6IjeKozWGuPNNJ+2mesXKhsX7bo
22
+ vVCzRxPEupbEg/0FkJiWpiGlSPOdd6oJiwX8E6rlEeV605xrbOQewkbovHkYTMtG
23
+ +NH+u08x0z4Oj71kmDLwuj812uS0mtrCg2VhiYO0ZCQ4XrwBsBfK+/MtMlR+o6sG
24
+ /zvz/vHVJKaLTQxRp5oGo4QH6HfbOnwzTkXdZnt5AlN31ErJAgMBAAGjgYEwfzAJ
25
+ BgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUC7seYydsGO6O1qT4nVVD
26
+ G/LkiHYwIgYDVR0RBBswGYEXc3RhdGVsZXNzY29kZUBnbWFpbC5jb20wIgYDVR0S
27
+ BBswGYEXc3RhdGVsZXNzY29kZUBnbWFpbC5jb20wDQYJKoZIhvcNAQELBQADggGB
28
+ ADPRFRB1cjqdcE2O0jtqiDRmrR62uEYBiUbkRPVhyoEp/cK0TVhAs9mGWAyCWu0M
29
+ LewUeqNTUvQ9MgvagcKcnxa2RTjdrP3nGnwpStMr9bm3ArNJEzvWEs0Eusk9y73x
30
+ fjy0qH2pw5WPfWcKYlDehMXqOP+a4udYsz0YSNiI8qEfkDCSqTJN11d5kSjVjwGB
31
+ xkauxDT68j1JZRjPmQl3dl+DCgxkoziWX2mFTPLfGg5vZ0t6gmhdUtLvJtNIo0IX
32
+ 477E5UjmE1+rULQp/fsH6n5+H+t2eCED41ST+gkKbaQBUfIuUaCmdHz9sJaIIBw2
33
+ 6ordFa1nrLV4w5Uf6qYFnWVhIWX4GToyZSPO2s0DPYp3PWFJ4VtzKa2vp1TR5ZEA
34
+ dkij2eQ9M8bzWWmW+A7RNaI0CzLl967bKGBSaMVCsZGBarggWD8UwJnBhTuOPZGR
35
+ WQ4faXJSevxT+x9TgyUNJINPkz/KqreClzdL83cwxPzFFQto7zF6zMCsj0slqJjW
36
+ EQ==
37
+ -----END CERTIFICATE-----
38
+ date: 2020-12-07 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: rubocop
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.5'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.5.2
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.5'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.5.2
60
+ - !ruby/object:Gem::Dependency
61
+ name: rubocop-performance
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.9'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.9.1
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.9'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.9.1
80
+ - !ruby/object:Gem::Dependency
81
+ name: rubocop-rake
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '0.5'
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.5'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 0.5.1
100
+ - !ruby/object:Gem::Dependency
101
+ name: rubocop-rspec
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '2.0'
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 2.0.1
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '2.0'
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 2.0.1
120
+ description: |2
121
+ Nerd dice allows you to roll polyhedral dice and add bonuses as you would in
122
+ a tabletop roleplaying game. You can choose to roll multiple dice and keep a
123
+ specified number of dice such as rolling 4d6 and dropping the lowest for
124
+ ability scores or rolling with advantage and disadvantage if those mechanics
125
+ exist in your game.
126
+ email:
127
+ - statelesscode@gmail.com
128
+ executables:
129
+ - console
130
+ - setup
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".rubocop.yml"
137
+ - ".travis.yml"
138
+ - BURN_THE_CONTRIBUTOR_COVENANT_WITH_FIRE.md
139
+ - CHANGELOG.md
140
+ - Gemfile
141
+ - Gemfile.lock
142
+ - LICENSE.txt
143
+ - README.md
144
+ - Rakefile
145
+ - UNLICENSE.txt
146
+ - bin/console
147
+ - bin/setup
148
+ - lib/nerd_dice.rb
149
+ - lib/nerd_dice/version.rb
150
+ - nerd_dice.gemspec
151
+ homepage: https://github.com/statelesscode/nerd_dice
152
+ licenses:
153
+ - Unlicense
154
+ - MIT
155
+ metadata:
156
+ allowed_push_host: https://rubygems.org
157
+ homepage_uri: https://github.com/statelesscode/nerd_dice
158
+ source_code_uri: https://github.com/statelesscode/nerd_dice
159
+ changelog_uri: https://github.com/statelesscode/nerd_dice/CHANGELOG.md
160
+ bug_tracker_uri: https://github.com/statelesscode/nerd_dice/issues
161
+ documentation_uri: https://github.com/statelesscode/nerd_dice/README.md
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 2.7.0
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubygems_version: 3.1.4
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: A Ruby Gem for rolling polyhedral dice.
181
+ test_files: []
Binary file