the_gambler 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.rspec +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +8 -12
- data/lib/the_gambler/deck.rb +22 -1
- data/lib/the_gambler/version.rb +1 -1
- data/spec/decks_spec.rb +40 -0
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
Y2Y0MjdjMjhhMjQ5MjIyYmNlZjViYWQ0N2M2YmQzZDM1MDZjZDE4OGVkYzRi
|
10
|
-
ZDY5YzI1ZmU1OTQ1OWNiYWRmN2E5NzhmYmI5Y2ViNGE0OWQ2NTc0Nzk4ZmYz
|
11
|
-
MTNlNmI5NGI0NWUyOGU2ZTU2ZTc2OGRlNTZkOTU3MDAyZTgzNTM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YTQ1Y2YzNzU1MGY4MTNkNzU0Y2IzY2ZmMGEwODkzYWM5YzBkZGY5NDczMTFm
|
14
|
-
ZmI0N2M3NjgzMWM5YmVmZTlkMzM5MmYzMGMwNGE1OGE4Yzg1OWQzN2U1MzRm
|
15
|
-
N2VjZDFhMGVkNGYzZWZlYjJhZDZmMTM3ZGMzOTViMWYxMjA1NzU=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 567577eeb1b3ce7fce6ef55fa7917d0efe6adde0
|
4
|
+
data.tar.gz: b3b940488f946aebbd2433651099cccd0ca2a914
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b30be3b69d1e60f474b1f2e355c2554fb7c9a32ffaf0c075e95ce19420c26f57d83d410c3bb313aaa3cede8900b08c925f91e1cb520f13afd128e94d196d7cf
|
7
|
+
data.tar.gz: 579ad59eecf3793648e425d267e958c50e3244a39ab3dd22add91d9e8dd4db43acdabc92b09ffb76b544b8a722733b019840c8e3c757a68bb6f1872321d22c56
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--color --format
|
1
|
+
--color --format progress
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.1.1
|
data/Gemfile
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
source
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
1
|
+
source 'http://rubygems.org'
|
5
2
|
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
3
|
group :development do
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
4
|
+
gem 'rake'
|
5
|
+
gem 'rspec'
|
6
|
+
gem 'yard'
|
7
|
+
gem 'rdoc'
|
8
|
+
gem 'bundler'
|
9
|
+
gem 'nyan-cat-formatter'
|
10
|
+
gem 'simplecov'
|
15
11
|
end
|
data/lib/the_gambler/deck.rb
CHANGED
@@ -1,4 +1,25 @@
|
|
1
1
|
module TheGambler
|
2
2
|
class Deck
|
3
|
+
attr_reader :contents
|
4
|
+
|
5
|
+
# Exceptions ---------------------------------------------------------------
|
6
|
+
|
7
|
+
class EmptyDeckException
|
8
|
+
end
|
9
|
+
|
10
|
+
# Initializer --------------------------------------------------------------
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@contents = (0..51).map{|i| Card.new(i)}.shuffle
|
14
|
+
end
|
15
|
+
|
16
|
+
# Public instance methods --------------------------------------------------
|
17
|
+
|
18
|
+
def deal
|
19
|
+
@contents.pop.tap do |card|
|
20
|
+
raise EmptyDeckException.new if card.nil?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
3
24
|
end
|
4
|
-
end
|
25
|
+
end
|
data/lib/the_gambler/version.rb
CHANGED
data/spec/decks_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module TheGambler
|
2
|
+
describe Deck do
|
3
|
+
|
4
|
+
let(:deck) { Deck.new }
|
5
|
+
|
6
|
+
describe '#initialize' do
|
7
|
+
it 'creates a shuffled array of cards at @contents' do
|
8
|
+
expect(deck.contents).to be_a(Array)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'has 52 things in it' do
|
12
|
+
expect(deck.contents.count).to eq(52)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'is filled with Cards' do
|
16
|
+
deck.contents.each {|card| expect(card).to be_a(Card)}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#deal' do
|
21
|
+
it 'returns a card' do
|
22
|
+
card = deck.deal
|
23
|
+
expect(card).to be_a(Card)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'removes the returned card from the deck' do
|
27
|
+
card = deck.deal
|
28
|
+
expect(deck.contents).not_to include(card)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with an empty deck' do
|
32
|
+
it 'raises an EmptyDeckException' do
|
33
|
+
deck.contents.stub(:pop).and_return(nil)
|
34
|
+
expect { deck.deal }.to raise_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,56 +1,56 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_gambler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- max thom stahl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
42
|
-
|
41
|
+
description: "\n Really common tasks in programs that use playing cards are a pain
|
42
|
+
to\n implement. This is my implementation. Use it. Or don't.\n "
|
43
43
|
email:
|
44
44
|
- max@villainousindustries.com
|
45
45
|
executables: []
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- .document
|
50
|
-
- .gitignore
|
51
|
-
- .rspec
|
52
|
-
- .ruby-gemset
|
53
|
-
- .ruby-version
|
49
|
+
- ".document"
|
50
|
+
- ".gitignore"
|
51
|
+
- ".rspec"
|
52
|
+
- ".ruby-gemset"
|
53
|
+
- ".ruby-version"
|
54
54
|
- CHANGELOG.md
|
55
55
|
- Gemfile
|
56
56
|
- Gemfile.lock
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/the_gambler/version.rb
|
68
68
|
- spec/cards/comparison_spec.rb
|
69
69
|
- spec/cards/initialization_spec.rb
|
70
|
+
- spec/decks_spec.rb
|
70
71
|
- spec/hands/hands_spec.rb
|
71
72
|
- spec/hands/poker/hand_flush_spec.rb
|
72
73
|
- spec/hands/poker/hand_four_of_a_kind_spec.rb
|
@@ -95,23 +96,24 @@ require_paths:
|
|
95
96
|
- lib
|
96
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
98
|
requirements:
|
98
|
-
- -
|
99
|
+
- - ">="
|
99
100
|
- !ruby/object:Gem::Version
|
100
101
|
version: '0'
|
101
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
103
|
requirements:
|
103
|
-
- -
|
104
|
+
- - ">="
|
104
105
|
- !ruby/object:Gem::Version
|
105
106
|
version: '0'
|
106
107
|
requirements: []
|
107
108
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.2.2
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
112
|
summary: Classes and modules for card-playing apps.
|
112
113
|
test_files:
|
113
114
|
- spec/cards/comparison_spec.rb
|
114
115
|
- spec/cards/initialization_spec.rb
|
116
|
+
- spec/decks_spec.rb
|
115
117
|
- spec/hands/hands_spec.rb
|
116
118
|
- spec/hands/poker/hand_flush_spec.rb
|
117
119
|
- spec/hands/poker/hand_four_of_a_kind_spec.rb
|