adam 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
- module Adam
2
- VERSION = '1.5.1'
3
-
1
+ require 'adam/version'
2
+
3
+ module Adam
4
4
  autoload :Killmail, 'adam/killmail'
5
5
  autoload :KillLog, 'adam/kill_log'
6
6
  autoload :Kill, 'adam/kill'
@@ -9,12 +9,12 @@ module Adam
9
9
  autoload :Configuration, 'adam/configuration'
10
10
 
11
11
  CONFIGURATION = Configuration.new(
12
- :database => {
13
- :adapter => 'mysql2',
14
- :username => 'username',
15
- :password => 'password',
16
- :name => 'database',
17
- :host => 'localhost'
12
+ database: {
13
+ adapter: 'pg',
14
+ username: 'username',
15
+ password: 'password',
16
+ name: 'database',
17
+ host: 'localhost'
18
18
  }
19
19
  )
20
20
 
@@ -74,8 +74,10 @@ module Adam
74
74
  destroyed_items.each do |loot|
75
75
  killmail << "#{loot.name}"
76
76
  killmail << ", Qty: #{loot.quantity}" if loot.quantity > 1
77
- killmail << " (Cargo)" if loot.cargo
78
- killmail << " (Drone Bay)" if loot.drone_bay
77
+ killmail << " (Cargo)" if loot.location == :cargo_bay
78
+ killmail << " (Drone Bay)" if loot.location == :drone_bay
79
+ killmail << " (Implant)" if loot.location == :implant
80
+ killmail << " (Copy) (Cargo)" if loot.location == :copy
79
81
  killmail << "\n"
80
82
  end
81
83
  end
@@ -88,8 +90,10 @@ module Adam
88
90
  dropped_items.each do |loot|
89
91
  killmail << "#{loot.name}"
90
92
  killmail << ", Qty: #{loot.quantity}" if loot.quantity > 1
91
- killmail << " (Cargo)" if loot.cargo
92
- killmail << " (Drone Bay)" if loot.drone_bay
93
+ killmail << " (Cargo)" if loot.location == :cargo_bay
94
+ killmail << " (Drone Bay)" if loot.location == :drone_bay
95
+ killmail << " (Implant)" if loot.location == :implant
96
+ killmail << " (Copy) (Cargo)" if loot.location == :copy
93
97
  killmail << "\n"
94
98
  end
95
99
  end
@@ -132,7 +136,7 @@ module Adam
132
136
  # * +ship+ - A string describing the name of the ship that was destroyed.
133
137
  # * +damage_taken+ - An integer describing damage taken.
134
138
  class Kill::Victim
135
- attr_accessor :pilot, :corporation, :alliance, :faction, :ship, :damage_taken
139
+ attr_accessor :pilot, :corporation, :alliance, :faction, :ship, :damage_taken, :moon
136
140
 
137
141
  def initialize
138
142
  yield self if block_given?
@@ -173,19 +177,9 @@ module Adam
173
177
  # Accessors:
174
178
  # * +name+ - A string describing the name of the item.
175
179
  # * +quantity+ - An integer describing the quantity of the item.
176
- # * +cargo+ - A boolean describing whether or not this item was in the cargo hold.
177
- # * +drone_bay+ - A boolean describing whether or not this item was in the drone bay.
178
180
  # * +dropped+ - A boolean describing whether or not this item was dropped.
179
181
  class Kill::Loot
180
- attr_accessor :name, :quantity, :cargo, :drone_bay, :dropped
181
-
182
- def cargo?
183
- cargo
184
- end
185
-
186
- def dropped?
187
- dropped
188
- end
182
+ attr_accessor :name, :quantity, :dropped, :location
189
183
 
190
184
  def initialize
191
185
  yield self if block_given?
@@ -93,8 +93,10 @@ module Adam
93
93
  k.loot << Adam::Kill::Loot.new do |l|
94
94
  l.name = Item.find(loot_element['typeID']).name
95
95
  l.quantity = loot_element['qtyDropped'].to_i
96
- l.cargo = loot_element['flag'] == '5' ? true : false
97
- l.drone_bay = loot_element['flag'] == '87' ? true : false
96
+ l.location = :cargo_bay if loot_element['flag'] == '5'
97
+ l.location = :drone_bay if loot_element['flag'] == '87'
98
+ l.location = :implant if loot_element['flag'] == '89'
99
+ l.location = :copy if loot_element['singleton'] == '2'
98
100
  l.dropped = true
99
101
  end
100
102
  end
@@ -103,8 +105,10 @@ module Adam
103
105
  k.loot << Adam::Kill::Loot.new do |l|
104
106
  l.name = Item.find(loot_element['typeID']).name
105
107
  l.quantity = loot_element['qtyDestroyed'].to_i
106
- l.cargo = loot_element['flag'] == '5' ? true : false
107
- l.drone_bay = loot_element['flag'] == '87' ? true : false
108
+ l.location = :cargo_bay if loot_element['flag'] == '5'
109
+ l.location = :drone_bay if loot_element['flag'] == '87'
110
+ l.location = :implant if loot_element['flag'] == '89'
111
+ l.location = :copy if loot_element['singleton'] == '2'
108
112
  l.dropped = false
109
113
  end
110
114
  end
@@ -37,7 +37,11 @@ module Adam
37
37
  raise ValidationError.new(source), "No solar system called '#{kill.solar_system.name}' exists" unless SolarSystem.exists? :name => kill.solar_system.name
38
38
 
39
39
  kill.victim = Adam::Kill::Victim.new do |v|
40
- v.pilot = source[/Victim: ([a-zA-Z0-9]{1}[a-zA-Z0-9'. -]{1,48}[a-zA-Z0-9.]{1})/, 1] or raise ValidationError.new(source), "Victim pilot malformed"
40
+ if source =~ /Victim:/
41
+ v.pilot = source[/Victim: ([a-zA-Z0-9]{1}[a-zA-Z0-9'. -]{1,48}[a-zA-Z0-9.]{1})/, 1] or raise ValidationError.new(source), "Victim pilot malformed"
42
+ elsif source =~ /Moon:/
43
+ v.moon = source[/Moon: ([a-zA-Z0-9]{1}[a-zA-Z0-9'. -]{1,48}[a-zA-Z0-9.]{1})/, 1] or raise ValidationError.new(source), "Victim moon malformed"
44
+ end
41
45
  v.corporation = source[/Corp: ([a-zA-Z0-9]{1}[a-zA-Z0-9'. -]{1,48}[a-zA-Z0-9.]{1})/, 1] or raise ValidationError.new(source), "Victim corporation malformed"
42
46
  v.alliance = source[/Alliance: ([a-zA-Z0-9]{1}[a-zA-Z0-9'. -]{1,48}[a-zA-Z0-9.]{1})/, 1] or raise ValidationError.new(source), "Victim alliance malformed"
43
47
  v.faction = source[/Faction: ([a-zA-Z0-9]{1}[a-zA-Z0-9'. -]{1,48}[a-zA-Z0-9.]{1})/, 1] or raise ValidationError.new(source), "Victim faction malformed"
@@ -54,7 +58,7 @@ module Adam
54
58
 
55
59
  raise ValidationError.new(source), "No faction called '#{kill.victim.faction}' exists" if kill.victim.faction and !Faction.exists? :name => kill.victim.faction
56
60
  raise ValidationError.new(source), "No ship called '#{kill.victim.ship}' exists" unless Item.exists? :name => kill.victim.ship
57
-
61
+ raise ValidationError.new(source), "No moon called '#{kill.victim.moon}' exists" unless Moon.exists? :name => kill.victim.moon if kill.victim.moon
58
62
 
59
63
  kill.involved_parties = []
60
64
 
@@ -115,13 +119,15 @@ module Adam
115
119
  if source =~ /Destroyed items:/
116
120
  source[/Destroyed items:\n\n(((.+)\n?)*)/, 1].split("\n").each_with_index do |snippet, i|
117
121
  loot = Adam::Kill::Loot.new do |l|
118
- l.name = snippet[/([^,\(\)]+[^,\(\) ]{1})/, 1] or raise ValidationError.new(source), "Destroyed item #{i+1} name malformed"
122
+ l.name = snippet[/([^\(\)]+[^\s\(\)]{1})/, 1].gsub(/\b, Qty: \d+\b$/, "") or raise ValidationError.new(source), "Destroyed item #{i+1} name malformed"
119
123
  l.quantity = snippet =~ /Qty: ([0-9]+)/ ? snippet[/Qty: ([0-9]+)/, 1].to_i : 1
120
- l.cargo = snippet[/(Cargo)/] ? true : false
121
- l.drone_bay = snippet[/(Drone Bay)/] ? true : false
124
+ l.location = :cargo_bay if snippet[/(Cargo)/]
125
+ l.location = :drone_bay if snippet[/(Drone Bay)/]
126
+ l.location = :implant if snippet[/(Implant)/]
127
+ l.location = :copy if snippet[/(Copy)/]
122
128
  l.dropped = false
123
129
  end
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]
130
+ existing_loot = kill.loot.select { |el| el.name.eql?(loot.name) and el.location.eql?(loot.location) and el.dropped.eql?(loot.dropped) }[0]
125
131
  existing_loot ? existing_loot.quantity += loot.quantity : kill.loot << loot
126
132
  end
127
133
  end
@@ -129,13 +135,15 @@ module Adam
129
135
  if source =~ /Dropped items:/
130
136
  source[/Dropped items:\n\n(((.+)\n?)*)/, 1].split("\n").each_with_index do |snippet, i|
131
137
  loot = Adam::Kill::Loot.new do |l|
132
- l.name = snippet[/([^,\(\)]+[^,\(\) ]{1})/, 1] or raise ValidationError.new(source), "Dropped item #{i+1} name malformed"
138
+ l.name = snippet[/([^\(\)]+[^\s\(\)]{1})/, 1].gsub(/\b, Qty: \d+\b$/, "") or raise ValidationError.new(source), "Destroyed item #{i+1} name malformed"
133
139
  l.quantity = snippet =~ /Qty: ([0-9]+)/ ? snippet[/Qty: ([0-9]+)/, 1].to_i : 1
134
- l.cargo = snippet[/(Cargo)/] ? true : false
135
- l.drone_bay = snippet[/(Drone Bay)/] ? true : false
140
+ l.location = :cargo_bay if snippet[/(Cargo)/]
141
+ l.location = :drone_bay if snippet[/(Drone Bay)/]
142
+ l.location = :implant if snippet[/(Implant)/]
143
+ l.location = :copy if snippet[/(Copy)/]
136
144
  l.dropped = true
137
145
  end
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]
146
+ existing_loot = kill.loot.select { |el| el.name.eql?(loot.name) and el.location.eql?(loot.location) and el.dropped.eql?(loot.dropped) }[0]
139
147
  existing_loot ? existing_loot.quantity += loot.quantity : kill.loot << loot
140
148
  end
141
149
  end
@@ -0,0 +1,3 @@
1
+ module Adam
2
+ VERSION = '1.6.0'
3
+ end
metadata CHANGED
@@ -1,33 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: adam
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 5
8
- - 1
9
- version: 1.5.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.6.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Johannes Gorset
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-10-16 00:00:00 +02:00
18
- default_executable:
19
- dependencies: []
20
-
21
- description:
12
+ date: 2012-05-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: &70350302582640 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70350302582640
25
+ - !ruby/object:Gem::Dependency
26
+ name: hpricot
27
+ requirement: &70350311558720 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70350311558720
36
+ description: Adam is a library for all things EVE
22
37
  email: jgorset@gmail.com
23
38
  executables: []
24
-
25
39
  extensions: []
26
-
27
40
  extra_rdoc_files: []
28
-
29
- files:
30
- - lib/adam/api.rb
41
+ files:
31
42
  - lib/adam/configuration.rb
32
43
  - lib/adam/image.rb
33
44
  - lib/adam/kill.rb
@@ -37,42 +48,34 @@ files:
37
48
  - lib/adam/killboard.rb
38
49
  - lib/adam/killmail/validation_error.rb
39
50
  - lib/adam/killmail.rb
51
+ - lib/adam/version.rb
40
52
  - lib/adam.rb
41
53
  - lib/models/faction.rb
42
54
  - lib/models/item.rb
43
55
  - lib/models/solar_system.rb
44
56
  - README.md
45
- has_rdoc: true
46
- homepage: http://github.com/frkt/adam
57
+ homepage: http://github.com/jgorset/adam
47
58
  licenses: []
48
-
49
59
  post_install_message:
50
60
  rdoc_options: []
51
-
52
- require_paths:
61
+ require_paths:
53
62
  - lib
54
- required_ruby_version: !ruby/object:Gem::Requirement
63
+ required_ruby_version: !ruby/object:Gem::Requirement
55
64
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- segments:
60
- - 0
61
- version: "0"
62
- required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '1.9'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
70
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- version: "0"
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
70
75
  requirements: []
71
-
72
76
  rubyforge_project:
73
- rubygems_version: 1.3.7
77
+ rubygems_version: 1.8.11
74
78
  signing_key:
75
79
  specification_version: 3
76
80
  summary: Adam is a library for all things EVE
77
81
  test_files: []
78
-
@@ -1,46 +0,0 @@
1
- require 'uri'
2
- require 'net/http'
3
-
4
- module Adam
5
-
6
- class API
7
-
8
- @@character_portrait_uri = "http://image.eveonline.com/Character/"
9
-
10
- # Retrieves a character portrait.
11
- #
12
- # Parameters:
13
- # * +options+ - A hash with these keys:
14
- # * +id+ - An integer describing an EVE Online character id.
15
- # * +size+ - An integer describing what size to retrieve. Valid sizes are 32, 64, 128 or 256.
16
- def character_portrait(options = {})
17
- request(@@character_portrait_uri + "#{options[:id]}_#{options[:size]}.jpg")
18
- end
19
-
20
- private
21
-
22
- # Queries the EVE Online API for data.
23
- #
24
- # Parameters:
25
- # * +uri+ - A string describing the URI to send a request to.
26
- def request(uri)
27
- uri = URI.parse(uri)
28
-
29
- response, body = nil, nil
30
- Net::HTTP.new(uri.host, uri.port).start do |http|
31
- tries = 0
32
- begin
33
- response, body = http.get("#{uri.path}?#{uri.query}")
34
- rescue Timeout::Error
35
- tries += 1
36
- sleep 5
37
- retry if tries < 3
38
- end
39
- end
40
-
41
- body
42
- end
43
-
44
- end
45
-
46
- end