eaal 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/eaal.rb +1 -1
- data/lib/eaal/result.rb +20 -2
- data/test/test_eaal.rb +12 -0
- metadata +1 -1
data/lib/eaal.rb
CHANGED
@@ -34,7 +34,7 @@ require 'eaal/result'
|
|
34
34
|
require 'eaal/rowset'
|
35
35
|
|
36
36
|
module EAAL
|
37
|
-
VERSION = "0.1.
|
37
|
+
VERSION = "0.1.12" # fix for Hoe.spec 2.x
|
38
38
|
@@version_string = "EAAL" + VERSION # the version string, used as client name in http requests
|
39
39
|
|
40
40
|
@@api_base = "https://api.eveonline.com" # the url used as basis for all requests, you might want to use gatecamper url or a personal proxy instead
|
data/lib/eaal/result.rb
CHANGED
@@ -14,10 +14,11 @@ module EAAL
|
|
14
14
|
|
15
15
|
# Result Container class, ...
|
16
16
|
class ResultContainer
|
17
|
-
attr_accessor :container
|
17
|
+
attr_accessor :container, :attribs
|
18
18
|
|
19
19
|
def initialize
|
20
20
|
self.container = {}
|
21
|
+
self.attribs = {}
|
21
22
|
end
|
22
23
|
|
23
24
|
def add_element(key, val)
|
@@ -25,7 +26,11 @@ module EAAL
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def method_missing(method, *args)
|
28
|
-
self.
|
29
|
+
if self.attribs.has_key?(method.id2name)
|
30
|
+
self.attribs[method.id2name]
|
31
|
+
else
|
32
|
+
self.container[method.id2name]
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
36
|
def to_hash
|
@@ -84,6 +89,9 @@ module EAAL
|
|
84
89
|
re = ResultElement.new(key, value)
|
85
90
|
if element.attributes.to_hash.length > 0
|
86
91
|
re.attribs.merge!(element.attributes.to_hash)
|
92
|
+
if re.value.respond_to?(:attribs)
|
93
|
+
re.value.attribs.merge!(element.attributes.to_hash)
|
94
|
+
end
|
87
95
|
end
|
88
96
|
end
|
89
97
|
re
|
@@ -105,6 +113,7 @@ module EAAL
|
|
105
113
|
elements = (xml/"eveapi/result").first.containers
|
106
114
|
elements.each {|element|
|
107
115
|
el = EAAL::Result::ResultElement.parse_element(prefix, element)
|
116
|
+
|
108
117
|
members << el.name
|
109
118
|
if el.kind_of? EAAL::Rowset::RowsetBase
|
110
119
|
values.merge!({el.name => el})
|
@@ -124,6 +133,15 @@ module EAAL
|
|
124
133
|
result.request_time = (xml/"eveapi/currentTime").first.inner_html
|
125
134
|
result.cached_until = (xml/"eveapi/cachedUntil").first.inner_html
|
126
135
|
values.each { |key,value|
|
136
|
+
# This class may have been set up with some missing keys if the original
|
137
|
+
# response that trigged its creation didn't contain certain elements
|
138
|
+
# For example, some CharacterSheets don't have an "allianceName" element
|
139
|
+
# if the character isn't in an alliance. This adds them if they're missing
|
140
|
+
if(!result.respond_to?("#{key}=".to_sym))
|
141
|
+
result.class.class_eval do
|
142
|
+
attr_accessor key.to_sym
|
143
|
+
end
|
144
|
+
end
|
127
145
|
result.send(key + "=", value)
|
128
146
|
}
|
129
147
|
result
|
data/test/test_eaal.rb
CHANGED
@@ -57,6 +57,18 @@ class TestEaal < Test::Unit::TestCase
|
|
57
57
|
assert_kind_of EAAL::Rowset::RowsetBase, @api.AllianceList.alliances.first.memberCorporations
|
58
58
|
end
|
59
59
|
|
60
|
+
# test for ApiKeyInfo.xml
|
61
|
+
def test_api_key
|
62
|
+
@api.scope = "account"
|
63
|
+
assert_equal @api.APIKeyInfo.key.characters.length, 1
|
64
|
+
assert_equal @api.APIKeyInfo.key.characters[0].characterID, '12345'
|
65
|
+
assert_equal @api.APIKeyInfo.key.characters[0].characterName, 'Tester'
|
66
|
+
assert_equal @api.APIKeyInfo.key.characters[0].corporationID, '45678'
|
67
|
+
assert_equal @api.APIKeyInfo.key.accessMask, '59760264'
|
68
|
+
assert_equal @api.APIKeyInfo.key.type, 'Character'
|
69
|
+
assert_equal @api.APIKeyInfo.key.expires, '2011-09-11 00:00:00'
|
70
|
+
end
|
71
|
+
|
60
72
|
# test for Standings.xml
|
61
73
|
def test_standings
|
62
74
|
@api.scope = "account"
|