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,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
- module TF2LineParser
3
2
 
3
+ module TF2LineParser
4
4
  module Events
5
-
6
5
  class PlayerActionEvent < Event
7
-
8
6
  def self.regex
9
7
  @regex ||= /#{regex_time} #{regex_player} #{action_text} #{regex_action}/.freeze
10
8
  end
11
9
 
12
10
  def self.attributes
13
- @attributes ||= [:time, :player_nick, :player_steamid, :player_team, self.item]
11
+ @attributes ||= [:time, :player_nick, :player_steamid, :player_team, item]
14
12
  end
15
13
 
16
14
  def initialize(time, player_name, player_steam_id, player_team, item = self.class.item)
@@ -18,7 +16,6 @@ module TF2LineParser
18
16
  @player = Player.new(player_name, player_steam_id, player_team)
19
17
  instance_variable_set("@#{self.class.item}", item)
20
18
  end
21
-
22
19
  end
23
20
  end
24
21
  end
@@ -1,15 +1,14 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class PointCapture < Event
6
-
7
6
  def self.regex
8
7
  @regex ||= /#{regex_time} Team "(?'team'Red|Blue)" triggered "pointcaptured" \(cp "(?'cp_number'\d+)"\) \(cpname "(?'cp_name'.*)"\) \(numcappers/.freeze
9
8
  end
10
9
 
11
10
  def self.attributes
12
- @attributes ||= [:time, :team, :cp_number, :cp_name]
11
+ @attributes ||= %i[time team cp_number cp_name]
13
12
  end
14
13
 
15
14
  def initialize(time, team, cap_number, cap_name)
@@ -18,8 +17,6 @@ module TF2LineParser
18
17
  @cap_number = cap_number
19
18
  @cap_name = cap_name
20
19
  end
21
-
22
20
  end
23
-
24
21
  end
25
22
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
- module TF2LineParser
3
2
 
3
+ module TF2LineParser
4
4
  module Events
5
-
6
5
  class PVPEvent < Event
7
6
  def self.attributes
8
- @attributes ||= [:time, :player_nick, :player_steamid, :player_team, :target_nick, :target_steamid, :target_team]
7
+ @attributes ||= %i[time player_nick player_steamid player_team target_nick target_steamid
8
+ target_team]
9
9
  end
10
10
 
11
11
  def initialize(time, player_name, player_steam_id, player_team, target_name, target_steam_id, target_team)
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class Revenge < PVPEvent
6
-
7
6
  def self.regex
8
7
  @regex ||= /#{regex_time} #{regex_player} triggered "revenge" against #{regex_target}.*/.freeze
9
8
  end
10
-
11
9
  end
12
10
  end
13
11
  end
@@ -1,21 +1,19 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class RoleChange < PlayerActionEvent
6
-
7
6
  def self.action_text
8
- @action_text ||= "changed role to".freeze
7
+ @action_text ||= 'changed role to'
9
8
  end
10
9
 
11
10
  def self.regex_action
12
- @regex_role ||= '\"(?\'role\'.*)\"'.freeze
11
+ @regex_role ||= '\"(?\'role\'.*)\"'
13
12
  end
14
13
 
15
14
  def self.item
16
15
  :role
17
16
  end
18
-
19
17
  end
20
18
  end
21
19
  end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class RoundEventWithVariables < Event
6
-
7
6
  def self.regex
8
7
  @regex ||= /#{regex_time} World triggered "#{round_type}" #{round_variable_regex}/.freeze
9
8
  end
@@ -16,8 +15,6 @@ module TF2LineParser
16
15
  @time = parse_time(time)
17
16
  instance_variable_set("@#{self.class.round_variable}", round_variable)
18
17
  end
19
-
20
18
  end
21
-
22
19
  end
23
20
  end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class RoundEventWithoutVariables < Event
6
-
7
6
  def self.regex
8
7
  @regex ||= /#{regex_time} World triggered "#{round_type}"/.freeze
9
8
  end
@@ -15,8 +14,6 @@ module TF2LineParser
15
14
  def initialize(time)
16
15
  @time = parse_time(time)
17
16
  end
18
-
19
17
  end
20
-
21
18
  end
22
19
  end
@@ -1,22 +1,19 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class RoundLength < RoundEventWithVariables
6
-
7
6
  def self.round_type
8
- @round_type ||= "Round_Length".freeze
7
+ @round_type ||= 'Round_Length'
9
8
  end
10
9
 
11
10
  def self.round_variable_regex
12
- @round_variable_regex ||= /\(seconds \"(?'length'.*)"\)/.freeze
11
+ @round_variable_regex ||= /\(seconds "(?'length'.*)"\)/.freeze
13
12
  end
14
13
 
15
14
  def self.round_variable
16
15
  @round_variable ||= :length
17
16
  end
18
-
19
17
  end
20
-
21
18
  end
22
19
  end
@@ -1,14 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class RoundStalemate < RoundEventWithoutVariables
6
-
7
6
  def self.round_type
8
- @round_type ||= "Round_Stalemate".freeze
7
+ @round_type ||= 'Round_Stalemate'
9
8
  end
10
-
11
9
  end
12
-
13
10
  end
14
11
  end
@@ -1,14 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class RoundStart < RoundEventWithoutVariables
6
-
7
6
  def self.round_type
8
- @round_type ||= "Round_Start".freeze
7
+ @round_type ||= 'Round_Start'
9
8
  end
10
-
11
9
  end
12
-
13
10
  end
14
11
  end
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class RoundWin < RoundEventWithVariables
6
-
7
6
  def self.round_type
8
- @round_type ||= "Round_Win".freeze
7
+ @round_type ||= 'Round_Win'
9
8
  end
10
9
 
11
10
  def self.round_variable_regex
@@ -15,8 +14,6 @@ module TF2LineParser
15
14
  def self.round_variable
16
15
  @round_variable ||= :team
17
16
  end
18
-
19
17
  end
20
-
21
18
  end
22
19
  end
@@ -1,19 +1,18 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class Score < Event
6
-
7
6
  def self.regex_score
8
- @regex_score ||= '\"(?\'score\'\d+)\"'.freeze
7
+ @regex_score ||= '\"(?\'score\'\d+)\"'
9
8
  end
10
9
 
11
10
  def self.regex_team
12
- @regex_team ||= 'Team \"(?\'team\'Red|Blue)\"'.freeze
11
+ @regex_team ||= 'Team \"(?\'team\'Red|Blue)\"'
13
12
  end
14
13
 
15
14
  def self.attributes
16
- @attributes ||= [:time, :team, :score]
15
+ @attributes ||= %i[time team score]
17
16
  end
18
17
 
19
18
  def initialize(time, team, score)
@@ -21,8 +20,6 @@ module TF2LineParser
21
20
  @team = team
22
21
  @score = score
23
22
  end
24
-
25
23
  end
26
-
27
24
  end
28
25
  end
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class Spawn < RoleChange
6
-
7
6
  def self.action_text
8
- @action_text ||= "spawned as".freeze
7
+ @action_text ||= 'spawned as'
9
8
  end
10
-
11
9
  end
12
10
  end
13
11
  end
@@ -1,21 +1,19 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class Suicide < PlayerActionEvent
6
-
7
6
  def self.action_text
8
- @action_text ||= "committed suicide with".freeze
7
+ @action_text ||= 'committed suicide with'
9
8
  end
10
9
 
11
10
  def self.regex_action
12
- @regex_role ||= '\"(?\'method\'\w*)\"'.freeze
11
+ @regex_role ||= '\"(?\'method\'\w*)\"'
13
12
  end
14
13
 
15
14
  def self.item
16
15
  :method
17
16
  end
18
-
19
17
  end
20
18
  end
21
19
  end
@@ -1,27 +1,24 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  module Events
4
-
5
5
  class Unknown < Event
6
-
7
6
  def self.regex
8
7
  @regex ||= /#{regex_time} #{regex_unknown}/.freeze
9
8
  end
10
9
 
11
10
  def self.regex_unknown
12
- "(?'unknown'.*)".freeze
11
+ "(?'unknown'.*)"
13
12
  end
14
13
 
15
14
  def self.attributes
16
- @attributes ||= [:time, :unknown]
15
+ @attributes ||= %i[time unknown]
17
16
  end
18
17
 
19
18
  def initialize(time, unknown)
20
19
  @time = parse_time(time)
21
20
  @unknown = unknown
22
21
  end
23
-
24
22
  end
25
-
26
23
  end
27
24
  end
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'time'
3
4
  require 'active_support/multibyte/chars'
4
5
  require 'active_support/multibyte/unicode'
5
6
 
6
7
  module TF2LineParser
7
-
8
8
  class Line
9
-
10
9
  attr_accessor :line
11
10
 
12
11
  def initialize(line)
@@ -28,7 +27,5 @@ module TF2LineParser
28
27
  end
29
28
  @match
30
29
  end
31
-
32
30
  end
33
-
34
31
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
4
  class Parser
4
-
5
5
  attr_accessor :line
6
6
 
7
7
  def initialize(line)
@@ -11,6 +11,5 @@ module TF2LineParser
11
11
  def parse
12
12
  line.parse
13
13
  end
14
-
15
14
  end
16
15
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
- module TF2LineParser
3
2
 
3
+ module TF2LineParser
4
4
  class Player
5
-
6
5
  attr_accessor :name, :steam_id, :team
7
6
 
8
7
  def initialize(name, steam_id, team)
@@ -14,7 +13,5 @@ module TF2LineParser
14
13
  def ==(other)
15
14
  steam_id == other.steam_id
16
15
  end
17
-
18
16
  end
19
-
20
17
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TF2LineParser
3
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
4
5
  end
@@ -1,21 +1,20 @@
1
1
  # frozen_string_literal: true
2
- require "tf2_line_parser/version"
3
- require "tf2_line_parser/parser"
4
- require "tf2_line_parser/player"
5
-
6
- require "tf2_line_parser/events/event"
7
- require "tf2_line_parser/events/pvp_event"
8
- require "tf2_line_parser/events/player_action_event"
9
- require "tf2_line_parser/events/round_event_without_variables"
10
- require "tf2_line_parser/events/round_event_with_variables"
11
- require "tf2_line_parser/events/connect"
12
- require "tf2_line_parser/events/score"
13
- require "tf2_line_parser/events/role_change"
14
- require "tf2_line_parser/events/damage"
15
- Dir[File.dirname(__FILE__) + '/tf2_line_parser/events/*.rb'].each {|file| require file }
16
- require "tf2_line_parser/line"
17
2
 
3
+ require 'tf2_line_parser/version'
4
+ require 'tf2_line_parser/parser'
5
+ require 'tf2_line_parser/player'
18
6
 
7
+ require 'tf2_line_parser/events/event'
8
+ require 'tf2_line_parser/events/pvp_event'
9
+ require 'tf2_line_parser/events/player_action_event'
10
+ require 'tf2_line_parser/events/round_event_without_variables'
11
+ require 'tf2_line_parser/events/round_event_with_variables'
12
+ require 'tf2_line_parser/events/connect'
13
+ require 'tf2_line_parser/events/score'
14
+ require 'tf2_line_parser/events/role_change'
15
+ require 'tf2_line_parser/events/damage'
16
+ Dir["#{File.dirname(__FILE__)}/tf2_line_parser/events/*.rb"].sort.each { |file| require file }
17
+ require 'tf2_line_parser/line'
19
18
 
20
19
  module TF2LineParser
21
20
  end
@@ -4540,4 +4540,5 @@ L 07/01/2013 - 15:22:46: "Imm.SPIRIT<117><STEAM_0:0:51202358><Blue>" spawned as
4540
4540
  L 07/01/2013 - 15:22:46: "INF Scorpion's new acc<120><STEAM_0:0:42468138><Blue>" spawned as "Soldier"
4541
4541
  L 07/01/2013 - 15:22:46: "snaaw<123><STEAM_0:1:59955670><Red>" spawned as "Medic"
4542
4542
  L 07/01/2013 - 15:22:46: "candyyou # Infinity Gaming<124><STEAM_0:0:50979748><Red>" spawned as "Soldier"
4543
+ L 10/04/2012 - 21:25:53: "cc//TviQ<8><STEAM_0:0:8520477><Blue>" disconnected (reason "Disconnect by user.")
4543
4544
  L 02/07/2013 - 21:56:13: Log file closed