pokerstats 2.0.1
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.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/bin/checkps +190 -0
- data/generators/pokerstats/USAGE +1 -0
- data/generators/pokerstats/pokerstats_generator.rb +7 -0
- data/generators/pokerstats/templates/create_pokerstats.rhtml +28 -0
- data/lib/pokerstats.rb +2 -0
- data/lib/pokerstats/.gitignore +0 -0
- data/lib/pokerstats/hand_constants.rb +27 -0
- data/lib/pokerstats/hand_history.rb +38 -0
- data/lib/pokerstats/hand_statistics.rb +225 -0
- data/lib/pokerstats/hand_statistics_api.rb +64 -0
- data/lib/pokerstats/player_statistics.rb +58 -0
- data/lib/pokerstats/plugins/aggression_statistics.rb +57 -0
- data/lib/pokerstats/plugins/blind_attack_statistics.rb +78 -0
- data/lib/pokerstats/plugins/cash_statistics.rb +95 -0
- data/lib/pokerstats/plugins/continuation_bet_statistics.rb +68 -0
- data/lib/pokerstats/plugins/preflop_raise_statistics.rb +50 -0
- data/lib/pokerstats/poker-edge.rb +57 -0
- data/lib/pokerstats/pokerstars_file.rb +100 -0
- data/lib/pokerstats/pokerstars_hand_history_parser.rb +141 -0
- data/pokerstats.gemspec +91 -0
- data/spec/file_empty.txt +0 -0
- data/spec/file_many_hands.txt +564 -0
- data/spec/file_one_hand.txt +52 -0
- data/spec/hand_statistics_spec.rb +846 -0
- data/spec/hand_statistics_spec_helper.rb +89 -0
- data/spec/player_statistics_spec.rb +230 -0
- data/spec/pokerstars_file_spec.rb +160 -0
- data/spec/pokerstars_hand_history_parser_spec.rb +197 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/zpokerstars_hand_history_parser_integration.rb.txt +67 -0
- metadata +125 -0
@@ -0,0 +1,197 @@
|
|
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
|
+
include Pokerstats
|
11
|
+
|
12
|
+
include HandConstants
|
13
|
+
|
14
|
+
describe PokerstarsHandHistoryParser, "recognizes valid hand history" do
|
15
|
+
it "should recognize a valid tournament hand history" do
|
16
|
+
first_line = "PokerStars Game #21650436825: Tournament #117620218, $10+$1 Hold'em No Limit - Level I (10/20) - 2008/10/31 17:25:42 ET"
|
17
|
+
PokerstarsHandHistoryParser.game(first_line).should == "PS21650436825"
|
18
|
+
end
|
19
|
+
it "should recognize a valid cash game hand history" do
|
20
|
+
first_line = "PokerStars Game #21650146783: Hold'em No Limit ($0.25/$0.50) - 2008/10/31 17:14:44 ET"
|
21
|
+
PokerstarsHandHistoryParser.game(first_line).should == "PS21650146783"
|
22
|
+
end
|
23
|
+
it "should reject an invalid hand history" do
|
24
|
+
PokerstarsHandHistoryParser.game("an invalid hand history")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe PokerstarsHandHistoryParser, "when parsing structural matter" do
|
29
|
+
before :each do
|
30
|
+
@stats = HandStatistics.new
|
31
|
+
@parser = PokerstarsHandHistoryParser.new(@stats)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should parse a tournament header" do
|
35
|
+
@stats.should_receive(:update_hand).with(
|
36
|
+
:name => "PS21650436825",
|
37
|
+
:description => "117620218, $10+$1 Hold'em No Limit",
|
38
|
+
:sb => "10".to_d,
|
39
|
+
:bb => "20".to_d,
|
40
|
+
:played_at => Time.parse("2008/10/31 17:25:42 ET"),
|
41
|
+
:tournament => "117620218",
|
42
|
+
:street => :prelude
|
43
|
+
)
|
44
|
+
@parser.parse("PokerStars Game #21650436825: Tournament #117620218, $10+$1 Hold'em No Limit - Level I (10/20) - 2008/10/31 17:25:42 ET")
|
45
|
+
puts @stats.report_hand_information
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should recognize a tournament header" do
|
49
|
+
PokerstarsHandHistoryParser.should have_valid_header("PokerStars Game #21650436825: Tournament #117620218, $10+$1 Hold'em No Limit - Level I (10/20) - 2008/10/31 17:25:42 ET\nsnuggles\n")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should parse a cash game header" do
|
53
|
+
@stats.should_receive(:update_hand).with(
|
54
|
+
:name => 'PS21650146783',
|
55
|
+
:description => "Hold'em No Limit ($0.25/$0.50)",
|
56
|
+
:sb => "0.25".to_d,
|
57
|
+
:bb => "0.50".to_d,
|
58
|
+
:played_at => Time.parse("2008/10/31 17:14:44 ET"),
|
59
|
+
:tournament => nil,
|
60
|
+
:street => :prelude
|
61
|
+
)
|
62
|
+
@parser.parse("PokerStars Game #21650146783: Hold'em No Limit ($0.25/$0.50) - 2008/10/31 17:14:44 ET")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should recognize a cash game header" do
|
66
|
+
PokerstarsHandHistoryParser.should have_valid_header("PokerStars Game #21650146783: Hold'em No Limit ($0.25/$0.50) - 2008/10/31 17:14:44 ET\nsnuggles\n")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should not recognize an invalid header" do
|
70
|
+
PokerstarsHandHistoryParser.should_not have_valid_header("I will love you to the end of the earth\nNow and Forever\nEver Always,\nYour Andrew")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should parse a hole card header" do
|
74
|
+
@stats.should_receive(:update_hand).with(:street => :preflop)
|
75
|
+
@parser.parse("*** HOLE CARDS ***")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should parse a flop header" do
|
79
|
+
@stats.should_receive(:update_hand).with(:street => :flop)
|
80
|
+
@parser.parse("*** FLOP *** [5c 2d Jh]")
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should parse a turn header" do
|
84
|
+
@stats.should_receive(:update_hand).with(:street => :turn)
|
85
|
+
@parser.parse("*** TURN *** [5c 2d Jh] [4c]")
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should parse a river header" do
|
89
|
+
@stats.should_receive(:update_hand).with(:street => :river)
|
90
|
+
@parser.parse("*** RIVER *** [5c 2d Jh 4c] [5h]")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should parse a showdown header" do
|
94
|
+
@stats.should_receive(:update_hand).with(:street => :showdown)
|
95
|
+
@parser.parse("*** SHOW DOWN *** [5c 2d Jh 4c] [5h]")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should parse a summary header" do
|
99
|
+
@stats.should_receive(:update_hand).with(:street => :summary)
|
100
|
+
@parser.parse("*** SUMMARY *** [5c 2d Jh 4c] [5h]")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should parse a 'dealt to' header" do
|
104
|
+
@stats.should_receive(:register_action).with('wizardwerdna', 'dealt', :result => :cards, :data => "2s Th")
|
105
|
+
@parser.parse("Dealt to wizardwerdna [2s Th]")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should parse a 'Total pot' card header" do
|
109
|
+
@stats.should_receive(:update_hand).with(:total_pot => "10.75".to_d, :rake => "0.50".to_d)
|
110
|
+
@parser.parse("Total pot $10.75 | Rake $0.50")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should parse a board header" do
|
114
|
+
@stats.should_receive(:update_hand).with(:board => "5c 2d Jh 4c 5h")
|
115
|
+
@parser.parse("Board [5c 2d Jh 4c 5h]")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
describe PokerstarsHandHistoryParser, "when parsing prelude matter" do
|
121
|
+
before :each do
|
122
|
+
@stats = HandStatistics.new
|
123
|
+
@parser = PokerstarsHandHistoryParser.new(@stats)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should parse a tournament button line" do
|
127
|
+
@stats.should_receive(:register_button).with(6)
|
128
|
+
@parser.parse("Table '117620218 1' 9-max Seat #6 is the button")
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should parse a cash game button line" do
|
132
|
+
@stats.should_receive(:register_button).with(2)
|
133
|
+
@parser.parse("Table 'Charybdis IV' 9-max Seat #2 is the button")
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should parse a player line" do
|
137
|
+
@stats.should_receive(:register_player).with(:screen_name => 'BadBeat_Brat', :seat => 3)
|
138
|
+
@parser.parse("Seat 3: BadBeat_Brat (1500 in chips)")
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should parse a player line with accents" do
|
142
|
+
@stats.should_receive(:register_player).with(:screen_name => 'Gwünni', :seat => 8)
|
143
|
+
@parser.parse("Seat 8: Gwünni (3000 in chips)")
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should parse a small blind header and register the corresponding action" do
|
147
|
+
@stats.should_receive(:register_action).with("Hoggsnake", 'posts', :result => :post, :amount => "10".to_d)
|
148
|
+
@parser.parse("Hoggsnake: posts small blind 10")
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should parse a big blind header and register the corresponding action" do
|
152
|
+
@stats.should_receive(:register_action).with("BadBeat_Brat", 'posts', :result => :post, :amount => "20".to_d)
|
153
|
+
@parser.parse("BadBeat_Brat: posts big blind 20")
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should parse an ante header and register the corresponding action" do
|
157
|
+
@stats.should_receive(:register_action).with("BadBeat_Brat", 'antes', :result => :post, :amount => "15".to_d)
|
158
|
+
@parser.parse("BadBeat_Brat: posts the ante 15")
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe PokerstarsHandHistoryParser, "when parsing poker actions" do
|
163
|
+
before :each do
|
164
|
+
@stats = HandStatistics.new
|
165
|
+
@parser = PokerstarsHandHistoryParser.new(@stats)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should properly parse and register a fold" do
|
169
|
+
@stats.should_receive(:register_action).with("Gwünni", "folds", :result => :neutral)
|
170
|
+
@parser.parse("Gwünni: folds")
|
171
|
+
end
|
172
|
+
it "should properly parse and register a check" do
|
173
|
+
@stats.should_receive(:register_action).with("billy", "checks", :result => :neutral)
|
174
|
+
@parser.parse("billy: checks")
|
175
|
+
end
|
176
|
+
it "should properly parse and register a call" do
|
177
|
+
@stats.should_receive(:register_action).with("billy", "calls", :result => :pay, :amount => "1.25".to_d)
|
178
|
+
@parser.parse("billy: calls $1.25")
|
179
|
+
end
|
180
|
+
it "should properly parse and register a bet" do
|
181
|
+
@stats.should_receive(:register_action).with("billy", "bets", :result => :pay, :amount => "1.20".to_d)
|
182
|
+
@parser.parse("billy: bets $1.20")
|
183
|
+
end
|
184
|
+
it "should properly parse and register a raise" do
|
185
|
+
@stats.should_receive(:register_action).with("billy", "raises", :result => :pay_to, :amount => "1.23".to_d)
|
186
|
+
@parser.parse("billy: raises $1 to $1.23")
|
187
|
+
end
|
188
|
+
it "should properly parse and register a return" do
|
189
|
+
@stats.should_receive(:register_action).with("billy", "return", :result => :win, :amount => "1.50".to_d)
|
190
|
+
@parser.parse("Uncalled bet ($1.50) returned to billy")
|
191
|
+
end
|
192
|
+
it "should properly parse and register a collection" do
|
193
|
+
@stats.should_receive(:register_action).with("billy", "wins", :result => :win, :amount => "1.90".to_d)
|
194
|
+
@parser.parse("billy collected $1.90 from pot")
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -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
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pokerstats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew C. Greenberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-09 00:00:00 -07:00
|
13
|
+
default_executable: checkps
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: wizardwerdna-pluggable
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: wizardwerdna-pluggable
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: a library for extracting, computing and reporting statistics of poker hands parsed from hand history files
|
46
|
+
email: wizardwerdna@gmail.com
|
47
|
+
executables:
|
48
|
+
- checkps
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- .document
|
56
|
+
- .gitignore
|
57
|
+
- LICENSE
|
58
|
+
- README.rdoc
|
59
|
+
- Rakefile
|
60
|
+
- VERSION
|
61
|
+
- bin/checkps
|
62
|
+
- generators/pokerstats/USAGE
|
63
|
+
- generators/pokerstats/pokerstats_generator.rb
|
64
|
+
- generators/pokerstats/templates/create_pokerstats.rhtml
|
65
|
+
- lib/pokerstats.rb
|
66
|
+
- lib/pokerstats/.gitignore
|
67
|
+
- lib/pokerstats/hand_constants.rb
|
68
|
+
- lib/pokerstats/hand_history.rb
|
69
|
+
- lib/pokerstats/hand_statistics.rb
|
70
|
+
- lib/pokerstats/hand_statistics_api.rb
|
71
|
+
- lib/pokerstats/player_statistics.rb
|
72
|
+
- lib/pokerstats/plugins/aggression_statistics.rb
|
73
|
+
- lib/pokerstats/plugins/blind_attack_statistics.rb
|
74
|
+
- lib/pokerstats/plugins/cash_statistics.rb
|
75
|
+
- lib/pokerstats/plugins/continuation_bet_statistics.rb
|
76
|
+
- lib/pokerstats/plugins/preflop_raise_statistics.rb
|
77
|
+
- lib/pokerstats/poker-edge.rb
|
78
|
+
- lib/pokerstats/pokerstars_file.rb
|
79
|
+
- lib/pokerstats/pokerstars_hand_history_parser.rb
|
80
|
+
- pokerstats.gemspec
|
81
|
+
- spec/file_empty.txt
|
82
|
+
- spec/file_many_hands.txt
|
83
|
+
- spec/file_one_hand.txt
|
84
|
+
- spec/hand_statistics_spec.rb
|
85
|
+
- spec/hand_statistics_spec_helper.rb
|
86
|
+
- spec/player_statistics_spec.rb
|
87
|
+
- spec/pokerstars_file_spec.rb
|
88
|
+
- spec/pokerstars_hand_history_parser_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/zpokerstars_hand_history_parser_integration.rb.txt
|
91
|
+
has_rdoc: true
|
92
|
+
homepage: http://github.com/wizardwerdna/pokerstats
|
93
|
+
licenses: []
|
94
|
+
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options:
|
97
|
+
- --charset=UTF-8
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: "0"
|
105
|
+
version:
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: "0"
|
111
|
+
version:
|
112
|
+
requirements: []
|
113
|
+
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 1.3.5
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: poker hand history statistics library
|
119
|
+
test_files:
|
120
|
+
- spec/hand_statistics_spec.rb
|
121
|
+
- spec/hand_statistics_spec_helper.rb
|
122
|
+
- spec/player_statistics_spec.rb
|
123
|
+
- spec/pokerstars_file_spec.rb
|
124
|
+
- spec/pokerstars_hand_history_parser_spec.rb
|
125
|
+
- spec/spec_helper.rb
|