tf2_line_parser 0.7.0 → 0.8.0

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.
@@ -908,6 +908,48 @@ module TF2LineParser
908
908
  expect(result.value).to eq('BLU vs "RED"')
909
909
  end
910
910
 
911
+ it 'recognizes meta data with several properties' do
912
+ result = parse('L 11/20/2026 - 21:55:48: World triggered "meta_data" (plugin_version_supstats2 "3.0.0") (plugin_version_medicstats "2.0.0")')
913
+ expect(result).to be_a(Events::MetaData)
914
+ expect(result.key).to eq('plugin_version_supstats2')
915
+ expect(result.value).to eq('3.0.0')
916
+ expect(result.properties).to eq('plugin_version_supstats2' => '3.0.0', 'plugin_version_medicstats' => '2.0.0')
917
+ end
918
+
919
+ it 'exposes single meta data as properties too' do
920
+ result = parse('L 06/15/2026 - 21:55:48: World triggered "meta_data" (map "cp_process_f12")')
921
+ expect(result.properties).to eq('map' => 'cp_process_f12')
922
+ end
923
+
924
+ it 'does not split a title that looks like several properties' do
925
+ result = parse('L 06/15/2026 - 21:55:48: World triggered "meta_data" (title "a") (b "c")')
926
+ expect(result.key).to eq('title')
927
+ expect(result.value).to eq('a") (b "c')
928
+ expect(result.properties).to eq('title' => 'a") (b "c')
929
+ end
930
+
931
+ it 'recognizes medigun pickups' do
932
+ result = parse('L 11/20/2026 - 21:55:48: "Jib<3><[U:1:111]><Red>" triggered "medigun_pickup" (medigun "kritzkrieg") (uberpct "63") (previous_medigun "medigun") (previous_uberpct "40")')
933
+ expect(result).to be_a(Events::MedigunPickup)
934
+ expect(result.player.name).to eq('Jib')
935
+ expect(result.player.steam_id).to eq('[U:1:111]')
936
+ expect(result.player.team).to eq('Red')
937
+ expect(result.medigun).to eq('kritzkrieg')
938
+ expect(result.ubercharge).to eq(63)
939
+ expect(result.previous_medigun).to eq('medigun')
940
+ expect(result.previous_ubercharge).to eq(40)
941
+ end
942
+
943
+ it 'recognizes a headshot that is also an airshot' do
944
+ result = parse('L 11/20/2026 - 21:55:48: "Jib<3><[U:1:111]><Red>" triggered "damage" against "Kol<4><[U:1:222]><Blue>" (damage "150") (realdamage "120") (weapon "tf_projectile_arrow") (crit "crit") (airshot "1") (height "200") (headshot "1")')
945
+ expect(result).to be_a(Events::HeadshotDamage)
946
+ expect(result.damage).to eq(150)
947
+ expect(result.realdamage).to eq(120)
948
+ expect(result.crit).to eq('crit')
949
+ expect(result.headshot).to eq(true)
950
+ expect(result.airshot).to eq(true)
951
+ end
952
+
911
953
  it 'recognizes round overtime' do
912
954
  expect(parse('L 06/15/2026 - 19:33:13: World triggered "Round_Overtime"')).to be_a(Events::RoundOvertime)
913
955
  end
@@ -1086,5 +1128,58 @@ module TF2LineParser
1086
1128
  end
1087
1129
  end
1088
1130
  end
1131
+
1132
+ describe 'logs from supstats2 3.0.0' do
1133
+ def fixture_events(name)
1134
+ File.readlines(File.expand_path("../../fixtures/logs/#{name}", __dir__)).map { |line| Parser.parse(line) }
1135
+ end
1136
+
1137
+ # https://logs.tf/4155452
1138
+ context 'with the first round of a match' do
1139
+ let(:events) { fixture_events('supstats2_3.log') }
1140
+
1141
+ it 'parses every line except the demos.tf notice' do
1142
+ unknown = events.grep(Events::Unknown)
1143
+
1144
+ expect(events).not_to include(nil)
1145
+ expect(unknown.map(&:unknown)).to eq(['[demos.tf]: Demos must be at least 5 minutes long'])
1146
+ end
1147
+
1148
+ it 'reads the plugin versions from the meta data' do
1149
+ properties = events.grep(Events::MetaData).map(&:properties).reduce(:merge)
1150
+
1151
+ expect(properties.keys).to eq(%w[matchid map title plugin_version_supstats2 plugin_version_medicstats])
1152
+ expect(properties['map']).to eq('cp_granary_pro_rc17a3')
1153
+ expect(properties['plugin_version_supstats2']).to eq('3.0.0')
1154
+ expect(properties['plugin_version_medicstats']).to eq('2.0.0')
1155
+ end
1156
+
1157
+ it 'recognizes the medigun pickup' do
1158
+ pickups = events.grep(Events::MedigunPickup)
1159
+
1160
+ expect(pickups.size).to eq(1)
1161
+ expect(pickups.first.medigun).to eq('medigun')
1162
+ expect(pickups.first.ubercharge).to eq(80)
1163
+ expect(pickups.first.previous_medigun).to eq('medigun')
1164
+ expect(pickups.first.previous_ubercharge).to eq(35)
1165
+ expect(pickups.first.player.team).to eq('Red')
1166
+ end
1167
+ end
1168
+
1169
+ # https://logs.tf/4155431
1170
+ context 'with chat during a pause' do
1171
+ let(:events) { fixture_events('pause_chat.log') }
1172
+
1173
+ it 'parses the chat between the pause and the unpause' do
1174
+ expect(events.map(&:class)).to eq(
1175
+ [Events::GamePaused, Events::MatchPause, *[Events::Say] * 7,
1176
+ Events::GameUnpaused, Events::MatchUnpause, Events::PauseLength]
1177
+ )
1178
+ expect(events.grep(Events::Say).map(&:message)).to eq(
1179
+ ['GOOD GOD', 'tac or tech?', 'brp./', 'bro', 'BOTH', 'WTF\\', 'LMFAO']
1180
+ )
1181
+ end
1182
+ end
1183
+ end
1089
1184
  end
1090
1185
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tf2_line_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arie
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-11-01 00:00:00.000000000 Z
10
+ date: 2026-11-22 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: coveralls_reborn
@@ -121,6 +121,7 @@ files:
121
121
  - lib/tf2_line_parser/events/match_unpause.rb
122
122
  - lib/tf2_line_parser/events/medic_death.rb
123
123
  - lib/tf2_line_parser/events/medic_death_ex.rb
124
+ - lib/tf2_line_parser/events/medigun_pickup.rb
124
125
  - lib/tf2_line_parser/events/meta_data.rb
125
126
  - lib/tf2_line_parser/events/mini_round_length.rb
126
127
  - lib/tf2_line_parser/events/mini_round_selected.rb
@@ -169,7 +170,9 @@ files:
169
170
  - spec/fixtures/logs/detailed_damage.log
170
171
  - spec/fixtures/logs/example.log
171
172
  - spec/fixtures/logs/new_log.log
173
+ - spec/fixtures/logs/pause_chat.log
172
174
  - spec/fixtures/logs/special_characters.log
175
+ - spec/fixtures/logs/supstats2_3.log
173
176
  - spec/fixtures/logs/very_special_characters.log
174
177
  - spec/lib/tf2_line_parser/parser_spec.rb
175
178
  - spec/lib/tf2_line_parser/player_spec.rb
@@ -202,7 +205,9 @@ test_files:
202
205
  - spec/fixtures/logs/detailed_damage.log
203
206
  - spec/fixtures/logs/example.log
204
207
  - spec/fixtures/logs/new_log.log
208
+ - spec/fixtures/logs/pause_chat.log
205
209
  - spec/fixtures/logs/special_characters.log
210
+ - spec/fixtures/logs/supstats2_3.log
206
211
  - spec/fixtures/logs/very_special_characters.log
207
212
  - spec/lib/tf2_line_parser/parser_spec.rb
208
213
  - spec/lib/tf2_line_parser/player_spec.rb