steam_hlds_log_parser 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e50cd7e02251eb8f005cffa7db04028ef24c230
4
- data.tar.gz: 088c9c2ae149c651c7c221885c5df6e3cbcb0b70
3
+ data.tar.gz: bd893345adf64a1cd18271c4213ecaecfa0aa09e
4
+ metadata.gz: eb18a8ebc669f69ce843443295743e2577608eba
5
5
  SHA512:
6
- metadata.gz: fe0846e0981463819ccd9e033c2ed5249fc2b6e0c63c59b5333089f635bfd7bca0660d451e059677aba809a4db8484fd1d11e7da661ea6b8a2b94f6c41617a6d
7
- data.tar.gz: 6850d1f8eabfaf9fb55c5e3a3878c90582675d4ffab294a66d34499a1515187b026fd78dee4ef38754a1e35c850776f88019d06452e40f7a4e0a047b35bcb80e
6
+ data.tar.gz: 1db3bee454617d173c1077e655da535df1fb8cb406dbb74f369aebe91b26aff5dc0a6aac245d01073ce4fc593bb7ffc9f14d321bc8b19da654acc1be40268956
7
+ metadata.gz: 6ce8847b3758d2576bd08c67ca1f78f360d03b1be89e9b824e2e5ba64c980228bbffc8dc09ba71411775d1e5531d4ed1c28e06cb0a66bf90c46b13c4825c4871
@@ -14,6 +14,8 @@ options = {
14
14
  :host => "0.0.0.0",
15
15
  :port => 27115,
16
16
  :locale => :en,
17
+ :display_end_map => true,
18
+ :display_end_round => true,
17
19
  :display_kills => true,
18
20
  :display_actions => true,
19
21
  :display_changelevel => true,
@@ -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 => 'map_ends', :params => { :winner => get_short_team_name(winner), :score => winner_score } }
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 => 'victory', :params => { :score_ct => score_ct, :score_t => score_t } }
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
@@ -1,4 +1,4 @@
1
1
  module SteamHldsLogParser
2
2
  # Gem Version
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
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 'map_ends'" do
57
- it "returns Hash on map_ends" do
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=>"map_ends", :params=>{:winner=>"CT", :score=>"17"}}
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 'victory'" do
67
- it "returns Hash on victory" do
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=>"victory", :params=>{:score_ct=>"3", :score_t=>"0"}}
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 on killed" do
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 on killed" do
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 on suicide" do
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 on suicide" do
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 on event" do
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 on event" do
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 on changelevel" do
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 on changelevel" do
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 on changelevel" do
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 on changelevel provided by 'displayer'" do
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
@@ -46,6 +46,8 @@ def custom_options
46
46
  :host => "127.0.0.1",
47
47
  :port => 12345,
48
48
  :locale => :fr,
49
+ :display_end_map => false,
50
+ :display_end_round => false,
49
51
  :display_kills => false,
50
52
  :display_actions => false,
51
53
  :display_changelevel => false,
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.1
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-01 00:00:00 Z
12
+ date: 2013-10-03 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler