steam_hlds_log_parser 0.4.5 → 0.4.6
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 +5 -5
- data/README.md +3 -1
- data/examples/example-1.rb +2 -0
- data/examples/example-2.rb +2 -0
- data/lib/locales/en.yml +2 -0
- data/lib/locales/fr.yml +2 -0
- data/lib/steam_hlds_log_parser/client.rb +5 -1
- data/lib/steam_hlds_log_parser/handler.rb +10 -0
- data/lib/steam_hlds_log_parser/version.rb +1 -1
- data/spec/handler_spec.rb +18 -0
- data/spec/helper_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: a32a52ce679e252af994eedb84a7d2781ebffb95
|
4
|
-
data.tar.gz: f07dfa6ca9605ae974f034f237f25357eac3c7d8
|
5
2
|
SHA512:
|
6
|
-
|
7
|
-
|
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
|
|
data/examples/example-1.rb
CHANGED
data/examples/example-2.rb
CHANGED
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
|
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
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.
|
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-
|
12
|
+
date: 2013-08-15 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|