steam_hlds_log_parser 0.4.5 → 0.4.6

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
- SHA1:
3
- metadata.gz: a32a52ce679e252af994eedb84a7d2781ebffb95
4
- data.tar.gz: f07dfa6ca9605ae974f034f237f25357eac3c7d8
5
2
  SHA512:
6
- metadata.gz: 92fe4262801a3671c38291873f677634b13cf7047c6fd5096ac31ba451d1f3b51502996eaa5d3e78ebd51e0a36e9f751bd4fbe2d799ba14e694a57f5a9bd7318
7
- data.tar.gz: 8fd46eefe9a61187958f683eb8d7051a7263a3e1f0847cfe4d1f42764f29f853e59d22854c8c9abe8060263588480b27754766f59173139311890a407c967e86
3
+ data.tar.gz: 21f9f688aa94ffa40bddb17b43e0b2ae7774bec09d42ebbb00524ff1acaf70350ed703ae1eb59a3fdc52c2c9bd7d1c7a129d0bb2157f380528cb022e149124cb
4
+ metadata.gz: ec172491894a4a85647baf437dffff1a660f55a160c3e35b01b44b602b48a6497bbdd9ace675b52d22e08d5ccb2026417650011a40913bb5bd9319f41f40e826
5
+ SHA1:
6
+ data.tar.gz: 8b03a0b37424792c0f6698bdd2127b7dac379f36
7
+ metadata.gz: 3225c8d1342cbe90341bad78fe81404d87be864b
data/README.md CHANGED
@@ -42,7 +42,7 @@ If you are behind a router/firewall, you probably need to configure it.
42
42
 
43
43
  class Formatter
44
44
  def initialize(data)
45
- # will 'puts' the translated content
45
+ # will 'puts' the translated content using built-in displayer
46
46
  SteamHldsLogParser::Displayer.new(data).display_translation
47
47
  end
48
48
  end
@@ -54,6 +54,8 @@ If you are behind a router/firewall, you probably need to configure it.
54
54
  :display_kills => true,
55
55
  :display_actions => true,
56
56
  :display_changelevel => true,
57
+ :display_chat => true,
58
+ :display_team_chat => true,
57
59
  :displayer => Formatter
58
60
  }
59
61
 
@@ -15,6 +15,8 @@ options = {
15
15
  :display_kills => true,
16
16
  :display_actions => true,
17
17
  :display_changelevel => true,
18
+ :display_chat => true,
19
+ :display_team_chat => true,
18
20
  :displayer => Formatter
19
21
  }
20
22
 
@@ -18,6 +18,8 @@ options = {
18
18
  :display_kills => true,
19
19
  :display_actions => true,
20
20
  :display_changelevel => true,
21
+ :display_chat => true,
22
+ :display_team_chat => true,
21
23
  :displayer => FlowdockPusher
22
24
  }
23
25
 
data/lib/locales/en.yml CHANGED
@@ -40,3 +40,5 @@ en:
40
40
  suicide: "%{killed} commited suicide"
41
41
  event: "[%{person_team}] %{person} %{event_i18n}"
42
42
  loading_map: "Loading %{map}"
43
+ chat: "[%{player_team}] %{player} says \"%{chat}\""
44
+ team_chat: "[%{player_team}] %{player} says \"%{chat}\" to others [%{player_team}]"
data/lib/locales/fr.yml CHANGED
@@ -40,3 +40,5 @@ fr:
40
40
  suicide: "%{killed} s'est tué"
41
41
  event: "[%{person_team}] %{person} %{event_i18n}"
42
42
  loading_map: "Chargement de %{map}"
43
+ chat: "[%{player_team}] %{player} dit \"%{chat}\""
44
+ team_chat: "[%{player_team}] %{player} dit \"%{chat}\" aux autres [%{player_team}]"
@@ -19,6 +19,8 @@ module SteamHldsLogParser
19
19
  # @option options [Boolean] :display_kills (true) Enable kills / frags detail
20
20
  # @option options [Boolean] :display_actions (true) Enable players actions / defuse / ... detail
21
21
  # @option options [Boolean] :display_changelevel (true) Enable changelevel (map) display
22
+ # @option options [Boolean] :display_chat (true) Enable chat ('say') display
23
+ # @option options [Boolean] :display_team_chat (true) Enable chat ('say_team') display
22
24
  # @option options [Class] :displayer Class that will be use to display content
23
25
  #
24
26
  def initialize(host, port, options = {})
@@ -26,7 +28,9 @@ module SteamHldsLogParser
26
28
  :locale => :en,
27
29
  :display_kills => true,
28
30
  :display_actions => true,
29
- :display_changelevel => true
31
+ :display_changelevel => true,
32
+ :display_chat => true,
33
+ :display_team_chat => true,
30
34
  }
31
35
  @host, @port = host, port
32
36
  @options = default_options.merge(options)
@@ -72,6 +72,16 @@ module SteamHldsLogParser
72
72
  map = data.match(/: Loading map "(.+)"/i).captures.first
73
73
  content = { :type => 'loading_map', :params => { :map => map } }
74
74
 
75
+ # L 05/10/2000 - 12:34:56: "Player<15><STEAM_0:0:12345><TERRORIST>" say "gg" (dead)
76
+ elsif @options[:display_chat] && data.gsub(/: "(.+)<\d+><.+><([A-Z]+)>" say "(.+)"/).count > 0
77
+ player, player_team, message = data.match(/: "(.+)<\d+><.+><([A-Z]+)>" say "(.+)"/i).captures
78
+ content = { :type => 'chat', :params => { :player => player, :player_team => get_short_team_name(player_team), :chat => message } }
79
+
80
+ # L 05/10/2000 - 12:34:56: "Player<15><STEAM_0:0:12345><TERRORIST>" say_team "Rush B" (dead)
81
+ elsif @options[:display_team_chat] && data.gsub(/: "(.+)<\d+><.+><([A-Z]+)>" say_team "(.+)"/).count > 0
82
+ player, player_team, message = data.match(/: "(.+)<\d+><.+><([A-Z]+)>" say_team "(.+)"/i).captures
83
+ content = { :type => 'team_chat', :params => { :player => player, :player_team => get_short_team_name(player_team), :chat => message } }
84
+
75
85
  end
76
86
 
77
87
  # no matching pattern, no output
@@ -1,4 +1,4 @@
1
1
  module SteamHldsLogParser
2
2
  # Gem Version
3
- VERSION = "0.4.5"
3
+ VERSION = "0.4.6"
4
4
  end
data/spec/handler_spec.rb CHANGED
@@ -135,6 +135,24 @@ module SteamHldsLogParser
135
135
  end
136
136
  end
137
137
 
138
+ context "when data is 'chat'" do
139
+ it "returns Hash on changelevel" do
140
+ data = '# L 05/10/2000 - 12:34:56: "Player<15><STEAM_0:0:12345><TERRORIST>" say "gg" (dead)'
141
+ expected = {:type=>"chat", :params=>{:player=>"Player", :player_team=>"T", :chat=>"gg"}}
142
+ @handler.receive_data(data).class.should eq(Hash)
143
+ @handler.receive_data(data).should eq(expected)
144
+ end
145
+ end
146
+
147
+ context "when data is 'team_chat'" do
148
+ it "returns Hash on changelevel" do
149
+ data = '# L 05/10/2000 - 12:34:56: "Player<15><STEAM_0:0:12345><TERRORIST>" say_team "Rush B"'
150
+ expected = {:type=>"team_chat", :params=>{:player=>"Player", :player_team=>"T", :chat=>"Rush B"}}
151
+ @handler.receive_data(data).class.should eq(Hash)
152
+ @handler.receive_data(data).should eq(expected)
153
+ end
154
+ end
155
+
138
156
  context "when 'displayer' is set" do
139
157
  it "returns Hash on changelevel provided by 'displayer'" do
140
158
  data = '# L 05/10/2000 - 12:34:56: Loading map "de_dust2"'
data/spec/helper_spec.rb CHANGED
@@ -41,6 +41,8 @@ def custom_options
41
41
  :display_kills => false,
42
42
  :display_actions => false,
43
43
  :display_changelevel => true,
44
+ :display_chat => false,
45
+ :display_team_chat => false,
44
46
  :displayer => RSpecDisplayer
45
47
  }
46
48
  end
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.4.5
4
+ version: 0.4.6
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-08-14 00:00:00 Z
12
+ date: 2013-08-15 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler