tf2_line_parser 0.2.1 → 0.2.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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +13 -11
  4. data/README.md +0 -5
  5. data/lib/tf2_line_parser/events/airshot.rb +4 -7
  6. data/lib/tf2_line_parser/events/assist.rb +1 -4
  7. data/lib/tf2_line_parser/events/capture_block.rb +2 -5
  8. data/lib/tf2_line_parser/events/charge_deployed.rb +2 -4
  9. data/lib/tf2_line_parser/events/chat.rb +2 -10
  10. data/lib/tf2_line_parser/events/connect.rb +2 -6
  11. data/lib/tf2_line_parser/events/console_say.rb +2 -5
  12. data/lib/tf2_line_parser/events/current_score.rb +1 -4
  13. data/lib/tf2_line_parser/events/damage.rb +4 -7
  14. data/lib/tf2_line_parser/events/disconnect.rb +21 -0
  15. data/lib/tf2_line_parser/events/domination.rb +1 -3
  16. data/lib/tf2_line_parser/events/event.rb +12 -18
  17. data/lib/tf2_line_parser/events/final_score.rb +1 -4
  18. data/lib/tf2_line_parser/events/headshot_damage.rb +5 -9
  19. data/lib/tf2_line_parser/events/heal.rb +3 -4
  20. data/lib/tf2_line_parser/events/kill.rb +4 -6
  21. data/lib/tf2_line_parser/events/match_end.rb +2 -5
  22. data/lib/tf2_line_parser/events/medic_death.rb +5 -6
  23. data/lib/tf2_line_parser/events/pickup_item.rb +3 -5
  24. data/lib/tf2_line_parser/events/player_action_event.rb +2 -5
  25. data/lib/tf2_line_parser/events/point_capture.rb +2 -5
  26. data/lib/tf2_line_parser/events/pvp_event.rb +3 -3
  27. data/lib/tf2_line_parser/events/revenge.rb +1 -3
  28. data/lib/tf2_line_parser/events/role_change.rb +3 -5
  29. data/lib/tf2_line_parser/events/round_event_with_variables.rb +1 -4
  30. data/lib/tf2_line_parser/events/round_event_without_variables.rb +1 -4
  31. data/lib/tf2_line_parser/events/round_length.rb +3 -6
  32. data/lib/tf2_line_parser/events/round_stalemate.rb +2 -5
  33. data/lib/tf2_line_parser/events/round_start.rb +2 -5
  34. data/lib/tf2_line_parser/events/round_win.rb +2 -5
  35. data/lib/tf2_line_parser/events/score.rb +4 -7
  36. data/lib/tf2_line_parser/events/spawn.rb +2 -4
  37. data/lib/tf2_line_parser/events/suicide.rb +3 -5
  38. data/lib/tf2_line_parser/events/unknown.rb +3 -6
  39. data/lib/tf2_line_parser/line.rb +1 -4
  40. data/lib/tf2_line_parser/parser.rb +1 -2
  41. data/lib/tf2_line_parser/player.rb +1 -4
  42. data/lib/tf2_line_parser/version.rb +2 -1
  43. data/lib/tf2_line_parser.rb +14 -15
  44. data/spec/fixtures/logs/broder_vs_epsilon.log +1 -0
  45. data/spec/lib/tf2_line_parser/parser_spec.rb +167 -148
  46. data/spec/lib/tf2_line_parser/player_spec.rb +5 -7
  47. data/spec/spec_helper.rb +3 -1
  48. data/tf2_line_parser.gemspec +11 -10
  49. metadata +3 -2
@@ -1,106 +1,107 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
1
+ # frozen_string_literal: true
3
2
 
3
+ require 'spec_helper'
4
4
 
5
5
  module TF2LineParser
6
-
7
6
  describe Parser do
8
-
9
- let(:log_file) { File.expand_path('../../../fixtures/logs/broder_vs_epsilon.log', __FILE__) }
7
+ let(:log_file) { File.expand_path('../../fixtures/logs/broder_vs_epsilon.log', __dir__) }
10
8
  let(:log) { File.read(log_file) }
11
9
  let(:log_lines) { log.lines.map(&:to_s) }
12
- let(:detailed_log_file) { File.expand_path('../../../fixtures/logs/detailed_damage.log', __FILE__) }
10
+ let(:detailed_log_file) { File.expand_path('../../fixtures/logs/detailed_damage.log', __dir__) }
13
11
  let(:detailed_log) { File.read(detailed_log_file) }
14
12
  let(:detailed_log_lines) { detailed_log.lines.map(&:to_s) }
15
- let(:airshot_log_file) { File.expand_path('../../../fixtures/logs/airshot.log', __FILE__) }
13
+ let(:airshot_log_file) { File.expand_path('../../fixtures/logs/airshot.log', __dir__) }
16
14
  let(:airshot_log) { File.read(airshot_log_file) }
17
15
  let(:airshot_log_lines) { airshot_log.lines.map(&:to_s) }
18
- let(:new_log_file) { File.expand_path('../../../fixtures/logs/new_log.log', __FILE__) }
16
+ let(:new_log_file) { File.expand_path('../../fixtures/logs/new_log.log', __dir__) }
19
17
  let(:new_log) { File.read(new_log_file) }
20
18
  let(:new_log_lines) { new_log.lines.map(&:to_s) }
21
- let(:csgo_log_file) { File.expand_path('../../../fixtures/logs/csgo.log', __FILE__) }
19
+ let(:csgo_log_file) { File.expand_path('../../fixtures/logs/csgo.log', __dir__) }
22
20
  let(:csgo_log) { File.read(csgo_log_file) }
23
21
  let(:csgo_log_lines) { csgo_log.lines.map(&:to_s) }
24
22
 
25
23
  describe '#new' do
26
-
27
24
  it 'takes the log line and gets the date from it' do
28
25
  expect(Parser.new(log_lines.first).parse.time).to eql Time.local(2013, 2, 7, 21, 21, 8)
29
26
  end
30
-
31
27
  end
32
28
 
33
29
  describe '#parse' do
34
-
35
30
  def parse(line)
36
31
  Parser.new(line).parse
37
32
  end
38
33
 
39
34
  it 'recognizes damage' do
40
35
  line = log_lines[1001]
41
- player_name = "Epsilon numlocked"
42
- player_steam_id = "STEAM_0:1:16347045"
36
+ player_name = 'Epsilon numlocked'
37
+ player_steam_id = 'STEAM_0:1:16347045'
43
38
  player_team = 'Red'
44
39
  value = '69'
45
40
  weapon = nil
46
- expect(Events::Damage).to receive(:new).with(anything, player_name, player_steam_id, player_team, nil, nil, nil, value, weapon)
41
+ expect(Events::Damage).to receive(:new).with(anything, player_name, player_steam_id, player_team, nil, nil,
42
+ nil, value, weapon)
47
43
  parse(line)
48
44
  end
49
45
 
50
46
  it 'recognizes new steam id log lines with detailed damage' do
51
47
  line = new_log_lines[0]
52
- player_name = "iM yUKi intel @i52"
53
- player_steam_id = "[U:1:3825470]"
48
+ player_name = 'iM yUKi intel @i52'
49
+ player_steam_id = '[U:1:3825470]'
54
50
  player_team = 'Blue'
55
- target_team = "Red"
56
- target_name = "mix^ enigma @ i52"
57
- target_steam_id = "[U:1:33652944]"
51
+ target_team = 'Red'
52
+ target_name = 'mix^ enigma @ i52'
53
+ target_steam_id = '[U:1:33652944]'
58
54
  value = '78'
59
- weapon = "tf_projectile_rocket"
60
- expect(Events::Damage).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name, target_steam_id, target_team, value, weapon)
55
+ weapon = 'tf_projectile_rocket'
56
+ expect(Events::Damage).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name,
57
+ target_steam_id, target_team, value, weapon)
61
58
  parse(line)
62
59
  end
63
60
 
64
61
  it 'recognizes detailed damage' do
65
62
  line = detailed_log_lines[61]
66
- player_name = "LittleLies"
67
- player_steam_id = "STEAM_0:0:55031498"
68
- player_team = "Blue"
69
- target_name = "Aquila"
70
- target_steam_id = "STEAM_0:0:43087158"
71
- target_team = "Red"
72
- value = "102"
73
- weapon = "tf_projectile_pipe"
74
- expect(Events::Damage).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name, target_steam_id, target_team, value, weapon)
63
+ player_name = 'LittleLies'
64
+ player_steam_id = 'STEAM_0:0:55031498'
65
+ player_team = 'Blue'
66
+ target_name = 'Aquila'
67
+ target_steam_id = 'STEAM_0:0:43087158'
68
+ target_team = 'Red'
69
+ value = '102'
70
+ weapon = 'tf_projectile_pipe'
71
+ expect(Events::Damage).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name,
72
+ target_steam_id, target_team, value, weapon)
75
73
  parse(line)
76
74
  end
77
75
 
78
76
  it 'recognizes airshots' do
79
77
  line = airshot_log_lines[0]
80
- weapon = "tf_projectile_rocket"
81
- airshot = "1"
82
- expect(Events::Airshot).to receive(:new).with(anything, anything, anything, anything, anything, anything, anything, anything, weapon, airshot)
78
+ weapon = 'tf_projectile_rocket'
79
+ airshot = '1'
80
+ expect(Events::Airshot).to receive(:new).with(anything, anything, anything, anything, anything, anything,
81
+ anything, anything, weapon, airshot)
83
82
  parse(line).inspect
84
83
  end
85
84
 
86
85
  it 'recognizes sniper headshot damage' do
87
86
  line = detailed_log_lines[3645]
88
- weapon = "sniperrifle"
89
- expect(Events::HeadshotDamage).to receive(:new).with(anything, anything, anything, anything, anything, anything, anything, anything, weapon)
87
+ weapon = 'sniperrifle'
88
+ expect(Events::HeadshotDamage).to receive(:new).with(anything, anything, anything, anything, anything,
89
+ anything, anything, anything, weapon)
90
90
  parse(line).inspect
91
91
  end
92
92
 
93
93
  it 'ignores realdamage' do
94
94
  line = detailed_log_lines[65]
95
- player_name = "LittleLies"
96
- player_steam_id = "STEAM_0:0:55031498"
97
- player_team = "Blue"
98
- target_name = "Aquila"
99
- target_steam_id = "STEAM_0:0:43087158"
100
- target_team = "Red"
101
- value = "98"
102
- weapon = "tf_projectile_pipe"
103
- expect(Events::Damage).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name, target_steam_id, target_team, value, weapon)
95
+ player_name = 'LittleLies'
96
+ player_steam_id = 'STEAM_0:0:55031498'
97
+ player_team = 'Blue'
98
+ target_name = 'Aquila'
99
+ target_steam_id = 'STEAM_0:0:43087158'
100
+ target_team = 'Red'
101
+ value = '98'
102
+ weapon = 'tf_projectile_pipe'
103
+ expect(Events::Damage).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name,
104
+ target_steam_id, target_team, value, weapon)
104
105
  parse(line)
105
106
  end
106
107
 
@@ -121,7 +122,7 @@ module TF2LineParser
121
122
 
122
123
  it 'recognizes a round win' do
123
124
  line = log_lines[1439]
124
- winner = "Blue"
125
+ winner = 'Blue'
125
126
  expect(Events::RoundWin).to receive(:new).with(anything, winner)
126
127
  parse(line)
127
128
  end
@@ -134,72 +135,86 @@ module TF2LineParser
134
135
 
135
136
  it 'recognizes a match end' do
136
137
  line = log_lines[4169]
137
- reason = "Reached Win Difference Limit"
138
+ reason = 'Reached Win Difference Limit'
138
139
  expect(Events::MatchEnd).to receive(:new).with(anything, reason)
139
140
  parse(line)
140
141
  end
141
142
 
142
143
  it 'recognizes a heal' do
143
144
  line = log_lines[1433]
144
- player_name = "Epsilon KnOxXx"
145
- player_steam_id = "STEAM_0:1:12124893"
146
- player_team = "Red"
147
- target_name = "Epsilon numlocked"
148
- target_steam_id = "STEAM_0:1:16347045"
149
- target_team = "Red"
145
+ player_name = 'Epsilon KnOxXx'
146
+ player_steam_id = 'STEAM_0:1:12124893'
147
+ player_team = 'Red'
148
+ target_name = 'Epsilon numlocked'
149
+ target_steam_id = 'STEAM_0:1:16347045'
150
+ target_team = 'Red'
150
151
  value = '1'
151
- expect(Events::Heal).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name, target_steam_id, target_team, value)
152
+ expect(Events::Heal).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name,
153
+ target_steam_id, target_team, value)
152
154
  parse(line)
153
155
  end
154
156
 
155
157
  it 'recognizes a kill' do
156
158
  line = log_lines[1761]
157
- player_name = "Epsilon basH."
158
- player_steam_id = "STEAM_0:1:15829615"
159
- player_team = "Red"
160
- target_name = "broder jukebox"
161
- target_steam_id = "STEAM_0:1:13978585"
162
- target_team = "Blue"
163
- weapon = "pistol_scout"
159
+ player_name = 'Epsilon basH.'
160
+ player_steam_id = 'STEAM_0:1:15829615'
161
+ player_team = 'Red'
162
+ target_name = 'broder jukebox'
163
+ target_steam_id = 'STEAM_0:1:13978585'
164
+ target_team = 'Blue'
165
+ weapon = 'pistol_scout'
164
166
  customkill = nil
165
- expect(Events::Kill).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name, target_steam_id, target_team, weapon, customkill)
167
+ expect(Events::Kill).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name,
168
+ target_steam_id, target_team, weapon, customkill)
166
169
  parse(line)
167
170
  end
168
171
 
169
172
  it 'recognizes headshot kills' do
170
173
  line = log_lines[1951]
171
- weapon = "sniperrifle"
172
- customkill = "headshot"
173
- expect(Events::Kill).to receive(:new).with(anything, anything, anything, anything, anything, anything, anything, weapon, customkill)
174
+ weapon = 'sniperrifle'
175
+ customkill = 'headshot'
176
+ expect(Events::Kill).to receive(:new).with(anything, anything, anything, anything, anything, anything,
177
+ anything, weapon, customkill)
174
178
  parse(line)
175
179
  end
176
180
 
177
181
  it 'recognizes an assist' do
178
182
  line = log_lines[1451]
179
- player_name = "broder jukebox"
180
- player_steam_id = "STEAM_0:1:13978585"
181
- player_team = "Blue"
182
- target_name = "Epsilon Mitsy"
183
- target_steam_id = "STEAM_0:0:16858056"
184
- target_team = "Red"
185
- expect(Events::Assist).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name, target_steam_id, target_team)
183
+ player_name = 'broder jukebox'
184
+ player_steam_id = 'STEAM_0:1:13978585'
185
+ player_team = 'Blue'
186
+ target_name = 'Epsilon Mitsy'
187
+ target_steam_id = 'STEAM_0:0:16858056'
188
+ target_team = 'Red'
189
+ expect(Events::Assist).to receive(:new).with(anything, player_name, player_steam_id, player_team, target_name,
190
+ target_steam_id, target_team)
186
191
  parse(line)
187
192
  end
188
193
 
189
194
  it 'recognizes connect' do
190
195
  line = log_lines[9]
191
- name = "Epsilon numlocked"
192
- steam_id = "STEAM_0:1:16347045"
196
+ name = 'Epsilon numlocked'
197
+ steam_id = 'STEAM_0:1:16347045'
193
198
  team = ''
194
- message = "0.0.0.0:27005"
199
+ message = '0.0.0.0:27005'
195
200
  expect(Events::Connect).to receive(:new).with(anything, name, steam_id, team, message)
196
201
  parse(line)
197
202
  end
198
203
 
204
+ it 'recognizes disconnect' do
205
+ line = log_lines[4542]
206
+ name = 'cc//TviQ'
207
+ steam_id = 'STEAM_0:0:8520477'
208
+ team = 'Blue'
209
+ message = 'Disconnect by user.'
210
+ expect(Events::Disconnect).to receive(:new).with(anything, name, steam_id, team, message)
211
+ parse(line)
212
+ end
213
+
199
214
  it 'recognizes chat' do
200
215
  line = log_lines[89]
201
- name = "Epsilon KnOxXx"
202
- steam_id = "STEAM_0:1:12124893"
216
+ name = 'Epsilon KnOxXx'
217
+ steam_id = 'STEAM_0:1:12124893'
203
218
  team = 'Red'
204
219
  message = "it's right for the ping"
205
220
  expect(Events::Say).to receive(:new).with(anything, name, steam_id, team, message)
@@ -208,50 +223,52 @@ module TF2LineParser
208
223
 
209
224
  it 'recognizes team chat' do
210
225
  line = log_lines[303]
211
- name = "broder mirelin"
212
- steam_id = "STEAM_0:1:18504112"
226
+ name = 'broder mirelin'
227
+ steam_id = 'STEAM_0:1:18504112'
213
228
  team = 'Blue'
214
- message = ">>> USING UBER <<<[info] "
229
+ message = '>>> USING UBER <<<[info] '
215
230
  expect(Events::TeamSay).to receive(:new).with(anything, name, steam_id, team, message)
216
231
  parse(line)
217
232
  end
218
233
 
219
234
  it 'recognizes dominations' do
220
235
  line = log_lines[1948]
221
- name = "Epsilon basH."
222
- steam_id = "STEAM_0:1:15829615"
223
- team = "Red"
224
- target_name = "broder jukebox"
225
- target_steam_id = "STEAM_0:1:13978585"
226
- target_team = "Blue"
227
- expect(Events::Domination).to receive(:new).with(anything, name, steam_id, team, target_name, target_steam_id, target_team)
236
+ name = 'Epsilon basH.'
237
+ steam_id = 'STEAM_0:1:15829615'
238
+ team = 'Red'
239
+ target_name = 'broder jukebox'
240
+ target_steam_id = 'STEAM_0:1:13978585'
241
+ target_team = 'Blue'
242
+ expect(Events::Domination).to receive(:new).with(anything, name, steam_id, team, target_name, target_steam_id,
243
+ target_team)
228
244
  parse(line)
229
245
  end
230
246
 
231
247
  it 'recognizes revenges' do
232
248
  line = log_lines[2354]
233
- name = "broder jukebox"
234
- steam_id = "STEAM_0:1:13978585"
235
- team = "Blue"
236
- target_name = "Epsilon basH."
237
- target_steam_id = "STEAM_0:1:15829615"
238
- target_team = "Red"
239
- expect(Events::Revenge).to receive(:new).with(anything, name, steam_id, team, target_name, target_steam_id, target_team)
249
+ name = 'broder jukebox'
250
+ steam_id = 'STEAM_0:1:13978585'
251
+ team = 'Blue'
252
+ target_name = 'Epsilon basH.'
253
+ target_steam_id = 'STEAM_0:1:15829615'
254
+ target_team = 'Red'
255
+ expect(Events::Revenge).to receive(:new).with(anything, name, steam_id, team, target_name, target_steam_id,
256
+ target_team)
240
257
  parse(line)
241
258
  end
242
259
 
243
260
  it 'recognizes current score' do
244
261
  line = log_lines[1442]
245
- team = "Blue"
246
- score = "1"
262
+ team = 'Blue'
263
+ score = '1'
247
264
  expect(Events::CurrentScore).to receive(:new).with(anything, team, score)
248
265
  parse(line)
249
266
  end
250
267
 
251
268
  it 'recognizes final score' do
252
269
  line = log_lines[4170]
253
- team = "Red"
254
- score = "6"
270
+ team = 'Red'
271
+ score = '6'
255
272
  expect(Events::FinalScore).to receive(:new).with(anything, team, score)
256
273
  parse(line)
257
274
  end
@@ -259,8 +276,8 @@ module TF2LineParser
259
276
  it 'recognizes item pickup' do
260
277
  line = log_lines[51]
261
278
  name = 'Epsilon Mike'
262
- steam_id = "STEAM_0:1:1895232"
263
- team = "Blue"
279
+ steam_id = 'STEAM_0:1:1895232'
280
+ team = 'Blue'
264
281
  item = 'medkit_medium'
265
282
  expect(Events::PickupItem).to receive(:new).with(anything, name, steam_id, team, item)
266
283
  parse(line)
@@ -274,50 +291,53 @@ module TF2LineParser
274
291
 
275
292
  it 'recognizes ubercharges' do
276
293
  line = log_lines[1416]
277
- name = "broder mirelin"
278
- steam_id = "STEAM_0:1:18504112"
279
- team = "Blue"
294
+ name = 'broder mirelin'
295
+ steam_id = 'STEAM_0:1:18504112'
296
+ team = 'Blue'
280
297
  expect(Events::ChargeDeployed).to receive(:new).with(anything, name, steam_id, team)
281
298
  parse(line)
282
299
 
283
300
  line = detailed_log_lines[782]
284
- name = "flo ❤"
285
- steam_id = "STEAM_0:1:53945481"
286
- team = "Blue"
301
+ name = 'flo ❤'
302
+ steam_id = 'STEAM_0:1:53945481'
303
+ team = 'Blue'
287
304
  expect(Events::ChargeDeployed).to receive(:new).with(anything, name, steam_id, team)
288
305
  parse(line)
289
306
  end
290
307
 
291
308
  it 'recognizes medic deaths' do
292
309
  line = log_lines[1700]
293
- medic_name = "broder mirelin"
294
- medic_steam_id = "STEAM_0:1:18504112"
295
- medic_team = "Blue"
296
- killer_name = "Epsilon numlocked"
297
- killer_steam_id = "STEAM_0:1:16347045"
298
- killer_team = "Red"
299
- healing = "1975"
300
- expect(Events::MedicDeath).to receive(:new).with(anything, killer_name, killer_steam_id, killer_team, medic_name, medic_steam_id, medic_team, healing, "0")
310
+ medic_name = 'broder mirelin'
311
+ medic_steam_id = 'STEAM_0:1:18504112'
312
+ medic_team = 'Blue'
313
+ killer_name = 'Epsilon numlocked'
314
+ killer_steam_id = 'STEAM_0:1:16347045'
315
+ killer_team = 'Red'
316
+ healing = '1975'
317
+ expect(Events::MedicDeath).to receive(:new).with(anything, killer_name, killer_steam_id, killer_team,
318
+ medic_name, medic_steam_id, medic_team, healing, '0')
301
319
  parse(line)
302
320
  end
303
321
 
304
322
  it 'recognizes medic uberdrops' do
305
323
  uberdrop = 'L 10/04/2012 - 21:43:06: "TLR Traxantic<28><STEAM_0:1:1328042><Red>" triggered "medic_death" against "cc//Admirable<3><STEAM_0:0:154182><Blue>" (healing "6478") (ubercharge "1")'
306
- expect(Events::MedicDeath).to receive(:new).with(anything, anything, anything, anything, anything, anything, anything, anything, "1")
324
+ expect(Events::MedicDeath).to receive(:new).with(anything, anything, anything, anything, anything, anything,
325
+ anything, anything, '1')
307
326
  parse(uberdrop)
308
327
  end
309
328
 
310
329
  it 'recognizes medic healing on death' do
311
330
  line = 'L 10/04/2012 - 21:43:06: "TLR Traxantic<28><STEAM_0:1:1328042><Red>" triggered "medic_death" against "cc//Admirable<3><STEAM_0:0:154182><Blue>" (healing "6478") (ubercharge "1")'
312
- expect(Events::MedicDeath).to receive(:new).with(anything, anything, anything, anything, anything, anything, anything, "6478", anything)
331
+ expect(Events::MedicDeath).to receive(:new).with(anything, anything, anything, anything, anything, anything,
332
+ anything, '6478', anything)
313
333
  parse(line)
314
334
  end
315
335
 
316
336
  it 'recognizes role changes' do
317
337
  line = log_lines[1712]
318
- player_name = "broder bybben"
319
- player_steam_id = "STEAM_0:1:159631"
320
- player_team = "Blue"
338
+ player_name = 'broder bybben'
339
+ player_steam_id = 'STEAM_0:1:159631'
340
+ player_team = 'Blue'
321
341
  role = 'scout'
322
342
  expect(Events::RoleChange).to receive(:new).with(anything, player_name, player_steam_id, player_team, role)
323
343
  parse(line)
@@ -325,87 +345,86 @@ module TF2LineParser
325
345
 
326
346
  it 'recognizes round length' do
327
347
  line = log_lines[2275]
328
- length = "237.35"
348
+ length = '237.35'
329
349
  expect(Events::RoundLength).to receive(:new).with(anything, length)
330
350
  parse(line)
331
351
  end
332
352
 
333
353
  it 'recognizes capture block' do
334
354
  line = log_lines[3070]
335
- name = "Epsilon basH."
336
- steam_id = "STEAM_0:1:15829615"
337
- team = "Red"
338
- cap_number = "2"
339
- cap_name = "#Badlands_cap_cp3"
355
+ name = 'Epsilon basH.'
356
+ steam_id = 'STEAM_0:1:15829615'
357
+ team = 'Red'
358
+ cap_number = '2'
359
+ cap_name = '#Badlands_cap_cp3'
340
360
  expect(Events::CaptureBlock).to receive(:new).with(anything, name, steam_id, team, cap_number, cap_name)
341
361
  parse(line)
342
362
  end
343
363
 
344
364
  it 'recognizes suicides' do
345
365
  line = log_lines[76]
346
- name = ".schocky"
347
- steam_id = "STEAM_0:0:2829363"
348
- team = "Red"
349
- suicide_method = "world"
366
+ name = '.schocky'
367
+ steam_id = 'STEAM_0:0:2829363'
368
+ team = 'Red'
369
+ suicide_method = 'world'
350
370
  expect(Events::Suicide).to receive(:new).with(anything, name, steam_id, team, suicide_method)
351
371
  parse(line)
352
372
  end
353
373
 
354
374
  it 'recognizes spawns' do
355
375
  line = log_lines[4541]
356
- name = "candyyou # Infinity Gaming"
357
- steam_id = "STEAM_0:0:50979748"
358
- team = "Red"
359
- klass = "Soldier"
376
+ name = 'candyyou # Infinity Gaming'
377
+ steam_id = 'STEAM_0:0:50979748'
378
+ team = 'Red'
379
+ klass = 'Soldier'
360
380
  expect(Events::Spawn).to receive(:new).with(anything, name, steam_id, team, klass)
361
381
  parse(line)
362
382
  end
363
383
 
364
384
  it 'deals with unknown lines' do
365
385
  line = log_lines[0]
366
- time = "02/07/2013 - 21:21:08"
386
+ time = '02/07/2013 - 21:21:08'
367
387
  unknown = 'Log file started (file "logs/L0207006.log") (game "/home/hz00112/tf2/orangebox/tf") (version "5198")'
368
388
  expect(Events::Unknown).to receive(:new).with(time, unknown)
369
389
  parse(line)
370
390
  end
371
391
 
372
-
373
392
  it 'can parse all lines in the example log files without exploding' do
374
- broder_vs_epsilon = File.expand_path('../../../fixtures/logs/broder_vs_epsilon.log', __FILE__)
375
- special_characters = File.expand_path('../../../fixtures/logs/special_characters.log', __FILE__)
376
- very_special_characters = File.expand_path('../../../fixtures/logs/very_special_characters.log', __FILE__)
377
- ntraum_example = File.expand_path('../../../fixtures/logs/example.log', __FILE__)
378
- detailed_damage = File.expand_path('../../../fixtures/logs/detailed_damage.log', __FILE__)
393
+ broder_vs_epsilon = File.expand_path('../../fixtures/logs/broder_vs_epsilon.log', __dir__)
394
+ special_characters = File.expand_path('../../fixtures/logs/special_characters.log', __dir__)
395
+ very_special_characters = File.expand_path('../../fixtures/logs/very_special_characters.log', __dir__)
396
+ ntraum_example = File.expand_path('../../fixtures/logs/example.log', __dir__)
397
+ detailed_damage = File.expand_path('../../fixtures/logs/detailed_damage.log', __dir__)
379
398
  log_files = [broder_vs_epsilon, special_characters, very_special_characters, ntraum_example, detailed_damage]
380
399
 
381
400
  log_files.each do |log_file|
382
401
  log = File.read(log_file)
383
- expect {
402
+ expect do
384
403
  log.lines.map(&:to_s).each do |line|
385
404
  parse(line)
386
405
  end
387
- }.to_not raise_error
406
+ end.to_not raise_error
388
407
  end
389
408
  end
390
409
 
391
410
  it 'recognizes cs:go chat' do
392
411
  line = csgo_log_lines[299]
393
- name = "• Ben •"
394
- steam_id = "STEAM_1:0:160621749"
412
+ name = '• Ben •'
413
+ steam_id = 'STEAM_1:0:160621749'
395
414
  team = 'TERRORIST'
396
- message = "!rcon changelevel de_dust2"
415
+ message = '!rcon changelevel de_dust2'
397
416
  expect(Events::Say).to receive(:new).with(anything, name, steam_id, team, message)
398
417
  parse(line)
399
418
  end
400
419
 
401
420
  it "doesn't fall for twiikuu's cheeky name" do
402
421
  player_name = 't<1><[U:1:123456]><Red>" say "'
403
- line = %Q|L 02/07/2013 - 21:22:08: "#{player_name}<5><[U:1:1337]><Red>" say "!who"|
422
+ line = %(L 02/07/2013 - 21:22:08: "#{player_name}<5><[U:1:1337]><Red>" say "!who")
404
423
 
405
424
  name = 't<1><[U:1:123456]><Red>" say "'
406
- steam_id = "[U:1:1337]"
425
+ steam_id = '[U:1:1337]'
407
426
  team = 'Red'
408
- message = "!who"
427
+ message = '!who'
409
428
  expect(Events::Say).to receive(:new).with(anything, name, steam_id, team, message)
410
429
 
411
430
  parse(line)
@@ -1,15 +1,13 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'spec_helper'
3
4
 
4
5
  module TF2LineParser
5
-
6
6
  describe Player do
7
-
8
- it "compares based on steam_id" do
9
- p1 = Player.new("Arie", "12345", "Red")
10
- p2 = Player.new("Arie fakenicking", "12345", "Red")
7
+ it 'compares based on steam_id' do
8
+ p1 = Player.new('Arie', '12345', 'Red')
9
+ p2 = Player.new('Arie fakenicking', '12345', 'Red')
11
10
  expect(p1).to eq p2
12
11
  end
13
-
14
12
  end
15
13
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
4
  require 'coveralls'
3
5
 
@@ -8,4 +10,4 @@ SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter[
8
10
  SimpleCov.start
9
11
 
10
12
  require 'pry-nav'
11
- require "tf2_line_parser"
13
+ require 'tf2_line_parser'
@@ -1,21 +1,22 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/tf2_line_parser/version', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('lib/tf2_line_parser/version', __dir__)
3
4
 
4
5
  Gem::Specification.new do |gem|
5
6
  gem.name = 'tf2_line_parser'
6
7
  gem.version = TF2LineParser::VERSION
7
8
  gem.date = Time.new
8
- gem.summary = "TF2 log line parser"
9
- gem.description = "A gem to parse log lines from TF2 servers"
10
- gem.authors = ["Arie"]
9
+ gem.summary = 'TF2 log line parser'
10
+ gem.description = 'A gem to parse log lines from TF2 servers'
11
+ gem.authors = ['Arie']
11
12
  gem.email = 'rubygems@ariekanarie.nl'
12
- gem.files = `git ls-files`.split($\)
13
+ gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
13
14
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.require_paths = ["lib"]
15
+ gem.require_paths = ['lib']
15
16
  gem.homepage = 'http://github.com/Arie/tf2_line_parser'
16
17
 
17
- gem.add_dependency "activesupport"
18
+ gem.add_dependency 'activesupport'
18
19
  gem.add_development_dependency 'coveralls'
19
- gem.add_development_dependency "pry-nav"
20
- gem.add_development_dependency "rspec", "~> 3.5.0"
20
+ gem.add_development_dependency 'pry-nav'
21
+ gem.add_development_dependency 'rspec', '~> 3.5.0'
21
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tf2_line_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2021-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -89,6 +89,7 @@ files:
89
89
  - lib/tf2_line_parser/events/console_say.rb
90
90
  - lib/tf2_line_parser/events/current_score.rb
91
91
  - lib/tf2_line_parser/events/damage.rb
92
+ - lib/tf2_line_parser/events/disconnect.rb
92
93
  - lib/tf2_line_parser/events/domination.rb
93
94
  - lib/tf2_line_parser/events/event.rb
94
95
  - lib/tf2_line_parser/events/final_score.rb