tf2_line_parser 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +43 -0
- data/README.md +15 -0
- data/lib/tf2_line_parser/events/assist.rb +13 -0
- data/lib/tf2_line_parser/events/capture_block.rb +26 -0
- data/lib/tf2_line_parser/events/charge_deployed.rb +23 -0
- data/lib/tf2_line_parser/events/chat.rb +38 -0
- data/lib/tf2_line_parser/events/console_say.rb +24 -0
- data/lib/tf2_line_parser/events/current_score.rb +13 -0
- data/lib/tf2_line_parser/events/damage.rb +24 -0
- data/lib/tf2_line_parser/events/domination.rb +12 -0
- data/lib/tf2_line_parser/events/event.rb +70 -0
- data/lib/tf2_line_parser/events/final_score.rb +13 -0
- data/lib/tf2_line_parser/events/heal.rb +25 -0
- data/lib/tf2_line_parser/events/kill.rb +13 -0
- data/lib/tf2_line_parser/events/match_end.rb +24 -0
- data/lib/tf2_line_parser/events/medic_death.rb +12 -0
- data/lib/tf2_line_parser/events/pickup_item.rb +28 -0
- data/lib/tf2_line_parser/events/point_capture.rb +26 -0
- data/lib/tf2_line_parser/events/revenge.rb +12 -0
- data/lib/tf2_line_parser/events/role_change.rb +28 -0
- data/lib/tf2_line_parser/events/round_length.rb +24 -0
- data/lib/tf2_line_parser/events/round_stalemate.rb +23 -0
- data/lib/tf2_line_parser/events/round_start.rb +23 -0
- data/lib/tf2_line_parser/events/round_win.rb +23 -0
- data/lib/tf2_line_parser/events/score.rb +29 -0
- data/lib/tf2_line_parser/events/suicide.rb +28 -0
- data/lib/tf2_line_parser/events/unknown.rb +28 -0
- data/lib/tf2_line_parser/line.rb +25 -0
- data/lib/tf2_line_parser/parser.rb +15 -0
- data/lib/tf2_line_parser/player.rb +19 -0
- data/lib/tf2_line_parser/version.rb +3 -0
- data/lib/tf2_line_parser.rb +13 -0
- data/script/bundler +10 -0
- data/script/ci +22 -0
- data/spec/fixtures/logs/broder_vs_epsilon.log +4539 -0
- data/spec/fixtures/logs/example.log +4528 -0
- data/spec/fixtures/logs/special_characters.log +275 -0
- data/spec/lib/tf2_line_parser/parser_spec.rb +273 -0
- data/spec/lib/tf2_line_parser/player_spec.rb +15 -0
- data/spec/spec_helper.rb +2 -0
- data/tf2_line_parser.gemspec +20 -0
- metadata +144 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
module TF2LineParser
|
2
|
+
module Events
|
3
|
+
|
4
|
+
class Suicide < Event
|
5
|
+
|
6
|
+
def self.regex
|
7
|
+
@regex ||= /#{regex_time} #{regex_player} committed suicide with #{regex_suicide}/
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.regex_suicide
|
11
|
+
@regex_role ||= '\"(?\'method\'\w*)\"'
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.attributes
|
15
|
+
@attributes ||= [:time, :player_nick, :player_steamid, :player_team, :method]
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_accessor :time, :player, :method
|
19
|
+
|
20
|
+
def initialize(time, player_name, player_steam_id, player_team, method)
|
21
|
+
@time = parse_time(time)
|
22
|
+
@player = Player.new(player_name, player_steam_id, player_team)
|
23
|
+
@method = method
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module TF2LineParser
|
2
|
+
module Events
|
3
|
+
|
4
|
+
class Unknown < Event
|
5
|
+
|
6
|
+
def self.regex
|
7
|
+
@regex ||= /#{regex_time} #{regex_unknown}/
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.regex_unknown
|
11
|
+
"(?'unknown'.*)"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.attributes
|
15
|
+
@attributes ||= [:time, :unknown]
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_accessor :time, :unknown
|
19
|
+
|
20
|
+
def initialize(time, unknown)
|
21
|
+
@time = parse_time(time)
|
22
|
+
@unknown = unknown
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module TF2LineParser
|
4
|
+
|
5
|
+
class Line
|
6
|
+
|
7
|
+
attr_accessor :line
|
8
|
+
|
9
|
+
def initialize(line)
|
10
|
+
@line = line.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace, :replace => '').encode('UTF-8')
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse
|
14
|
+
Events::Event.types.each do |type|
|
15
|
+
if match = line.match(type.regex)
|
16
|
+
@match ||= type.new(*type.regex_results(match))
|
17
|
+
break
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@match
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module TF2LineParser
|
2
|
+
|
3
|
+
class Player
|
4
|
+
|
5
|
+
attr_accessor :name, :steam_id, :team
|
6
|
+
|
7
|
+
def initialize(name, steam_id, team)
|
8
|
+
@name = name
|
9
|
+
@steam_id = steam_id
|
10
|
+
@team = team
|
11
|
+
end
|
12
|
+
|
13
|
+
def ==(other)
|
14
|
+
steam_id == other.steam_id
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "tf2_line_parser/version"
|
2
|
+
require "tf2_line_parser/parser"
|
3
|
+
require "tf2_line_parser/player"
|
4
|
+
|
5
|
+
require "tf2_line_parser/events/event"
|
6
|
+
require "tf2_line_parser/events/score"
|
7
|
+
Dir[File.dirname(__FILE__) + '/tf2_line_parser/events/*.rb'].each {|file| require file }
|
8
|
+
require "tf2_line_parser/line"
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
module TF2LineParser
|
13
|
+
end
|
data/script/bundler
ADDED
data/script/ci
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
run() {
|
2
|
+
time bundle exec $*
|
3
|
+
}
|
4
|
+
|
5
|
+
echo "--- Starting continuous integration build"
|
6
|
+
|
7
|
+
./script/bundler
|
8
|
+
|
9
|
+
if [[ -d coverage ]]; then
|
10
|
+
echo "Removing old coverage report"
|
11
|
+
rm -r coverage
|
12
|
+
fi
|
13
|
+
|
14
|
+
echo "--- Running RSpec"
|
15
|
+
|
16
|
+
run rspec --color spec --format SpecCoverage --format progress --format html --out rspec.html
|
17
|
+
rspec=$?
|
18
|
+
|
19
|
+
if [[ $rspec -ne 0 ]]; then
|
20
|
+
echo "--- Some tests have failed."
|
21
|
+
exit 1
|
22
|
+
fi
|