adam 1.2.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Adam
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.1'
3
3
 
4
4
  autoload :Killmail, 'adam/killmail'
5
5
  autoload :KillLog, 'adam/kill_log'
@@ -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.cargo_hold
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.cargo_hold
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
- # * +cargo_hold+ - A boolean describing whether or not this item was in the cargo hold.
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, :cargo_hold, :drone_bay, :dropped
184
+ attr_accessor :name, :quantity, :cargo, :drone_bay, :dropped
185
185
 
186
- def cargo_hold?
187
- cargo_hold
186
+ def cargo?
187
+ cargo
188
188
  end
189
189
 
190
190
  def dropped?
@@ -1,5 +1,8 @@
1
1
  require 'adam/kill_log/validation_error'
2
- require 'models' unless defined?(SolarSystem) and defined?(Item)
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.cargo_hold = loot_element['flag'] == '5' ? true : false
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.cargo_hold = loot_element['flag'] == '5' ? true : false
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
@@ -1,5 +1,8 @@
1
1
  require 'adam/killmail/validation_error'
2
- require 'models' unless defined?(SolarSystem) and defined?(Item) and defined?(Faction)
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.cargo_hold = snippet[/(Cargo)/] ? true : false
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.cargo_hold.eql?(loot.cargo_hold) and el.drone_bay.eql?(loot.drone_bay) and el.dropped.eql?(loot.dropped) }[0]
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.cargo_hold = snippet[/(Cargo)/] ? true : false
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.cargo_hold.eql?(loot.cargo_hold) and el.drone_bay.eql?(loot.drone_bay) and el.dropped.eql?(loot.dropped) }[0]
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
@@ -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
- - 2
8
- - 0
9
- version: 1.2.0
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-01 00:00:00 +02:00
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
@@ -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