cardshark 0.0.1 → 0.0.2
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 +7 -0
- data/.github/workflows/rspec.yml +20 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rubocop.yml +20 -0
- data/Gemfile +2 -2
- data/Guardfile +23 -0
- data/LICENSE +19 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/cardshark.gemspec +20 -13
- data/lib/cardshark.rb +8 -1
- data/lib/cardshark/abstract.rb +30 -0
- data/lib/cardshark/card.rb +31 -6
- data/lib/cardshark/deck.rb +72 -25
- data/lib/cardshark/dimension.rb +57 -0
- data/lib/cardshark/error.rb +11 -0
- data/lib/cardshark/version.rb +3 -1
- data/spec/cardshark/abstract_spec.rb +27 -0
- data/spec/cardshark/card_spec.rb +86 -0
- data/spec/cardshark/deck_spec.rb +252 -0
- data/spec/cardshark/dimension_spec.rb +113 -0
- data/spec/cardshark/error/abstract_class_spec.rb +21 -0
- data/spec/cardshark/error_spec.rb +21 -0
- data/spec/cardshark_spec.rb +6 -0
- data/spec/spec_helper.rb +20 -0
- metadata +117 -78
- data/README +0 -8
- data/lib/cardshark/canasta_deck.rb +0 -21
- data/lib/cardshark/french_deck.rb +0 -20
- data/lib/cardshark/piquet_deck.rb +0 -16
- data/lib/cardshark/uno_deck.rb +0 -20
- data/spec/canasta_deck_spec.rb +0 -13
- data/spec/card_spec.rb +0 -15
- data/spec/deck_spec.rb +0 -39
- data/spec/french_deck_spec.rb +0 -17
- data/spec/piquet_deck_spec.rb +0 -13
- data/spec/uno_deck_spec.rb +0 -47
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cardshark/error'
|
4
|
+
|
5
|
+
RSpec.describe Cardshark::Error::AbstractClass do
|
6
|
+
describe '::new' do
|
7
|
+
before do
|
8
|
+
@result = described_class.new
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'return value' do
|
12
|
+
it 'is a an instance of the class' do
|
13
|
+
expect(@result).to be_an_instance_of(described_class)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'is a kind of Cardshark::Error' do
|
17
|
+
expect(@result).to be_kind_of(Cardshark::Error)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cardshark/error'
|
4
|
+
|
5
|
+
RSpec.describe Cardshark::Error do
|
6
|
+
describe '::new' do
|
7
|
+
before do
|
8
|
+
@result = described_class.new
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'return value' do
|
12
|
+
it 'is a an instance of the class' do
|
13
|
+
expect(@result).to be_an_instance_of(described_class)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'is a kind of StandardError' do
|
17
|
+
expect(@result).to be_kind_of(StandardError)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
6
|
+
end
|
7
|
+
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_partial_doubles = true
|
10
|
+
end
|
11
|
+
|
12
|
+
config.disable_monkey_patching!
|
13
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
14
|
+
config.filter_run_when_matching :focus
|
15
|
+
config.order = :random
|
16
|
+
config.profile_examples = 10
|
17
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
18
|
+
Kernel.srand config.seed
|
19
|
+
config.warnings = true
|
20
|
+
end
|
metadata
CHANGED
@@ -1,106 +1,145 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cardshark
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- John Britton - @johndbritton
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
date: 2020-02-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: guard-rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.7.3
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.7.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard-rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.3.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
21
42
|
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.9.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.9.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.79.0
|
62
|
+
type: :development
|
22
63
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
version: 2.0.0.beta.22
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.79.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: terminal-notifier-guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.7.0
|
36
76
|
type: :development
|
37
|
-
|
38
|
-
|
39
|
-
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.7.0
|
83
|
+
description: A library for building decks of cards.
|
84
|
+
email:
|
40
85
|
- public@johndbritton.com
|
41
86
|
executables: []
|
42
|
-
|
43
87
|
extensions: []
|
44
|
-
|
45
88
|
extra_rdoc_files: []
|
46
|
-
|
47
|
-
|
48
|
-
- .gitignore
|
89
|
+
files:
|
90
|
+
- ".github/workflows/rspec.yml"
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".rubocop.yml"
|
49
94
|
- Gemfile
|
50
|
-
-
|
95
|
+
- Guardfile
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
51
98
|
- Rakefile
|
52
99
|
- cardshark.gemspec
|
53
100
|
- lib/cardshark.rb
|
54
|
-
- lib/cardshark/
|
101
|
+
- lib/cardshark/abstract.rb
|
55
102
|
- lib/cardshark/card.rb
|
56
103
|
- lib/cardshark/deck.rb
|
57
|
-
- lib/cardshark/
|
58
|
-
- lib/cardshark/
|
59
|
-
- lib/cardshark/uno_deck.rb
|
104
|
+
- lib/cardshark/dimension.rb
|
105
|
+
- lib/cardshark/error.rb
|
60
106
|
- lib/cardshark/version.rb
|
61
|
-
- spec/
|
62
|
-
- spec/card_spec.rb
|
63
|
-
- spec/deck_spec.rb
|
64
|
-
- spec/
|
65
|
-
- spec/
|
66
|
-
- spec/
|
67
|
-
|
107
|
+
- spec/cardshark/abstract_spec.rb
|
108
|
+
- spec/cardshark/card_spec.rb
|
109
|
+
- spec/cardshark/deck_spec.rb
|
110
|
+
- spec/cardshark/dimension_spec.rb
|
111
|
+
- spec/cardshark/error/abstract_class_spec.rb
|
112
|
+
- spec/cardshark/error_spec.rb
|
113
|
+
- spec/cardshark_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
homepage: https://github.com/johndbritton/cardshark
|
68
116
|
licenses: []
|
69
|
-
|
117
|
+
metadata: {}
|
70
118
|
post_install_message:
|
71
119
|
rdoc_options: []
|
72
|
-
|
73
|
-
require_paths:
|
120
|
+
require_paths:
|
74
121
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
|
77
|
-
requirements:
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
78
124
|
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
version: "0"
|
84
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
|
-
requirements:
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
87
129
|
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
93
132
|
requirements: []
|
94
|
-
|
95
|
-
rubyforge_project: cardshark
|
96
|
-
rubygems_version: 1.7.2
|
133
|
+
rubygems_version: 3.0.3
|
97
134
|
signing_key:
|
98
|
-
specification_version:
|
99
|
-
summary: A library for
|
100
|
-
test_files:
|
101
|
-
- spec/
|
102
|
-
- spec/card_spec.rb
|
103
|
-
- spec/deck_spec.rb
|
104
|
-
- spec/
|
105
|
-
- spec/
|
106
|
-
- spec/
|
135
|
+
specification_version: 4
|
136
|
+
summary: A library for building decks of cards.
|
137
|
+
test_files:
|
138
|
+
- spec/cardshark/abstract_spec.rb
|
139
|
+
- spec/cardshark/card_spec.rb
|
140
|
+
- spec/cardshark/deck_spec.rb
|
141
|
+
- spec/cardshark/dimension_spec.rb
|
142
|
+
- spec/cardshark/error/abstract_class_spec.rb
|
143
|
+
- spec/cardshark/error_spec.rb
|
144
|
+
- spec/cardshark_spec.rb
|
145
|
+
- spec/spec_helper.rb
|
data/README
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'cardshark/deck'
|
2
|
-
require 'cardshark/card'
|
3
|
-
|
4
|
-
module Cardshark
|
5
|
-
# Representation of the 108 Card deck used to play Canasta. Essentially it is two French Decks with the Jokers included.
|
6
|
-
class CanastaDeck
|
7
|
-
include Deck
|
8
|
-
RANKS = [:ace, :two, :three, :four, :five, :six, :seven, :eight, :nine, :ten, :jack, :queen, :king]
|
9
|
-
SUITS = [:spades, :hearts, :diamonds, :clubs]
|
10
|
-
JOKERS = [:joker]
|
11
|
-
JOKER_SUITS = [:red, :black]
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@cards = Array.new()
|
15
|
-
2.times do
|
16
|
-
@cards += create_cards(SUITS, RANKS)
|
17
|
-
@cards += create_cards(JOKER_SUITS, JOKERS)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'cardshark/deck'
|
2
|
-
require 'cardshark/card'
|
3
|
-
|
4
|
-
module Cardshark
|
5
|
-
class FrenchDeck
|
6
|
-
include Deck
|
7
|
-
RANKS = [:ace, :two, :three, :four, :five, :six, :seven, :eight, :nine, :ten, :jack, :queen, :king]
|
8
|
-
SUITS = [:spades, :hearts, :diamonds, :clubs]
|
9
|
-
JOKERS = [:joker]
|
10
|
-
JOKER_SUITS = [:red, :black]
|
11
|
-
|
12
|
-
def initialize(opts={:include_jokers => false})
|
13
|
-
@cards = Array.new()
|
14
|
-
@cards += create_cards(SUITS, RANKS)
|
15
|
-
if opts[:include_jokers] then
|
16
|
-
@cards += create_cards(JOKER_SUITS, JOKERS)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'cardshark/deck'
|
2
|
-
require 'cardshark/card'
|
3
|
-
|
4
|
-
module Cardshark
|
5
|
-
# Representation of the 32 Card deck used to play Piquet. http://en.wikipedia.org/wiki/Playing_card#Piquet
|
6
|
-
class PiquetDeck
|
7
|
-
include Deck
|
8
|
-
RANKS = [:ace, :seven, :eight, :nine, :ten, :jack, :queen, :king]
|
9
|
-
SUITS = [:spades, :hearts, :diamonds, :clubs]
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@cards = Array.new()
|
13
|
-
@cards += create_cards(SUITS, RANKS)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/lib/cardshark/uno_deck.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'cardshark/deck'
|
2
|
-
require 'cardshark/card'
|
3
|
-
|
4
|
-
module Cardshark
|
5
|
-
class UnoDeck
|
6
|
-
include Deck
|
7
|
-
RANKS = [:one, :two, :three, :four, :five, :six, :seven, :eight, :nine, :skip, :draw_two, :reverse]
|
8
|
-
ZERO = [:zero]
|
9
|
-
SUITS = [:red, :green, :blue, :yellow]
|
10
|
-
SPECIALS = [ :wild, :wild_draw_four]
|
11
|
-
SPECIAL_SUITS = [:black]
|
12
|
-
|
13
|
-
def initialize()
|
14
|
-
@cards = Array.new()
|
15
|
-
2.times { @cards += create_cards(SUITS, RANKS) }
|
16
|
-
@cards += create_cards(SUITS, ZERO)
|
17
|
-
4.times { @cards += create_cards(SPECIAL_SUITS, SPECIALS)}
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/spec/canasta_deck_spec.rb
DELETED
data/spec/card_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'cardshark/card'
|
2
|
-
|
3
|
-
describe Cardshark::Card do
|
4
|
-
before :all do
|
5
|
-
@card = Cardshark::Card.new(:rank => :K, :suit => :H)
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'has a rank' do
|
9
|
-
@card.rank.should == :K
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'has a suit' do
|
13
|
-
@card.suit.should == :H
|
14
|
-
end
|
15
|
-
end
|
data/spec/deck_spec.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'cardshark/deck'
|
2
|
-
|
3
|
-
describe Cardshark::Deck do
|
4
|
-
#define a simple deck for testing basic functionality of the module
|
5
|
-
module Cardshark
|
6
|
-
class SimpleDeck
|
7
|
-
include Deck
|
8
|
-
def initialize
|
9
|
-
@cards = Array.new
|
10
|
-
for i in 1..10 do
|
11
|
-
@cards.push Card.new(:rank => i, :suit => :anything)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
before :each do
|
18
|
-
@simple = Cardshark::SimpleDeck.new
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should contain 10 cards' do
|
22
|
-
@simple.size.should == 10
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should not be shuffled' do
|
26
|
-
@simple.shuffled?.should == false
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should be in order' do
|
30
|
-
for i in 0..9 do
|
31
|
-
@simple.cards[i].rank.should == i+1
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should be shuffled' do
|
36
|
-
@simple.shuffle!
|
37
|
-
@simple.shuffled?.should == true
|
38
|
-
end
|
39
|
-
end
|