wizardwerdna-pokerstats 1.0.15 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/pokerstats/hand_statistics.rb +3 -1
- data/pokerstats.gemspec +3 -2
- data/spec/hand_statistics_spec.rb +29 -10
- data/spec/zpokerstars_hand_history_parser_integration.rb.txt +67 -0
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.16
|
@@ -26,7 +26,9 @@ module Pokerstats
|
|
26
26
|
|
27
27
|
def hand_record
|
28
28
|
raise "#{HAND_RECORD_INCOMPLETE_MESSAGE}: #{(HAND_INFORMATION_KEYS - @hand_information.keys).inspect}" unless (HAND_INFORMATION_KEYS - @hand_information.keys).empty?
|
29
|
-
|
29
|
+
HAND_INFORMATION_KEYS.inject({}) do |hash, key|
|
30
|
+
hash.merge!(key => @hand_information[key])
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
def update_hand update
|
data/pokerstats.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pokerstats}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andrew C. Greenberg"]
|
@@ -53,7 +53,8 @@ Gem::Specification.new do |s|
|
|
53
53
|
"spec/player_statistics_spec.rb",
|
54
54
|
"spec/pokerstars_file_spec.rb",
|
55
55
|
"spec/pokerstars_hand_history_parser.rb",
|
56
|
-
"spec/spec_helper.rb"
|
56
|
+
"spec/spec_helper.rb",
|
57
|
+
"spec/zpokerstars_hand_history_parser_integration.rb.txt"
|
57
58
|
]
|
58
59
|
s.homepage = %q{http://github.com/wizardwerdna/pokerstats}
|
59
60
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -6,6 +6,23 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_stati
|
|
6
6
|
include Pokerstats
|
7
7
|
require File.expand_path(File.dirname(__FILE__) + '/hand_statistics_spec_helper')
|
8
8
|
|
9
|
+
|
10
|
+
Spec::Matchers.define :have_all_and_only_keys do |keylist|
|
11
|
+
match do |hash|
|
12
|
+
hashkeys = hash.keys
|
13
|
+
hashkeys.size == keylist.size && hash.keys.all?{|each_key| keylist.include? each_key}
|
14
|
+
end
|
15
|
+
failure_message_for_should do |hash|
|
16
|
+
"missing keys: #{(keylist - hash.keys).inspect}, extra keys: #{(hash.keys - keylist).inspect}"
|
17
|
+
end
|
18
|
+
failure_message_for_should_not do |hash|
|
19
|
+
"the keys (#{hash.keys.inspect}) are all the same"
|
20
|
+
end
|
21
|
+
description do
|
22
|
+
"have all and only the specified keys"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
9
26
|
describe HandStatistics, "when created" do
|
10
27
|
before(:each) do
|
11
28
|
@stats = HandStatistics.new
|
@@ -14,30 +31,32 @@ describe HandStatistics, "when created" do
|
|
14
31
|
@stats.should have(0).players
|
15
32
|
end
|
16
33
|
|
17
|
-
it "should properly
|
34
|
+
it "should properly chain updates of hand record information" do
|
18
35
|
sample_hand.each{|key, value| @stats.update_hand(key => value)}
|
19
36
|
@stats.hand_record.should == sample_hand
|
20
37
|
end
|
21
38
|
|
22
|
-
it "should properly chain hand record information updates" do
|
23
|
-
sample_hand.each{|key, value| @stats.update_hand(key => value)}
|
24
|
-
@stats.update_hand(:test => :foo)
|
25
|
-
@stats.hand_record.should.should == sample_hand.update(:test => :foo)
|
26
|
-
end
|
27
|
-
|
28
39
|
it "should not complain when asked to generate hand record with all HAND_INFORMATION_KEYS filled out" do
|
29
|
-
|
40
|
+
@stats.update_hand(sample_hand)
|
41
|
+
lambda{@stats.hand_record}.should_not raise_error(/#{HAND_RECORD_INCOMPLETE_MESSAGE}/)
|
30
42
|
end
|
31
|
-
|
43
|
+
|
32
44
|
it "should complain when asked to generate hand record if no information is given" do
|
33
45
|
lambda{@stats.hand_record}.should raise_error(/#{HAND_RECORD_INCOMPLETE_MESSAGE}/)
|
34
46
|
end
|
35
47
|
|
36
48
|
HandStatistics::HAND_INFORMATION_KEYS.each do |thing|
|
37
49
|
it "should complain when asked to generate hand record without a #{thing.to_s}" do
|
38
|
-
|
50
|
+
@stats.update_hand(sample_hand.except(thing))
|
51
|
+
lambda{@stats.hand_record}.should raise_error(/#{HAND_RECORD_INCOMPLETE_MESSAGE}/)
|
39
52
|
end
|
40
53
|
end
|
54
|
+
|
55
|
+
it "should not produce hand records having extra keys" do
|
56
|
+
@stats.update_hand(sample_hand)
|
57
|
+
@stats.update_hand(:street => :river)
|
58
|
+
@stats.hand_record.should have_all_and_only_keys HAND_INFORMATION_KEYS
|
59
|
+
end
|
41
60
|
end
|
42
61
|
|
43
62
|
describe HandStatistics, "when registering game activity" do
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
# require 'activesupport'
|
3
|
+
# require 'bigdecimal'
|
4
|
+
# require 'bigdecimal/util'
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_history')
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_statistics')
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/pokerstars_file')
|
9
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/pokerstars_hand_history_parser')
|
10
|
+
|
11
|
+
include Pokerstats
|
12
|
+
include HandConstants
|
13
|
+
|
14
|
+
# describe PokerstarsHandHistoryParser, "when parsing PokerstarsFile" do
|
15
|
+
# before :each do
|
16
|
+
# @psfile = PokerstarsFile.open(File.dirname(__FILE__) + '/file_many_hands.txt')
|
17
|
+
# @expanded_path = File.expand_path(File.dirname(__FILE__) + '/file_many_hands.txt')
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# it "should parse every line of every entry in the file" do
|
21
|
+
# @psfile.entries.each do |handrecord|
|
22
|
+
# lambda{handrecord.parse}.should_not raise_error
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
describe PokerstarsHandHistoryParser, "when parsing all the PokerstarsFiles in Andy's directory" do
|
28
|
+
before :each do
|
29
|
+
@filenames = Dir["/Users/werdna/Library/Application Support/Pokerstars/HandHistory/**/*.txt"]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should parse every line of every entry in the file" do
|
33
|
+
times = 10
|
34
|
+
@filenames.each do |filename|
|
35
|
+
puts "====== #{filename} ====="
|
36
|
+
@psfile = PokerstarsFile.open(filename).entries.each do |handrecord|
|
37
|
+
printf(".")
|
38
|
+
lambda{handrecord.parse}.should_not raise_error
|
39
|
+
end
|
40
|
+
printf("\n")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# describe PokerstarsHandHistoryParser, "when parsing all the PokerstarsFiles in Judi's directory" do
|
46
|
+
# before :each do
|
47
|
+
# @filenames = Dir["/Users/werdna/juditest/*.txt"]
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# it "should parse every line of every entry in the file" do
|
51
|
+
# times = 10
|
52
|
+
# @filenames.each do |filename|
|
53
|
+
# puts "====== #{filename} ====="
|
54
|
+
# @psfile = PokerstarsFile.open(filename).entries.each do |handrecord|
|
55
|
+
# @stats = HandStatistics.new
|
56
|
+
# @parser = PokerstarsHandHistoryParser.new(@stats)
|
57
|
+
# # puts handrecord.lines.first
|
58
|
+
# printf(".")
|
59
|
+
# handrecord.lines.each do |line|
|
60
|
+
# lambda{@parser.parse(line)}.should_not raise_error
|
61
|
+
# end
|
62
|
+
# # @stats.debug_display
|
63
|
+
# end
|
64
|
+
# printf("\n")
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
# end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wizardwerdna-pokerstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew C. Greenberg
|
@@ -87,8 +87,10 @@ files:
|
|
87
87
|
- spec/pokerstars_file_spec.rb
|
88
88
|
- spec/pokerstars_hand_history_parser.rb
|
89
89
|
- spec/spec_helper.rb
|
90
|
+
- spec/zpokerstars_hand_history_parser_integration.rb.txt
|
90
91
|
has_rdoc: false
|
91
92
|
homepage: http://github.com/wizardwerdna/pokerstats
|
93
|
+
licenses:
|
92
94
|
post_install_message:
|
93
95
|
rdoc_options:
|
94
96
|
- --charset=UTF-8
|
@@ -109,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
111
|
requirements: []
|
110
112
|
|
111
113
|
rubyforge_project:
|
112
|
-
rubygems_version: 1.
|
114
|
+
rubygems_version: 1.3.5
|
113
115
|
signing_key:
|
114
116
|
specification_version: 3
|
115
117
|
summary: poker hand history statistics library
|