Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for getting research data from agents. Also, I still reme…

…mber how to write Ruby :)
  • Loading branch information...
commit 87e91139403abc0752031a906bc2c6f4ace59473 1 parent 66ab0e4
Lisa Seelye authored
Showing with 57 additions and 2 deletions.
  1. +2 −1  init.rb
  2. +16 −1 lib/reve.rb
  3. +19 −0 lib/reve/classes.rb
  4. +20 −0 test/test_reve.rb
View
3  init.rb
@@ -1,2 +1,3 @@
-# I make Rails happy.
+# I exist to make Reve work as a Rails plugin.
+# (It's such a glamorous job!)
require 'reve'
View
17 lib/reve.rb
@@ -87,6 +87,7 @@ class API
@@corporate_medals_url = 'http://api.eve-online.com/corp/Medals.xml.aspx'
@@corp_member_medals_url = 'http://api.eve-online.com/corp/MemberMedals.xml.aspx'
@@server_status_url = 'http://api.eve-online.com/Server/ServerStatus.xml.aspx'
+ @@research_url = 'http://api.eve-online.com/char/Research.xml.aspx'
cattr_accessor :character_sheet_url, :training_skill_url, :characters_url, :personal_wallet_journal_url,
:corporate_wallet_journal_url, :personal_wallet_trans_url, :corporate_wallet_trans_url,
@@ -99,7 +100,8 @@ class API
:personal_faction_war_stats_url, :corporate_faction_war_stats_url,
:general_faction_war_stats_url, :top_faction_war_stats_url, :faction_war_occupancy_url,
:certificate_tree_url, :character_medals_url, :corporate_medals_url,
- :corp_member_medals_url, :server_status_url, :skill_queue_url, :corporation_member_security_url
+ :corp_member_medals_url, :server_status_url, :skill_queue_url, :corporation_member_security_url,
+ :research_url
attr_accessor :key, :userid, :charid
@@ -335,6 +337,19 @@ def member_tracking(opts = {:characterid => nil})
return h if h
process_query(Reve::Classes::MemberTracking,opts[:url] || @@member_tracking_url,false,args)
end
+
+
+ # Gets one's research stats from agents
+ # http://api.eve-online/char/Research.xml.aspx
+ # Expects:
+ # * characterid ( Integer | String ) - Get stats for this Character
+ # See also: Reve::Classes::Research
+ def research(opts = { :characterid => nil })
+ args = postfields(opts)
+ h = compute_hash(args.merge(:url => @@research_url))
+ return h if h
+ process_query(Reve::Classes::Research,opts[:url] || @@research_url,false,args)
+ end
# Gets one's own personal WalletBalance from
# http://api.eve-online.com/char/AccountBalance.xml.aspx
View
19 lib/reve/classes.rb
@@ -269,6 +269,25 @@ def initialize(characters, corporations, factions) #:nodoc:
end
+ # A Research object holds information about Agents the Character is doing research with.
+ # Attributes
+ # * agent_id ( Fixnum ) - ID of the Agent
+ # * skill_type_id ( Fixnum ) - Skill used for research (not the ID of the core received)
+ # * research_started_at ( Time ) - Date the Character began research with the Agent
+ # * points_per_day ( Float ) - Number of points generated per day
+ # * remainder_points ( Float ) - Number of points remaining since last datacore purchase andor points_per_day update.
+ # See Also: Character, Skill, Reve::API#research_stats
+ class Research
+ attr_reader :agent_id, :skill_type_id, :research_started_at, :points_per_day, :remainder_points
+ def initialize(elem) #:nodoc:
+ @agent_id = elem['agentID'].to_i
+ @skill_type_id = elem['skillTypeID'].to_i
+ @research_started_at = elem['researchStartDate'].to_time
+ @points_per_day = elem['pointsPerDay'].to_f
+ @remainder_points = elem['remainderPoints'].to_f
+ end
+ end
+
# A Skill has a RequiredAttribute, either a PrimaryAttribute or SecondaryAttribute, which both derrive from this.
# Attributes
# * name ( String ) - Name of the required Attribute
View
20 test/test_reve.rb
@@ -82,6 +82,7 @@ def test_saving_xml_works
File.open(File.join(SAVE_PATH,'alliances',@api.cached_until.to_i.to_s + '.xml')).read)
end
+
def test_saving_xml_when_save_path_is_nil
assert_nil @api.save_path
alliances = @api.alliances :url => File.join(XML_BASE,'alliances.xml')
@@ -134,6 +135,25 @@ def test_errors_api_call
end
end
+ def test_research_api_call
+ Reve::API.research_url = XML_BASE + 'research.xml'
+ research = nil
+ assert_nothing_raised do
+ research = @api.research :characterid => 123
+ end
+ assert_not_nil(research)
+ assert_not_nil(@api.last_hash)
+ assert_equal(4, research.size)
+ research.each do |ri|
+ assert_kind_of(Fixnum, ri.agent_id)
+ assert_kind_of(Fixnum, ri.skill_type_id)
+ assert_kind_of(Time, ri.research_started_at)
+ assert_kind_of(Float, ri.points_per_day)
+ assert_kind_of(Float, ri.remainder_points)
+ end
+ end
+
+
def test_corporation_sheet_clean
Reve::API.corporation_sheet_url = XML_BASE + 'corporation_sheet.xml'
corporation = nil
Please sign in to comment.
Something went wrong with that request. Please try again.