pokerstats 2.0.3 → 2.0.4
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/VERSION +1 -1
- data/lib/pokerstats/pokerstars_hand_history_parser.rb +58 -60
- data/pokerstats.gemspec +2 -2
- data/spec/pokerstars_hand_history_parser_spec.rb +1 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.4
|
@@ -4,6 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + '/hand_statistics')
|
|
4
4
|
module Pokerstats
|
5
5
|
CASH = "[0-9$,.]+"
|
6
6
|
|
7
|
+
class HandHistoryParseError < RuntimeError
|
8
|
+
end
|
7
9
|
class PokerstarsHandHistoryParser
|
8
10
|
def self.parse_lines(lines, stats=nil)
|
9
11
|
parser = self.new(stats)
|
@@ -58,66 +60,62 @@ module Pokerstats
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def parse(line)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
raise "invalid line for parse: #{line}" unless ignorable?(line)
|
118
|
-
end
|
119
|
-
rescue => e
|
120
|
-
raise e
|
63
|
+
case line
|
64
|
+
when /PokerStars Game #([0-9]+): Tournament #([0-9]+), (\$[0-9+$]+) ([^\-]*) - Level ([IVXL]+) \((#{CASH})\/(#{CASH})\) - (.*)$/
|
65
|
+
@stats.update_hand :name => "PS#{$1}", :description=> "#{$2}, #{$3} #{$4}", :tournament=> $2, :sb=> $6.to_d, :bb=> $7.to_d, :played_at=> Time.parse($8), :street => :prelude
|
66
|
+
when /PokerStars Game #([0-9]+): +([^(]*) \((#{CASH})\/(#{CASH})\) - (.*)$/
|
67
|
+
@stats.update_hand :name => "PS#{$1}", :description=> "#{$2} (#{$3}/#{$4})", :tournament=> nil, :sb=> cash_to_d($3), :bb=> cash_to_d($4), :played_at=> Time.parse($5), :street => :prelude
|
68
|
+
when /PokerStars Game #([0-9]+): +([^(]*) \((#{CASH})\/(#{CASH}) USD\) - (.*)$/
|
69
|
+
@stats.update_hand :name => "PS#{$1}", :description=> "#{$2} (#{$3}/#{$4})", :tournament=> nil, :sb=> cash_to_d($3), :bb=> cash_to_d($4), :played_at=> Time.parse($5), :street => :prelude
|
70
|
+
when /PokerStars Game #([0-9]+):/
|
71
|
+
raise HandHistoryParseError, "invalid hand record: #{line}"
|
72
|
+
when /\*\*\* HOLE CARDS \*\*\*/
|
73
|
+
@stats.register_button(@stats.button)
|
74
|
+
@stats.update_hand :street => :preflop
|
75
|
+
when /\*\*\* FLOP \*\*\* \[(.*)\]/
|
76
|
+
@stats.update_hand :street => :flop
|
77
|
+
when /\*\*\* TURN \*\*\* \[([^\]]*)\] \[([^\]]*)\]/
|
78
|
+
@stats.update_hand :street => :turn
|
79
|
+
when /\*\*\* RIVER \*\*\* \[([^\]]*)\] \[([^\]]*)\]/
|
80
|
+
@stats.update_hand :street => :river
|
81
|
+
when /\*\*\* SHOW DOWN \*\*\*/
|
82
|
+
@stats.update_hand :street => :showdown
|
83
|
+
when /\*\*\* SUMMARY \*\*\*/
|
84
|
+
@stats.update_hand :street => :summary
|
85
|
+
when /Dealt to ([^)]+) \[([^\]]+)\]/
|
86
|
+
@stats.register_action($1, 'dealt', :result => :cards, :data => $2)
|
87
|
+
when /(.*): shows \[(.*)\]/
|
88
|
+
@stats.register_action($1, 'shows', :result => :cards, :data => $2)
|
89
|
+
when /Board \[(.*)\]/
|
90
|
+
@stats.update_hand :board => $1
|
91
|
+
when /Total pot (#{CASH}) (((Main)|(Side)) pot(-[0-9]+)? (#{CASH}). )*\| Rake (#{CASH})/
|
92
|
+
@stats.update_hand(:total_pot => cash_to_d($1), :rake => cash_to_d($8))
|
93
|
+
when /Total pot (#{CASH}) Main pot (#{CASH}).( Side pot-[0-9]+ (#{CASH}).)* | Rake (#{CASH})/
|
94
|
+
raise HandHistoryParseError, "popo!"
|
95
|
+
when /Seat ([0-9]+): (.+) \(#{CASH} in chips\)( is sitting out)?/
|
96
|
+
@stats.register_player(:seat => $1.to_i, :screen_name => $2)
|
97
|
+
when /(.*): posts ((small)|(big)|(small \& big)) blind(s)? (#{CASH})/
|
98
|
+
@stats.register_action($1, 'posts', :result => :post, :amount => cash_to_d($7))
|
99
|
+
when /(.*): posts the ante (#{CASH})/
|
100
|
+
@stats.register_action($1, 'antes', :result => :post, :amount => cash_to_d($2))
|
101
|
+
when /Table '([0-9]+) ([0-9]+)' (.*) Seat #([0-9]+) is the button/
|
102
|
+
@stats.register_button($4.to_i)
|
103
|
+
when /Table '(.*)' (.*) Seat #([0-9]+) is the button/
|
104
|
+
@stats.register_button($3.to_i)
|
105
|
+
when /Uncalled bet \((.*)\) returned to (.*)/
|
106
|
+
@stats.register_action($2, 'return', :result => :win, :amount => cash_to_d($1))
|
107
|
+
when /(.+): ((folds)|(checks))/
|
108
|
+
@stats.register_action($1, $2, :result => :neutral)
|
109
|
+
when /(.+): ((calls)|(bets)) ((#{CASH})( and is all-in)?)?$/
|
110
|
+
@stats.register_action($1, $2, :result => :pay, :amount => cash_to_d($6))
|
111
|
+
when /(.+): raises (#{CASH}) to (#{CASH})( and is all-in)?$/
|
112
|
+
@stats.register_action($1, 'raises', :result => :pay_to, :amount => cash_to_d($3))
|
113
|
+
when /(.*) collected (.*) from ((side )|(main ))?pot/
|
114
|
+
@stats.register_action($1, "wins", :result => :win, :amount => cash_to_d($2))
|
115
|
+
when /Seat [0-9]+: (.*) (\((small blind)|(big blind)|(button)\) )?showed \[([^\]]+)\] and ((won) \(#{CASH}\)|(lost)) with (.*)/
|
116
|
+
when /Seat [0-9]+: (.*) mucked \[([^\]]+)\]/
|
117
|
+
else
|
118
|
+
raise HandHistoryParseError, "invalid line for parse: #{line}" unless ignorable?(line)
|
121
119
|
end
|
122
120
|
end
|
123
121
|
|
data/pokerstats.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pokerstats}
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.4"
|
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"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-31}
|
13
13
|
s.default_executable = %q{checkps}
|
14
14
|
s.description = %q{a library for extracting, computing and reporting statistics of poker hands parsed from hand history files}
|
15
15
|
s.email = %q{wizardwerdna@gmail.com}
|
@@ -8,7 +8,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_stati
|
|
8
8
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/pokerstars_file')
|
9
9
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/pokerstars_hand_history_parser')
|
10
10
|
include Pokerstats
|
11
|
-
|
12
11
|
include HandConstants
|
13
12
|
|
14
13
|
describe PokerstarsHandHistoryParser, "recognizes valid hand history" do
|
@@ -21,7 +20,7 @@ describe PokerstarsHandHistoryParser, "recognizes valid hand history" do
|
|
21
20
|
PokerstarsHandHistoryParser.game(first_line).should == "PS21650146783"
|
22
21
|
end
|
23
22
|
it "should reject an invalid hand history" do
|
24
|
-
PokerstarsHandHistoryParser.game("an invalid hand history")
|
23
|
+
PokerstarsHandHistoryParser.game("an invalid hand history").should raise_error
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
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.
|
4
|
+
version: 2.0.4
|
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-10-
|
12
|
+
date: 2009-10-31 00:00:00 -07:00
|
13
13
|
default_executable: checkps
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|