badcards 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +10 -0
- data/badcards.gemspec +25 -0
- data/lib/badcards.rb +4 -0
- data/lib/badcards/card.rb +94 -0
- data/lib/badcards/deck.rb +42 -0
- data/lib/badcards/hand.rb +21 -0
- data/lib/badcards/version.rb +3 -0
- data/spec/badcards/card_spec.rb +25 -0
- data/spec/badcards/deck_spec.rb +119 -0
- data/spec/badcards/hand_spec.rb +57 -0
- data/spec/helper.rb +13 -0
- data/spec/spec_helper.rb +25 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4cf97c02eabece811867193a76a7c01e0aea1ee8
|
4
|
+
data.tar.gz: 8217a7d8870e2520fe9dc9bcd1f10e730a16239a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b973f25983514a5e507dc0f8891418572570aacbe2285cc75542f6e564debfca71003db0cab30a348d8d042c252e8f946fb0f5c99dccb254b19ae4e6f888111
|
7
|
+
data.tar.gz: 3ab531f6455671af4c0bc0671357d1a4c2d297f6e0330ead76f6ac7b7507a33de1a41cd5b2c026f58eba20a0a01aab614c930fc14e9b2e6bd8a870e160a8a86a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Benjamin Hsieh
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# BaDcards
|
2
|
+
[![Build Status](https://travis-ci.org/BensPotatoes/BaDCards.svg?branch=master)](https://travis-ci.org/BensPotatoes/BaDCards)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/BensPotatoes/BaDCards/badge.png?branch=master)](https://coveralls.io/r/BensPotatoes/BaDCards?branch=master)
|
4
|
+
|
5
|
+
Ruby library of playing cards.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'badcards'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install badcards
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
card = Card.new("Ace", "Spades") # create an "Ace of Spades" card
|
25
|
+
hand = Hand.new # create a hand that can hold onto cards
|
26
|
+
deck = Deck.new(6) # create a deck consisting of six mini-decks of 52 cards
|
27
|
+
```
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it ( http://github.com/benspotatoes/badcards/fork )
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/badcards.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'badcards/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "badcards"
|
8
|
+
spec.version = Badcards::VERSION
|
9
|
+
spec.authors = ["Benjamin Hsieh, Ben's Potatoes"]
|
10
|
+
spec.email = ["benspotatoes@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby library for playing cards including BaDEmporium images.}
|
12
|
+
spec.description = %q{Includes cards, decks (of multiple sizes), hands, and drawing (of multiple cards).}
|
13
|
+
spec.homepage = "http://github.com/sicophrenic/badcards"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.1.0", ">= 10.1.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.14.1", ">= 2.14.1"
|
24
|
+
spec.add_development_dependency "coveralls", "~> 0.7.0", ">= 0.7.0"
|
25
|
+
end
|
data/lib/badcards.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
class Card
|
2
|
+
SUITS = %w[Diamonds Clubs Hearts Spades]
|
3
|
+
VALUES = %w[Ace 2 3 4 5 6 7 8 9 10 Jack Queen King]
|
4
|
+
|
5
|
+
S3_URLS = {
|
6
|
+
"ace+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/ace.png",
|
7
|
+
"two+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/two.png",
|
8
|
+
"three+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/three.png",
|
9
|
+
"four+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/four.png",
|
10
|
+
"five+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/five.png",
|
11
|
+
"six+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/six.png",
|
12
|
+
"seven+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/seven.png",
|
13
|
+
"eight+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/eight.png",
|
14
|
+
"nine+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/nine.png",
|
15
|
+
"ten+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/ten.png",
|
16
|
+
"jack+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/jack.png",
|
17
|
+
"queen+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/queen.png",
|
18
|
+
"king+diamonds" => "https://s3-us-west-2.amazonaws.com/badcards/cards/diamond/king.png",
|
19
|
+
|
20
|
+
"ace+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/ace.png",
|
21
|
+
"two+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/two.png",
|
22
|
+
"three+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/three.png",
|
23
|
+
"four+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/four.png",
|
24
|
+
"five+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/five.png",
|
25
|
+
"six+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/six.png",
|
26
|
+
"seven+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/seven.png",
|
27
|
+
"eight+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/eight.png",
|
28
|
+
"nine+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/nine.png",
|
29
|
+
"ten+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/ten.png",
|
30
|
+
"jack+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/jack.png",
|
31
|
+
"queen+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/queen.png",
|
32
|
+
"king+clubs" => "https://s3-us-west-2.amazonaws.com/badcards/cards/club/king.png",
|
33
|
+
|
34
|
+
"ace+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/ace.png",
|
35
|
+
"two+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/two.png",
|
36
|
+
"three+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/three.png",
|
37
|
+
"four+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/four.png",
|
38
|
+
"five+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/five.png",
|
39
|
+
"six+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/six.png",
|
40
|
+
"seven+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/seven.png",
|
41
|
+
"eight+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/eight.png",
|
42
|
+
"nine+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/nine.png",
|
43
|
+
"ten+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/ten.png",
|
44
|
+
"jack+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/jack.png",
|
45
|
+
"queen+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/queen.png",
|
46
|
+
"king+hearts" => "https://s3-us-west-2.amazonaws.com/badcards/cards/heart/king.png",
|
47
|
+
|
48
|
+
"ace+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/ace.png",
|
49
|
+
"two+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/two.png",
|
50
|
+
"three+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/three.png",
|
51
|
+
"four+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/four.png",
|
52
|
+
"five+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/five.png",
|
53
|
+
"six+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/six.png",
|
54
|
+
"seven+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/seven.png",
|
55
|
+
"eight+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/eight.png",
|
56
|
+
"nine+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/nine.png",
|
57
|
+
"ten+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/ten.png",
|
58
|
+
"jack+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/jack.png",
|
59
|
+
"queen+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/queen.png",
|
60
|
+
"king+spades" => "https://s3-us-west-2.amazonaws.com/badcards/cards/spade/king.png"
|
61
|
+
}
|
62
|
+
|
63
|
+
def initialize(value, suit)
|
64
|
+
if !VALUES.include?(value)
|
65
|
+
raise ArgumentError, "Invalid Card value"
|
66
|
+
end
|
67
|
+
if !SUITS.include?(suit)
|
68
|
+
raise ArgumentError, "Invalid Card suit"
|
69
|
+
end
|
70
|
+
@value = value
|
71
|
+
@suit = suit
|
72
|
+
@image = S3_URLS["#{value.downcase}+#{suit.downcase}"]
|
73
|
+
end
|
74
|
+
|
75
|
+
def value
|
76
|
+
@value
|
77
|
+
end
|
78
|
+
|
79
|
+
def suit
|
80
|
+
@suit
|
81
|
+
end
|
82
|
+
|
83
|
+
def img
|
84
|
+
@image
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.all_cards
|
88
|
+
VALUES.each do |value|
|
89
|
+
SUITS.each do |suit|
|
90
|
+
yield value, suit
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Deck
|
2
|
+
def initialize(num_decks = 1)
|
3
|
+
@cards = []
|
4
|
+
num_decks.times do
|
5
|
+
Card.all_cards do |value, suit|
|
6
|
+
@cards << Card.new(value, suit)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def cards
|
12
|
+
@cards
|
13
|
+
end
|
14
|
+
|
15
|
+
def size
|
16
|
+
@cards.count
|
17
|
+
end
|
18
|
+
|
19
|
+
def peek
|
20
|
+
@cards.first
|
21
|
+
end
|
22
|
+
|
23
|
+
def draw(num_to_draw = 1, hand_for_draw = nil)
|
24
|
+
@drawn = []
|
25
|
+
num_to_draw.times do
|
26
|
+
if card = @cards.shift
|
27
|
+
@drawn << card
|
28
|
+
else
|
29
|
+
break
|
30
|
+
end
|
31
|
+
end
|
32
|
+
if hand_for_draw && hand_for_draw.is_a?(Hand)
|
33
|
+
hand_for_draw.cards += @drawn
|
34
|
+
else
|
35
|
+
if @drawn.count <= 1
|
36
|
+
return @drawn.first
|
37
|
+
else
|
38
|
+
return @drawn
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Hand
|
2
|
+
def initialize
|
3
|
+
@cards = []
|
4
|
+
end
|
5
|
+
|
6
|
+
def cards
|
7
|
+
@cards
|
8
|
+
end
|
9
|
+
|
10
|
+
def cards=(new_cards)
|
11
|
+
@cards = new_cards
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_card(card)
|
15
|
+
@cards << card
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_cards(cards)
|
19
|
+
@cards += cards
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Card do
|
4
|
+
describe 'values' do
|
5
|
+
Card.all_cards do |value, suit|
|
6
|
+
it 'should return the appropriate suit' do
|
7
|
+
make_card(value, suit)
|
8
|
+
@card.suit.should == suit
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return the appropriate value' do
|
12
|
+
make_card(value, suit)
|
13
|
+
@card.value.should == value
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should fail for an invalid suit' do
|
18
|
+
expect { make_card('Ace', 'fake_suit') }.to raise_error
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should fail for an invalid value' do
|
22
|
+
expect { make_card('fake_value', 'Spades') }.to raise_error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Deck do
|
4
|
+
describe 'creation' do
|
5
|
+
describe 'defaults' do
|
6
|
+
before(:all) do
|
7
|
+
make_deck
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should create a deck with 52 cards' do
|
11
|
+
@deck.size.should == 52
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have every single combination of card suit and value' do
|
15
|
+
found_cards = []
|
16
|
+
@deck.cards.each do |card|
|
17
|
+
Card.all_cards do |value, suit|
|
18
|
+
@match = ((card.suit == suit) && (card.value == value))
|
19
|
+
if @match
|
20
|
+
break
|
21
|
+
end
|
22
|
+
end
|
23
|
+
if @match
|
24
|
+
found_cards << true
|
25
|
+
next
|
26
|
+
else
|
27
|
+
found_cards << false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'custom' do
|
34
|
+
it 'should create a specific deck size' do
|
35
|
+
custom_size = 6
|
36
|
+
@deck = Deck.new(custom_size)
|
37
|
+
@deck.size.should == custom_size * 52
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'operation' do
|
43
|
+
describe 'shuffling' do
|
44
|
+
pending("can't be tested?")
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'drawing' do
|
48
|
+
describe 'peek' do
|
49
|
+
before(:all) do
|
50
|
+
@deck_size = 6
|
51
|
+
@card_count = @deck_size * 52
|
52
|
+
make_deck(@deck_size)
|
53
|
+
make_hand
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should return the first card in the deck' do
|
57
|
+
top_card = @deck.peek
|
58
|
+
top_card.should == @deck.cards.first
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should not draw a card from the deck' do
|
62
|
+
top_card = @deck.peek
|
63
|
+
@deck.cards.count.should == @card_count
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'single' do
|
68
|
+
before(:all) do
|
69
|
+
@deck_size = 6
|
70
|
+
@card_count = @deck_size * 52
|
71
|
+
make_deck(@deck_size)
|
72
|
+
make_hand
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should return a single card' do
|
76
|
+
new_card = @deck.draw
|
77
|
+
@deck.cards.count.should == @card_count - 1
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'multiple' do
|
82
|
+
before(:all) do
|
83
|
+
@deck_size = 6
|
84
|
+
@card_count = @deck_size * 52
|
85
|
+
make_deck(@deck_size)
|
86
|
+
make_hand
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should return an array of cards' do
|
90
|
+
draw_count = 5
|
91
|
+
new_cards = @deck.draw(draw_count)
|
92
|
+
new_cards.class.should == Array
|
93
|
+
@deck.cards.count.should == @card_count - draw_count
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'limit' do
|
98
|
+
it 'should return all possible cards if there are not enough cards' do
|
99
|
+
@new_deck = Deck.new
|
100
|
+
@num_to_draw = 51
|
101
|
+
@new_deck.draw(@num_to_draw)
|
102
|
+
@new_deck.cards.count.should == 52 - @num_to_draw
|
103
|
+
new_cards = @new_deck.draw(5)
|
104
|
+
@new_deck.cards.count.should == 0
|
105
|
+
new_cards.class.should == Card
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should return nil if there are no more cards' do
|
109
|
+
@new_deck = Deck.new
|
110
|
+
@new_deck.draw(52)
|
111
|
+
@new_deck.cards.count.should == 0
|
112
|
+
new_cards = @new_deck.draw(5)
|
113
|
+
@new_deck.cards.count.should == 0
|
114
|
+
new_cards.should == nil
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hand do
|
4
|
+
describe 'drawing cards' do
|
5
|
+
describe 'manual' do
|
6
|
+
describe 'single' do
|
7
|
+
before(:all) do
|
8
|
+
make_deck(6)
|
9
|
+
make_hand
|
10
|
+
end
|
11
|
+
it 'should add the card(s) to the hand' do
|
12
|
+
new_card = @deck.peek
|
13
|
+
@hand.add_card(@deck.draw)
|
14
|
+
@hand.cards.count.should == 1
|
15
|
+
@hand.cards.should include(new_card)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'multiple' do
|
20
|
+
before(:all) do
|
21
|
+
make_deck(6)
|
22
|
+
make_hand
|
23
|
+
end
|
24
|
+
it 'should add the card(s) to the hand' do
|
25
|
+
@hand.add_cards(@deck.draw(5))
|
26
|
+
@hand.cards.count.should == 5
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'automatic' do
|
32
|
+
describe 'single' do
|
33
|
+
before(:all) do
|
34
|
+
make_deck(6)
|
35
|
+
make_hand
|
36
|
+
end
|
37
|
+
it 'should add the card(s) to the hand' do
|
38
|
+
new_card = @deck.peek
|
39
|
+
@deck.draw(1, @hand)
|
40
|
+
@hand.cards.count.should == 1
|
41
|
+
@hand.cards.should include(new_card)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'multiple' do
|
46
|
+
before(:all) do
|
47
|
+
make_deck(6)
|
48
|
+
make_hand
|
49
|
+
end
|
50
|
+
it 'should add the card(s) to the hand' do
|
51
|
+
@deck.draw(5, @hand)
|
52
|
+
@hand.cards.count.should == 5
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/spec/helper.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
5
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
6
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
7
|
+
# loaded once.
|
8
|
+
#
|
9
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
# Run specs in random order to surface order dependencies. If you find an
|
16
|
+
# order dependency and want to debug it, you can fix the order by providing
|
17
|
+
# the seed, which is printed after each run.
|
18
|
+
# --seed 1234
|
19
|
+
config.order = 'random'
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'badcards'
|
23
|
+
|
24
|
+
require 'helper'
|
25
|
+
include Helper
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: badcards
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Hsieh, Ben's Potatoes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-27 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: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
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.1.0
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 10.1.0
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 10.1.0
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 10.1.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.14.1
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.14.1
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.14.1
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.14.1
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: coveralls
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.7.0
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.7.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.7.0
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.7.0
|
87
|
+
description: Includes cards, decks (of multiple sizes), hands, and drawing (of multiple
|
88
|
+
cards).
|
89
|
+
email:
|
90
|
+
- benspotatoes@gmail.com
|
91
|
+
executables: []
|
92
|
+
extensions: []
|
93
|
+
extra_rdoc_files: []
|
94
|
+
files:
|
95
|
+
- ".gitignore"
|
96
|
+
- ".rspec"
|
97
|
+
- ".travis.yml"
|
98
|
+
- Gemfile
|
99
|
+
- LICENSE.txt
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- badcards.gemspec
|
103
|
+
- lib/badcards.rb
|
104
|
+
- lib/badcards/card.rb
|
105
|
+
- lib/badcards/deck.rb
|
106
|
+
- lib/badcards/hand.rb
|
107
|
+
- lib/badcards/version.rb
|
108
|
+
- spec/badcards/card_spec.rb
|
109
|
+
- spec/badcards/deck_spec.rb
|
110
|
+
- spec/badcards/hand_spec.rb
|
111
|
+
- spec/helper.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
homepage: http://github.com/sicophrenic/badcards
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.2.2
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Ruby library for playing cards including BaDEmporium images.
|
137
|
+
test_files:
|
138
|
+
- spec/badcards/card_spec.rb
|
139
|
+
- spec/badcards/deck_spec.rb
|
140
|
+
- spec/badcards/hand_spec.rb
|
141
|
+
- spec/helper.rb
|
142
|
+
- spec/spec_helper.rb
|