reve 0.0.132 → 0.0.133

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.132
1
+ 0.0.133
data/lib/reve.rb CHANGED
@@ -17,6 +17,7 @@ require 'uri'
17
17
  require 'cgi'
18
18
  require 'digest'
19
19
  require 'fileutils'
20
+ require 'time'
20
21
 
21
22
  $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
22
23
 
@@ -90,9 +91,13 @@ module Reve
90
91
  @@corp_member_medals_url = 'http://api.eve-online.com/corp/MemberMedals.xml.aspx'
91
92
  @@server_status_url = 'http://api.eve-online.com/Server/ServerStatus.xml.aspx'
92
93
  @@research_url = 'http://api.eve-online.com/char/Research.xml.aspx'
93
- @@personal_notification_url = 'http://api.eve-online.com/char/Notifications.xml.aspx'
94
- @@personal_mailing_lists_url = 'http://api.eve-online.com/char/mailinglists.xml.aspx'
95
- @@personal_mail_messages_url = 'http://api.eve-online.com/char/MailMessages.xml.aspx'
94
+ @@personal_notification_url = 'http://api.eve-online.com/char/Notifications.xml.aspx'
95
+ @@personal_mailing_lists_url = 'http://api.eve-online.com/char/mailinglists.xml.aspx'
96
+ @@personal_mail_messages_url = 'http://api.eve-online.com/char/MailMessages.xml.aspx'
97
+ @@personal_contacts_url = 'http://api.eve-online.com/char/ContactList.xml.aspx'
98
+ @@corporate_contacts_url = 'http://api.eve-online.com/corp/ContactList.xml.aspx'
99
+ @@account_status_url = 'http://api.eve-online.com/account/AccountStatus.xml.aspx'
100
+ @@character_info_url = 'http://api.eve-online.com/eve/CharacterInfo.xml.aspx'
96
101
 
97
102
  cattr_accessor :character_sheet_url, :training_skill_url, :characters_url, :personal_wallet_journal_url,
98
103
  :corporate_wallet_journal_url, :personal_wallet_trans_url, :corporate_wallet_trans_url,
@@ -107,7 +112,8 @@ module Reve
107
112
  :certificate_tree_url, :character_medals_url, :corporate_medals_url,
108
113
  :corp_member_medals_url, :server_status_url, :skill_queue_url, :corporation_member_security_url,
109
114
  :personal_notification_url, :personal_mailing_lists_url, :personal_mail_messages_url,
110
- :research_url
115
+ :research_url, :personal_contacts_url, :corporate_contacts_url,
116
+ :account_status_url, :character_info_url
111
117
 
112
118
 
113
119
  attr_accessor :key, :userid, :charid
@@ -294,7 +300,23 @@ module Reve
294
300
  return h if h
295
301
  process_query(Reve::Classes::CorporateIndustryJob, opts[:url] || @@corporate_industry_jobs_url,false,args)
296
302
  end
297
-
303
+
304
+ # Returns a list of Reve::Classes::PersonalContact objects.
305
+ def personal_contacts(opts = {:characterid => nil})
306
+ args = postfields(opts)
307
+ h = compute_hash(args.merge(:url => @@personal_contacts_url))
308
+ return h if h
309
+ process_query(Reve::Classes::PersonalContact, opts[:url] || @@personal_contacts_url,false,args)
310
+ end
311
+
312
+ # Returns a list of Reve::Classes::CorporateContact objects.
313
+ def corporate_contacts(opts = {:characterid => nil})
314
+ args = postfields(opts)
315
+ h = compute_hash(args.merge(:url => @@corporate_contacts_url))
316
+ return h if h
317
+ process_query(Reve::Classes::PersonalContact, opts[:url] || @@corporate_contacts_url,false,args)
318
+ end
319
+
298
320
  # Returns the SkillTree from
299
321
  # http://api.eve-online.com/eve/SkillTree.xml.aspx
300
322
  # See also: Reve::Classes::SkillTree
@@ -940,6 +962,26 @@ module Reve
940
962
  process_query(Reve::Classes::MailMessage, opts[:url] || @@personal_mail_messages_url,false,args)
941
963
  end
942
964
 
965
+ # Gets the status of the selected account. Returns
966
+ # Reve::Classes::AccountStatus
967
+ def account_status(opts = {})
968
+ args = postfields(opts)
969
+ h = compute_hash(args.merge(:url => @@account_status_url))
970
+ return h if h
971
+ xml = process_query(nil,opts[:url] || @@account_status_url,true,args)
972
+ Reve::Classes::AccountStatus.new(xml.search('//result').first)
973
+ end
974
+
975
+ # Gets the character info sheet for the selected Character
976
+ # Reve::Classes::CharacterInfo
977
+ def character_info(opts = { :characterid => nil })
978
+ args = postfields(opts)
979
+ h = compute_hash(args.merge(:url => @@character_info_url))
980
+ return h if h
981
+ xml = process_query(nil,opts[:url] || @@character_info_url,true,args)
982
+ Reve::Classes::CharacterInfo.new(xml.search('//result').first)
983
+ end
984
+
943
985
  protected
944
986
  # Sets up the post fields for Net::HTTP::Get hash for process_query method.
945
987
  # See also format_url_request
data/lib/reve/classes.rb CHANGED
@@ -159,6 +159,24 @@ module Reve #:nodoc:
159
159
  end
160
160
  end
161
161
 
162
+ # Represents a single Contact
163
+ # Attributes:
164
+ # * contact_id ( Fixnum ) - ID of the Contact.
165
+ # * contact_name ( String ) - Name of the belligerant Contact.
166
+ # * in_watchlist ( Fixnum ) - Whether or not the Contact is in the watchlist.
167
+ # * standing ( String ) - The standing of the Contact.
168
+ class PersonalContact
169
+ attr_reader :contact_id, :contact_name, :in_watchlist, :standing
170
+ def initialize(elem) #:nodoc:
171
+ @contact_id = elem['contactID'].to_i
172
+ @contact_name = elem['contactName']
173
+ @in_watchlist = elem['inWatchlist'] == 'True' ? true : false
174
+ @standing = elem['standing'].to_i
175
+ end
176
+ end
177
+
178
+ class CorporateContact < PersonalContact; end
179
+
162
180
  # The status of a System with regards to a FactionWar. Who controls what
163
181
  # and what System is contested
164
182
  # Attributes:
@@ -1503,5 +1521,84 @@ module Reve #:nodoc:
1503
1521
  @read = elem['read'] == '1'
1504
1522
  end
1505
1523
  end
1524
+
1525
+ # Represents a AccountStatus for
1526
+ # Reve::API#account_status
1527
+ # Attributes
1528
+ # * user_id ( Fixnum ) - The account's userID
1529
+ # * paid_until ( Time ) - DateTime until when the account is still active.
1530
+ # * created_at ( Time ) - DateTime when the account was created.
1531
+ # * logon_count ( Fixnum ) - The amount of times the User logged in.
1532
+ # * logon_minutes ( Fixnum ) - The amount of minutes the user was logged in.
1533
+ # GTC buy offers not yet inplemented
1534
+ class AccountStatus
1535
+ attr_reader :user_id, :paid_until, :created_at, :logon_count, :logon_minutes
1536
+ def initialize(elem) #:nodoc:
1537
+ @user_id = (elem/'userID').inner_html.to_i
1538
+ @paid_until = Time.parse((elem/'paidUntil').inner_html)
1539
+ @created_at = Time.parse((elem/'createDate').inner_html)
1540
+ @logon_count = (elem/'logonCount').inner_html.to_i
1541
+ @logon_minutes = (elem/'logonMinutes').inner_html.to_i
1542
+ end
1543
+ end
1544
+
1545
+ # Represents a CharacterInfo for
1546
+ # Reve::API#character_info
1547
+ # Basic Attributes
1548
+ # * id ( Fixnum ) - ID of the Character
1549
+ # * name ( String ) - Name of the Character
1550
+ # * race ( String ) - Race of the Character
1551
+ # * bloodline ( String ) - Bloodline of the Character
1552
+ # * corporation_id ( Fixnum ) - ID of the Corporation the Character is in
1553
+ # * corporation_name ( String ) - Name of the Corporation the Character is in
1554
+ # * corporation_date ( Time ) - Date the Character joined his Corporation
1555
+ # * alliance_id ( Fixnum | NilClass ) - The ID of the Alliance the Character is in, if any. Will be nil unless the victim was in an Alliance
1556
+ # * alliance_name ( String | NilClass ) - Name of the Alliance the Character is in, if any.
1557
+ # * alliance_date ( Time | NilClass ) - Date the Character's Corporations joined the Alliance.
1558
+ # * security_status ( Float ) - Security status of the Character
1559
+ # Limited Attributes
1560
+ # * skillpoints ( Fixnum ) - The amount of Skillpoints
1561
+ # * skill_training_ends ( Time )-
1562
+ # * ship_name ( String ) -
1563
+ # * ship_type_id ( Fixnum ) -
1564
+ # * ship_type_name ( String ) -
1565
+ # Full Attributes
1566
+ # * last_known_location ( String ) -
1567
+ # * acount_balance ( Float )
1568
+ class CharacterInfo
1569
+ attr_reader :id, :name, :race, :bloodline, :corporation_id, :corporation_name, :corporation_date, :alliance_id, :alliance_name, :alliance_date
1570
+ attr_reader :security_status, :skillpoints, :skill_training_ends, :ship_name, :ship_type_id, :ship_type_name, :last_known_location, :acount_balance
1571
+
1572
+ def initialize(elem) #:nodoc:
1573
+ @id = (elem/'characterID').inner_html.to_i
1574
+ @name = (elem/'characterName').inner_html
1575
+ @race = (elem/'race').inner_html
1576
+ @bloodline = (elem/'bloodline').inner_html
1577
+ @corporation_id = (elem/'corporationID').inner_html.to_i
1578
+ @corporation_name = (elem/'corporation').inner_html
1579
+ @corporation_date = Time.parse((elem/'corporationDate').inner_html)
1580
+ @alliance_id = (elem/'allianceID').inner_html.to_i
1581
+ @alliance_name = (elem/'alliance').inner_html
1582
+ @alliance_date = Time.parse((elem/'alliancenDate').inner_html)
1583
+ @security_status = (elem/'securityStatus').inner_html.to_f
1584
+ @skillpoints = (elem/'skillPoints').inner_html == "" ? nil : (elem/'skillPoints').inner_html.to_i
1585
+ @skill_training_ends = (elem/'nextTrainingEnds').inner_html == "" ? nil : Time.parse((elem/'nextTrainingEnds').inner_html)
1586
+ @ship_name = (elem/'shipName').inner_html == "" ? nil : (elem/'shipName').inner_html
1587
+ @ship_type_id = (elem/'shipTypeID').inner_html == "" ? nil : (elem/'shipTypeID').inner_html.to_i
1588
+ @ship_type_name = (elem/'shipTypeName').inner_html == "" ? nil : (elem/'shipTypeName').inner_html
1589
+ @last_known_location = (elem/'lastKnownLocation').inner_html == "" ? nil : (elem/'lastKnownLocation').inner_html
1590
+ @acount_balance = (elem/'accountBalance').inner_html == "" ? nil : (elem/'accountBalance').inner_html.to_f
1591
+ end
1592
+
1593
+ def type
1594
+ if self.acount_balance
1595
+ return :full
1596
+ elsif self.skillpoints
1597
+ return :limited
1598
+ else
1599
+ return :basic
1600
+ end
1601
+ end
1602
+ end
1506
1603
  end
1507
1604
  end
data/test/test_reve.rb CHANGED
@@ -295,6 +295,26 @@ class TestReve < Test::Unit::TestCase
295
295
  end
296
296
  end
297
297
 
298
+ def test_personal_contacts_clean
299
+ Reve::API.personal_contacts_url = XML_BASE + 'char_contacts.xml'
300
+ contacts = @api.personal_contacts
301
+ assert_equal(2, contacts.length)
302
+ assert_equal("Hirento Raikkanen", contacts.first.contact_name )
303
+ assert_equal(3010913, contacts.first.contact_id )
304
+ assert_equal(false, contacts.first.in_watchlist )
305
+ assert_equal(0, contacts.first.standing )
306
+ end
307
+
308
+ def test_corporate_contacts_clean
309
+ Reve::API.corporate_contacts_url = XML_BASE + 'char_contacts.xml'
310
+ contacts = @api.corporate_contacts
311
+ assert_equal(2, contacts.length)
312
+ assert_equal("Hirento Raikkanen", contacts.first.contact_name )
313
+ assert_equal(3010913, contacts.first.contact_id )
314
+ assert_equal(false, contacts.first.in_watchlist )
315
+ assert_equal(0, contacts.first.standing )
316
+ end
317
+
298
318
  def test_faction_war_system_stats_clean(skip_preamble = false,stats = nil)
299
319
  Reve::API.faction_war_occupancy_url = XML_BASE + 'map_facwarsystems.xml'
300
320
  unless skip_preamble # not best practice but will get the job done!
@@ -1189,6 +1209,74 @@ class TestReve < Test::Unit::TestCase
1189
1209
  assert_equal [128250439,141157801], mails[4].to_list_ids
1190
1210
  end
1191
1211
 
1212
+ def test_account_status_cleanly
1213
+ Reve::API.account_status_url = XML_BASE + 'account_status.xml'
1214
+ status = nil
1215
+ assert_nothing_raised do
1216
+ status = @api.account_status
1217
+ end
1218
+ assert_equal 3000000, status.user_id
1219
+ assert_equal Time.parse("2004-01-01 00:00:00"), status.created_at
1220
+ assert_equal Time.parse("2011-01-01 00:00:00"), status.paid_until
1221
+ assert_equal 9998, status.logon_count
1222
+ assert_equal 9999, status.logon_minutes
1223
+
1224
+ end
1225
+
1226
+ def test_character_info_cleanly
1227
+ Reve::API.character_info_url = XML_BASE + 'char_info.xml'
1228
+ info = nil
1229
+ assert_nothing_raised do
1230
+ info = @api.character_info
1231
+ end
1232
+ assert_equal :basic, info.type
1233
+ assert_equal 1643072492, info.id
1234
+ assert_equal 'Catari Taga', info.name
1235
+ assert_equal 'Caldari', info.race
1236
+ assert_equal 'Achura', info.bloodline
1237
+ assert_equal 553239300, info.corporation_id
1238
+ assert_equal 'Centre Of Attention', info.corporation_name
1239
+ assert_equal Time.parse('2009-02-03 13:06:00'), info.corporation_date
1240
+ assert_equal 1923227030, info.alliance_id
1241
+ assert_equal 'Middle of Nowhere', info.alliance_name
1242
+ assert_equal Time.parse('2009-02-03 13:06:00'), info.alliance_date
1243
+ assert_equal 0.0, info.security_status
1244
+ # limited
1245
+ assert_equal nil, info.skillpoints
1246
+ assert_equal nil, info.skill_training_ends
1247
+ assert_equal nil, info.ship_name
1248
+ assert_equal nil, info.ship_type_id
1249
+ assert_equal nil, info.ship_type_name
1250
+
1251
+ end
1252
+
1253
+ def test_character_info_limited_cleanly
1254
+ Reve::API.character_info_url = XML_BASE + 'char_info_limited.xml'
1255
+ info = nil
1256
+ assert_nothing_raised do
1257
+ info = @api.character_info
1258
+ end
1259
+ assert_equal :limited, info.type
1260
+ assert_equal 9999, info.skillpoints
1261
+ assert_equal Time.parse('2010-10-10 08:10:48'), info.skill_training_ends
1262
+ assert_equal '.', info.ship_name
1263
+ assert_equal 24694, info.ship_type_id
1264
+ assert_equal 'Maelstrom', info.ship_type_name
1265
+ # full
1266
+ assert_equal nil, info.last_known_location
1267
+ assert_equal nil, info.acount_balance
1268
+ end
1269
+
1270
+ def test_character_info_full_cleanly
1271
+ Reve::API.character_info_url = XML_BASE + 'char_info_full.xml'
1272
+ info = nil
1273
+ assert_nothing_raised do
1274
+ info = @api.character_info
1275
+ end
1276
+ assert_equal :full, info.type
1277
+ assert_equal 'FD-MLJ VII - Moon 2 - Intaki Bank Investment Bank', info.last_known_location
1278
+ assert_equal 9999.29, info.acount_balance
1279
+ end
1192
1280
  # Can we reassign a URL?
1193
1281
  def test_assignment
1194
1282
  assert_nothing_raised do
@@ -1270,7 +1358,7 @@ class TestReve < Test::Unit::TestCase
1270
1358
  def test_reve_version
1271
1359
  # Path to Reve version is ../VERSION. We rely on File.read here and in the
1272
1360
  # class so it's kind of crummy.
1273
- version = File.read(File.join(File.dirname(__FILE__),'../','VERSION'))
1361
+ version = File.read(File.join(File.dirname(__FILE__),'../','VERSION')).chomp
1274
1362
  assert_equal(@api.reve_version, version)
1275
1363
  assert_equal("Reve v#{version}; http://github.com/lisa/reve", @api.http_user_agent)
1276
1364
  end
@@ -0,0 +1,13 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2010-10-05 20:28:55</currentTime>
4
+ <result>
5
+ <userID>3000000</userID>
6
+ <paidUntil>2011-01-01 00:00:00</paidUntil>
7
+ <createDate>2004-01-01 00:00:00</createDate>
8
+ <logonCount>9998</logonCount>
9
+ <logonMinutes>9999</logonMinutes>
10
+ <rowset name="Offers" key="offerID" columns="offerID,offeredDate,from,to,ISK" />
11
+ </result>
12
+ <cachedUntil>2010-10-05 20:33:55</cachedUntil>
13
+ </eveapi>
@@ -0,0 +1,11 @@
1
+ <eveapi version="2">
2
+ <currentTime>2010-05-29 22:35:46</currentTime>
3
+ <result>
4
+ <rowset name="contactList" key="contactID" columns="contactID,contactName,inWatchlist,standing">
5
+ <row contactID="3010913" contactName="Hirento Raikkanen" inWatchlist="False" standing="0" />
6
+ <row contactID="797400947" contactName="CCP Garthagk" inWatchlist="True" standing="10" />
7
+ </rowset>
8
+ </result>
9
+ <cachedUntil>2010-05-29 22:50:46</cachedUntil>
10
+ </eveapi>
11
+
@@ -0,0 +1,18 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2010-10-05 19:45:21</currentTime>
4
+ <result>
5
+ <characterID>1643072492</characterID>
6
+ <characterName>Catari Taga</characterName>
7
+ <race>Caldari</race>
8
+ <bloodline>Achura</bloodline>
9
+ <corporationID>553239300</corporationID>
10
+ <corporation>Centre Of Attention</corporation>
11
+ <corporationDate>2009-02-03 13:06:00</corporationDate>
12
+ <allianceID>1923227030</allianceID>
13
+ <alliance>Middle of Nowhere</alliance>
14
+ <alliancenDate>2009-02-03 13:06:00</alliancenDate>
15
+ <securityStatus>0.0</securityStatus>
16
+ </result>
17
+ <cachedUntil>2010-10-05 20:41:58</cachedUntil>
18
+ </eveapi>
@@ -0,0 +1,25 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2010-10-05 19:41:58</currentTime>
4
+ <result>
5
+ <characterID>1643072492</characterID>
6
+ <characterName>Catari Taga</characterName>
7
+ <race>Caldari</race>
8
+ <bloodline>Achura</bloodline>
9
+ <accountBalance>9999.29</accountBalance>
10
+ <skillPoints>9999</skillPoints>
11
+ <nextTrainingEnds>2010-10-10 08:10:48</nextTrainingEnds>
12
+ <shipName>.</shipName>
13
+ <shipTypeID>24694</shipTypeID>
14
+ <shipTypeName>Maelstrom</shipTypeName>
15
+ <corporationID>553239300</corporationID>
16
+ <corporation>Centre Of Attention</corporation>
17
+ <corporationDate>2009-02-03 13:06:00</corporationDate>
18
+ <allianceID>1923227030</allianceID>
19
+ <alliance>Middle of Nowhere</alliance>
20
+ <alliancenDate>2009-02-03 13:06:00</alliancenDate>
21
+ <lastKnownLocation>FD-MLJ VII - Moon 2 - Intaki Bank Investment Bank</lastKnownLocation>
22
+ <securityStatus>0.0</securityStatus>
23
+ </result>
24
+ <cachedUntil>2010-10-05 20:41:58</cachedUntil>
25
+ </eveapi>
@@ -0,0 +1,23 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2010-10-05 19:41:58</currentTime>
4
+ <result>
5
+ <characterID>1643072492</characterID>
6
+ <characterName>Catari Taga</characterName>
7
+ <race>Caldari</race>
8
+ <bloodline>Achura</bloodline>
9
+ <skillPoints>9999</skillPoints>
10
+ <nextTrainingEnds>2010-10-10 08:10:48</nextTrainingEnds>
11
+ <shipName>.</shipName>
12
+ <shipTypeID>24694</shipTypeID>
13
+ <shipTypeName>Maelstrom</shipTypeName>
14
+ <corporationID>553239300</corporationID>
15
+ <corporation>Centre Of Attention</corporation>
16
+ <corporationDate>2009-02-03 13:06:00</corporationDate>
17
+ <allianceID>1923227030</allianceID>
18
+ <alliance>Middle of Nowhere</alliance>
19
+ <alliancenDate>2009-02-03 13:06:00</alliancenDate>
20
+ <securityStatus>0.0</securityStatus>
21
+ </result>
22
+ <cachedUntil>2010-10-05 20:41:58</cachedUntil>
23
+ </eveapi>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 132
9
- version: 0.0.132
8
+ - 133
9
+ version: 0.0.133
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-10-03 00:00:00 -04:00
17
+ date: 2010-11-03 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -82,11 +82,16 @@ specification_version: 3
82
82
  summary: Reve is a Ruby library to interface with the Eve Online API
83
83
  test_files:
84
84
  - test/test_reve.rb
85
+ - test/xml/account_status.xml
85
86
  - test/xml/alliances.xml
86
87
  - test/xml/assets.xml
87
88
  - test/xml/badxml.xml
88
89
  - test/xml/certificate_tree.xml
90
+ - test/xml/char_contacts.xml
89
91
  - test/xml/char_facwarstats.xml
92
+ - test/xml/char_info.xml
93
+ - test/xml/char_info_full.xml
94
+ - test/xml/char_info_limited.xml
90
95
  - test/xml/char_medals.xml
91
96
  - test/xml/character_sheet.xml
92
97
  - test/xml/characterid.xml