pokerstats 2.0.13 → 2.0.14

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.
@@ -10,20 +10,28 @@ module HandStatisticsFactories
10
10
  :starting_at => Time.now,
11
11
  :name => "PS0001",
12
12
  :description => "This is a description",
13
+ :table_name => "foobie-doobie III",
14
+ :max_players => 6,
15
+ :number_players => 6,
13
16
  :sb => "1.00".to_d,
14
17
  :bb => "2.00".to_d,
18
+ :ante => "0.50".to_d,
15
19
  :board => "AS KS QS JS TS",
16
20
  :total_pot => "100.00".to_d,
17
21
  :rake => "4.00".to_d,
18
22
  :played_at => Time.now,
19
- :tournament => "T123"
23
+ :tournament => "T123",
24
+ :game_type => "Hold'em",
25
+ :limit_type => "No Limit",
26
+ :stakes_type => "25".to_d
20
27
  }
21
28
  end
22
29
 
23
30
  def sample_player
24
31
  @@sample_player_result ||= {
25
32
  :screen_name => 'sample_player_screen_name',
26
- :seat => 1
33
+ :seat => 1,
34
+ :starting_stack => 10
27
35
  }
28
36
  end
29
37
 
@@ -84,6 +92,9 @@ module HandStatisticsFactories
84
92
 
85
93
  def register_cards(player, data, hash={})
86
94
  @stats.register_action player[:screen_name], 'shows', hash.merge(:result => :cards, :data => data)
87
- end
95
+ end
96
+ def register_muck(player, hash={})
97
+ @stats.register_action player[:screen_name], 'mucks', hash.merge(:result => :neutral)
98
+ end
88
99
  end
89
100
  include HandStatisticsFactories
@@ -10,6 +10,45 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/pokerstars
10
10
  include Pokerstats
11
11
  include HandConstants
12
12
 
13
+
14
+ describe PokerstarsTimeStringConverter do
15
+ context "when first created" do
16
+ it "should not reject valid pokerstars time strings" do
17
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 UTC")}.should_not raise_error
18
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 PT")}.should_not raise_error
19
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 MT")}.should_not raise_error
20
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 CT")}.should_not raise_error
21
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 ET")}.should_not raise_error
22
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 AT")}.should_not raise_error
23
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 BRT")}.should_not raise_error
24
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 WET")}.should_not raise_error
25
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 CET")}.should_not raise_error
26
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 EET")}.should_not raise_error
27
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 MSK")}.should_not raise_error
28
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 CCT")}.should_not raise_error
29
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 JST")}.should_not raise_error
30
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 AWST")}.should_not raise_error
31
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 ACST")}.should_not raise_error
32
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 AEST")}.should_not raise_error
33
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 NZT")}.should_not raise_error
34
+ end
35
+
36
+ it "should reject invalid pokerstars time strings" do
37
+ lambda {PokerstarsTimeStringConverter.new("2008/10/31 17:25:42 XX")}.should raise_error(ArgumentError)
38
+ end
39
+ end
40
+
41
+ context "when converting a pokerstars time string string" do
42
+ it "returns the correct utc dateime for eastern daylight time" do
43
+ PokerstarsTimeStringConverter.new("2008/7/30 17:25:42 ET").as_utc_datetime.should == DateTime.parse("2008/7/30 17:25:42 EDT")
44
+ end
45
+
46
+ it "returns the correct utc result for eastern standard time" do
47
+ PokerstarsTimeStringConverter.new("2008/01/30 17:25:42 ET").as_utc_datetime.should == DateTime.parse("2008/01/30 17:25:42 EST")
48
+ end
49
+ end
50
+ end
51
+
13
52
  describe PokerstarsHandHistoryParser, "recognizes valid hand history" do
14
53
  it "should recognize a valid tournament hand history" do
15
54
  first_line = "PokerStars Game #21650436825: Tournament #117620218, $10+$1 Hold'em No Limit - Level I (10/20) - 2008/10/31 17:25:42 ET"
@@ -34,12 +73,19 @@ describe PokerstarsHandHistoryParser, "when parsing structural matter" do
34
73
  @stats.should_receive(:update_hand).with(
35
74
  :name => "PS21650436825",
36
75
  :description => "117620218, $10+$1 Hold'em No Limit",
76
+ :ante => "0.0".to_d,
77
+ :table_name => "",
78
+ :max_players => 0,
79
+ :number_players => 0,
37
80
  :sb => "10".to_d,
38
81
  :bb => "20".to_d,
39
- :played_at => Time.parse("2008/10/31 17:25:42 ET"),
82
+ :played_at => DateTime.parse("2008/10/31 17:25:42 EDT"),
40
83
  :tournament => "117620218",
41
84
  :street => :prelude,
42
- :board => "" # due to pokerstars hand history bug (does not have Board record unless flop is seen)
85
+ :board => "",
86
+ :game_type => "Hold'em",
87
+ :stakes_type => "10".to_d,
88
+ :limit_type => "No Limit"
43
89
  )
44
90
  @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
91
  end
@@ -52,12 +98,19 @@ describe PokerstarsHandHistoryParser, "when parsing structural matter" do
52
98
  @stats.should_receive(:update_hand).with(
53
99
  :name => 'PS21650146783',
54
100
  :description => "Hold'em No Limit ($0.25/$0.50)",
101
+ :ante => "0.00".to_d,
102
+ :table_name => "",
103
+ :max_players => 0,
104
+ :number_players => 0,
55
105
  :sb => "0.25".to_d,
56
106
  :bb => "0.50".to_d,
57
- :played_at => Time.parse("2008/10/31 17:14:44 ET"),
107
+ :played_at => DateTime.parse("2008/10/31 17:14:44 EDT"),
58
108
  :tournament => nil,
59
109
  :street => :prelude,
60
- :board => "" # due to pokerstars hand history bug
110
+ :board => "", # due to pokerstars hand history bug
111
+ :game_type => "Hold'em",
112
+ :stakes_type => "0.50".to_d,
113
+ :limit_type => "No Limit"
61
114
  )
62
115
  @parser.parse("PokerStars Game #21650146783: Hold'em No Limit ($0.25/$0.50) - 2008/10/31 17:14:44 ET")
63
116
  end
@@ -125,21 +178,23 @@ describe PokerstarsHandHistoryParser, "when parsing prelude matter" do
125
178
 
126
179
  it "should parse a tournament button line" do
127
180
  @stats.should_receive(:register_button).with(6)
181
+ @stats.should_receive(:update_hand).with(:max_players => 9, :table_name => '117620218 1')
128
182
  @parser.parse("Table '117620218 1' 9-max Seat #6 is the button")
129
183
  end
130
184
 
131
185
  it "should parse a cash game button line" do
132
186
  @stats.should_receive(:register_button).with(2)
133
- @parser.parse("Table 'Charybdis IV' 9-max Seat #2 is the button")
187
+ @stats.should_receive(:update_hand).with(:max_players => 6, :table_name => 'Charybdis IV')
188
+ @parser.parse("Table 'Charybdis IV' 6-max Seat #2 is the button")
134
189
  end
135
190
 
136
191
  it "should parse a player line" do
137
- @stats.should_receive(:register_player).with(:screen_name => 'BadBeat_Brat', :seat => 3)
192
+ @stats.should_receive(:register_player).with(:screen_name => 'BadBeat_Brat', :seat => 3, :starting_stack => "1500".to_d)
138
193
  @parser.parse("Seat 3: BadBeat_Brat (1500 in chips)")
139
194
  end
140
195
 
141
196
  it "should parse a player line with accents" do
142
- @stats.should_receive(:register_player).with(:screen_name => 'Gwünni', :seat => 8)
197
+ @stats.should_receive(:register_player).with(:screen_name => 'Gwünni', :seat => 8, :starting_stack => "3000".to_d)
143
198
  @parser.parse("Seat 8: Gwünni (3000 in chips)")
144
199
  end
145
200
 
@@ -153,8 +208,17 @@ describe PokerstarsHandHistoryParser, "when parsing prelude matter" do
153
208
  @parser.parse("BadBeat_Brat: posts big blind 20")
154
209
  end
155
210
 
156
- it "should parse an ante header and register the corresponding action" do
211
+ it "should parse an ante header and register the corresponding action, :updating the :ante field as well when ante is larger" do
212
+ @stats.update_hand(:ante=>0)
213
+ @stats.should_receive(:register_action).with("BadBeat_Brat", 'antes', :result => :post, :amount => "15".to_d)
214
+ @stats.should_receive(:update_hand).with(:ante => "15".to_d)
215
+ @parser.parse("BadBeat_Brat: posts the ante 15")
216
+ end
217
+
218
+ it "should parse an ante header and register the corresponding action, :updating the :ante field as well when ante is not larger" do
219
+ @stats.update_hand(:ante=>20)
157
220
  @stats.should_receive(:register_action).with("BadBeat_Brat", 'antes', :result => :post, :amount => "15".to_d)
221
+ @stats.should_receive(:update_hand).with(:ante => "20".to_d)
158
222
  @parser.parse("BadBeat_Brat: posts the ante 15")
159
223
  end
160
224
  end
@@ -193,5 +257,8 @@ describe PokerstarsHandHistoryParser, "when parsing poker actions" do
193
257
  @stats.should_receive(:register_action).with("billy", "wins", :result => :win, :amount => "1.90".to_d)
194
258
  @parser.parse("billy collected $1.90 from pot")
195
259
  end
196
- end
197
-
260
+ it "should properly parse and register a muck" do
261
+ @stats.should_receive(:register_action).with("billy", "mucks", :result => :neutral)
262
+ @parser.parse("billy mucks hand")
263
+ end
264
+ end
@@ -24,27 +24,9 @@ include HandConstants
24
24
  # end
25
25
  # end
26
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
27
+ # describe PokerstarsHandHistoryParser, "when parsing all the PokerstarsFiles in Andy's directory" do
46
28
  # before :each do
47
- # @filenames = Dir["/Users/werdna/juditest/*.txt"]
29
+ # @filenames = Dir["/Users/werdna/Library/Application Support/Pokerstars/HandHistory/**/*.txt"]
48
30
  # end
49
31
  #
50
32
  # it "should parse every line of every entry in the file" do
@@ -52,16 +34,34 @@ end
52
34
  # @filenames.each do |filename|
53
35
  # puts "====== #{filename} ====="
54
36
  # @psfile = PokerstarsFile.open(filename).entries.each do |handrecord|
55
- # @stats = HandStatistics.new
56
- # @parser = PokerstarsHandHistoryParser.new(@stats)
57
- # # puts handrecord.[/[^\n]+/]
58
37
  # printf(".")
59
- # handrecord.lines.each do |line|
60
- # lambda{@parser.parse(line)}.should_not raise_error
61
- # end
62
- # # @stats.debug_display
38
+ # lambda{handrecord.parse}.should_not raise_error
63
39
  # end
64
40
  # printf("\n")
65
41
  # end
66
42
  # end
67
- # 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.[/[^\n]+/]
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: pokerstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew C. Greenberg
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-09 00:00:00 -08:00
12
+ date: 2009-11-18 00:00:00 -08:00
13
13
  default_executable: checkps
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -75,6 +75,8 @@ files:
75
75
  - lib/pokerstats/plugins/cash_statistics.rb
76
76
  - lib/pokerstats/plugins/continuation_bet_statistics.rb
77
77
  - lib/pokerstats/plugins/preflop_raise_statistics.rb
78
+ - lib/pokerstats/plugins/street_bet_statistics.rb
79
+ - lib/pokerstats/plugins/street_statistics.rb
78
80
  - lib/pokerstats/poker-edge.rb
79
81
  - lib/pokerstats/pokerstars_file.rb
80
82
  - lib/pokerstats/pokerstars_hand_history_parser.rb