reve 0.0.133 → 0.1.0

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/ChangeLog CHANGED
@@ -1,155 +1 @@
1
- Revision 61: 2008-01-13
2
- Please see http://revetrac.crudvision.com/log/trunk?action=stop_on_copy&rev=61&stop_rev=40&mode=stop_on_copy&verbose=on
3
- for ChangeLog
4
-
5
- Revision 41: 2007-12-19
6
- Add support for the nesting of Corporation under Alliance in
7
- Reve::API#alliances
8
- Added missing tests
9
-
10
- Revisions 31-37: December 2007
11
- Add support for version 2 API stuff.
12
-
13
- Revision 30: 2007-11-15
14
- Added initial support for the API version 2 CorporationSheet method.
15
-
16
- Revision 29: 2007-09-19
17
- Removed rolldocs.rake and just put the documentation building into the
18
- Rakefile. To build docs just use `rake doc`.
19
- Added some rescue statements the internal Reve::API#check_exception to try
20
- and handle problems when some things aren't found in the XML document.
21
-
22
- Revision 28: 2007-09-09
23
- Fixed typos that made the library, uh, not work.
24
-
25
- Revision 27: 2007-09-08 21:29:07 +0100 (Sat, 08 Sep 2007)
26
- Added preliminary support for the ConqurableStation API, see
27
- Reve::Clases::ConqurableStation class.
28
- Migrated subversion to a traditional trunk directory for my sanity. Expect
29
- future releases to also be in the tags directory.
30
-
31
- Revision 21: 2007-08-28 02:45 (Tue, 28 Augu 2007)
32
- Changed all methods to require a Hash of parameters. Please refer to the
33
- documentation <http://docs.crudvision.com/reve/> for new method signatures,
34
- especially Reve::API main documentation.
35
- Add a protected method 'compute_hash' which every other public method calls,
36
- using this new Hash parameter system, to construct a hash to represent the
37
- call uniquely. The result of this method should be suitable to store in a
38
- database so it can be used in conjunction with the cached_until variable.
39
- This hash is computed after each call and is available through the
40
- last_hash instance variable (like cached_until)
41
- Updated the test suite for these changes
42
-
43
- Revision 20: 2007-08-22 23:36:00 +0100 (Wed, 22 Aug 2007)
44
- Added this ChangeLog
45
-
46
- Revision 19: 2007-08-22 23:33:57 +0100 (Wed, 22 Aug 2007)
47
- docs in svn removed. Roll docs with rake -f rolldocs.rake doc
48
-
49
- Revision 18: 2007-08-21 09:19:16 +0100 (Tue, 21 Aug 2007)
50
- Add Reve::API.cached_until. Users of Reve PLEASE obey this setting! It will
51
- be set (overwritten) after each call and should be copied somewhere before
52
- another call is made.
53
- Change tester.rb to print the cached_until response for each test call.
54
- Change Reve::API#postfields to take a hash of post fields and change each
55
- Reve::API method accordingly.
56
-
57
- Revision 17: 2007-08-16 23:07:00 +0100 (Thu, 16 Aug 2007)
58
- RDoc update
59
-
60
- Revision 16: 2007-08-16 23:04:56 +0100 (Thu, 16 Aug 2007)
61
- Add preliminary support for Reve::API#starbases and Reve::API#starbase_fuel
62
- Modify Reve::API#postfields to allow for item_id for Reve::API#starbase_fuel
63
- Add Reve::Classes::Starbase and Reve::Classes::StarbaseFuel
64
- Add new exceptions: Reve::Exceptions::VersionMismatchException,
65
- Reve::Exceptions::InvalidItemIDProvided,
66
- Reve::Exceptions::MustBeDirectorOrCEO,
67
- Reve::Exceptions::StarbaseDetailFetchFailure,
68
- Reve::Exceptions::EveDatabaseConnectionFailure
69
-
70
- Revision 15: 2007-08-16 21:23:08 +0100 (Thu, 16 Aug 2007)
71
- Add Reve::Exceptions::VersionEscalationException
72
-
73
- Revision 14: 2007-08-15 21:58:20 +0100 (Wed, 15 Aug 2007)
74
- Fix badxml xml file to actually break it
75
- Fix class attributes in Reve::API (wallet transactions) to point to the right
76
- place
77
- Add a warning to Reve::Exceptions#raise_it for
78
- Reve::Exceptions::SecurityLevelNotHighEnough to warn the user that maybe
79
- they don't have the full API key
80
-
81
- Revision 13: 2007-08-14 22:36:50 +0100 (Tue, 14 Aug 2007)
82
- Global attempts to fix when to_time can be nil
83
- Add a check in Reve::Classes::WalletTransaction#new to check for the presence
84
- of character_id in the return data before trying to use it
85
-
86
- Revision 12: 2007-08-14 21:10:26 +0100 (Tue, 14 Aug 2007)
87
- Add a test for malformed XML input
88
- Subclass Reve::Classes::WalletTransaction for Personal and Corporate
89
- wallet transactions ('transactionFor' in the XML) as per
90
- http://myeve.eve-online.com/ingameboard.asp?a=topic&threadID=575626&page=1#1
91
- Removed characterID and characterName attributes frm WalletTransaction as
92
- per the above link
93
-
94
- Revision 11: 2007-08-10 22:13:46 +0100 (Fri, 10 Aug 2007)
95
- Add alliances test xml for test suite
96
-
97
- Revision 10: 2007-08-10 22:12:59 +0100 (Fri, 10 Aug 2007)
98
- Add a test suite
99
- Add Reve::Exceptions::WebsiteOffline
100
- Reve::Classes::WalletBalance.account_key now works
101
- Reve::Classes::CharacterSheet.skill_in_training is boolean (and now works)
102
- Reve::Classes::SkillTree.description now works
103
-
104
-
105
- Revision 9: 2007-08-07 07:22:42 +0100 (Tue, 07 Aug 2007)
106
- Add Reve::Exceptions::EveDatabaseOffline for when the Eve DB is offline
107
-
108
- Revision 8: 2007-08-01 22:30:57 +0100 (Wed, 01 Aug 2007)
109
- First tarball release
110
- Remove Curl dependency in favour of Ruby's built-in Net::HTTP
111
- Change Reve::API#postfields and Reve::API#process_query for Curl removal
112
- RDoc has inline source with line numbers
113
- Document existance of Reve::Classes::PrimaryAttribute,
114
- Reve::Classes::SecondaryAttribute, Reve::Classes::WillpowerEnhancer,
115
- Reve::Classes::IntelligenceEnhancer, Reve::Classes::MemoryEnhancer,
116
- Reve::Classes::PerceptionEnhancer, Reve::Classes::CharismaEnhancer
117
- Add Reve::Exceptions::ReveNetworkStatusException for when the network times
118
- out.
119
-
120
- Revision 7: 2007-08-01 19:28:52 +0100 (Wed, 01 Aug 2007)
121
- Finish the Reve::API#character_sheet method
122
- Add Reve::Classes::AttributeEnhancer (and IntelligenceEnhancer,
123
- MemoryEnhancer, PerceptionEnhancer, CharismaEnhancer and WillpowerEnhancer
124
- subclasses, for implants)
125
- Add enhancers (Array) attribute to Reve::Classes::CharacterSheet
126
- Add Reve::Extensions::String#to_i in an attempt to make an integer from a
127
- String when possible. See the docs for the method for details.
128
- Update RDoc
129
-
130
- Revision 6: 2007-08-01 08:04:33 +0100 (Wed, 01 Aug 2007)
131
- Remove some pretty print debug info.
132
-
133
- Revision 5: 2007-07-29 23:08:45 +0100 (Sun, 29 Jul 2007)
134
- Change Reve::Classes::Sovereignty to use nil (not 0) for alliance_id and
135
- faction_id where applicable.
136
-
137
- Revision 4: 2007-07-26 20:07:30 +0100 (Thu, 26 Jul 2007)
138
- Add Copyright notice
139
- More documentation with brief sample usage in the Reve::API class
140
- Change Reve::Extensions::String#to_date to use :utc instead of :local for
141
- conversions
142
-
143
- Revision 3: 2007-07-22 15:18:06 +0100 (Sun, 22 Jul 2007)
144
- Add better 'require reve' support ($:.unshift fun)
145
- Add Documentation (RDoc)
146
-
147
- Revision 2:2007-07-22 10:06:11 +0100 (Sun, 22 Jul 2007)
148
- Add sample "tester.rb"
149
- Add Reve::Classes::RequiredAttribute and Primary/Secondary subclass
150
- for skill_tree
151
- Change Reve::Classes::Alliance's attribute alliance_id to plain id
152
- Fix Reve::API.current_time assignment in Reve::API#check_exception
153
-
154
- Revision 1: 2007-07-22 02:02:33 +0100 (Sun, 22 Jul 2007)
155
- Initial Import
1
+ For a ChangeLog please refer to Github, https://github.com/lisa/reve/commits/master
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007, 2008 Lisa Seelye <lisa@thedoh.com>
1
+ Copyright (c) 2007 - 2010 Lisa Seelye <lisa@thedoh.com>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ Rake::RDocTask.new("doc") { |rdoc|
10
10
  rdoc.title = 'Reve API Documentation'
11
11
  rdoc.options << '--line-numbers' << '--inline-source' << '--all'
12
12
  rdoc.rdoc_files.include('./ChangeLog')
13
+ rdoc.rdoc_files.include('./README.rdoc')
13
14
  rdoc.rdoc_files.include('*.rb')
14
15
  rdoc.rdoc_files.include('lib/**/*.rb')
15
16
  rdoc.rdoc_files.include('test/**/*')
@@ -23,7 +24,7 @@ if File.exists?('.git')
23
24
  s.rubyforge_project = "reve"
24
25
  s.author = "Lisa Seelye"
25
26
  s.email = "lisa@thedoh.com"
26
- s.homepage = "http://github.com/lisa/reve"
27
+ s.homepage = "https://github.com/lisa/reve"
27
28
  s.platform = Gem::Platform::RUBY
28
29
  s.summary = "Reve is a Ruby library to interface with the Eve Online API"
29
30
  s.files = FileList["Rakefile","VERSION","LICENSE", "lib/**/*.rb","reve.rb","tester.rb","init.rb"].to_a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.133
1
+ 0.1.0
data/lib/reve/classes.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # The author is not adverse to tokens of appreciation in the form of Eve ISK,
7
7
  # ships, and feedback. Please use
8
8
  # http://www.crudvision.com/reve-ruby-eve-online-api-library/ to provide
9
- # feedback or send ISK to Raquel Smith in Eve. :-)
9
+ # feedback
10
10
  #++
11
11
  module Reve #:nodoc:
12
12
  module Classes #:nodoc:
@@ -176,6 +176,7 @@ module Reve #:nodoc:
176
176
  end
177
177
 
178
178
  class CorporateContact < PersonalContact; end
179
+ class AllianceContact < PersonalContact; end
179
180
 
180
181
  # The status of a System with regards to a FactionWar. Who controls what
181
182
  # and what System is contested
@@ -615,7 +616,7 @@ module Reve #:nodoc:
615
616
  class CharacterSheet
616
617
  attr_accessor :name, :race, :bloodline, :gender, :id, :corporation_name, :corporation_id, :balance
617
618
  attr_accessor :intelligence, :memory, :charisma, :perception, :willpower, :clone_name, :clone_skill_points
618
- attr_accessor :skills, :enhancers, :roles, :certificate_ids, :corporate_titles
619
+ attr_accessor :skills, :enhancers, :roles, :certificate_ids, :corporate_titles, :dob, :ancestry
619
620
  attr_accessor :corporationRolesAtHQ, :corporationRoles, :corporationRolesAtBase, :corporationRolesAtOther
620
621
  alias_method :corporate_roles_at_hq, :corporationRolesAtHQ
621
622
  alias_method :corporate_roles, :corporationRoles
@@ -1403,7 +1404,7 @@ module Reve #:nodoc:
1403
1404
  # * balance ( Float ) - New wallet balance after this action
1404
1405
  # * reason ( String ) - Any reason for the action. May be blank (useful in giving ISK)
1405
1406
  class WalletJournal
1406
- attr_reader :date, :ref_id, :reftype_id, :owner_name1, :owner_id1, :owner_name2, :owner_id2, :arg_name1, :arg_id1, :amount, :balance, :reason
1407
+ attr_reader :date, :ref_id, :reftype_id, :owner_name1, :owner_id1, :owner_name2, :owner_id2, :arg_name1, :arg_id1, :amount, :balance, :reason, :tax_amount, :tax_receiver_id
1407
1408
  alias_method :id, :ref_id
1408
1409
  def initialize(elem) #:nodoc:
1409
1410
  @date = elem['date'].to_time
@@ -1416,6 +1417,8 @@ module Reve #:nodoc:
1416
1417
  @arg_name1 = elem['argName1']
1417
1418
  @arg_id1 = elem['argID1'].to_i if elem['argID1']
1418
1419
  @amount = elem['amount'].to_f
1420
+ @tax_amount = elem['taxAmount'].to_f
1421
+ @tax_receiver_id = elem['taxReceiverID'].to_i if elem['taxReceiverID']
1419
1422
  @balance = elem['balance'].to_f
1420
1423
  @reason = elem['reason']
1421
1424
  end
@@ -1439,7 +1442,7 @@ module Reve #:nodoc:
1439
1442
  class WalletTransaction
1440
1443
  attr_reader :created_at, :id, :quantity, :type_name, :type_id, :price,
1441
1444
  :client_id, :client_name, :character_id, :station_id, :station_name, :type,
1442
- :transaction_for
1445
+ :transaction_for, :character_name
1443
1446
  def initialize(elem) #:nodoc:
1444
1447
  @created_at = elem['transactionDateTime'].to_time
1445
1448
  @id = elem['transactionID'].to_i
@@ -1449,6 +1452,7 @@ module Reve #:nodoc:
1449
1452
  @price = elem['price'].to_f
1450
1453
  @client_id = elem['clientID'].to_i if elem['clientID']
1451
1454
  @client_name = elem['clientName']
1455
+ @character_name = elem['characterName']
1452
1456
  @station_id = elem['stationID'].to_i
1453
1457
  @station_name = elem['stationName']
1454
1458
  @character_id = elem['characterID'].to_i if elem['characterID'] && elem['characterID'] != '0'
@@ -1566,14 +1570,16 @@ module Reve #:nodoc:
1566
1570
  # * last_known_location ( String ) -
1567
1571
  # * acount_balance ( Float )
1568
1572
  class CharacterInfo
1569
- attr_reader :id, :name, :race, :bloodline, :corporation_id, :corporation_name, :corporation_date, :alliance_id, :alliance_name, :alliance_date
1573
+ attr_reader :id, :name, :race, :bloodline, :corporation_id, :corporation_name, :corporation_date, :alliance_id, :alliance_name, :alliance_date, :dob, :ancestry
1570
1574
  attr_reader :security_status, :skillpoints, :skill_training_ends, :ship_name, :ship_type_id, :ship_type_name, :last_known_location, :acount_balance
1571
1575
 
1572
1576
  def initialize(elem) #:nodoc:
1573
1577
  @id = (elem/'characterID').inner_html.to_i
1574
1578
  @name = (elem/'characterName').inner_html
1579
+ @dob = (elem/'DoB').inner_html
1575
1580
  @race = (elem/'race').inner_html
1576
1581
  @bloodline = (elem/'bloodline').inner_html
1582
+ @ancestry = (elem/'ancestry').inner_html
1577
1583
  @corporation_id = (elem/'corporationID').inner_html.to_i
1578
1584
  @corporation_name = (elem/'corporation').inner_html
1579
1585
  @corporation_date = Time.parse((elem/'corporationDate').inner_html)
@@ -6,7 +6,7 @@
6
6
  # The author is not adverse to tokens of appreciation in the form of Eve ISK,
7
7
  # ships, and feedback. Please use
8
8
  # http://www.crudvision.com/reve-ruby-eve-online-api-library/ to provide
9
- # feedback or send ISK to Raquel Smith in Eve. :-)
9
+ # feedback
10
10
  #++
11
11
  module Reve
12
12
  # Exceptions live here.
data/lib/reve.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  # Contributors at: http://github.com/lisa/reve/contributors
4
4
  # This library is licensed under the terms of the MIT license. For full text
5
5
  # see the LICENSE file distributed with this package.
6
- # (Also, send Raquel Smith some ISK if you would like to show appreciation ;-)
7
6
  #++
8
7
 
9
8
  begin
@@ -29,7 +28,7 @@ require 'reve/classes'
29
28
  module Reve
30
29
  # API Class.
31
30
  # Basic Usage:
32
- # api = Reve::API.new('my_UserID', 'my_apiKey')
31
+ # api = Reve::API.new('my_keyID', 'my_vCode')
33
32
  # alliances = api.alliances # Returns an array of Reve::Classes::Alliance
34
33
  #
35
34
  # api.personal_wallet_blanace(:characterid => 892008733) # Returns an array of
@@ -78,8 +77,8 @@ module Reve
78
77
  @@corporate_assets_url = 'http://api.eve-online.com/corp/AssetList.xml.aspx'
79
78
  @@personal_kills_url = 'http://api.eve-online.com/char/KillLog.xml.aspx'
80
79
  @@corporate_kills_url = 'http://api.eve-online.com/corp/KillLog.xml.aspx'
81
- @@character_id_url = 'http://api.eve-online.com/eve/CharacterID.xml.aspx' # ?names=CCP%20Garthagk,Raquel%20Smith
82
- @@character_name_url = 'http://api.eve-online.com/eve/CharacterName.xml.aspx' # ?ids=797400947,892008733
80
+ @@character_id_url = 'http://api.eve-online.com/eve/CharacterID.xml.aspx' # ?names=CCP%20Garthagk
81
+ @@character_name_url = 'http://api.eve-online.com/eve/CharacterName.xml.aspx' # ?ids=797400947
83
82
  @@personal_faction_war_stats_url= 'http://api.eve-online.com/char/FacWarStats.xml.aspx'
84
83
  @@corporate_faction_war_stats_url= 'http://api.eve-online.com/corp/FacWarStats.xml.aspx'
85
84
  @@general_faction_war_stats_url= 'http://api.eve-online.com/eve/FacWarStats.xml.aspx'
@@ -116,22 +115,28 @@ module Reve
116
115
  :account_status_url, :character_info_url
117
116
 
118
117
 
119
- attr_accessor :key, :userid, :charid
118
+ attr_accessor :key, :keyid, :cak, :charid
119
+ alias :userid :keyid
120
+ alias :userid= :keyid=
120
121
  attr_accessor :http_user_agent, :save_path, :timeout
121
122
  attr_reader :current_time, :cached_until, :last_hash, :reve_version
122
123
 
123
124
  # Create a new API instance.
124
125
  # current_time and cached_until are meaningful only for the LAST call made.
125
126
  # Expects:
126
- # * userid ( Integer | String ) - Your API userID
127
- # * key ( String ) - Your API key (Full key or restricted key)
127
+ # * keyid ( Integer | String ) - Your Key ID (or legacy key UserID)
128
+ # * key ( String ) - Your API key verification code (or legacy API Key)
128
129
  # * charid ( Integer | String ) - Default characterID for calls requiring it.
130
+ #
131
+ # If you are using legacy key ids, you must explicitly set the
132
+ # cak attribute on the returned API instance to false.
133
+ #
129
134
  # NOTE: All values passed to the constructor are typecasted to a String for safety.
130
- def initialize(userid = "", key = "", charid = "")
131
- @userid = (userid || "").to_s
135
+ def initialize(keyid = "", key = "", charid = "")
136
+ @keyid = (keyid || "").to_s
132
137
  @key = (key || "").to_s
133
138
  @charid = (charid || "").to_s
134
-
139
+ @cak = true
135
140
  @save_path = nil
136
141
 
137
142
  @max_tries = 3
@@ -144,7 +149,7 @@ module Reve
144
149
  @http_user_agent = "Reve v#{@reve_version}; http://github.com/lisa/reve"
145
150
  end
146
151
  # Save XML to this directory with the format:
147
- # :save_path/:userid/:method/:expires_at_in_unixtime.xml
152
+ # :save_path/:keyid/:method/:expires_at_in_unixtime.xml
148
153
  # eg: ./xml/12345/characters/1200228878.xml
149
154
  # or: ./xml/alliances/1200228878.xml
150
155
  # If @save_path is nil then XML is not saved.
@@ -314,7 +319,15 @@ module Reve
314
319
  args = postfields(opts)
315
320
  h = compute_hash(args.merge(:url => @@corporate_contacts_url))
316
321
  return h if h
317
- process_query(Reve::Classes::PersonalContact, opts[:url] || @@corporate_contacts_url,false,args)
322
+ xml = process_query(nil, opts[:url] || @@corporate_contacts_url,true,args)
323
+ contacts = []
324
+ xml.search("/eveapi/result/rowset[@name='corporateContactList']/row").each do |corporate|
325
+ contacts << Reve::Classes::CorporateContact.new(corporate)
326
+ end
327
+ xml.search("/eveapi/result/rowset[@name='allianceContactList']/row").each do |alliance|
328
+ contacts << Reve::Classes::AllianceContact.new(alliance)
329
+ end
330
+ contacts
318
331
  end
319
332
 
320
333
  # Returns the SkillTree from
@@ -607,15 +620,7 @@ module Reve
607
620
  h = compute_hash(args.merge(:url => @@personal_assets_url))
608
621
  return h if h
609
622
  xml = process_query(nil,opts[:url] || @@personal_assets_url,true,args)
610
- assets = []
611
- xml.search("/eveapi/result/rowset[@name='assets']/row").each do |container|
612
- asset_container = Reve::Classes::AssetContainer.new(container)
613
- container.search("rowset[@name='contents']/row").each do |asset|
614
- asset_container.assets << Reve::Classes::Asset.new(asset)
615
- end
616
- assets << asset_container
617
- end
618
- assets
623
+ self.recur_through_assets(xml.search("/eveapi/result/rowset[@name='assets']/row"))
619
624
  end
620
625
 
621
626
  # Get a list of the Corporate Assets. Pass the characterid of the Corporate member See also assets_list method
@@ -624,18 +629,10 @@ module Reve
624
629
  h = compute_hash(args.merge(:url => @@corporate_assets_url))
625
630
  return h if h
626
631
  xml = process_query(nil,opts[:url] || @@corporate_assets_url,true,args)
627
- assets = []
628
- xml.search("/eveapi/result/rowset/row").each do |container|
629
- asset_container = Reve::Classes::AssetContainer.new(container)
630
- container.search("rowset[@name='contents']/row").each do |asset|
631
- asset_container.assets << Reve::Classes::Asset.new(asset)
632
- end
633
- assets << asset_container
634
- end
635
- assets
632
+ self.recur_through_assets(xml.search("/eveapi/result/rowset[@name='assets']/row"))
636
633
  end
637
634
 
638
- # Returns a Character list for the associated key and userid from
635
+ # Returns a Character list for the associated key from
639
636
  # http://api.eve-online.com/account/Characters.xml.aspx
640
637
  # See also: Reve::Classes::Character
641
638
  def characters(opts = {})
@@ -828,7 +825,7 @@ module Reve
828
825
  xml = process_query(nil,opts[:url] || @@corporation_member_security_url,true,args)
829
826
 
830
827
  cmc = Reve::Classes::CorporationMemberSecurity.new
831
- xml.search("/eveapi/result/member").each do |member|
828
+ xml.search("/eveapi/result/rowset[@name=members]/row").each do |member|
832
829
  mem = Reve::Classes::CorporationMember.new(member)
833
830
  cmc.members << mem
834
831
  [:roles, :grantableRoles, :rolesAtHQ, :grantableRolesAtHQ, :rolesAtBase, :grantableRolesAtBase, :rolesAtOther, :grantableRolesAtOther].each do |rowset|
@@ -897,7 +894,7 @@ module Reve
897
894
  cs.enhancers << i
898
895
  end
899
896
 
900
- [ 'characterID', 'name', 'race', 'bloodLine', 'gender','corporationName',
897
+ [ 'characterID', 'name', 'race', 'bloodLine', 'ancestry', 'dob', 'gender','corporationName',
901
898
  'corporationID','balance', 'cloneName', 'cloneSkillPoints'
902
899
  ].each do |field|
903
900
  cs.send("#{field.downcase}=",xml.search("/eveapi/result/#{field}/").first.to_s)
@@ -983,12 +980,40 @@ module Reve
983
980
  end
984
981
 
985
982
  protected
983
+ # Helper method to handle nested assets
984
+ def recur_through_assets(rows)
985
+ assets = []
986
+ rows.each do |container|
987
+ unless container.empty?
988
+ asset_container = Reve::Classes::AssetContainer.new(container)
989
+ asset_container.assets = self.recur_through_assets(container.search("/rowset/row"))
990
+ assets << asset_container
991
+ else
992
+ assets << Reve::Classes::Asset.new(container)
993
+ end
994
+ end
995
+ assets
996
+ end
997
+
986
998
  # Sets up the post fields for Net::HTTP::Get hash for process_query method.
987
999
  # See also format_url_request
988
1000
  # TODO: Consider moving this whole thing into process_query to avoid
989
1001
  # calling this in every method!
990
1002
  def postfields(opts = {})
991
- ret = { "userid" => @userid, "apikey" => @key, "characterid" => @charid }.merge(opts.stringify_keys)
1003
+ baseargs = { :characterid => @charid }
1004
+ if @cak
1005
+ baseargs[:keyid] = @keyid
1006
+ baseargs[:vcode] = @key
1007
+ else
1008
+ baseargs[:userid] = @keyid
1009
+ baseargs[:apikey] = @key
1010
+ end
1011
+ ret = opts.clone
1012
+ baseargs.each do |k,v|
1013
+ if ret[k].nil?
1014
+ ret[k] = v
1015
+ end
1016
+ end
992
1017
  ret.inject({}) do |n, (k,v)|
993
1018
  n[k.downcase] = v.to_s if v
994
1019
  n
@@ -1033,7 +1058,8 @@ module Reve
1033
1058
  #return h if h
1034
1059
 
1035
1060
  @last_hash = compute_hash(opts.merge({:url => url, :just_hash => true })) # compute hash
1036
-
1061
+
1062
+
1037
1063
  xml = check_exception(get_xml(url,opts))
1038
1064
  save_xml(xml) if @save_path
1039
1065
 
@@ -1060,7 +1086,7 @@ module Reve
1060
1086
  # Gets the XML from a source.
1061
1087
  # Expects:
1062
1088
  # * source ( String | URI ) - If the +source+ is a String Reve will attempt to load the XML file from the local filesystem by the path specified as +source+. If the +source+ is a URI or is a String starting with http (lowercase) Reve will fetch it from that URI on the web.
1063
- # * opts ( Hash ) - Hash of parameters for the request, such as userid, apikey and such.
1089
+ # * opts ( Hash ) - Hash of parameters for the request, such as keyid, vcode and such.
1064
1090
  # NOTE: To override the lowercase http -> URI rule make the HTTP part uppercase.
1065
1091
  def get_xml(source,opts)
1066
1092
  xml = ""
@@ -1134,7 +1160,7 @@ module Reve
1134
1160
  end
1135
1161
  def build_save_filename
1136
1162
  method = caller(3).first.match(/\`(.+)'/)[1] # Get the API method that's being called. This is called from save_xml -> process_query -> :real_method
1137
- File.join(@save_path,@userid.to_s,method,( @cached_until || Time.now.utc).to_i.to_s + '.xml')
1163
+ File.join(@save_path,@keyid.to_s,method,( @cached_until || Time.now.utc).to_i.to_s + '.xml')
1138
1164
  end
1139
1165
 
1140
1166
  # Returns an array of +klass+
data/test/test_reve.rb CHANGED
@@ -306,13 +306,20 @@ class TestReve < Test::Unit::TestCase
306
306
  end
307
307
 
308
308
  def test_corporate_contacts_clean
309
- Reve::API.corporate_contacts_url = XML_BASE + 'char_contacts.xml'
309
+ Reve::API.corporate_contacts_url = XML_BASE + 'corp_contact.xml'
310
310
  contacts = @api.corporate_contacts
311
311
  assert_equal(2, contacts.length)
312
- assert_equal("Hirento Raikkanen", contacts.first.contact_name )
313
- assert_equal(3010913, contacts.first.contact_id )
312
+ assert_equal("CCP Garthagk", contacts.first.contact_name )
313
+ assert_equal(797400947, contacts.first.contact_id )
314
314
  assert_equal(false, contacts.first.in_watchlist )
315
- assert_equal(0, contacts.first.standing )
315
+ assert_equal(-10, contacts.first.standing )
316
+ assert_equal(Reve::Classes::CorporateContact, contacts.first.class )
317
+
318
+ assert_equal("CCP Garthagk", contacts.last.contact_name )
319
+ assert_equal(797400947, contacts.last.contact_id )
320
+ assert_equal(false, contacts.last.in_watchlist )
321
+ assert_equal(5, contacts.last.standing )
322
+ assert_equal(Reve::Classes::AllianceContact, contacts.last.class )
316
323
  end
317
324
 
318
325
  def test_faction_war_system_stats_clean(skip_preamble = false,stats = nil)
@@ -467,21 +474,22 @@ class TestReve < Test::Unit::TestCase
467
474
  assert_nothing_raised do
468
475
  assets = @api.personal_assets_list
469
476
  end
470
- assert_equal 18, assets.size # 18 single and 1 container
471
- contained_assets = assets.inject([]) { |ass,container| ass << container.assets }.flatten
477
+ assert_equal 19, assets.size # 18 single and 1 container
478
+ contained_assets = assets.select { |ass| ass.instance_of? Reve::Classes::AssetContainer}
479
+
472
480
  assert_equal(1, contained_assets.size) # We have a container it happens to have 1 asset in it
473
481
  contained_assets.each do |asset|
474
- assert_instance_of(Reve::Classes::Asset, asset)
482
+ assert_instance_of(Reve::Classes::AssetContainer, asset)
475
483
  assert_not_nil(asset.item_id)
484
+ assert_not_nil(asset.location_id)
476
485
  assert_not_nil(asset.type_id)
477
486
  assert_not_nil(asset.quantity)
478
487
  assert_not_nil(asset.flag)
479
488
  assert_not_nil(asset.singleton)
480
489
  end
481
- assets.each do |asset|
482
- assert_instance_of(Reve::Classes::AssetContainer, asset)
490
+ assets.select { |ass| ass.instance_of? Reve::Classes::Asset}.each do |asset|
491
+ assert_instance_of(Reve::Classes::Asset, asset)
483
492
  assert_not_nil(asset.item_id)
484
- assert_not_nil(asset.location_id)
485
493
  assert_not_nil(asset.type_id)
486
494
  assert_not_nil(asset.quantity)
487
495
  assert_not_nil(asset.flag)
@@ -695,7 +703,7 @@ class TestReve < Test::Unit::TestCase
695
703
  trans.each do |tran|
696
704
  [ :created_at, :id, :quantity, :type_name, :type_id, :price,
697
705
  :client_id, :client_name, :character_id, :station_id, :station_name, :type,
698
- :transaction_for ].each do |attr|
706
+ :transaction_for, :character_name ].each do |attr|
699
707
  assert_not_nil(tran.send(attr))
700
708
  end
701
709
  assert_instance_of(Time, tran.created_at)
@@ -724,15 +732,15 @@ class TestReve < Test::Unit::TestCase
724
732
  assert_nothing_raised do
725
733
  journal = @api.corporate_wallet_journal :url => File.join(XML_BASE,'corporate_wallet_journal.xml')
726
734
  end
727
- assert_equal 2, journal.size
735
+ assert_equal 3, journal.size
728
736
  assert journal.all? { |j| j.kind_of?(Reve::Classes::WalletJournal) }
729
737
  journal.each do |j|
730
- [ :date, :ref_id, :reftype_id, :owner_name1, :owner_name2, :arg_name1, :amount, :balance, :reason ].each do |attr|
738
+ [ :date, :ref_id, :reftype_id, :owner_name1, :owner_name2, :arg_name1, :amount, :balance, :reason , :tax_amount, :tax_receiver_id].each do |attr|
731
739
  assert_not_nil(j.send(attr))
732
740
  end
733
741
  end
734
742
  end
735
-
743
+
736
744
  def test_corporate_assets_list_clean
737
745
  assets = nil
738
746
  assert_nothing_raised do
@@ -741,7 +749,30 @@ class TestReve < Test::Unit::TestCase
741
749
  assert_equal 2, assets.size
742
750
  assert assets.all? { |a| a.kind_of?(Reve::Classes::AssetContainer) }
743
751
  end
744
-
752
+
753
+ def test_corporate_assets_list_nesting_clean
754
+ assets = nil
755
+ assert_nothing_raised do
756
+ assets = @api.corporate_assets_list :url => File.join(XML_BASE,'corporate_assets_list_nesting.xml')
757
+ end
758
+
759
+ assert_equal 3, assets.size
760
+ assert assets[0].kind_of?(Reve::Classes::Asset)
761
+ assert assets[1].kind_of?(Reve::Classes::AssetContainer)
762
+ assert assets[2].kind_of?(Reve::Classes::Asset)
763
+
764
+ first_container = assets[1]
765
+ assert_equal 2, first_container.type_id
766
+ assert_equal 2, first_container.assets.size
767
+
768
+ second_container = first_container.assets[0]
769
+ assert_equal 3, second_container.type_id
770
+ assert_equal 1, second_container.assets.size
771
+ assert second_container.assets[0].kind_of?(Reve::Classes::Asset)
772
+
773
+ nested_item = second_container.assets[0]
774
+ assert_equal 640, nested_item.type_id
775
+ end
745
776
  def test_map_jumps_clean
746
777
  Reve::API.map_jumps_url = XML_BASE + 'mapjumps.xml'
747
778
  mapjumps = nil
@@ -1100,6 +1131,8 @@ class TestReve < Test::Unit::TestCase
1100
1131
 
1101
1132
  assert_not_nil sheet.name
1102
1133
  assert_not_nil sheet.race
1134
+ assert_not_nil sheet.ancestry
1135
+ assert_not_nil sheet.dob
1103
1136
  assert_not_nil sheet.bloodline
1104
1137
  assert_not_nil sheet.gender
1105
1138
  assert_not_nil sheet.id
data/test/xml/assets.xml CHANGED
@@ -3,30 +3,30 @@
3
3
  <currentTime>2007-12-18 18:27:27</currentTime>
4
4
  <result>
5
5
  <rowset columns="itemID,locationID,typeID,quantity,flag,singleton" name="assets" key="itemID">
6
- <row typeid="222" itemid="427545405" singleton="0" quantity="100" flag="4" locationid="60004390">
7
- <row typeid="649" itemid="543447240" singleton="1" quantity="1" flag="4" locationid="60003913">
6
+ <row typeID="222" itemID="427545405" singleton="0" quantity="100" flag="4" locationID="60004390" />
7
+ <row typeID="649" itemID="543447240" singleton="1" quantity="1" flag="4" locationID="60003913">
8
8
  <rowset columns="itemID,typeID,quantity,flag,singleton" name="contents" key="itemID">
9
- <row typeid="11489" itemid="782544272" singleton="1" quantity="1" flag="5">
10
- </row></rowset>
9
+ <row typeID="11489" itemID="782544272" singleton="1" quantity="1" flag="5" />
10
+ </rowset>
11
11
  </row>
12
- </row><row typeid="222" itemid="550639494" singleton="0" quantity="100" flag="4" locationid="60004384">
13
- </row><row typeid="7447" itemid="591233762" singleton="0" quantity="1" flag="4" locationid="60003865">
14
- </row><row typeid="9668" itemid="591233776" singleton="0" quantity="1" flag="4" locationid="60003865">
15
- </row><row typeid="7409" itemid="591233791" singleton="0" quantity="1" flag="4" locationid="60003865">
16
- </row><row typeid="5441" itemid="591233797" singleton="0" quantity="1" flag="4" locationid="60003865">
17
- </row><row typeid="14280" itemid="591233811" singleton="0" quantity="1" flag="4" locationid="60003865">
18
- </row><row typeid="14358" itemid="591233816" singleton="0" quantity="50" flag="4" locationid="60003865">
19
- </row><row typeid="215" itemid="627545204" singleton="0" quantity="1" flag="4" locationid="60002296">
20
- </row><row typeid="530" itemid="673815728" singleton="0" quantity="3" flag="4" locationid="60003865">
21
- </row><row typeid="444" itemid="673815903" singleton="0" quantity="1" flag="4" locationid="60003865">
22
- </row><row typeid="533" itemid="681785163" singleton="0" quantity="1" flag="4" locationid="60003865">
23
- </row><row typeid="11740" itemid="781256936" singleton="0" quantity="1" flag="4" locationid="60003865">
24
- </row><row typeid="11489" itemid="782544130" singleton="1" quantity="1" flag="4" locationid="60003865">
25
- </row><row typeid="51" itemid="1125520018" singleton="1" quantity="1" flag="4" locationid="60014545">
26
- </row><row typeid="602" itemid="1943266444" singleton="0" quantity="1" flag="4" locationid="60003865">
27
- </row><row typeid="12865" itemid="1812312532" singleton="0" quantity="18" flag="4" locationid="60003865">
28
- </row><row typeid="25373" itemid="1711554909" singleton="0" quantity="30" flag="4" locationid="60003865">
29
- </row></rowset>
12
+ <row typeID="222" itemID="550639494" singleton="0" quantity="100" flag="4" locationID="60004384" />
13
+ <row typeID="7447" itemID="591233762" singleton="0" quantity="1" flag="4" locationID="60003865" />
14
+ <row typeID="9668" itemID="591233776" singleton="0" quantity="1" flag="4" locationID="60003865" />
15
+ <row typeID="7409" itemID="591233791" singleton="0" quantity="1" flag="4" locationID="60003865" />
16
+ <row typeID="5441" itemID="591233797" singleton="0" quantity="1" flag="4" locationID="60003865" />
17
+ <row typeID="14280" itemID="591233811" singleton="0" quantity="1" flag="4" locationID="60003865" />
18
+ <row typeID="14358" itemID="591233816" singleton="0" quantity="50" flag="4" locationID="60003865" />
19
+ <row typeID="215" itemID="627545204" singleton="0" quantity="1" flag="4" locationID="60002296" />
20
+ <row typeID="530" itemID="673815728" singleton="0" quantity="3" flag="4" locationID="60003865" />
21
+ <row typeID="444" itemID="673815903" singleton="0" quantity="1" flag="4" locationID="60003865" />
22
+ <row typeID="533" itemID="681785163" singleton="0" quantity="1" flag="4" locationID="60003865" />
23
+ <row typeID="11740" itemID="781256936" singleton="0" quantity="1" flag="4" locationID="60003865" />
24
+ <row typeID="11489" itemID="782544130" singleton="1" quantity="1" flag="4" locationID="60003865" />
25
+ <row typeID="51" itemID="1125520018" singleton="1" quantity="1" flag="4" locationID="60014545" />
26
+ <row typeID="602" itemID="1943266444" singleton="0" quantity="1" flag="4" locationID="60003865" />
27
+ <row typeID="12865" itemID="1812312532" singleton="0" quantity="18" flag="4" locationID="60003865" />
28
+ <row typeID="25373" itemID="1711554909" singleton="0" quantity="30" flag="4" locationID="60003865" />
29
+ </rowset>
30
30
  </result>
31
31
  <cacheduntil>2007-12-19 17:27:27</cacheduntil>
32
32
  </eveapi>
@@ -4,8 +4,10 @@
4
4
  <result>
5
5
  <characterID>892008733</characterID>
6
6
  <name>Raquel Smith</name>
7
+ <DoB>2009-04-20 00:30:00</DoB>
7
8
  <race>Caldari</race>
8
- <bloodLine>Civire</bloodLine>
9
+ <bloodLine>Civire</bloodLine>
10
+ <ancestry>Scientists</ancestry>
9
11
  <gender>Female</gender>
10
12
  <corporationName>Freedom-Technologies</corporationName>
11
13
  <corporationID>1668136112</corporationID>
@@ -0,0 +1,12 @@
1
+ <eveapi version="2">
2
+ <currentTime>2010-05-29 22:35:46</currentTime>
3
+ <result>
4
+ <rowset name="corporateContactList" key="contactID" columns="contactID,contactName,standing">
5
+ <row contactID="797400947" contactName="CCP Garthagk" standing="-10" />
6
+ </rowset>
7
+ <rowset name="allianceContactList" key="contactID" columns="contactID,contactName,standing">
8
+ <row contactID="797400947" contactName="CCP Garthagk" standing="5" />
9
+ </rowset>
10
+ </result>
11
+ <cachedUntil>2010-05-29 22:50:46</cachedUntil>
12
+ </eveapi>
File without changes
@@ -0,0 +1,22 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2011-02-20 19:24:54</currentTime>
4
+ <result>
5
+ <rowset name="assets" key="itemID" columns="itemID,locationID,typeID,quantity,flag,singleton">
6
+ <row itemID="1000986294535" typeID="1" quantity="2" flag="64" singleton="0" />
7
+
8
+ <row itemID="144702314" locationID="66006338" typeID="2" quantity="1" flag="85" singleton="1">
9
+ <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
10
+ <row itemID="1000993385751" typeID="3" quantity="1" flag="119" singleton="1">
11
+ <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
12
+ <row itemID="1000986294535" typeID="640" quantity="1" flag="64" singleton="0" />
13
+ </rowset>
14
+ </row>
15
+ <row itemID="1000986294535" typeID="4" quantity="1" flag="64" singleton="0" />
16
+ </rowset>
17
+ </row>
18
+ <row itemID="1000986294535" typeID="5" quantity="1" flag="64" singleton="0" />
19
+ </rowset>
20
+ </result>
21
+ <cachedUntil>2011-02-20 23:08:04</cachedUntil>
22
+ </eveapi>
@@ -3,8 +3,9 @@
3
3
  <currentTime>2008-02-03 14:51:03</currentTime>
4
4
  <result>
5
5
  <rowset columns="date,refID,refTypeID,ownerName1,ownerID1,ownerName2,ownerID2,argName1,argID1,amount,balance,reason" name="entries" key="refID">
6
- <row date="2008-02-03 14:47:00" argID1="1" argName1="EVE System" amount="-100.00" ownerID1="892804655" refID="922128913" ownerName1="Liquidator Brunt" refTypeID="46" ownerID2="1000035" reason="" ownerName2="Caldari Navy" balance="18004409.84">
7
- </row><row date="2008-02-03 14:47:00" argID1="0" argName1="" amount="-270.00" ownerID1="892804655" refID="922126594" ownerName1="Liquidator Brunt" refTypeID="42" ownerID2="0" reason="" ownerName2="" balance="18004509.84">
6
+ <row date="2008-08-20 13:10:00" refID="1575178032" refTypeID="85" ownerName1="CONCORD" ownerID1="1000125" ownerName2="anonymous" ownerID2="173993711" argName1="Jita" argID1="30001660" amount="135000.00" balance="609292267.52" reason="29200:15," taxReceiverID="1734917694" taxAmount="15000.00">
7
+ </row><row date="2008-08-20 13:10:00" refID="1575178032" refTypeID="85" ownerName1="CONCORD" ownerID1="1000125" ownerName2="anonymous" ownerID2="173993711" argName1="Jita" argID1="30001660" amount="135000.00" balance="609292267.52" reason="29200:15," taxReceiverID="1734917694" taxAmount="15000.00">
8
+ </row><row date="2008-08-20 13:10:00" refID="1575178032" refTypeID="85" ownerName1="CONCORD" ownerID1="1000125" ownerName2="anonymous" ownerID2="173993711" argName1="Jita" argID1="30001660" amount="135000.00" balance="609292267.52" reason="29200:15," taxReceiverID="1734917694" taxAmount="15000.00">
8
9
  </row></rowset>
9
10
  </result>
10
11
  <cacheduntil>2008-02-03 15:51:03</cacheduntil>
data/tester.rb CHANGED
@@ -4,8 +4,8 @@ require 'reve'
4
4
  # Create an instance of the API
5
5
  api = Reve::API.new
6
6
 
7
- fids = [ 797400947,892008733 ] # converting from these IDs
8
- fnames = [ 'CCP Garthagk', 'Raquel Smith' ] # converting from these names
7
+ fids = [ 797400947 ] # converting from these IDs
8
+ fnames = [ 'CCP Garthagk' ] # converting from these names
9
9
 
10
10
  ids = api.character_name({ :ids => fids })
11
11
  names = api.character_id({ :names => fnames })
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 133
9
- version: 0.0.133
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lisa Seelye
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-03 00:00:00 -04:00
17
+ date: 2012-02-05 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -51,7 +51,7 @@ files:
51
51
  - tester.rb
52
52
  - ChangeLog
53
53
  has_rdoc: true
54
- homepage: http://github.com/lisa/reve
54
+ homepage: https://github.com/lisa/reve
55
55
  licenses: []
56
56
 
57
57
  post_install_message:
@@ -98,11 +98,13 @@ test_files:
98
98
  - test/xml/charactername.xml
99
99
  - test/xml/characters.xml
100
100
  - test/xml/conqurable_stations.xml
101
+ - test/xml/corp_contact.xml
101
102
  - test/xml/corp_facwarstats.xml
102
103
  - test/xml/corp_medals.xml
103
104
  - test/xml/corp_member_medals.xml
104
105
  - test/xml/corp_membersecurity.xml
105
106
  - test/xml/corporate_assets_list.xml
107
+ - test/xml/corporate_assets_list_nesting.xml
106
108
  - test/xml/corporate_market_orders.xml
107
109
  - test/xml/corporate_wallet_balance.xml
108
110
  - test/xml/corporate_wallet_journal.xml