dsander-reve 0.0.120 → 0.0.121

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -58,11 +58,11 @@ elsif File.exists?('.git')
58
58
  begin
59
59
  require 'jeweler'
60
60
  Jeweler::Tasks.new do |s|
61
- s.name = "dsander-reve"
61
+ s.name = "reve"
62
62
  s.rubyforge_project = "reve"
63
63
  s.author = "Lisa Seelye"
64
64
  s.email = "lisa@thedoh.com"
65
- s.homepage = "http://github.com/lisa/reve"
65
+ s.homepage = "http://revetrac.crudvision.com"
66
66
  s.platform = Gem::Platform::RUBY
67
67
  s.summary = "Reve is a Ruby library to interface with the Eve Online API"
68
68
  s.files = FileList["Rakefile","LICENSE", "lib/**/*.rb","reve.rb","tester.rb","init.rb"].to_a
@@ -72,21 +72,8 @@ elsif File.exists?('.git')
72
72
  s.extra_rdoc_files = ["ChangeLog"]
73
73
  s.add_dependency("hpricot",">= 0.6")
74
74
  end
75
- Jeweler::GemcutterTasks.new
76
75
  rescue LoadError
77
76
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
78
77
  end
79
78
  end
80
79
 
81
- begin
82
- require 'rcov/rcovtask'
83
- Rcov::RcovTask.new do |test|
84
- test.libs << 'test'
85
- test.pattern = 'test/**/test_*.rb'
86
- test.verbose = true
87
- end
88
- rescue LoadError
89
- task :rcov do
90
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
91
- end
92
- end
data/init.rb CHANGED
@@ -1,2 +1,3 @@
1
- # I make Rails happy.
1
+ # I exist to make Reve work as a Rails plugin.
2
+ # (It's such a glamorous job!)
2
3
  require 'reve'
data/lib/reve.rb CHANGED
@@ -87,6 +87,7 @@ module Reve
87
87
  @@corporate_medals_url = 'http://api.eve-online.com/corp/Medals.xml.aspx'
88
88
  @@corp_member_medals_url = 'http://api.eve-online.com/corp/MemberMedals.xml.aspx'
89
89
  @@server_status_url = 'http://api.eve-online.com/Server/ServerStatus.xml.aspx'
90
+ @@research_url = 'http://api.eve-online.com/char/Research.xml.aspx'
90
91
  @@personal_notification_url = 'http://api.eve-online.com/char/Notifications.xml.aspx'
91
92
  @@personal_mailing_lists_url = 'http://api.eve-online.com/char/mailinglists.xml.aspx'
92
93
  @@personal_mail_messages_url = 'http://api.eve-online.com/char/MailMessages.xml.aspx'
@@ -103,7 +104,8 @@ module Reve
103
104
  :general_faction_war_stats_url, :top_faction_war_stats_url, :faction_war_occupancy_url,
104
105
  :certificate_tree_url, :character_medals_url, :corporate_medals_url,
105
106
  :corp_member_medals_url, :server_status_url, :skill_queue_url, :corporation_member_security_url,
106
- :personal_notification_url, :personal_mailing_lists_url, :personal_mail_messages_url
107
+ :personal_notification_url, :personal_mailing_lists_url, :personal_mail_messages_url,
108
+ :research_url
107
109
 
108
110
 
109
111
  attr_accessor :key, :userid, :charid
@@ -339,6 +341,19 @@ module Reve
339
341
  return h if h
340
342
  process_query(Reve::Classes::MemberTracking,opts[:url] || @@member_tracking_url,false,args)
341
343
  end
344
+
345
+
346
+ # Gets one's research stats from agents
347
+ # http://api.eve-online/char/Research.xml.aspx
348
+ # Expects:
349
+ # * characterid ( Integer | String ) - Get stats for this Character
350
+ # See also: Reve::Classes::Research
351
+ def research(opts = { :characterid => nil })
352
+ args = postfields(opts)
353
+ h = compute_hash(args.merge(:url => @@research_url))
354
+ return h if h
355
+ process_query(Reve::Classes::Research,opts[:url] || @@research_url,false,args)
356
+ end
342
357
 
343
358
  # Gets one's own personal WalletBalance from
344
359
  # http://api.eve-online.com/char/AccountBalance.xml.aspx
@@ -647,21 +662,46 @@ module Reve
647
662
  process_query(Reve::Classes::Starbase,opts[:url] || @@starbases_url,false,args)
648
663
  end
649
664
 
650
- # Returns the fuel status for the Starbase whose item id is starbase_id
665
+ # Returns the starbase details for the Starbase whose item id is starbase_id
651
666
  # http://api.eve-online.com/corp/StarbaseDetail.xml.aspx
652
667
  # Expects:
653
668
  # * characterid ( Integer | String ) - Get the Starbase associated wih this character's Corporation
654
- # * starbase_id ( Integer ) - Get the fuel for this Starbase. This is the Starbase's itemid.
655
- # See also Reve::Classes::StarbaseFuel
656
- def starbase_fuel(opts = { :characterid => nil, :starbaseid => nil })
669
+ # * starbaseid ( Integer ) - Get the fuel for this Starbase. This is the Starbase's itemid.
670
+ # See also Reve::Classes::StarbaseDetails
671
+ def starbase_details(opts = { :characterid => nil, :starbaseid => nil })
672
+ opts[:itemid] = opts.delete(:starbaseid)
657
673
  args = postfields(opts)
658
674
  h = compute_hash(args.merge(:url => @@starbasedetail_url))
659
675
  return h if h
660
- ret = process_query(Reve::Classes::StarbaseFuel,opts[:url] || @@starbasedetail_url, false, args)
661
- ret.each { |r| r.starbase_id = opts[:starbaseid] }
662
- ret
676
+ xml = process_query(Reve::Classes::StarbaseDetails,opts[:url] || @@starbasedetail_url, true, args)
677
+
678
+ state = xml.search("/eveapi/result/state").inner_text
679
+ state_timestamp = xml.search("/eveapi/result/stateTimestamp").inner_text
680
+ online_timestamp = xml.search("/eveapi/result/onlineTimestamp").inner_text
681
+
682
+ h = {'usageFlags' => 0, 'deployFlags' => 0, 'allowCorporationMembers' => 0, 'allowAllianceMembers' => 0, 'claimSovereignty' => 0}
683
+ h.keys.each {|k| h[k] = xml.search("/eveapi/result/generalSettings/#{k}").inner_text }
684
+ general_settings = Reve::Classes::StarbaseGeneralSettings.new(h)
685
+
686
+ h = {'onStandingDrop' => 0, 'onStatusDrop' => 0, 'onAggression' => 0, 'onCorporationWar' => 0}
687
+ h.keys.each {|k| h[k] = xml.search("/eveapi/result/combatSettings/#{k}") }
688
+ combat_settings = Reve::Classes::StarbaseCombatSettings.new(h)
689
+
690
+ fuel = []
691
+ xml.search("/eveapi/result/rowset[@name='fuel']/row").each do |entry|
692
+ fuel << Reve::Classes::StarbaseFuel.new(entry)
693
+ end
694
+
695
+ res = Hash.new
696
+ { :state => :state, :stateTimestamp => :state_timestamp, :onlineTimestamp => :online_timestamp }.each do |k,v|
697
+ res[v] = xml.search("/eveapi/result/#{k.to_s}/").first.to_s.strip
698
+ end
699
+
700
+ Reve::Classes::StarbaseDetails.new res, general_settings, combat_settings, fuel
663
701
  end
664
702
 
703
+ alias_method :starbase_fuel, :starbase_details
704
+
665
705
 
666
706
  # Get the last kills for the characterid passed.
667
707
  # Expects:
data/lib/reve/classes.rb CHANGED
@@ -269,6 +269,25 @@ module Reve #:nodoc:
269
269
 
270
270
  end
271
271
 
272
+ # A Research object holds information about Agents the Character is doing research with.
273
+ # Attributes
274
+ # * agent_id ( Fixnum ) - ID of the Agent
275
+ # * skill_type_id ( Fixnum ) - Skill used for research (not the ID of the core received)
276
+ # * research_started_at ( Time ) - Date the Character began research with the Agent
277
+ # * points_per_day ( Float ) - Number of points generated per day
278
+ # * remainder_points ( Float ) - Number of points remaining since last datacore purchase andor points_per_day update.
279
+ # See Also: Character, Skill, Reve::API#research_stats
280
+ class Research
281
+ attr_reader :agent_id, :skill_type_id, :research_started_at, :points_per_day, :remainder_points
282
+ def initialize(elem) #:nodoc:
283
+ @agent_id = elem['agentID'].to_i
284
+ @skill_type_id = elem['skillTypeID'].to_i
285
+ @research_started_at = elem['researchStartDate'].to_time
286
+ @points_per_day = elem['pointsPerDay'].to_f
287
+ @remainder_points = elem['remainderPoints'].to_f
288
+ end
289
+ end
290
+
272
291
  # A Skill has a RequiredAttribute, either a PrimaryAttribute or SecondaryAttribute, which both derrive from this.
273
292
  # Attributes
274
293
  # * name ( String ) - Name of the required Attribute
@@ -1255,35 +1274,75 @@ module Reve #:nodoc:
1255
1274
  # Used for a list of Starbases, Reve::API#starbases
1256
1275
  # Attributes
1257
1276
  # * type_id ( Fixnum ) - Type of Starbase (Refer to CCP database dump invtypes)
1258
- # * type_name ( String ) - Name of the type of Starbase
1259
1277
  # * id ( Fixnum ) - ID of the Starbase
1260
1278
  # * system_id ( Fixnum ) - ID of the System where the Starbase is
1261
- # * system_name ( Starbase ) - Name of the System where the Starbase is
1279
+ # * moon_id ( Fixnum ) - ID of the Moon where the Starbase is
1280
+ # * state ( Fixnum ) - Mode of the POS. See Known POS States, below, see: http://wiki.eve-id.net/APIv2_Corp_StarbaseList_XML
1281
+ # * state_timestamp ( Time ) - Depends on the state, for example cycle time or Reinforced until
1282
+ # * online_timestamp ( Time ) - Since when the starbase is online
1262
1283
  # See Also: StarbaseFuel, Reve::API#starbases, Reve::API#starbase_fuel
1263
1284
  class Starbase
1264
- attr_reader :type_id, :type_name, :id, :system_id, :system_name
1285
+ attr_reader :type_id, :type_name, :id, :system_id, :moon_id, :state, :state_timestamp, :online_timestamp
1265
1286
  alias_method :item_id, :id
1266
1287
  alias_method :location_id,:system_id
1267
- alias_method :location_name, :system_name
1268
1288
  def initialize(elem) #:nodoc:
1269
1289
  @type_id = elem['typeID'].to_i
1270
- @type_name = elem['typeName']
1271
1290
  @id = elem['itemID'].to_i
1272
1291
  @system_id = elem['locationID'].to_i
1273
- @system_name = elem['locationName']
1292
+ @moon_id = elem['moonID'].to_i
1293
+ @state = elem['state'].to_i
1294
+ @state_timestamp = elem['stateTimestamp'].to_time
1295
+ @online_timestamp = elem['onlineTimestamp'].to_time
1274
1296
  end
1275
1297
  end
1276
1298
 
1277
- # Used for the fuel status of a Starbase. See Reve::API#starbase_fuel
1278
- # starbase_id is set in the Reve::API#starbase_fuel method and not here
1299
+ # Returns the starbase details for the Starbase whose item id is starbase_id
1279
1300
  # Attributes
1280
- # * type_id ( Fixnum ) - Type of fuel in the Starbase (Refer to CCP database dump invtypes)
1281
- # * quantity ( Fixnum ) - How much of the fuel is in the Starbase
1282
- # * starbase_id ( Fixnum ) - ID of the Starbase
1283
- # See Also: Starbase, Reve::API#starbase_fuel, Reve::API#starbases
1301
+ # * state ( Fixnum ) - State of the starbase (Refer to CCP database dump invtypes)
1302
+ # * state_timestamp ( Time ) - Depents on state
1303
+ # * online_timestamp ( Time ) - Since when this starbase is online
1304
+ # * general_settings ( StarbaseGeneralSettings ) - See StarbaseGeneralSettings
1305
+ # * combat_settings ( StarbaseCombatSettings ) - See StarbaseCombatSettings
1306
+ # * fuel ( [StarbaseFuel ] ) - See StarbaseFuel
1307
+ # See Also: Starbase, StarbaseGeneralSettings, StarbaseCombatSettings, StarbaseFuel, Reve::API#starbase_details, Reve::API#starbases
1308
+ class StarbaseDetails
1309
+ attr_reader :state, :state_timestamp, :online_timestamp
1310
+ attr_accessor :general_settings, :combat_settings, :fuel
1311
+
1312
+ def initialize(elem, general_settings, combat_settings, fuel) #:nodoc:
1313
+ @state = elem[:state].to_i
1314
+ @state_timestamp = elem[:state_timestamp].to_time
1315
+ @online_timestamp = elem[:online_timestamp].to_time
1316
+ @general_settings = general_settings
1317
+ @combat_settings = combat_settings
1318
+ @fuel = fuel
1319
+ end
1320
+ end
1321
+
1322
+ class StarbaseGeneralSettings
1323
+ attr_reader :usage_flags, :deploy_flags, :allow_corporation_members,
1324
+ :allow_alliance_members, :claim_sovereignty
1325
+ def initialize(elem) #:nodoc:
1326
+ @usage_flags = elem['usageFlags'].to_i
1327
+ @deploy_flags = elem['deployFlags'].to_i
1328
+ @allow_corporation_members = elem['allowCorporationMembers'] == '1'
1329
+ @allow_alliance_members = elem['allowAllianceMembers'] == '1'
1330
+ @claim_sovereignty = elem['claimSovereignty'] == '1'
1331
+ end
1332
+ end
1333
+
1334
+ class StarbaseCombatSettings
1335
+ attr_reader :on_standings_drop, :on_status_drop, :on_aggression, :on_corporation_war
1336
+ def initialize(elem) #:nodoc:
1337
+ @on_standings_drop = elem['onStandingDrop'].attr('standing').to_i
1338
+ @on_status_drop = (elem['onStatusDrop'].attr('enabled') == '1' ? elem['onStatusDrop'].attr('standing').to_i : false)
1339
+ @on_aggression = elem['onAggression'].attr('enabled') == '1'
1340
+ @on_corporation_war = elem['onCorporationWar'].attr('enabled') == '1'
1341
+ end
1342
+ end
1343
+
1284
1344
  class StarbaseFuel
1285
1345
  attr_reader :type_id, :quantity
1286
- attr_accessor :starbase_id
1287
1346
  def initialize(elem) #:nodoc:
1288
1347
  @type_id = elem['typeID'].to_i
1289
1348
  @quantity = elem['quantity'].to_i
data/test/test_reve.rb CHANGED
@@ -82,6 +82,7 @@ class TestReve < Test::Unit::TestCase
82
82
  File.open(File.join(SAVE_PATH,'alliances',@api.cached_until.to_i.to_s + '.xml')).read)
83
83
  end
84
84
 
85
+
85
86
  def test_saving_xml_when_save_path_is_nil
86
87
  assert_nil @api.save_path
87
88
  alliances = @api.alliances :url => File.join(XML_BASE,'alliances.xml')
@@ -134,6 +135,25 @@ class TestReve < Test::Unit::TestCase
134
135
  end
135
136
  end
136
137
 
138
+ def test_research_api_call
139
+ Reve::API.research_url = XML_BASE + 'research.xml'
140
+ research = nil
141
+ assert_nothing_raised do
142
+ research = @api.research :characterid => 123
143
+ end
144
+ assert_not_nil(research)
145
+ assert_not_nil(@api.last_hash)
146
+ assert_equal(4, research.size)
147
+ research.each do |ri|
148
+ assert_kind_of(Fixnum, ri.agent_id)
149
+ assert_kind_of(Fixnum, ri.skill_type_id)
150
+ assert_kind_of(Time, ri.research_started_at)
151
+ assert_kind_of(Float, ri.points_per_day)
152
+ assert_kind_of(Float, ri.remainder_points)
153
+ end
154
+ end
155
+
156
+
137
157
  def test_corporation_sheet_clean
138
158
  Reve::API.corporation_sheet_url = XML_BASE + 'corporation_sheet.xml'
139
159
  corporation = nil
@@ -488,24 +508,42 @@ class TestReve < Test::Unit::TestCase
488
508
  bases.each do |starbase|
489
509
  assert_instance_of Reve::Classes::Starbase, starbase
490
510
  assert_not_nil starbase.type_id
491
- assert_not_nil starbase.type_name
492
511
  assert_not_nil starbase.id
493
512
  assert_not_nil starbase.system_id
494
- assert_not_nil starbase.system_name
513
+ assert_not_nil starbase.moon_id
514
+ assert_not_nil starbase.state
515
+ assert_not_nil starbase.state_timestamp
516
+ assert_not_nil starbase.online_timestamp
495
517
  end
496
518
  end
497
519
 
498
- def test_starbase_fuel_clean
520
+ def test_starbase_details_clean
499
521
  Reve::API.starbasedetail_url = XML_BASE + 'starbase_fuel.xml'
500
- fuels = nil
522
+ detail = nil
501
523
  assert_nothing_raised do
502
- fuels = @api.starbase_fuel(:starbaseid => 1,:characterid => 2)
524
+ detail = @api.starbase_details(:starbaseid => 1,:characterid => 2)
503
525
  end
504
526
  assert_not_nil @api.last_hash
505
527
  assert_kind_of Time, @api.cached_until
506
- assert_equal 14, fuels.size
507
- fuels.each do |fuel|
508
- assert_equal 1, fuel.starbase_id
528
+
529
+ assert_not_nil detail.state
530
+ assert_kind_of Time, detail.state_timestamp
531
+ assert_kind_of Time, detail.online_timestamp
532
+ assert_instance_of Reve::Classes::StarbaseGeneralSettings, detail.general_settings
533
+ assert_instance_of Reve::Classes::StarbaseCombatSettings, detail.combat_settings
534
+ assert_equal 9, detail.fuel.size
535
+
536
+ assert_not_nil detail.general_settings.usage_flags
537
+ assert [TrueClass, FalseClass].include?(detail.general_settings.allow_corporation_members.class)
538
+ assert [TrueClass, FalseClass].include?(detail.general_settings.allow_alliance_members.class)
539
+ assert [TrueClass, FalseClass].include?(detail.general_settings.claim_sovereignty.class)
540
+
541
+ assert_not_nil detail.combat_settings.on_standings_drop
542
+ assert_not_nil detail.combat_settings.on_status_drop
543
+ assert_not_nil detail.combat_settings.on_aggression
544
+ assert_not_nil detail.combat_settings.on_corporation_war
545
+
546
+ detail.fuel.each do |fuel|
509
547
  assert_not_nil fuel.type_id
510
548
  assert_not_nil fuel.quantity
511
549
  end
@@ -1,23 +1,33 @@
1
- <eveapi version="1">
2
- <currentTime>2007-08-16 19:52:38</currentTime>
1
+ <eveapi version="2">
2
+ <currentTime>2009-11-03 18:52:44</currentTime>
3
3
  <result>
4
- <stateTimestamp>2007-08-14 13:47:02</stateTimestamp>
4
+ <state>4</state>
5
+ <stateTimestamp>2009-11-03 19:27:23</stateTimestamp>
6
+ <onlineTimestamp>2009-08-03 14:22:44</onlineTimestamp>
7
+ <generalSettings>
8
+ <usageFlags>3</usageFlags>
9
+ <deployFlags>0</deployFlags>
10
+ <allowCorporationMembers>1</allowCorporationMembers>
11
+ <allowAllianceMembers>0</allowAllianceMembers>
12
+ <claimSovereignty>0</claimSovereignty>
13
+ </generalSettings>
14
+ <combatSettings>
15
+ <onStandingDrop standing="200" />
16
+ <onStatusDrop enabled="0" standing="0" />
17
+ <onAggression enabled="1" />
18
+ <onCorporationWar enabled="1" />
19
+ </combatSettings>
5
20
  <rowset name="fuel" key="typeID" columns="typeID,quantity">
6
- <row typeID="16272" quantity="60000"/>
7
- <row typeID="16273" quantity="60000"/>
8
- <row typeID="24597" quantity="400"/>
9
- <row typeID="24596" quantity="400"/>
10
- <row typeID="24595" quantity="400"/>
11
- <row typeID="24594" quantity="400"/>
12
- <row typeID="24593" quantity="400"/>
13
- <row typeID="24592" quantity="400"/>
14
- <row typeID="16274" quantity="148500"/>
15
- <row typeID="9848" quantity="330"/>
16
- <row typeID="9832" quantity="2640"/>
17
- <row typeID="3689" quantity="1650"/>
18
- <row typeID="3683" quantity="8250"/>
19
- <row typeID="44" quantity="1320"/>
21
+ <row typeID="16273" quantity="10171" />
22
+ <row typeID="16272" quantity="9316" />
23
+ <row typeID="9848" quantity="123" />
24
+ <row typeID="9832" quantity="492" />
25
+ <row typeID="3689" quantity="369" />
26
+ <row typeID="3683" quantity="1599" />
27
+ <row typeID="44" quantity="246" />
28
+ <row typeID="16275" quantity="6000" />
29
+ <row typeID="17887" quantity="27675" />
20
30
  </rowset>
21
31
  </result>
22
- <cachedUntil>2007-08-16 19:52:48</cachedUntil>
32
+ <cachedUntil>2009-11-03 19:52:44</cachedUntil>
23
33
  </eveapi>
@@ -1,12 +1,12 @@
1
1
  <eveapi version="1">
2
- <currentTime>2007-08-16 19:51:38</currentTime>
2
+ <currentTime>2009-11-02 19:51:38</currentTime>
3
3
  <result>
4
- <rowset name="starbases" key="itemID" columns="typeID,typeName,itemID,locationID,locationName">
5
- <row typeID="12235" typeName="Amarr Control Tower" itemID="150354725" locationID="30000380" locationName="Polaris"/>
6
- <row typeID="20059" typeName="Amarr Control Tower Medium" itemID="150354773" locationID="30001984" locationName="EC-P8R"/>
7
- <row typeID="12235" typeName="Amarr Control Tower" itemID="150357658" locationID="30001984" locationName="EC-P8R"/>
8
- <row typeID="16286" typeName="Ultra Fast Control Tower" itemID="150318232" locationID="30003109" locationName="C9N-CC"/>
4
+ <rowset name="starbases" key="itemID" columns="itemID,typeID,locationID,moonID,state,stateTimestamp,onlineTimestamp">
5
+ <row typeID="12235" itemID="150354725" locationID="30000380" moonID="12513141" state="4" stateTimestamp="2009-11-03 17:57:32" onlineTimestamp="2009-11-01 10:57:24" />
6
+ <row typeID="20059" itemID="150354773" locationID="30001984" moonID="12513142" state="4" stateTimestamp="2009-11-03 15:25:12" onlineTimestamp="2009-10-01 11:24:35" />
7
+ <row typeID="12235" itemID="150357658" locationID="30001984" moonID="12513143" state="4" stateTimestamp="2009-11-03 17:57:32" onlineTimestamp="2008-07-01 16:10:44"/>
8
+ <row typeID="16286" itemID="150318232" locationID="30003109" moonID="12513144" state="1" stateTimestamp="2009-11-16 17:57:32" onlineTimestamp="2009-09-01 01:35:02"/>
9
9
  </rowset>
10
10
  </result>
11
- <cachedUntil>2007-08-16 19:51:50</cachedUntil>
11
+ <cachedUntil>2009-08-16 19:51:50</cachedUntil>
12
12
  </eveapi>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsander-reve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.120
4
+ version: 0.0.121
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lisa Seelye