Permalink
Browse files

Removed Array#xml_hash extension, fixed a bug with paused skill queues

  • Loading branch information...
1 parent 9f75a66 commit ddadc0bdb82321423226cc85ca4084fd0b589e9d @dsander dsander committed with Lisa Seelye Jun 15, 2010
Showing with 27 additions and 33 deletions.
  1. +1 −0 lib/reve.rb
  2. +6 −6 lib/reve/classes.rb
  3. +0 −26 lib/reve/extensions.rb
  4. +9 −1 test/test_reve.rb
  5. +11 −0 test/xml/skill_queue-paused.xml
View
@@ -14,6 +14,7 @@
require 'net/http'
require 'uri'
require 'cgi'
+require 'digest'
require 'fileutils'
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
View
@@ -425,7 +425,7 @@ def initialize(elem, victim, attackers, losses) #:nodoc:
# * assets ( [Asset] ) - A list of Asset objects that are contained in this AssetContainer.
# See Also: Asset, Reve::API#corporate_assets_list, Reve::API#personal_assets_list
class AssetContainer
- attr_reader :item_id, :location_id, :type_id, :quantity, :flag, :singleton
+ attr_reader :item_id, :location_id, :type_id, :quantity, :flag, :singleton, :xml_hash
attr_accessor :assets
def initialize(elem)
@item_id = elem['itemID'].to_i
@@ -436,7 +436,7 @@ def initialize(elem)
@singleton = elem['singleton'] == "1"
@assets = []
#@xml_hash = elem.to_s.gsub(/\n|\r|\s/,'')
- #@xml_hash = ::Digest::SHA1.hexdigest elem.to_s.gsub(/\n|\r|\s/,'')
+ @xml_hash = ::Digest::SHA1.hexdigest elem.to_s.gsub(/\n|\r|\s/,'')
end
end
@@ -448,15 +448,15 @@ def initialize(elem)
# * flag ( Fixnum ) - Inventory flag, refer to http://wiki.eve-dev.net/API_Inventory_Flags (See also KillLoss's flag)
# See Also: AssetContainer, Reve::API#corporate_assets_list, Reve::API#personal_assets_list
class Asset
- attr_reader :item_id, :type_id, :quantity, :flag, :singleton
+ attr_reader :item_id, :type_id, :quantity, :flag, :singleton, :xml_hash
def initialize(elem) #:nodoc:
@item_id = elem['itemID'].to_i
@type_id = elem['typeID'].to_i
@quantity = elem['quantity'].to_i
@flag = elem['flag'].to_i
@singleton = elem['singleton'].to_i
#@xml_hash = elem.to_s.gsub(/\n|\r|\s/,'')
- #@xml_hash = ::Digest::SHA1.hexdigest elem.to_s.gsub(/\n|\r|\s/,'')
+ @xml_hash = ::Digest::SHA1.hexdigest elem.to_s.gsub(/\n|\r|\s/,'')
end
end
@@ -1244,8 +1244,8 @@ class QueuedSkill
attr_reader :queue_position, :end_time, :start_time, :type_id, :start_sp, :end_sp, :to_level
def initialize(elem) #:nodoc:
@queue_position = elem['queuePosition'].to_i
- @end_time = elem['endTime'].to_time
- @start_time = elem['startTime'].to_time
+ @end_time = elem['endTime'] == "" ? nil : elem['endTime'].to_time
+ @start_time = elem['startTime'] == "" ? nil : elem['startTime'].to_time
@type_id = elem['typeID'].to_i
@start_sp = elem['startSP'].to_i
@end_sp = elem['endSP'].to_i
View
@@ -87,28 +87,6 @@ def to_time(form = :utc)
end
end
end
- module Array
- def to_hash(space = 0)
- hash = ""
- each do |c|
- vars = []
- c.instance_variables.each do |m|
- data = c.instance_variable_get(m)
- if data.kind_of? Array
- if data.length == 0
- vars << "#{m} => {}"
- else
- vars << "#{m} => {\n#{data.to_hash(space + 1)}}"
- end
- else
- vars << " #{m} => #{data}"
- end
- end
- hash << "#{' ' * space}{#{vars.join(',')}}\n"
- end
- hash
- end
- end
end
end
@@ -129,10 +107,6 @@ class NilClass #:nodoc:
include Reve::Extensions::NilClass
end
-class Array #:nodoc:
- include Reve::Extensions::Array
-end
-
class Object
def rsend(*args, &block)
obj = self
View
@@ -919,7 +919,15 @@ def test_skill_queue_clean
assert_not_nil queue.first.to_level
assert_not_nil queue.first.start_sp
assert_not_nil queue.first.end_sp
- assert_equal 9, queue.length
+ assert_equal 9, queue.length
+ Reve::API.skill_queue_url = XML_BASE + 'skill_queue-paused.xml'
+ queue = nil
+ assert_nothing_raised do
+ queue = @api.skill_queue(:characerid => 1)
+ end
+ assert_kind_of(Reve::Classes::QueuedSkill, queue.first)
+ assert_nil queue.first.start_time
+ assert_nil queue.first.end_time
end
def test_corporate_medals
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<eveapi version="2">
+ <currentTime>2010-06-15 11:34:42</currentTime>
+ <result>
+ <rowset name="skillqueue" key="queuePosition" columns="queuePosition,typeID,level,startSP,endSP,startTime,endTime">
+ <row queuePosition="0" typeID="3318" level="5" startSP="90510" endSP="512000" startTime="" endTime="" />
+ <row queuePosition="1" typeID="23594" level="5" startSP="226275" endSP="1280000" startTime="" endTime="" />
+ </rowset>
+ </result>
+ <cachedUntil>2010-06-15 11:49:42</cachedUntil>
+</eveapi>

0 comments on commit ddadc0b

Please sign in to comment.