neweden-km-parser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/init.rb +4 -0
- data/lib/neweden-km-parser.rb +165 -0
- data/test/helper.rb +23 -0
- data/test/km_generic.txt +42 -0
- data/test/km_podmail_w_implants.txt +67 -0
- data/test/km_podmail_wo_implants.txt +49 -0
- data/test/test_neweden-km-parser.rb +166 -0
- metadata +120 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Add dependencies to develop your gem here.
|
4
|
+
# Include everything needed to run rake, tests, features, etc.
|
5
|
+
group :development do
|
6
|
+
gem "shoulda", ">= 0"
|
7
|
+
gem "bundler", "~> 1.0.0"
|
8
|
+
gem "jeweler", "~> 1.8.3"
|
9
|
+
gem "awesome_print"
|
10
|
+
gem "pry"
|
11
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
awesome_print (1.0.2)
|
5
|
+
coderay (1.0.6)
|
6
|
+
git (1.2.5)
|
7
|
+
jeweler (1.8.3)
|
8
|
+
bundler (~> 1.0)
|
9
|
+
git (>= 1.2.5)
|
10
|
+
rake
|
11
|
+
rdoc
|
12
|
+
json (1.6.5)
|
13
|
+
method_source (0.7.1)
|
14
|
+
pry (0.9.9)
|
15
|
+
coderay (~> 1.0.5)
|
16
|
+
method_source (~> 0.7.1)
|
17
|
+
slop (>= 2.4.4, < 3)
|
18
|
+
rake (0.9.2.2)
|
19
|
+
rdoc (3.12)
|
20
|
+
json (~> 1.4)
|
21
|
+
shoulda (3.0.0)
|
22
|
+
shoulda-context (~> 1.0.0)
|
23
|
+
shoulda-matchers (~> 1.0.0)
|
24
|
+
shoulda-context (1.0.0)
|
25
|
+
shoulda-matchers (1.0.0)
|
26
|
+
slop (2.4.4)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
awesome_print
|
33
|
+
bundler (~> 1.0.0)
|
34
|
+
jeweler (~> 1.8.3)
|
35
|
+
pry
|
36
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Jason Adams
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= neweden-km-parser
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to neweden-km-parser
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Jason Adams. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "neweden-km-parser"
|
18
|
+
gem.homepage = "http://github.com/ealdent/neweden-km-parser"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Parser for killmails generated by the MMO EVE Online.}
|
21
|
+
gem.description = %Q{Parser for the mails generated by the MMO EVE Online when an internet spaceship is destroyed.}
|
22
|
+
gem.email = "jasonmadams@gmail.com"
|
23
|
+
gem.authors = ["Jason Adams"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rdoc/task'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "neweden-km-parser #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/init.rb
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
class KillmailParser
|
2
|
+
REGEXP_PRIMITIVES = {
|
3
|
+
:victim_name => "Victim: (.*)",
|
4
|
+
:corp => "Corp: (.*)",
|
5
|
+
:alliance => "Alliance: (.*)",
|
6
|
+
:faction => "Faction: (.*)",
|
7
|
+
:destroyed => "Destroyed: (.*)",
|
8
|
+
:system => "System: (.*)",
|
9
|
+
:security => "Security: (-?\\d{1,2}\\.\\d{1,2})",
|
10
|
+
:damage_taken => "Damage Taken: (-?\\d+)",
|
11
|
+
:name => "Name: (.*)",
|
12
|
+
:ship => "Ship: (.*)",
|
13
|
+
:weapon => "Weapon: (.*)",
|
14
|
+
:damage_done => "Damage Done: (-?\\d+)",
|
15
|
+
:involved_parties => "Involved parties:",
|
16
|
+
:date => "\\d{4}\\.\\d{2}\\.\\d{2} \\d{2}:\\d{2}:\\d{2}"
|
17
|
+
}
|
18
|
+
|
19
|
+
attr_reader :killmail, :date, :victim, :attackers, :destroyed_items, :dropped_items
|
20
|
+
|
21
|
+
def initialize(killmail)
|
22
|
+
@valid = false
|
23
|
+
@killmail = killmail.to_s.dup.freeze
|
24
|
+
process
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_victim_and_date(pbody)
|
28
|
+
raise "Could not parse victim and date" if pbody.nil? || pbody.empty?
|
29
|
+
|
30
|
+
header, pbody = pbody.split("Involved parties:").map { |txt| txt.strip }
|
31
|
+
date, victim = header.split("\n\n").map { |txt| txt.strip }
|
32
|
+
[date, victim, pbody]
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse_attackers(pbody)
|
36
|
+
raise "Could not parse attackers" if pbody.nil? || pbody.empty?
|
37
|
+
|
38
|
+
split_on = if pbody =~ /Destroyed items:/
|
39
|
+
@has_destroyed = true
|
40
|
+
'Destroyed items:'
|
41
|
+
elsif pbody =~ /Dropped items:/
|
42
|
+
@has_destroyed = false
|
43
|
+
'Dropped items:'
|
44
|
+
else
|
45
|
+
@has_destroyed = false
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
attacker_txt, pbody = if split_on
|
50
|
+
pbody.split(split_on).map { |txt| txt.strip }
|
51
|
+
else
|
52
|
+
[pbody.strip, nil]
|
53
|
+
end
|
54
|
+
|
55
|
+
attackers = attacker_txt.split("\n\n").map { |txt| txt.strip }
|
56
|
+
[attackers, pbody]
|
57
|
+
end
|
58
|
+
|
59
|
+
def parse_destroyed_items(pbody)
|
60
|
+
return [nil, nil] if pbody.nil? || pbody.empty?
|
61
|
+
|
62
|
+
if pbody =~ /Dropped items:/
|
63
|
+
pbody.split("Dropped items:").map { |txt| txt.strip }
|
64
|
+
else
|
65
|
+
[pbody.strip, nil]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def process
|
70
|
+
date, victim, pbody = parse_victim_and_date(@killmail)
|
71
|
+
attackers, pbody = parse_attackers(pbody)
|
72
|
+
destroyed, pbody = parse_destroyed_items(pbody) if pbody && @has_destroyed
|
73
|
+
dropped = pbody.nil? ? nil : pbody.strip
|
74
|
+
|
75
|
+
@date = DateTime.parse(date)
|
76
|
+
|
77
|
+
victim_match = _victim.match(victim)
|
78
|
+
@victim = {
|
79
|
+
:name => victim_match[1],
|
80
|
+
:corp => victim_match[2],
|
81
|
+
:alliance => victim_match[3],
|
82
|
+
:faction => victim_match[4],
|
83
|
+
:ship => victim_match[5],
|
84
|
+
:system => victim_match[6],
|
85
|
+
:security => victim_match[7],
|
86
|
+
:damage => victim_match[8]
|
87
|
+
}
|
88
|
+
|
89
|
+
@attackers = []
|
90
|
+
attackers.each do |attacker|
|
91
|
+
attacker_match = _attacker.match(attacker)
|
92
|
+
attacker_name_match = /^([^()]+)( \((.*)\))?$/.match(attacker_match[1])
|
93
|
+
attacker_name = attacker_name_match[1]
|
94
|
+
final_blow = !!attacker_name_match[3]
|
95
|
+
@attackers << {
|
96
|
+
:name => attacker_name,
|
97
|
+
:final_blow => final_blow,
|
98
|
+
:security => attacker_match[2],
|
99
|
+
:corp => attacker_match[3],
|
100
|
+
:alliance => attacker_match[4],
|
101
|
+
:faction => attacker_match[5],
|
102
|
+
:ship => attacker_match[6],
|
103
|
+
:weapon => attacker_match[7],
|
104
|
+
:damage => attacker_match[8]
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
@destroyed_items = []
|
109
|
+
@dropped_items = []
|
110
|
+
[[destroyed, @destroyed_items], [dropped, @dropped_items]].each do |body, items|
|
111
|
+
body.to_s.split(/[\n\r]+/).each do |item|
|
112
|
+
item_match = _item.match(item.strip)
|
113
|
+
qty, loc = [item_match[3] || 1, item_match[5]]
|
114
|
+
|
115
|
+
items << {
|
116
|
+
:name => item_match[1],
|
117
|
+
:quantity => qty.to_i,
|
118
|
+
:location => loc
|
119
|
+
}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
@hash = {
|
124
|
+
:victim => @victim,
|
125
|
+
:attackers => @attackers,
|
126
|
+
:destroyed_items => @destroyed_items,
|
127
|
+
:dropped_items => @dropped_items,
|
128
|
+
:date => @date
|
129
|
+
}
|
130
|
+
|
131
|
+
@valid = true
|
132
|
+
end
|
133
|
+
|
134
|
+
def valid?
|
135
|
+
@valid
|
136
|
+
end
|
137
|
+
|
138
|
+
def to_hash
|
139
|
+
@hash
|
140
|
+
end
|
141
|
+
|
142
|
+
def to_json
|
143
|
+
@hash.to_json
|
144
|
+
end
|
145
|
+
|
146
|
+
def _item
|
147
|
+
/^([^,()]*)(, Qty: (\d+))?( \((.*)\))?$/
|
148
|
+
end
|
149
|
+
|
150
|
+
def _victim
|
151
|
+
Regexp.new(%{#{_victim_name}\n#{_corp}\n#{_alliance}\n#{_faction}\n#{_destroyed}\n#{_system}\n#{_security}\n#{_damage_taken}})
|
152
|
+
end
|
153
|
+
|
154
|
+
def _attacker
|
155
|
+
Regexp.new(%{#{_name}\n#{_security}\n#{_corp}\n#{_alliance}\n#{_faction}\n#{_ship}\n#{_weapon}\n#{_damage_done}})
|
156
|
+
end
|
157
|
+
|
158
|
+
REGEXP_PRIMITIVES.each_pair do |name, regexp|
|
159
|
+
class_eval <<-RUBY
|
160
|
+
def _#{name}
|
161
|
+
#{regexp.inspect}
|
162
|
+
end
|
163
|
+
RUBY
|
164
|
+
end
|
165
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'neweden-km-parser'
|
16
|
+
|
17
|
+
EXAMPLE_KILLMAILS = {}
|
18
|
+
Dir.glob(File.join(File.dirname(__FILE__), '*.txt')).map do |f|
|
19
|
+
EXAMPLE_KILLMAILS[f.split('/').last] = File.read(f)
|
20
|
+
end
|
21
|
+
|
22
|
+
class Test::Unit::TestCase
|
23
|
+
end
|
data/test/km_generic.txt
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
2012.02.26 03:42:00
|
2
|
+
|
3
|
+
Victim: Roboticus420
|
4
|
+
Corp: Ever Flow
|
5
|
+
Alliance: Northern Coalition.
|
6
|
+
Faction: Unknown
|
7
|
+
Destroyed: Basilisk
|
8
|
+
System: O1-FTD
|
9
|
+
Security: -0.4
|
10
|
+
Damage Taken: 20738
|
11
|
+
|
12
|
+
Involved parties:
|
13
|
+
|
14
|
+
Name: Angel Drade (laid the final blow)
|
15
|
+
Security: -3.70
|
16
|
+
Corp: SQUINGEL
|
17
|
+
Alliance: Nulli Tertius
|
18
|
+
Faction: None
|
19
|
+
Ship: Hurricane
|
20
|
+
Weapon: Hurricane
|
21
|
+
Damage Done: 19235
|
22
|
+
|
23
|
+
Name: SkippyTheWonderTard
|
24
|
+
Security: 3.10
|
25
|
+
Corp: Kickass inc
|
26
|
+
Alliance: Nulli Tertius
|
27
|
+
Faction: None
|
28
|
+
Ship: Hurricane
|
29
|
+
Weapon: Hurricane
|
30
|
+
Damage Done: 1503
|
31
|
+
|
32
|
+
Destroyed items:
|
33
|
+
|
34
|
+
Photon Scattering Field II
|
35
|
+
Reactor Control Unit II, Qty: 2
|
36
|
+
Warrior II, Qty: 3 (Drone Bay)
|
37
|
+
|
38
|
+
Dropped items:
|
39
|
+
|
40
|
+
Large S95a Partial Shield Transporter, Qty: 3
|
41
|
+
Warrior II, Qty: 2 (Drone Bay)
|
42
|
+
Damage Control II
|
@@ -0,0 +1,67 @@
|
|
1
|
+
2012.04.17 21:12
|
2
|
+
|
3
|
+
Victim: Saratos852
|
4
|
+
Corp: Eternally Corporation
|
5
|
+
Alliance: RED Citizens
|
6
|
+
Faction: None
|
7
|
+
Destroyed: Capsule
|
8
|
+
System: 9CG6-H
|
9
|
+
Security: 0.0
|
10
|
+
Damage Taken: 262
|
11
|
+
|
12
|
+
Involved parties:
|
13
|
+
|
14
|
+
Name: Niles Montgomery (laid the final blow)
|
15
|
+
Security: 1.2
|
16
|
+
Corp: Space Marine Academy
|
17
|
+
Alliance: Nulli Tertius
|
18
|
+
Faction: None
|
19
|
+
Ship: Harbinger
|
20
|
+
Weapon: Heavy Pulse Laser II
|
21
|
+
Damage Done: 262
|
22
|
+
|
23
|
+
Name: Transonic
|
24
|
+
Security: 1.3
|
25
|
+
Corp: Aliastra
|
26
|
+
Alliance: None
|
27
|
+
Faction: None
|
28
|
+
Ship: Stiletto
|
29
|
+
Weapon: 'Langour' Drive Disruptor I
|
30
|
+
Damage Done: 0
|
31
|
+
|
32
|
+
Name: Berdennol
|
33
|
+
Security: 5.0
|
34
|
+
Corp: 101st Space Marine Force
|
35
|
+
Alliance: Nulli Secunda
|
36
|
+
Faction: None
|
37
|
+
Ship: Drake
|
38
|
+
Weapon: Warp Disruptor II
|
39
|
+
Damage Done: 0
|
40
|
+
|
41
|
+
Name: Senobritis
|
42
|
+
Security: 5.0
|
43
|
+
Corp: 101st Space Marine Force
|
44
|
+
Alliance: Nulli Secunda
|
45
|
+
Faction: None
|
46
|
+
Ship: Sabre
|
47
|
+
Weapon: J5b Phased Prototype Warp Scrambler I
|
48
|
+
Damage Done: 0
|
49
|
+
|
50
|
+
Name: Totalani
|
51
|
+
Security: 5.0
|
52
|
+
Corp: 101st Space Marine Force
|
53
|
+
Alliance: Nulli Secunda
|
54
|
+
Faction: None
|
55
|
+
Ship: Retribution
|
56
|
+
Weapon: J5b Phased Prototype Warp Scrambler I
|
57
|
+
Damage Done: 0
|
58
|
+
|
59
|
+
|
60
|
+
Destroyed items:
|
61
|
+
|
62
|
+
Cybernetic Subprocessor - Improved (Implant)
|
63
|
+
Social Adaptation Chip - Improved (Implant)
|
64
|
+
Memory Augmentation - Improved (Implant)
|
65
|
+
Mining Foreman Mindlink (Implant)
|
66
|
+
Neural Boost - Improved (Implant)
|
67
|
+
Ocular Filter - Improved (Implant)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
2012.04.19 02:23
|
2
|
+
|
3
|
+
Victim: Waister
|
4
|
+
Corp: Tactical Soldiers
|
5
|
+
Alliance: Nulli Secunda
|
6
|
+
Faction: None
|
7
|
+
Destroyed: Capsule
|
8
|
+
System: BWF-ZZ
|
9
|
+
Security: 0.0
|
10
|
+
Damage Taken: 351
|
11
|
+
|
12
|
+
Involved parties:
|
13
|
+
|
14
|
+
Name: cas0
|
15
|
+
Security: 1.3
|
16
|
+
Corp: Interstellar eXodus
|
17
|
+
Alliance: BricK sQuAD.
|
18
|
+
Faction: None
|
19
|
+
Ship: Tornado
|
20
|
+
Weapon: 1400mm Prototype Siege Cannon
|
21
|
+
Damage Done: 341
|
22
|
+
|
23
|
+
Name: Naternine (laid the final blow)
|
24
|
+
Security: 3.8
|
25
|
+
Corp: Liberation Army
|
26
|
+
Alliance: BricK sQuAD.
|
27
|
+
Faction: None
|
28
|
+
Ship: Drake
|
29
|
+
Weapon: Caldari Navy Scourge Heavy Missile
|
30
|
+
Damage Done: 10
|
31
|
+
|
32
|
+
Name: Misera Blue
|
33
|
+
Security: 5.0
|
34
|
+
Corp: Liberation Army
|
35
|
+
Alliance: BricK sQuAD.
|
36
|
+
Faction: None
|
37
|
+
Ship: Tornado
|
38
|
+
Weapon: 1200mm Artillery Cannon II
|
39
|
+
Damage Done: 0
|
40
|
+
|
41
|
+
Name: WaveDragon
|
42
|
+
Security: -2.1
|
43
|
+
Corp: Red Sky Morning
|
44
|
+
Alliance: BricK sQuAD.
|
45
|
+
Faction: None
|
46
|
+
Ship: Unknown
|
47
|
+
Weapon: Prototype 'Arbalest' Torpedo Launcher
|
48
|
+
Damage Done: 0
|
49
|
+
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'awesome_print'
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestNewedenKmParser < Test::Unit::TestCase
|
5
|
+
context "a generic killmail" do
|
6
|
+
should "parse without error" do
|
7
|
+
kmp = KillmailParser.new(EXAMPLE_KILLMAILS['km_generic.txt'])
|
8
|
+
end
|
9
|
+
|
10
|
+
context "after parsing" do
|
11
|
+
setup do
|
12
|
+
@kmp = KillmailParser.new(EXAMPLE_KILLMAILS['km_generic.txt'])
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have the correct date" do
|
16
|
+
assert_equal @kmp.date, DateTime.parse("2012-02-26 03:42:00")
|
17
|
+
end
|
18
|
+
|
19
|
+
should "have the correct victim" do
|
20
|
+
assert_equal @kmp.victim[:name], 'Roboticus420'
|
21
|
+
assert_equal @kmp.victim[:corp], 'Ever Flow'
|
22
|
+
assert_equal @kmp.victim[:alliance], 'Northern Coalition.'
|
23
|
+
assert_equal @kmp.victim[:faction], 'Unknown'
|
24
|
+
assert_equal @kmp.victim[:ship], 'Basilisk'
|
25
|
+
assert_equal @kmp.victim[:system], 'O1-FTD'
|
26
|
+
assert_equal @kmp.victim[:security], '-0.4'
|
27
|
+
assert_equal @kmp.victim[:damage], '20738'
|
28
|
+
end
|
29
|
+
|
30
|
+
should "have the correct number of attackers" do
|
31
|
+
assert_equal @kmp.attackers.count, 2
|
32
|
+
end
|
33
|
+
|
34
|
+
should "have the correct attackers" do
|
35
|
+
assert_equal @kmp.attackers[0][:name], 'Angel Drade'
|
36
|
+
assert_equal @kmp.attackers[0][:security], '-3.70'
|
37
|
+
assert_equal @kmp.attackers[0][:corp], 'SQUINGEL'
|
38
|
+
assert_equal @kmp.attackers[0][:alliance], 'Nulli Tertius'
|
39
|
+
assert_equal @kmp.attackers[0][:faction], 'None'
|
40
|
+
assert_equal @kmp.attackers[0][:ship], 'Hurricane'
|
41
|
+
assert_equal @kmp.attackers[0][:weapon], 'Hurricane'
|
42
|
+
assert_equal @kmp.attackers[0][:damage], '19235'
|
43
|
+
|
44
|
+
assert_equal @kmp.attackers[1][:name], 'SkippyTheWonderTard'
|
45
|
+
assert_equal @kmp.attackers[1][:security], '3.10'
|
46
|
+
assert_equal @kmp.attackers[1][:corp], 'Kickass inc'
|
47
|
+
assert_equal @kmp.attackers[1][:alliance], 'Nulli Tertius'
|
48
|
+
assert_equal @kmp.attackers[1][:faction], 'None'
|
49
|
+
assert_equal @kmp.attackers[1][:ship], 'Hurricane'
|
50
|
+
assert_equal @kmp.attackers[1][:weapon], 'Hurricane'
|
51
|
+
assert_equal @kmp.attackers[1][:damage], '1503'
|
52
|
+
end
|
53
|
+
|
54
|
+
should "have the correct number of destroyed items" do
|
55
|
+
assert_equal @kmp.destroyed_items.count, 3
|
56
|
+
end
|
57
|
+
|
58
|
+
should "have the correct destroyed items" do
|
59
|
+
assert_equal @kmp.destroyed_items[0][:name], 'Photon Scattering Field II'
|
60
|
+
assert_equal @kmp.destroyed_items[0][:quantity], 1
|
61
|
+
assert_equal @kmp.destroyed_items[0][:location], nil
|
62
|
+
|
63
|
+
assert_equal @kmp.destroyed_items[1][:name], 'Reactor Control Unit II'
|
64
|
+
assert_equal @kmp.destroyed_items[1][:quantity], 2
|
65
|
+
assert_equal @kmp.destroyed_items[1][:location], nil
|
66
|
+
|
67
|
+
assert_equal @kmp.destroyed_items[2][:name], 'Warrior II'
|
68
|
+
assert_equal @kmp.destroyed_items[2][:quantity], 3
|
69
|
+
assert_equal @kmp.destroyed_items[2][:location], 'Drone Bay'
|
70
|
+
end
|
71
|
+
|
72
|
+
should "have the correct number of dropped items" do
|
73
|
+
assert_equal @kmp.dropped_items.count, 3
|
74
|
+
end
|
75
|
+
|
76
|
+
should "have the correct dropped items" do
|
77
|
+
assert_equal @kmp.dropped_items[0][:name], 'Large S95a Partial Shield Transporter'
|
78
|
+
assert_equal @kmp.dropped_items[0][:quantity], 3
|
79
|
+
assert_equal @kmp.dropped_items[0][:location], nil
|
80
|
+
|
81
|
+
assert_equal @kmp.dropped_items[1][:name], 'Warrior II'
|
82
|
+
assert_equal @kmp.dropped_items[1][:quantity], 2
|
83
|
+
assert_equal @kmp.dropped_items[1][:location], 'Drone Bay'
|
84
|
+
|
85
|
+
assert_equal @kmp.dropped_items[2][:name], 'Damage Control II'
|
86
|
+
assert_equal @kmp.dropped_items[2][:quantity], 1
|
87
|
+
assert_equal @kmp.dropped_items[2][:location], nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "a pod mail with implants" do
|
93
|
+
should "parse without error" do
|
94
|
+
kmp = KillmailParser.new(EXAMPLE_KILLMAILS['km_podmail_w_implants.txt'])
|
95
|
+
end
|
96
|
+
|
97
|
+
context "after parsing" do
|
98
|
+
setup do
|
99
|
+
@kmp = KillmailParser.new(EXAMPLE_KILLMAILS['km_podmail_w_implants.txt'])
|
100
|
+
end
|
101
|
+
|
102
|
+
should "have the correct victim ship type" do
|
103
|
+
assert_equal @kmp.victim[:ship], 'Capsule'
|
104
|
+
end
|
105
|
+
|
106
|
+
should "show the correct implants" do
|
107
|
+
assert_equal @kmp.destroyed_items[0][:name], 'Cybernetic Subprocessor - Improved'
|
108
|
+
assert_equal @kmp.destroyed_items[1][:name], 'Social Adaptation Chip - Improved'
|
109
|
+
assert_equal @kmp.destroyed_items[2][:name], 'Memory Augmentation - Improved'
|
110
|
+
assert_equal @kmp.destroyed_items[3][:name], 'Mining Foreman Mindlink'
|
111
|
+
assert_equal @kmp.destroyed_items[4][:name], 'Neural Boost - Improved'
|
112
|
+
assert_equal @kmp.destroyed_items[5][:name], 'Ocular Filter - Improved'
|
113
|
+
|
114
|
+
assert_equal @kmp.destroyed_items[0][:quantity], 1
|
115
|
+
assert_equal @kmp.destroyed_items[1][:quantity], 1
|
116
|
+
assert_equal @kmp.destroyed_items[2][:quantity], 1
|
117
|
+
assert_equal @kmp.destroyed_items[3][:quantity], 1
|
118
|
+
assert_equal @kmp.destroyed_items[4][:quantity], 1
|
119
|
+
assert_equal @kmp.destroyed_items[5][:quantity], 1
|
120
|
+
|
121
|
+
assert_equal @kmp.destroyed_items[0][:location], 'Implant'
|
122
|
+
assert_equal @kmp.destroyed_items[1][:location], 'Implant'
|
123
|
+
assert_equal @kmp.destroyed_items[2][:location], 'Implant'
|
124
|
+
assert_equal @kmp.destroyed_items[3][:location], 'Implant'
|
125
|
+
assert_equal @kmp.destroyed_items[4][:location], 'Implant'
|
126
|
+
assert_equal @kmp.destroyed_items[5][:location], 'Implant'
|
127
|
+
end
|
128
|
+
|
129
|
+
should "have the correct number of attackers" do
|
130
|
+
assert_equal @kmp.attackers.count, 5
|
131
|
+
end
|
132
|
+
|
133
|
+
should "show no dropped items" do
|
134
|
+
assert_equal @kmp.dropped_items.count, 0
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "a pod mail with no implants" do
|
140
|
+
should "parse without error" do
|
141
|
+
kmp = KillmailParser.new(EXAMPLE_KILLMAILS['km_podmail_wo_implants.txt'])
|
142
|
+
end
|
143
|
+
|
144
|
+
context "after parsing" do
|
145
|
+
setup do
|
146
|
+
@kmp = KillmailParser.new(EXAMPLE_KILLMAILS['km_podmail_wo_implants.txt'])
|
147
|
+
end
|
148
|
+
|
149
|
+
should "have the correct victim ship type" do
|
150
|
+
assert_equal @kmp.victim[:ship], 'Capsule'
|
151
|
+
end
|
152
|
+
|
153
|
+
should "have the correct number of attackers" do
|
154
|
+
assert_equal @kmp.attackers.count, 4
|
155
|
+
end
|
156
|
+
|
157
|
+
should "show no destroyed items" do
|
158
|
+
assert_equal @kmp.destroyed_items.count, 0
|
159
|
+
end
|
160
|
+
|
161
|
+
should "show no dropped items" do
|
162
|
+
assert_equal @kmp.dropped_items.count, 0
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neweden-km-parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Adams
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: shoulda
|
16
|
+
requirement: &2151886240 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2151886240
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &2151880860 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2151880860
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &2151891640 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.8.3
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2151891640
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: awesome_print
|
49
|
+
requirement: &2151903080 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2151903080
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: pry
|
60
|
+
requirement: &2151909460 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2151909460
|
69
|
+
description: Parser for the mails generated by the MMO EVE Online when an internet
|
70
|
+
spaceship is destroyed.
|
71
|
+
email: jasonmadams@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.rdoc
|
77
|
+
files:
|
78
|
+
- .document
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.rdoc
|
83
|
+
- Rakefile
|
84
|
+
- VERSION
|
85
|
+
- init.rb
|
86
|
+
- lib/neweden-km-parser.rb
|
87
|
+
- test/helper.rb
|
88
|
+
- test/km_generic.txt
|
89
|
+
- test/km_podmail_w_implants.txt
|
90
|
+
- test/km_podmail_wo_implants.txt
|
91
|
+
- test/test_neweden-km-parser.rb
|
92
|
+
homepage: http://github.com/ealdent/neweden-km-parser
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
hash: -570784519100947383
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 1.8.17
|
117
|
+
signing_key:
|
118
|
+
specification_version: 3
|
119
|
+
summary: Parser for killmails generated by the MMO EVE Online.
|
120
|
+
test_files: []
|