steam_hlds_log_parser 0.5.1 → 0.5.2
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.
- checksums.yaml +4 -4
- data/examples/example-2.rb +2 -0
- data/lib/steam_hlds_log_parser/client.rb +4 -0
- data/lib/steam_hlds_log_parser/handler.rb +4 -4
- data/lib/steam_hlds_log_parser/version.rb +1 -1
- data/spec/client_spec.rb +16 -0
- data/spec/handler_spec.rb +16 -16
- data/spec/helper_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
|
4
|
-
|
3
|
+
data.tar.gz: bd893345adf64a1cd18271c4213ecaecfa0aa09e
|
4
|
+
metadata.gz: eb18a8ebc669f69ce843443295743e2577608eba
|
5
5
|
SHA512:
|
6
|
-
|
7
|
-
|
6
|
+
data.tar.gz: 1db3bee454617d173c1077e655da535df1fb8cb406dbb74f369aebe91b26aff5dc0a6aac245d01073ce4fc593bb7ffc9f14d321bc8b19da654acc1be40268956
|
7
|
+
metadata.gz: 6ce8847b3758d2576bd08c67ca1f78f360d03b1be89e9b824e2e5ba64c980228bbffc8dc09ba71411775d1e5531d4ed1c28e06cb0a66bf90c46b13c4825c4871
|
data/examples/example-2.rb
CHANGED
@@ -16,6 +16,8 @@ module SteamHldsLogParser
|
|
16
16
|
# @option options [String] :host (0.0.0.0) IP Address the client will be running, usually localhost
|
17
17
|
# @option options [Integer] :port (27115) Port will be listening to
|
18
18
|
# @option options [Symbol] :locale (:en) Set the language of returned content
|
19
|
+
# @option options [Boolean] :display_end_map (true) Enable display of score at the end of each map
|
20
|
+
# @option options [Boolean] :display_end_round (true) Enable display of score after each round
|
19
21
|
# @option options [Boolean] :display_kills (true) Enable kills / frags detail
|
20
22
|
# @option options [Boolean] :display_actions (true) Enable players actions / defuse / ... detail
|
21
23
|
# @option options [Boolean] :display_changelevel (true) Enable changelevel (map) display
|
@@ -29,6 +31,8 @@ module SteamHldsLogParser
|
|
29
31
|
:host => "0.0.0.0",
|
30
32
|
:port => 27115,
|
31
33
|
:locale => :en,
|
34
|
+
:display_end_map => true,
|
35
|
+
:display_end_round => true,
|
32
36
|
:display_kills => true,
|
33
37
|
:display_actions => true,
|
34
38
|
:display_changelevel => true,
|
@@ -46,14 +46,14 @@ module SteamHldsLogParser
|
|
46
46
|
def receive_data(data)
|
47
47
|
|
48
48
|
# L 05/10/2000 - 12:34:56: Team "CT" scored "17" with "0" players
|
49
|
-
if data.gsub(/Team "([A-Z]+)" scored "(\d+)" with "(\d+)"/).count > 0
|
49
|
+
if @options[:display_end_map] && data.gsub(/Team "([A-Z]+)" scored "(\d+)" with "(\d+)"/).count > 0
|
50
50
|
winner, winner_score = data.match(/Team "(.+)" scored "(\d+)" with/).captures
|
51
|
-
content = { :type => '
|
51
|
+
content = { :type => 'end_map', :params => { :winner => get_short_team_name(winner), :score => winner_score } }
|
52
52
|
|
53
53
|
# L 05/10/2000 - 12:34:56: Team "CT" triggered "CTs_Win" (CT "3") (T "0")
|
54
|
-
elsif data.gsub(/: Team "[A-Z]+" triggered/).count > 0
|
54
|
+
elsif @options[:display_end_map] && data.gsub(/: Team "[A-Z]+" triggered/).count > 0
|
55
55
|
winner, type, score_ct, score_t = data.match(/Team "([A-Z]+)" triggered "([A-Za-z_]+)" \(CT "(\d+)"\) \(T "(\d+)"\)/i).captures
|
56
|
-
content = { :type => '
|
56
|
+
content = { :type => 'end_round', :params => { :score_ct => score_ct, :score_t => score_t } }
|
57
57
|
|
58
58
|
# L 05/10/2000 - 12:34:56: "Killer | Player<66><STEAM_ID_LAN><TERRORIST>" killed "Killed | Player<60><STEAM_ID_LAN><CT>" with "ak47"
|
59
59
|
elsif @options[:display_kills] && data.gsub(/(\>" killed ")/).count > 0
|
data/spec/client_spec.rb
CHANGED
@@ -37,6 +37,14 @@ module SteamHldsLogParser
|
|
37
37
|
expect(default_client.options[:locale].class).to be(Symbol)
|
38
38
|
expect(default_client.options[:locale]).to be(:en)
|
39
39
|
end
|
40
|
+
it "has a default 'display_end_map'" do
|
41
|
+
expect(default_client.options[:display_end_map]).not_to be_nil
|
42
|
+
expect(default_client.options[:display_end_map]).to be_true
|
43
|
+
end
|
44
|
+
it "has a default 'display_end_round'" do
|
45
|
+
expect(default_client.options[:display_end_round]).not_to be_nil
|
46
|
+
expect(default_client.options[:display_end_round]).to be_true
|
47
|
+
end
|
40
48
|
it "has a default 'display_kills'" do
|
41
49
|
expect(default_client.options[:display_kills]).not_to be_nil
|
42
50
|
expect(default_client.options[:display_kills]).to be_true
|
@@ -87,6 +95,14 @@ module SteamHldsLogParser
|
|
87
95
|
expect(custom_client.options[:locale].class).to be(Symbol)
|
88
96
|
expect(custom_client.options[:locale]).to be(:fr)
|
89
97
|
end
|
98
|
+
it "has a default 'display_end_map'" do
|
99
|
+
expect(custom_client.options[:display_end_map]).not_to be_nil
|
100
|
+
expect(custom_client.options[:display_end_map]).to be_false
|
101
|
+
end
|
102
|
+
it "has a default 'display_end_round'" do
|
103
|
+
expect(custom_client.options[:display_end_round]).not_to be_nil
|
104
|
+
expect(custom_client.options[:display_end_round]).to be_false
|
105
|
+
end
|
90
106
|
it "has a custom 'display_kills'" do
|
91
107
|
expect(custom_client.options[:display_kills]).not_to be_nil
|
92
108
|
expect(custom_client.options[:display_kills]).to be_false
|
data/spec/handler_spec.rb
CHANGED
@@ -53,20 +53,20 @@ module SteamHldsLogParser
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
context "when data is '
|
57
|
-
it "returns Hash
|
56
|
+
context "when data is 'end_map'" do
|
57
|
+
it "returns a Hash" do
|
58
58
|
data = '# L 05/10/2000 - 12:34:56: Team "CT" scored "17" with "0" players"'
|
59
|
-
expected = {:type=>"
|
59
|
+
expected = {:type=>"end_map", :params=>{:winner=>"CT", :score=>"17"}}
|
60
60
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
61
61
|
expect(@handler.receive_data(data).data).to eq(expected)
|
62
62
|
expect(@handler.receive_data(data).data.class).to be(Hash)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
context "when data is '
|
67
|
-
it "returns Hash
|
66
|
+
context "when data is 'end_round'" do
|
67
|
+
it "returns a Hash" do
|
68
68
|
data = '# L 05/10/2000 - 12:34:56: Team "CT" triggered "CTs_Win" (CT "3") (T "0")'
|
69
|
-
expected = {:type=>"
|
69
|
+
expected = {:type=>"end_round", :params=>{:score_ct=>"3", :score_t=>"0"}}
|
70
70
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
71
71
|
expect(@handler.receive_data(data).data).to eq(expected)
|
72
72
|
expect(@handler.receive_data(data).data.class).to be(Hash)
|
@@ -74,7 +74,7 @@ module SteamHldsLogParser
|
|
74
74
|
end
|
75
75
|
|
76
76
|
context "when data is 'killed' (STEAM_ID_LAN)" do
|
77
|
-
it "returns Hash
|
77
|
+
it "returns a Hash" do
|
78
78
|
data = '# L 05/10/2000 - 12:34:56: "Killer | Player<66><STEAM_ID_LAN><TERRORIST>" killed "Killed | Player<60><STEAM_ID_LAN><CT>" with "ak47"'
|
79
79
|
expected = {:type=>"kill", :params => {:killer_team=>"T", :killer=>"Killer | Player", :killed_team=>"CT", :killed=>"Killed | Player", :weapon=>"ak47"}}
|
80
80
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -84,7 +84,7 @@ module SteamHldsLogParser
|
|
84
84
|
end
|
85
85
|
|
86
86
|
context "when data is 'killed' (STEAM_0:0:12345)" do
|
87
|
-
it "returns Hash
|
87
|
+
it "returns a Hash" do
|
88
88
|
data = '# L 05/10/2000 - 12:34:56: "Killer | Player<66><STEAM_0:0:12345><TERRORIST>" killed "Killed | Player<60><STEAM_0:0:12345><CT>" with "ak47"'
|
89
89
|
expected = {:type=>"kill", :params => {:killer_team=>"T", :killer=>"Killer | Player", :killed_team=>"CT", :killed=>"Killed | Player", :weapon=>"ak47"}}
|
90
90
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -94,7 +94,7 @@ module SteamHldsLogParser
|
|
94
94
|
end
|
95
95
|
|
96
96
|
context "when data is 'suicide' (STEAM_ID_LAN)" do
|
97
|
-
it "returns Hash
|
97
|
+
it "returns a Hash" do
|
98
98
|
data = '# L 05/10/2000 - 12:34:56: "Player<66><STEAM_ID_LAN><TERRORIST>" committed suicide with "worldspawn" (world)'
|
99
99
|
expected = {:type=>"suicide", :params=>{:killed=>"Player"}}
|
100
100
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -104,7 +104,7 @@ module SteamHldsLogParser
|
|
104
104
|
end
|
105
105
|
|
106
106
|
context "when data is 'suicide' (STEAM_0:0:12345)" do
|
107
|
-
it "returns Hash
|
107
|
+
it "returns a Hash" do
|
108
108
|
data = '# L 05/10/2000 - 12:34:56: "Player<66><STEAM_0:0:12345><TERRORIST>" committed suicide with "worldspawn" (world)'
|
109
109
|
expected = {:type=>"suicide", :params=>{:killed=>"Player"}}
|
110
110
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -114,7 +114,7 @@ module SteamHldsLogParser
|
|
114
114
|
end
|
115
115
|
|
116
116
|
context "when data is 'event' (STEAM_ID_LAN)" do
|
117
|
-
it "returns Hash
|
117
|
+
it "returns a Hash" do
|
118
118
|
data = '# L 05/10/2000 - 12:34:56: "Killer | Player<66><STEAM_ID_LAN><CT>" triggered "Defused_The_Bomb"'
|
119
119
|
expected = {:type=>"event", :params=> {:person_team=>"CT", :person=>"Killer | Player", :event_item=>"Defused_The_Bomb", :event_i18n=>"defused the bomb"}}
|
120
120
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -124,7 +124,7 @@ module SteamHldsLogParser
|
|
124
124
|
end
|
125
125
|
|
126
126
|
context "when data is 'event' (STEAM_0:0:12345)" do
|
127
|
-
it "returns Hash
|
127
|
+
it "returns a Hash" do
|
128
128
|
data = '# L 05/10/2000 - 12:34:56: "Killer | Player<66><STEAM_0:0:12345><CT>" triggered "Defused_The_Bomb"'
|
129
129
|
expected = {:type=>"event", :params=> {:person_team=>"CT", :person=>"Killer | Player", :event_item=>"Defused_The_Bomb", :event_i18n=>"defused the bomb"}}
|
130
130
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -134,7 +134,7 @@ module SteamHldsLogParser
|
|
134
134
|
end
|
135
135
|
|
136
136
|
context "when data is 'changelevel'" do
|
137
|
-
it "returns Hash
|
137
|
+
it "returns a Hash" do
|
138
138
|
data = '# L 05/10/2000 - 12:34:56: Loading map "de_dust2"'
|
139
139
|
expected = {:type=>"loading_map", :params=>{:map=>"de_dust2"}}
|
140
140
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -144,7 +144,7 @@ module SteamHldsLogParser
|
|
144
144
|
end
|
145
145
|
|
146
146
|
context "when data is 'chat'" do
|
147
|
-
it "returns Hash
|
147
|
+
it "returns a Hash" do
|
148
148
|
data = '# L 05/10/2000 - 12:34:56: "Player<15><STEAM_0:0:12345><TERRORIST>" say "gg" (dead)'
|
149
149
|
expected = {:type=>"chat", :params=>{:player=>"Player", :player_team=>"T", :chat=>"gg"}}
|
150
150
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -154,7 +154,7 @@ module SteamHldsLogParser
|
|
154
154
|
end
|
155
155
|
|
156
156
|
context "when data is 'team_chat'" do
|
157
|
-
it "returns Hash
|
157
|
+
it "returns a Hash" do
|
158
158
|
data = '# L 05/10/2000 - 12:34:56: "Player<15><STEAM_0:0:12345><TERRORIST>" say_team "Rush B"'
|
159
159
|
expected = {:type=>"team_chat", :params=>{:player=>"Player", :player_team=>"T", :chat=>"Rush B"}}
|
160
160
|
expect(@handler.receive_data(data).class).to be(RSpecDisplayer)
|
@@ -185,7 +185,7 @@ module SteamHldsLogParser
|
|
185
185
|
|
186
186
|
subject { @custom_handler }
|
187
187
|
context "when 'displayer' is set" do
|
188
|
-
it "returns Hash
|
188
|
+
it "returns a Hash provided by 'displayer'" do
|
189
189
|
data = '# L 05/10/2000 - 12:34:56: Loading map "de_dust2"'
|
190
190
|
expected = {:type=>"loading_map", :params=>{:map=>"de_dust2"}}
|
191
191
|
expect(@custom_handler.displayer).to be(RSpecDisplayer)
|
data/spec/helper_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steam_hlds_log_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas VIAL
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-03 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|