craps_dice 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 172cb8913b01aa78fadd49a205291d5481b52db7cf09ea6d37c937fbea8ac0b6
4
+ data.tar.gz: ab3e39f43b3ead563291f66686c5fd73819f1cb635c1122e27429cb41b22bcc5
5
+ SHA512:
6
+ metadata.gz: 21c937e08a07cb6f9296e78bfdafc92a2c08403091cdec19a08b152acb849a726d4db740f835e472bd48b2f6cb8dfbc648a37f945902ff868a07e0b03b7584ba
7
+ data.tar.gz: ce9df0cea7bcf4b37d120a490f3cbd1155ef2e0e9770bb8ea6a037669c5d316dcfde7bd8a1541720f64aa49dd191c3470f589acd39cc7e35c783a9ed3c391ea0
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.4
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in craps_dice.gemspec
4
+ gemspec
5
+
6
+ gem 'minitest-reporters', '1.2.0'
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # CrapsDice
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/craps_dice`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'craps_dice'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install craps_dice
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/craps_dice.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "craps_dice"
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(__FILE__)
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,33 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "craps_dice/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "craps_dice"
7
+ spec.version = CrapsDice::VERSION
8
+ spec.authors = ["Marshall Scott"]
9
+ spec.email = ["bacchist@gmail.com"]
10
+
11
+ spec.summary = %q{Dice for craps}
12
+ spec.description = %q{A class representing a pair of dice for playing craps}
13
+ spec.homepage = "https://github.com/bacchist/craps_dice"
14
+
15
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/bacchist/craps_dice"
19
+ spec.metadata["changelog_uri"] = "https://github.com/bacchist/craps_dice"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 2.0"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "minitest", "~> 5.0"
33
+ end
data/lib/craps_dice.rb ADDED
@@ -0,0 +1,34 @@
1
+ require "yaml"
2
+ require "craps_dice/version"
3
+
4
+ ROLL_NAMES = YAML.load(File.read(File.expand_path("../yaml/roll.yml", __FILE__)))
5
+
6
+ class Roll < Array
7
+ def initialize
8
+ 2.times { push(rand(1..6)) }
9
+ end
10
+
11
+ def reroll
12
+ clear
13
+ 2.times { push(rand(1..6)) }
14
+ self
15
+ end
16
+
17
+ def is_hard?
18
+ uniq.length == 1
19
+ end
20
+
21
+ def is_seven?
22
+ sum == 7
23
+ end
24
+
25
+ def name
26
+ ROLL_NAMES.find { |key, values|
27
+ values.include?(self.sort)
28
+ }.first
29
+ end
30
+
31
+ def dup
32
+ Marshal.load(Marshal.dump(self))
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module CrapsDice
2
+ VERSION = "0.1.5"
3
+ end
data/lib/yaml/roll.yml ADDED
@@ -0,0 +1,36 @@
1
+ :aces:
2
+ - [1, 1]
3
+ :ace_deuce:
4
+ - [1, 2]
5
+ :hard_four:
6
+ - [2, 2]
7
+ :easy_four:
8
+ - [1, 3]
9
+ :five:
10
+ - [1, 4]
11
+ - [2, 3]
12
+ :hard_six:
13
+ - [3, 3]
14
+ :easy_six:
15
+ - [1, 5]
16
+ - [2, 4]
17
+ :seven:
18
+ - [1, 6]
19
+ - [2, 5]
20
+ - [3, 4]
21
+ :hard_eight:
22
+ - [4, 4]
23
+ :easy_eight:
24
+ - [2, 6]
25
+ - [3, 5]
26
+ :nine:
27
+ - [3, 6]
28
+ - [4, 5]
29
+ :hard_ten:
30
+ - [5, 5]
31
+ :easy_ten:
32
+ - [4, 6]
33
+ :yo:
34
+ - [5, 6]
35
+ :twelve:
36
+ - [6, 6]
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: craps_dice
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Marshall Scott
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: A class representing a pair of dice for playing craps
56
+ email:
57
+ - bacchist@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - craps_dice.gemspec
70
+ - lib/craps_dice.rb
71
+ - lib/craps_dice/version.rb
72
+ - lib/yaml/roll.yml
73
+ homepage: https://github.com/bacchist/craps_dice
74
+ licenses: []
75
+ metadata:
76
+ allowed_push_host: https://rubygems.org
77
+ homepage_uri: https://github.com/bacchist/craps_dice
78
+ source_code_uri: https://github.com/bacchist/craps_dice
79
+ changelog_uri: https://github.com/bacchist/craps_dice
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubygems_version: 3.0.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Dice for craps
99
+ test_files: []