ruby-poker 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -16,4 +16,9 @@
16
16
  * Finally wrote the Unit Tests suite
17
17
  2008-02-08 (0.2.1)
18
18
  * Cards can be added to a hand after it is created by using (<<) on a PokerHand
19
- * Cards can be deleted from a hand with PokerHand.delete()
19
+ * Cards can be deleted from a hand with PokerHand.delete()
20
+ 2008-04-06 (0.2.2)
21
+ * Fixed bug where two hands that had the same values but different suits returned not equal
22
+ 2008-04-20 (0.2.4)
23
+ * Modernized the Rakefile
24
+ * Updated to be compatible with Ruby 1.9
data/README CHANGED
@@ -13,11 +13,11 @@ terms of the BSD license. See LICENSE for more details.
13
13
 
14
14
  The latest version of <b>ruby poker</b> can be found at
15
15
 
16
- * http://rubyforge.org/frs/?group_id=5257
16
+ http://rubyforge.org/frs/?group_id=5257
17
17
 
18
18
  The homepage of this project is located at
19
19
 
20
- * http://rubyforge.org/projects/rubypoker
20
+ http://rubyforge.org/projects/rubypoker
21
21
 
22
22
  == Description
23
23
 
@@ -43,6 +43,6 @@ In this section some examples show what can be done with this class.
43
43
 
44
44
  == Background
45
45
 
46
- I (Robert Olson) wrote all of the code in the original version of ruby-poker which limited
47
- hands to only 5 cards. As of the 0.2.0 release ruby-poker is based on Patrick Hurley's
48
- Texas Holdem code from http://rubyquiz.com/quiz24.html which I merged into ruby-poker.
46
+ The original version of ruby-poker was written entirely by myself (Robert Olson).
47
+ As of the 0.2.0 release ruby-poker incorporates Patrick Hurley's Texas
48
+ Holdem code from http://rubyquiz.com/quiz24.html which I merged into ruby-poker.
data/Rakefile ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Gem::manage_gems
4
+ require 'rake/rdoctask'
5
+ require "rake/testtask"
6
+ require 'rake/gempackagetask'
7
+
8
+ begin
9
+ require "rubygems"
10
+ rescue LoadError
11
+ nil
12
+ end
13
+
14
+ RUBYPOKER_VERSION = "0.2.4"
15
+
16
+ task :default => [:test]
17
+
18
+ spec = Gem::Specification::new do |s|
19
+ s.name = "ruby-poker"
20
+ s.summary = "Ruby library for comparing poker hands and determining the winner."
21
+ s.version = RUBYPOKER_VERSION
22
+
23
+ s.rubyforge_project = "rubypoker"
24
+ s.platform = Gem::Platform::RUBY
25
+
26
+ s.files = Dir.glob("{examples,lib,test}/**/**/*") + ["Rakefile"]
27
+ s.require_path = "lib"
28
+
29
+ s.has_rdoc = true
30
+ s.extra_rdoc_files = ["README", "CHANGELOG", "LICENSE"]
31
+ s.rdoc_options << '--title' << 'Ruby Poker Documentation' <<
32
+ '--main' << 'README' <<
33
+ '--inline-source' << '-q'
34
+
35
+ s.test_files = Dir.glob("test/*.rb")
36
+
37
+ s.author = "Robert Olson"
38
+ s.email = "rko618@gmail.com"
39
+ s.homepage = "http://rubyforge.org/projects/rubypoker/"
40
+ end
41
+
42
+ Rake::GemPackageTask.new(spec) do |pkg|
43
+ pkg.need_tar = true
44
+ end
45
+
46
+ Rake::TestTask.new do |test|
47
+ test.libs << "test"
48
+ test.test_files = Dir[ "test/test_*.rb" ]
49
+ test.verbose = true
50
+ end
51
+
52
+ desc "Start autotest"
53
+ task :autotest do
54
+ ruby "-I lib -w /usr/bin/autotest"
55
+ end
56
+
57
+ desc "Create Zentest tests"
58
+ task :zentest do
59
+ `zentest card.rb test_card.rb > test_card_2.rb`
60
+ `zentest ruby-poker.rb test_poker_hand.rb > test_poker_hand_2.rb`
61
+ end
62
+
63
+ Rake::RDocTask.new(:rdoc) do |rdoc|
64
+ rdoc.rdoc_files.include('README', 'CHANGELOG', 'LICENSE', 'lib/')
65
+ rdoc.main = 'README'
66
+ rdoc.rdoc_dir = 'doc/html'
67
+ rdoc.title = 'Ruby Poker Documentation'
68
+ rdoc.options << '--all' << '--inline-source'
69
+ end
data/lib/ruby-poker.rb CHANGED
@@ -269,10 +269,10 @@ class PokerHand
269
269
  # hand << "6s" # => Add a six of spades to the hand by passing a string
270
270
  # hand << ["7h", "8d"] # => Add multiple cards to the hand using an array
271
271
  def << new_cards
272
- # If they only passed one card we need to place it in an array for processing
273
- new_cards = [new_cards] if new_cards.is_a?(Card)
272
+ if new_cards.is_a?(Card) || new_cards.is_a?(String)
273
+ new_cards = [new_cards]
274
+ end
274
275
 
275
- # luckily .each behaves nicely regardless of whether new_cards is a string or array
276
276
  new_cards.each do |nc|
277
277
  @hand << Card.new(nc)
278
278
  end
@@ -128,7 +128,9 @@ class TestPokerHand < Test::Unit::TestCase
128
128
  def test_appending
129
129
  ph = PokerHand.new()
130
130
  ph << "Qd"
131
- assert_equal("Qd", ph.just_cards)
131
+ ph << Card.new("2D")
132
+ ph << ["3d", "4d"]
133
+ assert_equal("Qd 2d 3d 4d", ph.just_cards)
132
134
  end
133
135
 
134
136
  def test_delete
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-poker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Olson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-06 00:00:00 -07:00
12
+ date: 2008-04-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,14 +30,20 @@ files:
30
30
  - lib/ruby-poker.rb
31
31
  - test/test_card.rb
32
32
  - test/test_poker_hand.rb
33
+ - Rakefile
33
34
  - README
34
35
  - CHANGELOG
35
36
  - LICENSE
36
37
  has_rdoc: true
37
38
  homepage: http://rubyforge.org/projects/rubypoker/
38
39
  post_install_message:
39
- rdoc_options: []
40
-
40
+ rdoc_options:
41
+ - --title
42
+ - Ruby Poker Documentation
43
+ - --main
44
+ - README
45
+ - --inline-source
46
+ - -q
41
47
  require_paths:
42
48
  - lib
43
49
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -55,10 +61,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
61
  requirements: []
56
62
 
57
63
  rubyforge_project: rubypoker
58
- rubygems_version: 1.1.0
64
+ rubygems_version: 1.1.1
59
65
  signing_key:
60
66
  specification_version: 2
61
- summary: Ruby library for determining the winner in a game of poker.
67
+ summary: Ruby library for comparing poker hands and determining the winner.
62
68
  test_files:
63
69
  - test/test_card.rb
64
70
  - test/test_poker_hand.rb