reve 0.0.74 → 0.0.76

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/Rakefile CHANGED
@@ -18,7 +18,7 @@ Rake::RDocTask.new("doc") { |rdoc|
18
18
  rdoc.options << '--line-numbers' << '--inline-source' << '--all'
19
19
  rdoc.rdoc_files.include('./ChangeLog')
20
20
  rdoc.rdoc_files.include('*.rb')
21
- rdoc.rdoc_files.include('lib/*.rb')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
22
  rdoc.rdoc_files.include('test/**/*')
23
23
  }
24
24
 
@@ -30,7 +30,7 @@ spec = Gem::Specification.new do |s|
30
30
  s.homepage = "http://revetrac.crudvision.com"
31
31
  s.platform = Gem::Platform::RUBY
32
32
  s.summary = "Reve is a Ruby library to interface with the Eve Online API"
33
- s.files = FileList["Rakefile","lib/*.rb","reve.rb","tester.rb","init.rb"].to_a
33
+ s.files = FileList["Rakefile","lib/**/*.rb","reve.rb","tester.rb","init.rb"].to_a
34
34
  s.require_path = "lib"
35
35
  s.test_files = FileList["test/test_reve.rb","test/xml/**/*.xml"].to_a
36
36
  s.has_rdoc = true
@@ -0,0 +1,839 @@
1
+ #--
2
+ # Code copyright Lisa Seelye, 2007-2008. www.crudvision.com
3
+ # Reve is not licensed for commercial use. For other uses there are no
4
+ # restrictions.
5
+ #
6
+ # The author is not adverse to tokens of appreciation in the form of Eve ISK,
7
+ # ships, and feedback. Please use
8
+ # http://www.crudvision.com/reve-ruby-eve-online-api-library/ to provide
9
+ # feedback or send ISK to Raquel Smith in Eve. :-)
10
+ #++
11
+ module Reve #:nodoc:
12
+ module Classes #:nodoc:
13
+
14
+ # Represents an Alliance as it appears in the Reve::API#alliances call.
15
+ # Attributes
16
+ # * name ( String ) - Full Name of the Alliance
17
+ # * short_name ( String ) - Short name (ticker) of the Alliance
18
+ # * id ( Fixnum ) - The Alliance's Eve-Online ID
19
+ # * executor_corp_id ( Fixnum ) - ID of the Corporation that's in charge of the Alliance
20
+ # * member_count ( Fixnum ) - The number of members that are in the Alliance
21
+ # * start_date ( Time ) - When the Alliance was formed.
22
+ # * member_corporations ( [Corporation] ) - Array of the Corporation objects that belong to the Alliance.
23
+ class Alliance
24
+ attr_reader :name, :short_name, :id, :executor_corp_id, :member_count, :start_date
25
+ attr_accessor :member_corporations
26
+ def initialize(elem) #:nodoc:
27
+ @name = elem['name']
28
+ @short_name = elem['shortname']
29
+ @id = elem['allianceid'].to_i
30
+ @executor_corp_id = elem['executorcorpid'].to_i
31
+ @member_count = elem['membercount'].to_i
32
+ @start_date = elem['startdate'].to_time
33
+ @member_corporations = []
34
+ end
35
+ end
36
+
37
+ # Only for use in Alliance class (member_corporations array) from the Reve::API#alliances call
38
+ # Attributes
39
+ # * id ( Fixnum ) - ID of the Corporation (use this in the Reve::API#corporation_sheet call)
40
+ # * start_date ( Time ) - When the Corporation was started?
41
+ class Corporation
42
+ attr_reader :id, :start_date
43
+ def initialize(elem) #:nodoc:
44
+ @id = elem['corporationid'].to_i
45
+ @start_date = elem['startdate'].to_time
46
+ end
47
+ end
48
+
49
+ # A Skill has a RequiredAttribute, either a PrimaryAttribute or SecondaryAttribute, which both derrive from this.
50
+ # Attributes
51
+ # * name ( String ) - Name of the required Attribute
52
+ # See Also: PrimaryAttribute, SecondaryAttribute, Skill, Reve::API#skill_tree
53
+ class RequiredAttribute
54
+ attr_reader :name
55
+ def initialize(attrib) #:nodoc:
56
+ @name = attrib
57
+ end
58
+ end
59
+ # Denotes the PrimaryAttribute of the RequiredAttribute pair for a Skill. See also
60
+ # SecondaryAttribute and RequiredAttribute
61
+ class PrimaryAttribute < RequiredAttribute
62
+ end
63
+ # Denotes the SecondaryAttribute of the RequiredAttribute pair for a Skill. See also
64
+ # PrimaryAttribute and RequiredAttribute
65
+ class SecondaryAttribute < RequiredAttribute
66
+ end
67
+
68
+ # Represents the victim of a Kill.
69
+ # Attributes:
70
+ # * id ( Fixnum ) - ID of the Character that was killed.
71
+ # * name ( String ) - The name of the Character that was killed.
72
+ # * corporation_id ( Fixnum ) - The ID of the Corporation that the victim belongs to.
73
+ # * alliance_id ( Fixnum | NilClass ) - The ID of the Alliance that the victim belongs to, if applicable. Will be nil unless the victim was in an Alliance
74
+ # * damage_taken ( Fixnum ) - The amount of damage the victim took before being killed.
75
+ # * ship_type_id ( Fixnum ) - ID of the ship type (references CCP data dump) that the victim was flying.
76
+ # See Also: KillAttacker, Kill, KillLoss, Reve::API#personal_kills, Reve::API#corporate_kills
77
+ class KillVictim
78
+ attr_reader :id, :name, :corporation_id, :corporation_name, :alliance_id, :damage_taken, :ship_type_id
79
+ def initialize(elem) #:nodoc:
80
+ @id = elem['characterid'].to_i
81
+ @name = elem['charactername']
82
+ @corporation_id = elem['corporationname']
83
+ @alliance_id = elem['allianceid'] == "0" ? nil : elem['allianceid'].to_i
84
+ @damage_taken = elem['damagetaken'].to_i
85
+ @ship_type_id = elem['shiptypeid'].to_i
86
+ end
87
+ end
88
+
89
+ # It's possible to be killed/attacked by an NPC. In this case character_id, character_name,
90
+ # alliance_id, alliance_name and weapon_type_id will be nil
91
+ # Represents an attacker (attacking a KillVictim) in a Kill
92
+ # Attributes
93
+ # * id ( Fixnum | NilClass ) - ID of the attacker; nil if the attacker was an NPC or not a Character
94
+ # * name ( String | NilClass ) - Name of the attacker; nil if the attacker was an NPC or not a Character
95
+ # * corporation_id ( Fixnum ) - ID of the Corporation that the Character belongs to (could be NPC Corporation!)
96
+ # * corporation_name ( String ) - Name of the Corporation that the Character belongs to (could be NPC Corporation!)
97
+ # * alliance_id ( Fixnum | NilClass ) - ID of the Alliance that the Character belongs to (nil if the KillAttacker doesn't belong to an Alliance)
98
+ # * security_status ( Float ) - Security status of the KillAttacker
99
+ # * damage_done ( Fixnum ) - How much damage the KillAttacker did.
100
+ # * final_blow ( Boolean ) - True if this KillAttacker got the final blow to kill the KillVictim
101
+ # * weapon_type_id ( Fixnum | NilClass ) - Type ID of the (a?) weapon the KillAttacker was firing. (Refer to CCP database dump invtypes)
102
+ # * ship_type_id ( Fixnum ) - Type ID of the ship the KillAttacker was flying. (Refer to CCP database dump invtypes)
103
+ # See Also: Kill, KillLoss, KillVictim, Reve::API#personal_kills, Reve::API#corporate_kills
104
+ class KillAttacker
105
+ attr_reader :id, :name, :corporation_id, :corporation_name, :alliance_id, :alliance_name,
106
+ :security_status, :damage_done, :final_blow, :weapon_type_id, :ship_type_id
107
+ def initialize(elem) #:nodoc:
108
+ @id = elem['characterid'] == "0" ? nil : elem['characterid'].to_i
109
+ @name = elem['charactername'].empty? ? nil : elem['charactername']
110
+ @corporation_id = elem['corporationid'].to_i
111
+ @corporation_name = elem['corporationname']
112
+ @alliance_id = elem['allianceid'] == "0" ? nil : elem['allianceid'].to_i
113
+ @alliance_name = elem['alliancename'].empty? ? nil : elem['alliancename']
114
+ @security_status = elem['securitystatus'].to_f
115
+ @damage_done = elem['damagedone'].to_i
116
+ @final_blow = elem['finalblow'] == "1"
117
+ @weapon_type_id = elem['weapontypeid'] == "0" ? nil : elem['weapontypeid'].to_i
118
+ @ship_type_id = elem['shiptypeid'].to_i
119
+ end
120
+ end
121
+
122
+ # A model to represent losses from being killed.
123
+ # Attributes
124
+ # * type_id ( Fixnum ) - Type ID of the KillLoss. (Refer to CCP database dump invtypes)
125
+ # * flag ( Fixnum ) - A flag to denoe some special qualities of the KillLoss such as where it was mounted or if it was in a container. Refer to http://wiki.eve-dev.net/API_Inventory_Flags
126
+ # * quantity_dropped ( Fixnum ) - The number of +type_id+ that were dropped for looting - e.g., not destroyed.
127
+ # * quantity_destroyed ( Fixnum ) - The number of +type_id+ that were destroyed in the Kill.
128
+ # * contained_losses ( [KillLoss] ) - If the KillLoss was a container (refer to +type_id+) then this array will be populated with a list of KillLoss objects that were inside the container.
129
+ # See Also: Kill, KillAttacker, KillVictim, Reve::API#personal_kills, Reve::API#corporate_kills
130
+ class KillLoss
131
+ attr_reader :type_id, :flag, :quantity_dropped, :quantity_destroyed
132
+ attr_accessor :contained_losses
133
+ def initialize(elem)
134
+ @type_id = elem['typeid'].to_i
135
+ @flag = elem['flag'].to_i
136
+ @quantity_dropped = elem['qtydropped'].to_i
137
+ @quantity_destroyed = elem['qtydestroyed'].to_i
138
+ @contained_losses = []
139
+ end
140
+ end
141
+
142
+
143
+ # Simple class to contain the information relevant to a single Kill.
144
+ # Comprised of an array of KillLoss, an array of KillAttacker and one KillVictim
145
+ # Attributes
146
+ # * victim ( KillVictim ) - Instance of the KillVictim class to represent the victim of the Kill.
147
+ # * attackers ( [KillAttacker] ) - Array of KillAttacker objects that represent the people who killed the +victim+.
148
+ # * losses ( [KillLoss] ) - Array of KillLoss objects that represents the +victim+'s items destroyed in the Kill.
149
+ # * system_id ( Fixnum ) - The ID of the System that the Kill took place in.
150
+ # * id ( Fixnum ) - The ID of this specific Kill
151
+ # * moon_id ( Fixnum | NilClass ) - The ID of the Moon that this kill happened at (due to a POS?), if any; nil otherwise.
152
+ # See Also: KillAttacker, KillVictim, KillLoss, Reve::API#personal_kills, Reve::API#corporate_kills
153
+ class Kill
154
+ attr_reader :victim, :attackers, :losses
155
+ attr_reader :system_id, :created_at, :id, :moon_id
156
+ def initialize(elem, victim, attackers, losses) #:nodoc:
157
+ @victim, @attackers, @losses = victim, attackers, losses
158
+ @system_id = elem['solarsystemid'].to_i
159
+ @created_at = elem['killtime'].to_time
160
+ @id = elem['killid'].to_i
161
+ @moon_id = elem['moonid'] == "0" ? nil : elem['moonid'].to_i
162
+ end
163
+ end
164
+
165
+
166
+ # A container or singleton (unpackaged thing).
167
+ # Attributes
168
+ # * item_id ( Fixnum ) - A CCP-specific ID for the Asset/AssetContainer
169
+ # * location_id ( Fixnum ) - The ID of the Station (or POS?) that the Asset/AssetContainer is at.
170
+ # * type_id ( Fixnum ) - Type ID of the Asset/AssetContainer. (Refer to CCP database dump invtypes)
171
+ # * quantity ( Fixnum ) - The number of Asset/AssetContainer at this +location_id+
172
+ # * flag ( Fixnum ) - Inventory flag, refer to http://wiki.eve-dev.net/API_Inventory_Flags (See also KillLoss's flag)
173
+ # * singleton ( Boolean ) - True if the Asset/AssetContainer is not packaged up.
174
+ # * assets ( [Asset] ) - A list of Asset objects that are contained in this AssetContainer.
175
+ # See Also: Asset, Reve::API#corporate_assets_list, Reve::API#personal_assets_list
176
+ class AssetContainer
177
+ attr_reader :item_id, :location_id, :type_id, :quantity, :flag, :singleton
178
+ attr_accessor :assets
179
+ def initialize(elem)
180
+ @item_id = elem['itemid'].to_i
181
+ @location_id = elem['locationid'].to_i
182
+ @type_id = elem['typeid'].to_i
183
+ @quantity = elem['quantity'].to_i
184
+ @flag = elem['flag'].to_i
185
+ @singleton = elem['singleton'] == "1"
186
+ @assets = []
187
+ end
188
+ end
189
+
190
+ # An item contained within an AssetContainer (ship, or container)
191
+ # Attributes
192
+ # * item_id ( Fixnum ) - A CCP-specific ID for the Asset/AssetContainer
193
+ # * type_id ( Fixnum ) - Type ID of the Asset/AssetContainer. (Refer to CCP database dump invtypes)
194
+ # * quantity ( Fixnum ) - The number of Asset/AssetContainer at this +location_id+
195
+ # * flag ( Fixnum ) - Inventory flag, refer to http://wiki.eve-dev.net/API_Inventory_Flags (See also KillLoss's flag)
196
+ # See Also: AssetContainer, Reve::API#corporate_assets_list, Reve::API#personal_assets_list
197
+ class Asset
198
+ attr_reader :item_id, :type_id, :quantity, :flag, :singleton
199
+ def initialize(elem) #:nodoc:
200
+ @item_id = elem['itemid'].to_i
201
+ @type_id = elem['typeid'].to_i
202
+ @quantity = elem['quantity'].to_i
203
+ @flag = elem['flag'].to_i
204
+ @singleton = elem['singleton'].to_i
205
+ end
206
+ end
207
+
208
+ # Used for attribute enhancers (in-game Implants)
209
+ # IntelligenceEnhancer, MemoryEnhancer, PerceptionEnhancer, CharismaEnhancer
210
+ # and WillpowerEnhancer all subclass this class as this AttributeEnhancer
211
+ # class is never used (except in a fault-case). Use the kind_of? method
212
+ # to determine what kind of AttributeEnhancer one is dealing with.
213
+ # Attributes
214
+ # * name ( String ) - The name of the AttributeEnhancer (implant)
215
+ # * value ( Fixnum ) - How much the +name+ implant boosts.
216
+ # See Also: CharacterSheet, Reve::API#character_sheet
217
+ class AttributeEnhancer
218
+ attr_accessor :name, :value
219
+ def initialize(name = "", value = 0) #:nodoc:
220
+ @name = name
221
+ @value = value.to_i
222
+ end
223
+ end
224
+ class IntelligenceEnhancer < AttributeEnhancer; end
225
+ class MemoryEnhancer < AttributeEnhancer; end
226
+ class PerceptionEnhancer < AttributeEnhancer; end
227
+ class CharismaEnhancer < AttributeEnhancer; end
228
+ class WillpowerEnhancer < AttributeEnhancer; end
229
+
230
+ # Represents a Character for the Reve::API#characters, Reve::API#character_name and Reve::API#character_id calls.
231
+ # Attributes
232
+ # * name ( String ) - Name of the Character
233
+ # * id ( Fixnum ) - ID of the Character (use this for Reve::API method calls)
234
+ # * corporation_name ( String | NilClass ) - Name of the Corporation the Character belongs to. Nil if being used for Reve::API#character_name or Reve::API#character_id
235
+ # * corporation_id ( Fixnum | NilClass ) - ID of the Corporation the Character belongs to. Nil if being used for Reve::API#character_name or Reve::API#character_id
236
+ # See Also: Reve::API
237
+ class Character
238
+ attr_reader :name, :id, :corporation_name, :corporation_id
239
+ def initialize(elem) #:nodoc:
240
+ @id = elem['characterid'].to_i
241
+ @name = elem['name']
242
+ @corporation_name = elem['corporationname']
243
+ @corporation_id = elem['corporationid'].to_i
244
+ end
245
+ end
246
+
247
+ # Holds the result of the Reve::API#character_sheet call.
248
+ # This has all of the stuff that appears in the in-game 'character sheet'
249
+ # screen.
250
+ # The skills array is a Skill list (no name is stored in it)
251
+ # The enhancers array is an AttributeEnhancer derrived list
252
+ # Attributes
253
+ # * name ( String ) - Name of the Character
254
+ # * race ( String ) - Race of the Character
255
+ # * gender ( String ) - Gender of the Character
256
+ # * id ( Fixnum ) - ID of the Character
257
+ # * corporation_name ( String ) - Name of the Corporation the Character is in
258
+ # * corporation_id ( Fixnum ) - ID of the Corporation the Character is in
259
+ # * balance ( Float ) - How much ISK the Character has
260
+ # * intelligence ( Fixnum ) - Character's Intelligence level
261
+ # * memory ( Fixnum ) -
262
+ # * charisma ( Fixnum ) -
263
+ # * perception ( Fixnum ) -
264
+ # * willpower ( Fixnum ) -
265
+ # * skills ( [Skill] ) - An Array of Skill objects that the Character has trained.
266
+ # * enhancers ( [AttributeEnhancer] ) - An Array of any implants (AttributeEnhancer) the Character has in its head.
267
+ # See Also: Reve::API#character_sheet, AttributeEnhancer (and subclasses), Skill
268
+ class CharacterSheet
269
+ attr_accessor :name, :race, :bloodline, :gender, :id, :corporation_name, :corporation_id, :balance
270
+ attr_accessor :intelligence, :memory, :charisma, :perception, :willpower
271
+ attr_accessor :skills, :enhancers
272
+ def initialize #:nodoc:
273
+ @skills = []
274
+ @enhancers = []
275
+ end
276
+ def characterid=(i) #:nodoc:
277
+ @id = i.to_i
278
+ end
279
+ def corporationname=(i) #:nodoc:
280
+ @corporation_name = i
281
+ end
282
+ def corporationid=(i) #:nodoc:
283
+ @corporation_id = i.to_i
284
+ end
285
+ end
286
+
287
+ # Holds the result of the Reve::API#conqurable_stations call.
288
+ # Attributes
289
+ # * id ( Fixnum ) - ID of the ConqurableStation
290
+ # * name ( String ) - Name of the ConqurableStation
291
+ # * type_id ( Fixnum ) - What kind of ConqurableStation Station it is (Refer to CCP database dump invtypes).
292
+ # * type_name ( String ) - Name of the kind of Station this ConqurableStation is. (May not be present??)
293
+ # * corporation_id ( Fixnum ) - ID of the Corporation that owns the ConqurableStation
294
+ # * corporation_name ( String ) - Name of the Corporation that owns the ConqurableStation.
295
+ # See Also: Sovereignty, Reve::API#conqurable_stations, Reve::API#sovereignty, Reve::API#corporation_sheet, CorporationSheet
296
+ class ConqurableStation
297
+ attr_reader :id, :name, :type_id, :type_name, :system_id, :system_name, :corporation_id, :corporation_name
298
+ def initialize(elem) #:nodoc:
299
+ @id = elem['stationid'].to_i
300
+ @name = elem['stationname']
301
+ @type_id = elem['stationtypeid'].to_i
302
+ @type_name = elem['stationtypename']
303
+ @corporation_id = elem['corporationid'].to_i
304
+ @corporation_name = elem['corporationname']
305
+ end
306
+ end
307
+
308
+ # Part of the CorporationSheet; represnets a Corporation's in-game logo
309
+ # All of these values are internal to CCP; +shape_1+ matches with +color_1+ and so on.
310
+ # Attributes
311
+ # * graphic_id ( Fixnum )
312
+ # * shape_1 ( Fixnum )
313
+ # * shape_2 ( Fixnum )
314
+ # * shape_3 ( Fixnum )
315
+ # * color_1 ( Fixnum )
316
+ # * color_2 ( Fixnum )
317
+ # * color_3 ( Fixnum )
318
+ class CorporateLogo
319
+ attr_reader :graphic_id, :shape_1, :shape_2, :shape_3, :color_1, :color_2, :color_3
320
+ def initialize(elem) #:nodoc:
321
+ @graphic_id = elem['graphicid'].to_i
322
+ @shape_1 = elem['shape1'].to_i
323
+ @shape_2 = elem['shape2'].to_i
324
+ @shape_3 = elem['shape3'].to_i
325
+ @color_1 = elem['color1'].to_i
326
+ @color_2 = elem['color2'].to_i
327
+ @color_3 = elem['color3'].to_i
328
+ end
329
+ end
330
+
331
+ # Part of the CorporationSheet. Describes a division in the wallet
332
+ # Attributes
333
+ # * key ( Fixnum ) - Account key. Used for things like WalletBalance and such.
334
+ # * description ( String ) - Description of the WalletDivision
335
+ # See Also CorporationSheet
336
+ class WalletDivision
337
+ attr_reader :key, :description
338
+ def initialize(elem) #:nodoc:
339
+ @key = elem['accountkey'].to_i
340
+ @description = elem['description'].split(/\n/).collect { |s| s.strip }.join(' ') # newlines to spaces
341
+ end
342
+ end
343
+
344
+ # Part of the CorporationSheet. Describes a division of the Corporation
345
+ # Attributes
346
+ # * key ( Fixnum ) - Account key.
347
+ # * description ( String ) - Description of the CorporateDivision
348
+ # See Also CorporationSheet
349
+ class CorporateDivision
350
+ attr_reader :key, :description
351
+ def initialize(elem) #:nodoc:
352
+ @key = elem['accountkey'].to_i
353
+ @description = elem['description'].split(/\n/).collect { |s| s.strip }.join(' ') # newlines to spaces
354
+ end
355
+ end
356
+
357
+ # Describes a Corporation. The public listing when a Corporation is in an Alliance is limited. When the requestor is in the Corporation for which the CorporationSheet is for then the details are full.
358
+ # Attributes
359
+ # * id ( Fixnum ) - ID of the Corporation
360
+ # * name ( String ) - Name of the Corporation
361
+ # * ticker ( String ) - Ticker (short name) of the Corporation
362
+ # * ceo_id ( Fixnum ) - The ID of the Character who is the CEO of the Corporation
363
+ # * ceo_name ( String ) - The name of the Character whois he CEO of the Corporation
364
+ # * station_id ( Fixnum ) - The ID of the Corporation's home Station
365
+ # * station_name ( Station ) - The name of the Corporation's home Station
366
+ # * description ( String ) - Corporation's description
367
+ # * url ( String ) - URL of the Corporation's website. If none is set the value is an empty String
368
+ # * alliance_id ( Fixnum | NilClass ) - ID of the Alliance that this Corporation belongs to; nil if no membership
369
+ # * alliance_name ( String | NilClass ) - Name of the Alliance that this Corporation belongs to; nil if no membership
370
+ # * tax_rate ( Float ) - Tax rate for the Corporation
371
+ # * member_count ( Fixnum ) - How many Characters are in the Corporation
372
+ # * member_limit ( Fixnum ) - Member limit (Max number of Characters allowed in?)
373
+ # * shares ( Fixnum ) - Number of shares available for the Corporation
374
+ # * divisions ( [CorporateDivision] ) - Array of CorporateDivision objects representing the differet divisions in the Corporation
375
+ # * wallet_divisions ( [WalletDivision] ) - Array of WalletDivision objects representing the different divisions in the wallet for the Corporation
376
+ # * logo ( CorporateLogo ) - An object to represent the Corporation's logo.
377
+ # See Also: CorporateLogo, WalletDivision, CorporateDivision, Corporation, Reve::API#corporation_sheet
378
+ class CorporationSheet
379
+ attr_reader :id, :name, :ticker, :ceo_id, :ceo_name, :station_id, :station_name, :description, :url,
380
+ :alliance_id, :alliance_name, :tax_rate, :member_count, :member_limit, :shares
381
+ attr_accessor :divisions, :wallet_divisions, :logo
382
+
383
+ # Call it +h+ here cos it's a Hash and not any Hpricot object like in other constructors
384
+ def initialize(h, divisions = [],wallet_divisions = [], logo =Reve::Classes::CorporateLogo.new(Hash.new(0)) ) #:nodoc:
385
+ @divisions = divisions
386
+ @wallet_divisions = wallet_divisions
387
+ @logo = logo
388
+ @id = h[:id].to_i
389
+ @name = h[:name]
390
+ @ticker = h[:ticker]
391
+ @ceo_id = h[:ceo_id].to_i
392
+ @ceo_name = h[:ceo_name]
393
+ @station_id = h[:station_id].to_i
394
+ @station_name = h[:station_name]
395
+ @description = h[:description].split(/\n/).collect { |s| s.strip }.join(' ') # newlines to spaces
396
+ @url = h[:url] || ""
397
+ @alliance_id = h[:alliance_id].to_i rescue nil
398
+ @alliance_name = h[:alliance_name] rescue nil
399
+ @tax_rate = h[:tax_rate].to_f
400
+ @member_count = h[:member_count].to_i
401
+ @member_limit = h[:member_limit].to_i
402
+ @shares = h[:shares].to_i
403
+ end
404
+ end
405
+
406
+ # This is just for getting the list and writing to test/xml/errors
407
+ class APIError #:nodoc:
408
+ attr_reader :code, :text
409
+ def initialize(elem)
410
+ @code = elem['errorcode'].to_i
411
+ @text = elem['errortext']
412
+ end
413
+ end
414
+
415
+ # Used for the Reve::API#map_jumps method. If there are no jumps it is not listed.
416
+ # Attributes
417
+ # * system_id ( Fixnum ) - ID of the System
418
+ # * jumps ( Fixnum ) - Number of jumps through the System
419
+ # See Also: MapKill, Reve::API#map_jumps
420
+ class MapJump
421
+ attr_reader :system_id, :jumps
422
+ def initialize(elem) #:nodoc:
423
+ @system_id = elem['solarsystemid'].to_i
424
+ @jumps = elem['shipjumps'].to_i
425
+ end
426
+ end
427
+
428
+ # Used for the Reve::API#personal_market_orders and Reve::API#corporate_market_orders
429
+ # Each of those derrive from this parent class.
430
+ # Attributes
431
+ # * id ( Fixnum ) - ID of the MarketOrder. This is a CCP internal ID and is not guaranteed to always be unique! You may want to generate your own globally unique ID for this.
432
+ # * character_id ( Fixnum ) - ID of the Character who set this MarketOrder up
433
+ # * station_id ( Fixnum ) - ID of the Station where the MarketOrder is
434
+ # * volume_entered ( Fixnum ) - How many of +type_id+ was initially entered in the MarketOrder
435
+ # * volume_remaining ( Fixnum ) - How many of +type_id+ is left in the MarketOrder
436
+ # * minimum_volume ( Fixnum ) - How much of +type_id+ can be transacted (as a minimum) at once
437
+ # * order_state ( String ) - String representation of the MarketOrder's current state. Options are: Active, Closed, Expired, Cancelled, Pending, Character Deleted
438
+ # * type_id ( Fixnum ) - Type ID of item for which the MarketOrder was created. (Refer to CCP database dump invtypes)
439
+ # * range ( Fixnum ) - Range of the MarketOrder. For sell orders it is always 32767 (Entire Region), for sell orders the values are -1 (Station only), 0 (Solar system), 1..40 (Number of jumps away from the Station), 32767 (Region wide)
440
+ # * account_key ( Fixnum ) - For a CorporateMarketOrder the account key (see WalletDivision and CorporationSheet) that was used as the source/destination.
441
+ # * duration ( Fixnum ) - Duration of the MarketOrder in days from when it was +created_at+
442
+ # * escrow ( Float ) - How much ISK is held in escrow for the MarketOrder
443
+ # * price ( Float ) - Unit price of the item in the MarketOrder
444
+ # * bid ( Boolean ) - True if this MarketOrder is a sell order, false otherwise
445
+ # * created_at ( Time ) - When the MarketOrder was created
446
+ # See Also: CorporationSheet, WalletDivision, CorporateDivision, Reve::API#personal_market_orders, Reve::API#corporate_market_orders
447
+ class MarketOrder
448
+ attr_reader :id, :character_id, :station_id, :volume_entered, :volume_remaining, :minimum_volume,
449
+ :order_state, :type_id, :range, :account_key, :duration, :escrow, :price, :bid, :created_at
450
+ def initialize(elem) #:nodoc:
451
+ @id = elem['orderid'].to_i
452
+ @character_id = elem['characterid'].to_i
453
+ @station_id = elem['station_id'].to_i
454
+ @volume_entered = elem['volentered'].to_i
455
+ @volume_remaining = elem['volremaining'].to_i
456
+ @minimum_volume = elem['minvolume'].to_i
457
+ @order_state = case elem['orderstate'].to_i
458
+ when 0
459
+ 'Active'
460
+ when 1
461
+ 'Closed'
462
+ when 2
463
+ 'Expired'
464
+ when 3
465
+ 'Cancelled'
466
+ when 4
467
+ 'Pending'
468
+ when 5
469
+ 'Character Deleted'
470
+ end
471
+ @type_id = elem['typeid'].to_i
472
+ @range = elem['range'].to_i
473
+ @account_key = elem['accountkey'].to_i
474
+ @escrow = elem['escrow'].to_f
475
+ @price = elem['price'].to_f
476
+ @bid = elem['bid'] == '1'
477
+ @duration = elem['duration'].to_i
478
+ @created_at = elem['issued'].to_time
479
+ end
480
+ end
481
+ class PersonalMarketOrder < MarketOrder; end
482
+ class CorporateMarketOrder < MarketOrder; end
483
+
484
+
485
+ # Used in Reve::API#personal_industry_jobs and Reve::API#corporate_industry_jobs. PersonalIndustryJob and CorporateIndustryJob
486
+ # subclass this for more logical containment.
487
+ # These attributes should be largely self-explanatory. There are so many of them that it's soulcrushing to document each one! (Sorry ;)
488
+ # For further information please see: http://wiki.eve-dev.net/APIv2_Char_IndustryJobs_XML especially about +completed_status+ and +completed+
489
+ class IndustryJob
490
+ attr_reader :id, :assembly_line_id, :container_id, :installed_item_id, :installed_item_location_id,
491
+ :installed_item_quantity, :installed_item_productivity_level, :installed_item_material_level,
492
+ :installed_item_licensed_production_runs_remaining, :output_location_id, :installer_id, :runs,
493
+ :licensed_production_runs, :installed_system_id, :container_location_id, :material_multiplier,
494
+ :char_material_multiplier, :time_multiplier, :char_time_multiplier, :installed_item_type_id,
495
+ :output_type_id, :container_type_id, :installed_item_copy, :completed, :completed_successfully,
496
+ :installed_item_flag, :output_flag, :activity_id, :completed_status, :installed_at,
497
+ :begin_production_at, :end_production_at, :pause_production_time
498
+ def initialize(elem) #:nodoc:
499
+ @id = elem['jobid'].to_i; @assembly_line_id = elem['assemblylineid'].to_i ; @container_id = elem['containerid'].to_i
500
+ @installed_item_id = elem['installeditemid'].to_i ; @installed_item_location_id = elem['installeditemlocationid'].to_i
501
+ @installed_item_quantity = elem['installeditemquantity'].to_i
502
+ @installed_item_productivity_level = elem['installeditemproductivitylevel'].to_i
503
+ @installed_item_material_level = elem['installeditemmateriallevel'].to_i
504
+ @installed_item_licensed_production_runs_remaining = elem['installeditemlicensedproductionrunsremaining'].to_i
505
+ @output_location_id = elem['outputlocationid'].to_i ; @installer_id = elem['installerid'].to_i; @runs = elem['runs'].to_i
506
+ @licensed_production_runs = elem['licensedproductionruns'].to_i ; @installed_system_id = elem['installedsolarsystemid'].to_i
507
+ @container_location_id = elem['containerlocationid'].to_i ; @material_multiplier = elem['materialmultiplier'].to_f
508
+ @char_material_multiplier = elem['charmaterialmultiplier'].to_f; @time_multiplier = elem['timemultiplier'].to_f
509
+ @char_time_multiplier = elem['chartimemultiplier'].to_f ; @installed_item_type_id = elem['installeditemtypeid'].to_i
510
+ @output_type_id = elem['outputtypeid'].to_i ; @container_type_id = elem['containertypeid'].to_i
511
+ @installed_item_copy = (elem['installeditemcopy'] == "1") ; @completed = (elem['completed'] == "1")
512
+ @completed_successfully = (elem['completedsuccessfully'] == "1")
513
+ @installed_item_flag = elem['installeditemflag'].to_i ; @output_flag = elem['outputflag'].to_i
514
+ @activity_id = elem['activityid'].to_i ; @completed_status = elem['completedstatus'].to_i
515
+ @installed_at = elem['installtime'].to_time ; @begin_production_at = elem['beginproductiontime'].to_time
516
+ @end_production_at = elem['endproductiontime'].to_time
517
+ @pause_production_time = elem['pauseproductiontime'].to_time
518
+ end
519
+ end
520
+ class PersonalIndustryJob < IndustryJob; end
521
+ class CorporateIndustryJob < IndustryJob; end
522
+
523
+ # Used for the Reve::API#map_kills method. If there are no kills it's not listed.
524
+ # Attributes
525
+ # * system_id ( Fixnum ) - ID of the System
526
+ # * ship_kills ( Fixnum ) - Number of ships killed
527
+ # * faction_kills ( Fixnum ) - Number of faction ships killed (NPC Pirates)
528
+ # * pod_kills ( Fixnum ) - Number of podkills
529
+ # See also Reve::API#map_kills, MapJump
530
+ class MapKill
531
+ attr_reader :system_id, :ship_kills, :faction_kills, :pod_kills
532
+ def initialize(elem) #:nodoc:
533
+ @system_id = elem['solarsystemid'].to_i
534
+ @ship_kills = elem['shipkills'].to_i
535
+ @faction_kills = elem['factionkills'].to_i
536
+ @pod_kills = elem['podkills'].to_i
537
+ end
538
+ end
539
+
540
+ # Holds the result of the Reve::API#member_tracking call for big brother.
541
+ # * character_id ( Fixnum ) - ID of the Character
542
+ # * character_name ( Fixnum ) - Name of the Character
543
+ # * start_time ( Time ) - When the Character joined the Corporation
544
+ # * base_id ( Fixnum ) - ID of the Station (Starbase too?) where the Character calls home
545
+ # * base ( String ) - Name of the Station (Starbase?) where the Character calls home
546
+ # * title ( String ) - Title of the Character
547
+ # * logon_time ( Time | NilClass ) - When the Character last logged on (or nil for non-CEOs)
548
+ # * logoff_time ( Time | NilClass ) - When the Character last logged off (or nil for non-CEOs)
549
+ # * location_id ( Fixnum ) - ID of the Station (Starbase too?) where the Character last/currently is
550
+ # * location ( String ) - Name of the Station (Starbase?) where the Character last/currently is
551
+ # * ship_type_id ( Fixnum ) - Type ID of the ship the Character is flying. (Refer to CCP database dump invtypes)
552
+ # * ship_type ( String ) - Name of the type of ship the Character is flying
553
+ # * roles ( String ) - List of roles for the Character
554
+ # * grantable_roles ( String ) - List of grantable roles for the Character
555
+ # See Also: Reve::API#member_tracking
556
+ class MemberTracking
557
+ attr_reader :character_id, :character_name, :start_time, :base_id, :base, :title, :logon_time, :logoff_time,
558
+ :location_id, :location, :ship_type_id, :ship_type, :roles, :grantable_roles
559
+ def initialize(elem) #:nodoc:
560
+ @character_id = elem['characterid'].to_i
561
+ @character_name = elem['name']
562
+ @start_time = elem['startdatetime'].to_time
563
+ @base_id = elem['baseid'].to_i
564
+ @base = elem['base']
565
+ @title = elem['title']
566
+ @logon_time = elem['logondatetime'].to_time rescue nil # can be nil for non CEOs
567
+ @logoff_time = elem['logoffdatetime'].to_time rescue nil # Can be nil for non CEOs
568
+ @location_id = elem['locationid']
569
+ @location = elem['location']
570
+ @ship_type_id = elem['shiptypeid'].to_i
571
+ @ship_type = elem['shiptype']
572
+ @roles = elem['roles']
573
+ @grantable_roles = elem['grantableroles']
574
+ end
575
+ end
576
+
577
+ # Represents Reve::API#ref_types return. Used in WalletTransaction and WalletJournal, among others to qualify the "type" of the entry
578
+ # Attributes
579
+ # * id ( Fixnum ) - CCP's ID for the RefType
580
+ # * name ( String ) - CCP's name for the RefType
581
+ # See Also: Reve::API#ref_types, WalletJournal, WalletTransaction
582
+ class RefType
583
+ attr_reader :id, :name
584
+ def initialize(elem) #:nodoc:
585
+ @id = elem['reftypeid'].to_i
586
+ @name = elem['reftypename']
587
+ end
588
+ end
589
+
590
+ # A Skill is used in the CharacterSheet for Reve::API#character_sheet call.
591
+ # Attributes
592
+ # * id ( Fixnum ) - Type ID of the Skill. (Refer to CCP database dump invtypes)
593
+ # * skillpoints ( Fixnum ) - Number of skill points invested in this skill
594
+ # * level ( Fixnum ) - Level of the Skill
595
+ # See Also: CharacterSheet, Reve::API#character_sheet
596
+ class Skill
597
+ attr_accessor :id, :unpublished, :skillpoints, :level
598
+ def initialize(elem) #:nodoc:
599
+ @id = elem['typeid'].to_i
600
+ @skillpoints = elem['skillpoints'].to_i
601
+ @level = elem['level'].to_i
602
+ end
603
+ end
604
+
605
+ # A SkillBonus, for SkillTree and Reve::API#skill_tree.
606
+ # Bear in mind that "SkillBonus" doesn't always mean anything useful or beneficial
607
+ # * type ( String ) - Name of the bonus
608
+ # * value ( String ) - Value of the bonus. This is may be Fixnum or Float or Boolean but is left as a String
609
+ # See Also: SkillTree, Reve::API#skill_tree
610
+ class SkillBonus
611
+ attr_reader :type, :value
612
+ def initialize(elem) #:nodoc:
613
+ @type = elem['bonustype']
614
+ @value = elem['bonusvalue']
615
+ end
616
+ end
617
+
618
+ # A SkillRequirement, for SkillTree and Reve::API#skill_tree
619
+ # Attributes
620
+ # * type_id ( Fixnum ) - ID of the Skill that is the SkillRequirement (Refer to CCP database dump invtypes)
621
+ # * level ( Fixnum ) - What level of the Skill is required
622
+ # See Also: SkillTree, Reve::API#skill_tree
623
+ class SkillRequirement
624
+ attr_reader :type_id, :level
625
+ alias_method :id, :type_id
626
+ def initialize(elem)
627
+ @type_id = elem['typeid'].to_i
628
+ @level = elem['skilllevel'].to_i
629
+ end
630
+ end
631
+
632
+ # Holds the result of the Reve::API#skill_tree call. Currently this is not
633
+ # nested based on group_id in each individual skill.
634
+ # Attributes
635
+ # * name ( String ) - Name of a Skill
636
+ # * type_id ( Fixnum ) - ID of the Skill (Refer to CCP database dump invtypes)
637
+ # * group_id ( Fixnum ) - Group ID of the Skill (Refer to CCP database dump invgroups)
638
+ # * description ( Skill ) - Description of the Skill
639
+ # * rank ( Fixnum ) - Rank of the skill
640
+ # * attribs ( [RequiredAttribute] ) - Two-element array with the PrimaryAttribute and SecondaryAttribute for the Skill
641
+ # * skills ( [SkillTree] ) - Nested Skills under this group. NOT USED
642
+ # * bonuses ( [SkillBonus] ) - Bonuses given by this Skill
643
+ # See Also: SkillBonus, RequiredAttribute, Reve::API#skill_tree
644
+ class SkillTree
645
+ attr_reader :name, :type_id, :group_id, :description, :rank, :attribs, :required_skills, :bonuses
646
+ def initialize(name, typeid, groupid, desc, rank, attribs = [], skills = [], bonuses = []) #:nodoc:
647
+ @name = name
648
+ @type_id = typeid.to_i
649
+ @group_id = groupid.to_i
650
+ @rank = rank.to_i
651
+ @attribs = attribs
652
+ @required_skills = skills
653
+ @bonuses = bonuses
654
+ # turn multiline literals (embedded \n and lot of white space) into one
655
+ # line!
656
+ @description = desc.split(/\n/).collect { |s| s.strip }.join(' ')
657
+ end
658
+ end
659
+
660
+ # Holds the result of the Reve::API#skill_in_training call.
661
+ # Note: When a Character finishes training the API will not be updated until the Character next logs into the game.
662
+ # Attributes
663
+ # * tranquility_time ( Time ) - The current time on Tranquility
664
+ # * end_time ( Time ) - When the Skill is due to end
665
+ # * start_time ( Time ) - When the Skill training was started
666
+ # * type_id ( Fixnum ) - ID of the Skill (Refer to CCP database dump invtypes)
667
+ # * start_sp ( Fixnum ) - How many SP did the Character have before training was started
668
+ # * end_sp ( Fixnum ) - How many SP will the Character have after training finishes
669
+ # * to_level ( Fixnum ) - This is the level the Skill will be at when training is completed
670
+ # * skill_in_training ( Boolean ) - Is there actually a skill in training? (Check this first before doing anything)
671
+ # See Also: CharacterSheet, Reve::API#skill_in_training
672
+ class SkillInTraining
673
+ attr_reader :tranquility_time, :end_time, :start_time, :type_id, :start_sp, :end_sp, :to_level, :skill_in_training
674
+ def initialize(elem) #:nodoc:
675
+ @tranquility_time = elem['currenttqtime'].to_time
676
+ @end_time = elem['trainingendtime'].to_time
677
+ @start_time = elem['trainingstarttime'].to_time
678
+ @type_id = elem['trainingtypeid'].to_i
679
+ @start_sp = elem['trainingstartsp'].to_i
680
+ @end_sp = elem['trainingdestinationsp'].to_i
681
+ @to_level = elem['trainingtolevel'].to_i
682
+ @skill_in_training= elem['skillintraining'] == '1'
683
+ end
684
+ end
685
+
686
+ # Used for the Reve::API#sovereignty call.
687
+ # Attributes
688
+ # * system_id ( Fixnum ) - ID of the System
689
+ # * alliance_id ( Fixnum ) - ID of the Alliance that controls the System
690
+ # * constellation_sovereignty ( String ) - Not sure? Maybe this is if the System falls under a Constellation Sovereignty setup?
691
+ # * level ( Fixnum ) - Not sure? Level of Constellation Sovereignty
692
+ # * faction_id ( Fixnum ) - ID of the Faction that controls the System
693
+ # * system_name ( String ) - Name of the System
694
+ # See Also: Alliance, Reve::API#alliances
695
+ class Sovereignty
696
+ attr_reader :system_id, :alliance_id, :constellation_sovereignty, :level, :faction_id, :system_name
697
+ def initialize(elem) #:nodoc:
698
+ @system_id = elem['solarsystemid'].to_i
699
+ @alliance_id = elem['allianceid'] == '0' ? nil : elem['allianceid'].to_i
700
+ @constellation_sovereignty = elem['constellationsovereignty']
701
+ @level = elem['sovereigntylevel'].to_i if elem['sovereigntylevel']
702
+ @faction_id = elem['factionid'] == '0' ? nil : elem['factionid'].to_i
703
+ @system_name = elem['solarsystemname']
704
+ end
705
+ end
706
+
707
+ # Used for a list of Starbases, Reve::API#starbases
708
+ # Attributes
709
+ # * type_id ( Fixnum ) - Type of Starbase (Refer to CCP database dump invtypes)
710
+ # * type_name ( String ) - Name of the type of Starbase
711
+ # * id ( Fixnum ) - ID of the Starbase
712
+ # * system_id ( Fixnum ) - ID of the System where the Starbase is
713
+ # * system_name ( Starbase ) - Name of the System where the Starbase is
714
+ # See Also: StarbaseFuel, Reve::API#starbases, Reve::API#starbase_fuel
715
+ class Starbase
716
+ attr_reader :type_id, :type_name, :id, :system_id, :system_name
717
+ alias_method :item_id, :id
718
+ alias_method :location_id,:system_id
719
+ alias_method :location_name, :system_name
720
+ def initialize(elem) #:nodoc:
721
+ @type_id = elem['typeid'].to_i
722
+ @type_name = elem['typename']
723
+ @id = elem['itemid'].to_i
724
+ @system_id = elem['locationid'].to_i
725
+ @system_name = elem['locationname']
726
+ end
727
+ end
728
+
729
+ # Used for the fuel status of a Starbase. See Reve::API#starbase_fuel
730
+ # starbase_id is set in the Reve::API#starbase_fuel method and not here
731
+ # Attributes
732
+ # * type_id ( Fixnum ) - Type of fuel in the Starbase (Refer to CCP database dump invtypes)
733
+ # * quantity ( Fixnum ) - How much of the fuel is in the Starbase
734
+ # * starbase_id ( Fixnum ) - ID of the Starbase
735
+ # See Also: Starbase, Reve::API#starbase_fuel, Reve::API#starbases
736
+ class StarbaseFuel
737
+ attr_reader :type_id, :quantity
738
+ attr_accessor :starbase_id
739
+ def initialize(elem) #:nodoc:
740
+ @type_id = elem['typeid'].to_i
741
+ @quantity = elem['quantity'].to_i
742
+ end
743
+ end
744
+
745
+ # Corporation or Character WalletBalance for
746
+ # Reve::API#personal_wallet_transactions and
747
+ # Reve::API#corporate_wallet_balance
748
+ # Attributes
749
+ # * account_id ( Fixnum ) - ID of the account
750
+ # * account_key ( String ) - Account key
751
+ # * balance ( Float ) - Balance of the wallet
752
+ class WalletBalance
753
+ attr_reader :account_id, :account_key, :balance
754
+ def initialize(elem)
755
+ @account_id = elem['accountid'].to_i
756
+ @account_key = elem['accountkey']
757
+ @balance = elem['balance'].to_f
758
+ end
759
+ end
760
+ # Corporation or Character WalletJournal for
761
+ # Reve::API#personal_wallet_journal and
762
+ # Reve::API#corporate_wallet_journal
763
+ # Attributes:
764
+ # * date ( Time ) - Time the action occured
765
+ # * ref_id ( Integer ) - Reference ID for this action (used with stepping through Journal Entries)
766
+ # * reftype_id ( Integer ) - RefType id
767
+ # * owner_name1 ( String ) - Name of the Player/Corporation/whatever that did something to owner_name2
768
+ # * owner_name2 ( String ) - Recipient of this action (from owner_name1)
769
+ # * owner_id1 ( Integer ) - ID of the Owner's whatever (Player/Corporation/Faction/Whatever)
770
+ # * owner_id2 ( Integer ) - ID of the recpient (Player/Corporation/Faction/Whatever)
771
+ # * arg_name1 ( String ) - For bounty, what caused this. (May be blank)
772
+ # * arg_id1 ( Integer ) - ID of arg_name1
773
+ # * amount ( Float ) - Wallet delta
774
+ # * balance ( Float ) - New wallet balance after this action
775
+ # * reason ( String ) - Any reason for the action. May be blank (useful in giving ISK)
776
+ class WalletJournal
777
+ attr_reader :date, :ref_id, :reftype_id, :owner_name1, :owner_id1, :owner_name2, :owner_id2, :arg_name1, :arg_id1, :amount, :balance, :reason
778
+ alias_method :id, :ref_id
779
+ def initialize(elem) #:nodoc:
780
+ @date = elem['date'].to_time
781
+ @ref_id = elem['refid'].to_i
782
+ @reftype_id = elem['reftypeid'].to_i
783
+ @owner_name1 = elem['ownername1']
784
+ @owner_name2 = elem['ownername2']
785
+ @owner_id1 = elem['ownerid1'].to_i if elem['ownerid1']
786
+ @owner_id2 = elem['ownerid2'].to_i if elem['ownerid2']
787
+ @arg_name1 = elem['argname1']
788
+ @arg_id1 = elem['argid1'].to_i if elem['argid1']
789
+ @amount = elem['amount'].to_f
790
+ @balance = elem['balance'].to_f
791
+ @reason = elem['reason']
792
+ end
793
+ end
794
+ # Corporation or Character WalletTransaction for
795
+ # Reve::API#personal_wallet_transactions and
796
+ # Reve::API#corporate_wallet_transactions
797
+ # Attributes
798
+ # * created_at ( Time ) - When was the WalletTransaction created?
799
+ # * id ( Fixnum ) - CCP's ID of the WalletTransaction. Note: This is not guaranteed to be unique. It may be best to create your own unique ID
800
+ # * quantity ( Fixnum ) - Number of +type_id+ transacted
801
+ # * type_name ( String ) - Name of the transacted thing
802
+ # * price ( Float) - Price of the transacted thing
803
+ # * client_id ( Fixnum ) - ID of the client
804
+ # * client_name ( String ) - Name of the client
805
+ # * character_id ( Fixnum ) - ID of the Character
806
+ # * station_id ( Fixnum ) - ID of the Station where the WalletTransaction took place
807
+ # * station_name ( String ) - Name of the Station where the WalletTransaction took place
808
+ # * type ( String ) - Not sure?
809
+ # * transaction_for ( String ) - This is corporate or personal, mirrors the subclasses.
810
+ class WalletTransaction
811
+ attr_reader :created_at, :id, :quantity, :type_name, :type_id, :price,
812
+ :client_id, :client_name, :character_id, :station_id, :station_name, :type,
813
+ :transaction_for
814
+ def initialize(elem) #:nodoc:
815
+ @created_at = elem['transactiondatetime'].to_time rescue nil
816
+ @id = elem['transactionid'].to_i
817
+ @quantity = elem['quantity'].to_i
818
+ @type_name = elem['typename']
819
+ @type_id = elem['typeid'].to_i
820
+ @price = elem['price'].to_f
821
+ @client_id = elem['clientid'].to_i if elem['clientid']
822
+ @client_name = elem['clientname']
823
+ @station_id = elem['stationid'].to_i
824
+ @station_name = elem['stationname']
825
+ @character_id = elem['characterid'].to_i if elem['characterid'] && elem['characterid'] != '0'
826
+ @type = elem['transactiontype']
827
+ @transaction_for = elem['transactionfor'] # This is corporate or personal, mirrors the subclasses.
828
+ end
829
+ end
830
+ # For Corporate WalletTransaction (WalletTransaction#transaction_for == 'corporation')
831
+ # See WalletTransaction
832
+ class CorporateWalletTransaction < WalletTransaction
833
+ end
834
+ # For Personal WalletTransaction (WalletTransaction#transaction_for == 'personal')
835
+ # See WalletTransaction
836
+ class PersonalWalletTransaction < WalletTransaction
837
+ end
838
+ end
839
+ end
@@ -0,0 +1,343 @@
1
+ #--
2
+ # Code copyright Lisa Seelye, 2007-2008. www.crudvision.com
3
+ # Reve is not licensed for commercial use. For other uses there are no
4
+ # restrictions.
5
+ #
6
+ # The author is not adverse to tokens of appreciation in the form of Eve ISK,
7
+ # ships, and feedback. Please use
8
+ # http://www.crudvision.com/reve-ruby-eve-online-api-library/ to provide
9
+ # feedback or send ISK to Raquel Smith in Eve. :-)
10
+ #++
11
+ module Reve
12
+ # Exceptions live here.
13
+ module Exceptions
14
+ # Raise the flag!
15
+ def self.raise_it(code,msg = "No Error Message From CCP Server (But one DID occur!)")
16
+ msg = "(#{code.to_s}) #{msg}"
17
+ case code
18
+ when 100
19
+ raise WalletNotPreviouslyLoaded.new(msg)
20
+ when 101, 103
21
+ raise WalletExhausted.new(msg)
22
+ when 102
23
+ raise WalletPreviouslyLoaded.new(msg)
24
+ when 104
25
+ raise KeyNotFound.new(msg)
26
+ when 105
27
+ raise InvalidCharacterID.new(msg)
28
+ when 106
29
+ raise MustProvideUserIDParameterForAuthentication.new(msg)
30
+ when 107
31
+ raise InvalidBeforeRefID.new(msg)
32
+ when 108
33
+ raise InvalidAccountKey.new(msg)
34
+ when 109
35
+ raise AccountKeyOutOfRange.new(msg)
36
+ when 110
37
+ raise InvalidBeforeTransID.new(msg)
38
+ when 111
39
+ raise InvalidInteger.new(msg)
40
+ when 112
41
+ raise VersionMismatchException.new(msg)
42
+ when 113
43
+ raise VersionEscalationException.new(msg)
44
+ when 114
45
+ raise InvalidItemIDProvided.new(msg)
46
+ when 115
47
+ raise AssetsAlreadyFetched.new(msg)
48
+ when 116
49
+ raise IndustryJobsAlreadyFetched.new(msg)
50
+ when 117
51
+ raise MarketOrdersAlreadyFetched.new(msg)
52
+ when 118
53
+ raise ExpectedBeforeKillID.new(msg)
54
+ when 119
55
+ raise KillsExhausted.new(msg)
56
+ when 120
57
+ raise UnexpectedBeforeKillID.new(msg)
58
+ when 121
59
+ raise BadBeforeKillID.new(msg)
60
+ when 200
61
+ raise SecurityLevelNotHighEnough.new(msg + ' (Should you be using the full API Key?)')
62
+ when 201
63
+ raise CharacterDoesNotBelongToAccount.new(msg)
64
+ when 202
65
+ raise CachedAPIKeyAuthenticationFailure.new(msg)
66
+ when 203..205
67
+ raise AuthenticationFailure.new(msg)
68
+ when 206
69
+ raise MustHaveAccountantRole.new(msg)
70
+ when 207
71
+ raise NotAvailableForNPCCorps.new(msg)
72
+ when 208
73
+ raise MustHaveAccountantOrTraderRole.new(msg)
74
+ when 209
75
+ raise MustBeDirectorOrCEO.new(msg)
76
+ when 210,212
77
+ raise AuthenticationFailure.new(msg)
78
+ when 211
79
+ raise LoginDeniedByAccountStatus.new(msg)
80
+ when 213
81
+ raise CharacterNeedsFactoryManagerRole.new(msg)
82
+ when 214
83
+ raise CorporationNotInAlliance.new(msg)
84
+ when 500
85
+ raise GetNameInvalid.new(msg)
86
+ when 501
87
+ raise GetIDInvalid.new(msg)
88
+ when 502
89
+ raise CachedUntilException.new(msg)
90
+ when 503
91
+ raise InvalidInput.new(msg)
92
+ when 504
93
+ raise InvalidRace.new(msg)
94
+ when 505
95
+ raise InvalidGender.new(msg)
96
+ when 506
97
+ raise InvalidBloodline.new(msg)
98
+ when 507
99
+ raise InvalidAttribute.new(msg)
100
+ when 508
101
+ raise InvalidRefType.new(msg)
102
+ when 509
103
+ raise NullDataComponent.new(msg)
104
+ when 510
105
+ raise NoCorporationException.new(msg)
106
+ when 511
107
+ raise InvalidAccountKey.new(msg)
108
+ when 512
109
+ raise InvalidCharID.new(msg)
110
+ when 513
111
+ raise CorporateRoleFetchException.new(msg)
112
+ when 514
113
+ raise InvalidCorpID.new(msg)
114
+ when 515
115
+ raise InvalidUserIDOrAPIKey.new(msg)
116
+ when 516
117
+ raise UserInformationFetchException.new(msg)
118
+ when 517
119
+ raise CSVHeaderRowMismatch.new(msg)
120
+ when 518
121
+ raise TranquilityTimeException.new(msg)
122
+ when 519
123
+ raise StarbaseDetailFetchFailure.new(msg)
124
+ when 520
125
+ raise EveDatabaseConnectionFailure.new(msg)
126
+ when 521
127
+ raise InvalidUsernameOrPassword.new(msg)
128
+ when 522
129
+ raise CharacterRetrevialFailure.new(msg)
130
+ when 523
131
+ raise CorporationRetrevialFailure.new(msg)
132
+ when 900
133
+ raise BetaAccessDenied.new(msg)
134
+ when 901
135
+ raise WebsiteOffline.new(msg)
136
+ when 902
137
+ raise EveDatabaseOffline.new(msg)
138
+ when 903
139
+ raise ObeyCacheTimers.new(msg)
140
+ when 999
141
+ raise UserForcedException.new(msg)
142
+ end
143
+ end
144
+
145
+ # All API-specific exceptions derrive from this. Useful for rescuing one
146
+ # parent exception to handle all API exceptions.
147
+ class ReveError < StandardError
148
+ end
149
+
150
+ # 100
151
+ class WalletNotPreviouslyLoaded < ReveError #:nodoc:
152
+ end
153
+ # 101, 103
154
+ class WalletExhausted < ReveError #:nodoc:
155
+ end
156
+ # 102
157
+ class WalletPreviouslyLoaded < ReveError #:nodoc:
158
+ end
159
+ # 104
160
+ class KeyNotFound < ReveError #:nodoc:
161
+ end
162
+ # 105
163
+ class InvalidCharacterID < ReveError #:nodoc:
164
+ end
165
+ # 106
166
+ class MustProvideUserIDParameterForAuthentication < ReveError #:nodoc:
167
+ end
168
+ # 107
169
+ class InvalidBeforeRefID < ReveError #:nodoc:
170
+ end
171
+ # 108
172
+ class InvalidAccountKey < ReveError #:nodoc:
173
+ end
174
+ # 109
175
+ class AccountKeyOutOfRange < ReveError #:nodoc:
176
+ end
177
+ # 110
178
+ class InvalidBeforeTransID < ReveError #:nodoc:
179
+ end
180
+ # 111
181
+ class InvalidInteger < ReveError #:nodoc:
182
+ end
183
+ # 112
184
+ class VersionMismatchException < ReveError #:nodoc:
185
+ end
186
+ # 113
187
+ class VersionEscalationException < ReveError #:nodoc:
188
+ end
189
+ # 114
190
+ class InvalidItemIDProvided < ReveError #:nodoc:
191
+ end
192
+ # 115
193
+ class AssetsAlreadyFetched < ReveError #:nodoc:
194
+ end
195
+ # 116
196
+ class IndustryJobsAlreadyFetched < ReveError #:nodoc:
197
+ end
198
+ # 117
199
+ class MarketOrdersAlreadyFetched < ReveError #:nodoc:
200
+ end
201
+ # 118
202
+ class ExpectedBeforeKillID < ReveError #:nodoc:
203
+ end
204
+ # 119
205
+ class KillsExhausted < ReveError #:nodoc:
206
+ end
207
+ # 120
208
+ class UnexpectedBeforeKillID < ReveError #:nodoc:
209
+ end
210
+ # 121
211
+ class BadBeforeKillID < ReveError #:nodoc:
212
+ end
213
+ # 200
214
+ class SecurityLevelNotHighEnough < ReveError #:nodoc:
215
+ end
216
+ # 201
217
+ class CharacterDoesNotBelongToAccount < ReveError #:nodoc:
218
+ end
219
+ # 202
220
+ class CachedAPIKeyAuthenticationFailure < ReveError #:nodoc:
221
+ end
222
+ # 203, 204, 205
223
+ class AuthenticationFailure < ReveError #:nodoc:
224
+ end
225
+ # 206
226
+ class MustHaveAccountantRole < ReveError #:nodoc:
227
+ end
228
+ # 207
229
+ class NotAvailableForNPCCorps < ReveError #:nodoc:
230
+ end
231
+ # 208
232
+ class MustHaveAccountantOrTraderRole < ReveError #:nodoc:
233
+ end
234
+ # 209
235
+ class MustBeDirectorOrCEO < ReveError #:nodoc:
236
+ end
237
+ # 210, 212
238
+ class AuthenticationFailure < ReveError #:nodoc:
239
+ end
240
+ # 211
241
+ class LoginDeniedByAccountStatus < ReveError #:nodoc:
242
+ end
243
+ # 213
244
+ class CharacterNeedsFactoryManagerRole < ReveError #:nodoc:
245
+ end
246
+ # 214
247
+ class CorporationNotInAlliance < ReveError #:nodoc:
248
+ end
249
+
250
+ # 500
251
+ class GetNameInvalid < ReveError #:nodoc:
252
+ end
253
+ # 501
254
+ class GetIDInvalid < ReveError #:nodoc:
255
+ end
256
+ # 502
257
+ class CachedUntilException < ReveError #:nodoc:
258
+ end
259
+ # 503
260
+ class InvalidInput < ReveError #:nodoc:
261
+ end
262
+ # 504
263
+ class InvalidRace < ReveError #:nodoc:
264
+ end
265
+ # 505
266
+ class InvalidGender < ReveError #:nodoc:
267
+ end
268
+ # 506
269
+ class InvalidBloodline < ReveError #:nodoc:
270
+ end
271
+ # 507
272
+ class InvalidAttribute < ReveError #:nodoc:
273
+ end
274
+ # 508
275
+ class InvalidRefType < ReveError #:nodoc:
276
+ end
277
+ # 509
278
+ class NullDataComponent < ReveError #:nodoc:
279
+ end
280
+ # 510
281
+ class NoCorporationException < ReveError #:nodoc:
282
+ end
283
+ # 511
284
+ class InvalidAccountKey < ReveError #:nodoc:
285
+ end
286
+ # 512
287
+ class InvalidCharID < ReveError #:nodoc:
288
+ end
289
+ # 513
290
+ class CorporateRoleFetchException < ReveError #:nodoc:
291
+ end
292
+ # 514
293
+ class InvalidCorpID < ReveError #:nodoc:
294
+ end
295
+ # 515
296
+ class InvalidUserIDOrAPIKey < ReveError #:nodoc:
297
+ end
298
+ # 516
299
+ class UserInformationFetchException < ReveError #:nodoc:
300
+ end
301
+ # 517
302
+ class CSVHeaderRowMismatch < ReveError #:nodoc:
303
+ end
304
+ # 518
305
+ class TranquilityTimeException < ReveError #:nodoc:
306
+ end
307
+ # 519
308
+ class StarbaseDetailFetchFailure < ReveError #:nodoc:
309
+ end
310
+ # 520
311
+ class EveDatabaseConnectionFailure < ReveError #:nodoc:
312
+ end
313
+ # 521
314
+ class InvalidUsernameOrPassword < ReveError #:nodoc:
315
+ end
316
+ # 522
317
+ class CharacterRetrevialFailure < ReveError #:nodoc:
318
+ end
319
+ # 523
320
+ class CorporationRetrevialFailure < ReveError #:nodoc:
321
+ end
322
+
323
+ # 900
324
+ class BetaAccessDenied < ReveError #:nodoc:
325
+ end
326
+ class WebsiteOffline < ReveError #:nodoc:
327
+ end
328
+ # 902
329
+ class EveDatabaseOffline < ReveError #:nodoc:
330
+ end
331
+ # 903 - Obey the %*(&!*@ timers!!!
332
+ class ObeyCacheTimers < ReveError #:nodoc:
333
+ end
334
+
335
+ # 999
336
+ class UserForcedException < ReveError #:nodoc:
337
+ end
338
+
339
+ # this is an Exception to do with the connection to the Eve server failing
340
+ class ReveNetworkStatusException < StandardError
341
+ end
342
+ end
343
+ end
@@ -0,0 +1,165 @@
1
+ require 'parsedate'
2
+
3
+ module Reve #:nodoc:
4
+ # All of these are shamelessly nicked from Ruby on Rails.
5
+ # The String Extensions have a bit more fault tolerance.
6
+ module Extensions
7
+
8
+ module NilClass
9
+ def to_s
10
+ self
11
+ end
12
+ def to_i
13
+ self
14
+ end
15
+ def to_f
16
+ self
17
+ end
18
+ def to_date
19
+ self
20
+ end
21
+ def to_time
22
+ self
23
+ end
24
+ end
25
+
26
+ module Hash
27
+ def stringify_keys
28
+ inject({}) do |h, (key,value)|
29
+ h[key.to_s] = value
30
+ h
31
+ end
32
+ end
33
+ def stringify_keys!
34
+ keys.each do |key|
35
+ unless key.class.to_s == "String" # See ActiveSupport for why this is needed!
36
+ self[key.to_s] = self[key]
37
+ delete(key)
38
+ end
39
+ end
40
+ self
41
+ end
42
+ end
43
+
44
+ # Rails's cattr_ things. activesupport/lib/active_support/core_ext/class
45
+ # Really quite handy.
46
+ module Class #:nodoc:
47
+ def cattr_reader(*syms) #:nodoc:
48
+ syms.flatten.each do |sym|
49
+ next if sym.is_a?(Hash)
50
+ class_eval(<<-EOS, __FILE__, __LINE__)
51
+ unless defined? @@#{sym}
52
+ @@#{sym} = nil
53
+ end
54
+
55
+ def self.#{sym}
56
+ @@#{sym}
57
+ end
58
+
59
+ def #{sym}
60
+ @@#{sym}
61
+ end
62
+ EOS
63
+ end
64
+ end
65
+
66
+ def cattr_writer(*syms) #:nodoc:
67
+ options = syms.last.is_a?(Hash) ? syms.pop : {}
68
+ syms.flatten.each do |sym|
69
+ class_eval(<<-EOS, __FILE__, __LINE__)
70
+ unless defined? @@#{sym}
71
+ @@#{sym} = nil
72
+ end
73
+
74
+ def self.#{sym}=(obj)
75
+ @@#{sym} = obj
76
+ end
77
+ #{"
78
+ def #{sym}=(obj)
79
+ @@#{sym} = obj
80
+ end
81
+ " unless options[:instance_writer] == false }
82
+ EOS
83
+ end
84
+ end
85
+ def cattr_accessor(*syms) #:nodoc:
86
+ cattr_reader(*syms)
87
+ cattr_writer(*syms)
88
+ end
89
+ end
90
+
91
+ module String
92
+ def to_time(form = :utc)
93
+ begin
94
+ ::Time.send(form, *ParseDate.parsedate(self))
95
+ rescue TypeError
96
+ self
97
+ end
98
+ end
99
+
100
+ # Try to make an Integer from a string. Will make sure that there's
101
+ # actually an integer there. "ponies".to_i will return "ponies" since it
102
+ # isn't an Integer. Yeah, probably not the best way but I do this with
103
+ # to_time and to_date. Deal with it - at least it doesn't raise an
104
+ # Exception.
105
+ def to_i
106
+ begin
107
+ Integer(self).to_s == self ? Integer(self) : self
108
+ rescue ArgumentError
109
+ self
110
+ end
111
+ end
112
+ def to_date
113
+ begin
114
+ ::Date.new(*ParseDate.parsedate(self)[0..2])
115
+ rescue TypeError,ArgumentError
116
+ self
117
+ end
118
+ end
119
+ end
120
+ module Time
121
+ def to_date
122
+ ::Date.new(year,month,day)
123
+ end
124
+ def to_time
125
+ self
126
+ end
127
+ end
128
+ module Date
129
+ def to_date
130
+ self
131
+ end
132
+ def to_time(form = :utc)
133
+ if respond_to?(:hour)
134
+ ::Time.send(form,year,month,day,hour,min,sec)
135
+ else
136
+ ::Time.send(form, year, month, day)
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
142
+
143
+ class String #:nodoc:
144
+ include Reve::Extensions::String
145
+ end
146
+
147
+ class Time #:nodoc:
148
+ include Reve::Extensions::Time
149
+ end
150
+
151
+ class Date #:nodoc:
152
+ include Reve::Extensions::Date
153
+ end
154
+
155
+ class Class #:nodoc:
156
+ include Reve::Extensions::Class
157
+ end
158
+
159
+ class Hash #:nodoc:
160
+ include Reve::Extensions::Hash
161
+ end
162
+
163
+ class NilClass #:nodoc:
164
+ include Reve::Extensions::NilClass
165
+ end
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: reve
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.74
6
+ version: 0.0.76
7
7
  date: 2008-02-02 00:00:00 +00:00
8
8
  summary: Reve is a Ruby library to interface with the Eve Online API
9
9
  require_paths:
@@ -30,6 +30,9 @@ authors:
30
30
  - Lisa Seelye
31
31
  files:
32
32
  - Rakefile
33
+ - lib/reve/classes.rb
34
+ - lib/reve/exceptions.rb
35
+ - lib/reve/extensions.rb
33
36
  - lib/reve.rb
34
37
  - reve.rb
35
38
  - tester.rb