Skip to content

Commit

Permalink
Implement Map::Sovereignty endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
amclain committed Sep 3, 2016
1 parent fe628c5 commit 66cddc9
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/greeve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require_relative "greeve/row"
require_relative "greeve/rowset"
require_relative "greeve/eve/character_info"
require_relative "greeve/map/sovereignty"

# A Ruby wrapper for the EVE Online XML API.
module Greeve
Expand Down
25 changes: 25 additions & 0 deletions lib/greeve/map/sovereignty.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative "../base_item"

module Greeve
module Map
# Provides sovereignty / ownership information for solar systems in New Eden,
# excluding wormhole space.
#
# @see https://eveonline-third-party-documentation.readthedocs.io/en/latest/xmlapi/map/map_sovereignty.html
class Sovereignty < Greeve::BaseItem
endpoint "map/Sovereignty"

rowset :solar_systems, xpath: "eveapi/result/rowset[@name='solarSystems']" do
attribute :solar_system_id, xpath: "@solarSystemID", type: :integer
attribute :alliance_id, xpath: "@allianceID", type: :integer
attribute :faction_id, xpath: "@factionID", type: :integer
attribute :corporation_id, xpath: "@corporationID", type: :integer
attribute :solar_system_name, xpath: "@solarSystemName", type: :string
end

def initialize(opts = {})
super(opts)
end
end
end
end
28 changes: 28 additions & 0 deletions spec/map/sovereignty_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
describe Greeve::Map::Sovereignty do
let(:base_endpoint) { "#{Greeve::EVE_API_BASE_URL}/map/Sovereignty.xml.aspx" }
let(:xml_filename) { "map/sovereignty" }

before {
stub_endpoint(base_endpoint, xml_filename)

invalidate_remaining_endpoints
}

let(:resource) { Greeve::Map::Sovereignty.new }

context "resource" do
subject { resource }

its(:solar_systems) { should be_a Greeve::Rowset }
end

context "solar system" do
subject { resource.solar_systems.first }

its(:solar_system_id) { should eq 30000208 }
its(:alliance_id) { should eq 498125261 }
its(:faction_id) { should eq 0 }
its(:corporation_id) { should eq 416584095 }
its(:solar_system_name) { should eq "LZ-6SU" }
end
end
17 changes: 17 additions & 0 deletions spec/xml/map/sovereignty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
<currentTime>2016-09-03 20:39:31</currentTime>
<result>
<rowset name="solarSystems" key="solarSystemID" columns="solarSystemID,allianceID,factionID,solarSystemName,corporationID">
<row solarSystemID="30000208" allianceID="498125261" factionID="0" solarSystemName="LZ-6SU" corporationID="416584095" />
<row solarSystemID="30000209" allianceID="498125261" factionID="0" solarSystemName="MC6O-F" corporationID="416584095" />
<row solarSystemID="30000210" allianceID="498125261" factionID="0" solarSystemName="U54-1L" corporationID="416584095" />
<row solarSystemID="30000211" allianceID="498125261" factionID="0" solarSystemName="B-588R" corporationID="416584095" />
<row solarSystemID="30000212" allianceID="498125261" factionID="0" solarSystemName="NCGR-Q" corporationID="416584095" />
<row solarSystemID="30000213" allianceID="498125261" factionID="0" solarSystemName="G-LOIT" corporationID="416584095" />
<row solarSystemID="30000214" allianceID="498125261" factionID="0" solarSystemName="HE-V4V" corporationID="416584095" />
</rowset>
<dataTime>2016-09-03 20:23:11</dataTime>
</result>
<cachedUntil>2016-09-03 21:20:11</cachedUntil>
</eveapi>

0 comments on commit 66cddc9

Please sign in to comment.