adam 1.2.0 → 1.3.1
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.
- data/lib/adam.rb +1 -1
- data/lib/adam/kill.rb +6 -6
- data/lib/adam/kill_log.rb +6 -3
- data/lib/adam/killmail.rb +8 -5
- data/lib/models/faction.rb +8 -0
- data/lib/models/item.rb +8 -0
- data/lib/models/solar_system.rb +8 -0
- metadata +7 -5
- data/lib/models.rb +0 -8
data/lib/adam.rb
CHANGED
data/lib/adam/kill.rb
CHANGED
@@ -78,7 +78,7 @@ module Adam
|
|
78
78
|
destroyed_items.each do |loot|
|
79
79
|
killmail << "#{loot.name}"
|
80
80
|
killmail << ", Qty: #{loot.quantity}" if loot.quantity > 1
|
81
|
-
killmail << " (Cargo)" if loot.
|
81
|
+
killmail << " (Cargo)" if loot.cargo
|
82
82
|
killmail << " (Drone Bay)" if loot.drone_bay
|
83
83
|
killmail << "\n"
|
84
84
|
end
|
@@ -92,7 +92,7 @@ module Adam
|
|
92
92
|
dropped_items.each do |loot|
|
93
93
|
killmail << "#{loot.name}"
|
94
94
|
killmail << ", Qty: #{loot.quantity}" if loot.quantity > 1
|
95
|
-
killmail << " (Cargo)" if loot.
|
95
|
+
killmail << " (Cargo)" if loot.cargo
|
96
96
|
killmail << " (Drone Bay)" if loot.drone_bay
|
97
97
|
killmail << "\n"
|
98
98
|
end
|
@@ -177,14 +177,14 @@ module Adam
|
|
177
177
|
# Accessors:
|
178
178
|
# * +name+ - A string describing the name of the item.
|
179
179
|
# * +quantity+ - An integer describing the quantity of the item.
|
180
|
-
# * +
|
180
|
+
# * +cargo+ - A boolean describing whether or not this item was in the cargo hold.
|
181
181
|
# * +drone_bay+ - A boolean describing whether or not this item was in the drone bay.
|
182
182
|
# * +dropped+ - A boolean describing whether or not this item was dropped.
|
183
183
|
class Kill::Loot
|
184
|
-
attr_accessor :name, :quantity, :
|
184
|
+
attr_accessor :name, :quantity, :cargo, :drone_bay, :dropped
|
185
185
|
|
186
|
-
def
|
187
|
-
|
186
|
+
def cargo?
|
187
|
+
cargo
|
188
188
|
end
|
189
189
|
|
190
190
|
def dropped?
|
data/lib/adam/kill_log.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'adam/kill_log/validation_error'
|
2
|
-
|
2
|
+
|
3
|
+
SolarSystem rescue require 'models/solar_system'
|
4
|
+
Item rescue require 'models/item'
|
5
|
+
Faction rescue require 'models/faction'
|
3
6
|
|
4
7
|
require 'hpricot'
|
5
8
|
require 'time'
|
@@ -90,7 +93,7 @@ module Adam
|
|
90
93
|
k.loot << Adam::Kill::Loot.new do |l|
|
91
94
|
l.name = Item.find(loot_element['typeID']).name
|
92
95
|
l.quantity = loot_element['qtyDropped'].to_i
|
93
|
-
l.
|
96
|
+
l.cargo = loot_element['flag'] == '5' ? true : false
|
94
97
|
l.drone_bay = loot_element['flag'] == '87' ? true : false
|
95
98
|
l.dropped = true
|
96
99
|
end
|
@@ -100,7 +103,7 @@ module Adam
|
|
100
103
|
k.loot << Adam::Kill::Loot.new do |l|
|
101
104
|
l.name = Item.find(loot_element['typeID']).name
|
102
105
|
l.quantity = loot_element['qtyDestroyed'].to_i
|
103
|
-
l.
|
106
|
+
l.cargo = loot_element['flag'] == '5' ? true : false
|
104
107
|
l.drone_bay = loot_element['flag'] == '87' ? true : false
|
105
108
|
l.dropped = false
|
106
109
|
end
|
data/lib/adam/killmail.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'adam/killmail/validation_error'
|
2
|
-
|
2
|
+
|
3
|
+
SolarSystem rescue require 'models/solar_system'
|
4
|
+
Item rescue require 'models/item'
|
5
|
+
Faction rescue require 'models/faction'
|
3
6
|
|
4
7
|
require 'time'
|
5
8
|
|
@@ -114,11 +117,11 @@ module Adam
|
|
114
117
|
loot = Adam::Kill::Loot.new do |l|
|
115
118
|
l.name = snippet[/([^,\(\)]+)/, 1] or raise ValidationError.new(source), "Destroyed item #{i+1} name malformed"
|
116
119
|
l.quantity = snippet =~ /Qty: ([0-9]+)/ ? snippet[/Qty: ([0-9]+)/, 1].to_i : 1
|
117
|
-
l.
|
120
|
+
l.cargo = snippet[/(Cargo)/] ? true : false
|
118
121
|
l.drone_bay = snippet[/(Drone Bay)/] ? true : false
|
119
122
|
l.dropped = false
|
120
123
|
end
|
121
|
-
existing_loot = kill.loot.select { |el| el.name.eql?(loot.name) and el.
|
124
|
+
existing_loot = kill.loot.select { |el| el.name.eql?(loot.name) and el.cargo.eql?(loot.cargo) and el.drone_bay.eql?(loot.drone_bay) and el.dropped.eql?(loot.dropped) }[0]
|
122
125
|
existing_loot ? existing_loot.quantity += loot.quantity : kill.loot << loot
|
123
126
|
end
|
124
127
|
end
|
@@ -128,11 +131,11 @@ module Adam
|
|
128
131
|
loot = Adam::Kill::Loot.new do |l|
|
129
132
|
l.name = snippet[/([^,\(\)]+)/, 1] or raise ValidationError.new(source), "Dropped item #{i+1} name malformed"
|
130
133
|
l.quantity = snippet =~ /Qty: ([0-9]+)/ ? snippet[/Qty: ([0-9]+)/, 1].to_i : 1
|
131
|
-
l.
|
134
|
+
l.cargo = snippet[/(Cargo)/] ? true : false
|
132
135
|
l.drone_bay = snippet[/(Drone Bay)/] ? true : false
|
133
136
|
l.dropped = true
|
134
137
|
end
|
135
|
-
existing_loot = kill.loot.select { |el| el.name.eql?(loot.name) and el.
|
138
|
+
existing_loot = kill.loot.select { |el| el.name.eql?(loot.name) and el.cargo.eql?(loot.cargo) and el.drone_bay.eql?(loot.drone_bay) and el.dropped.eql?(loot.dropped) }[0]
|
136
139
|
existing_loot ? existing_loot.quantity += loot.quantity : kill.loot << loot
|
137
140
|
end
|
138
141
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
unless ActiveRecord::Base.connected?
|
4
|
+
database_configuration = YAML::load_file(File.dirname(__FILE__) + '/../../config/database.yml')
|
5
|
+
ActiveRecord::Base.establish_connection YAML::load_file(File.dirname(__FILE__) + '/../../config/database.yml')
|
6
|
+
end
|
7
|
+
|
8
|
+
class Faction < ActiveRecord::Base; end
|
data/lib/models/item.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
unless ActiveRecord::Base.connected?
|
4
|
+
database_configuration = YAML::load_file(File.dirname(__FILE__) + '/../../config/database.yml')
|
5
|
+
ActiveRecord::Base.establish_connection YAML::load_file(File.dirname(__FILE__) + '/../../config/database.yml')
|
6
|
+
end
|
7
|
+
|
8
|
+
class Item < ActiveRecord::Base; end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
unless ActiveRecord::Base.connected?
|
4
|
+
database_configuration = YAML::load_file(File.dirname(__FILE__) + '/../../config/database.yml')
|
5
|
+
ActiveRecord::Base.establish_connection YAML::load_file(File.dirname(__FILE__) + '/../../config/database.yml')
|
6
|
+
end
|
7
|
+
|
8
|
+
class SolarSystem < ActiveRecord::Base; end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 1.
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
version: 1.3.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Johannes Gorset
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-04 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -39,7 +39,9 @@ files:
|
|
39
39
|
- lib/adam/killmail/validation_error.rb
|
40
40
|
- lib/adam/killmail.rb
|
41
41
|
- lib/adam.rb
|
42
|
-
- lib/models.rb
|
42
|
+
- lib/models/faction.rb
|
43
|
+
- lib/models/item.rb
|
44
|
+
- lib/models/solar_system.rb
|
43
45
|
- README.md
|
44
46
|
has_rdoc: true
|
45
47
|
homepage: http://github.com/frkt/adam
|
data/lib/models.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
|
3
|
-
database_configuration = YAML::load_file(File.dirname(__FILE__) + '/../config/database.yml')
|
4
|
-
ActiveRecord::Base.establish_connection(database_configuration)
|
5
|
-
|
6
|
-
class Item < ActiveRecord::Base; end
|
7
|
-
class SolarSystem < ActiveRecord::Base; end
|
8
|
-
class Faction < ActiveRecord::Base; end
|