From 28c200945a2a2d166d97f413caf27d30f6c3c958 Mon Sep 17 00:00:00 2001 From: Lisa Seelye Date: Sat, 7 May 2016 14:54:56 -0400 Subject: [PATCH 1/4] Switch over to using Nokogiri instead of hpricot (Sorry _why) This is obviously a HUGE change to the library and as a result requires a lot of thorough user testing. The test suite is only so good, and indeed I found a gap (and plugged it) in the test suite. --- Gemfile | 4 +- lib/reve.rb | 118 +++++++++++++++++---------------- lib/reve/classes.rb | 10 +-- lib/reve/processing_helpers.rb | 10 +-- test/test_reve.rb | 54 +++++++++------ 5 files changed, 106 insertions(+), 90 deletions(-) diff --git a/Gemfile b/Gemfile index 5741cd0..2f97179 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,12 @@ source 'https://rubygems.org' group :deployment do - gem 'hpricot' + gem 'nokogiri' gem 'simplecov', :require => false #code coverage thingy end group :test, :development do - gem 'hpricot' + gem 'nokogiri' gem 'simplecov', :require => false #code coverage thingy end diff --git a/lib/reve.rb b/lib/reve.rb index 3c6dbe0..d069ca8 100644 --- a/lib/reve.rb +++ b/lib/reve.rb @@ -6,10 +6,13 @@ #++ begin - require 'hpricot' + require 'nokogiri' rescue LoadError require 'rubygems' - require 'hpricot' + require 'nokogiri' +rescue LoadError + require 'bundler' + require 'nokogiri' end require 'net/https' require 'uri' @@ -176,8 +179,8 @@ def server_status(opts = {}) return h if h xml = process_query(nil,opts[:url] || @@server_status_url,true,opts) Reve::Classes::ServerStatus.new( - xml.search("/eveapi/result/serverOpen/").first.to_s, - xml.search("/eveapi/result/onlinePlayers/").first.to_s + xml.search("/eveapi/result/serverOpen").first.text, + xml.search("/eveapi/result/onlinePlayers").first.text ) end @@ -359,29 +362,29 @@ def skill_tree(opts = {}) return h if h doc = process_query(nil,opts[:url] || @@skill_tree_url,true) skills = [] - (doc/'rowset[@name=skills]/row').each do |skill| + (doc/"rowset[@name='skills']/row").each do |skill| name = skill['typeName'] type_id = skill['typeID'] group_id = skill['groupID'] - rank = (skill/:rank).inner_html - desc = (skill/:description).inner_html + rank = skill.search('rank').text + desc = skill.search('description').text required_skills = [] - reqs = (skill/'rowset@name=[requiredskills]/row') + reqs = skill.search('rowset[@name=requiredSkills]/row') reqs.each do |required| - next if required.kind_of? Hpricot::Text # why is this needed? Why is this returned? How can I only get stuff with typeid and skilllevel? required_skills << Reve::Classes::SkillRequirement.new(required) if required['typeID'] && required['skillLevel'] end required_attribs = [] - (skill/'requiredAttributes').each do |req| - pri = doc.at(req.xpath + "/primaryAttribute") - sec = doc.at(req.xpath + "/secondaryAttribute") - required_attribs << Reve::Classes::PrimaryAttribute.new(pri.inner_html) - required_attribs << Reve::Classes::SecondaryAttribute.new(sec.inner_html) - end + pri = skill.search('requiredAttributes/primaryAttribute') + sec = skill.search('requiredAttributes/secondaryAttribute') +# skill.search('requiredAttributes').each do |req| +# pri = req.search("doc.at(req.xpath + "/primaryAttribute") +# sec = doc.at(req.xpath + "/secondaryAttribute") + required_attribs << Reve::Classes::PrimaryAttribute.new(pri.text) + required_attribs << Reve::Classes::SecondaryAttribute.new(sec.text) +# end bonuses = [] - res = (skill/'rowset@name=[skillBonusCollection]/row') + res = skill.search("rowset[@name=skillBonusCollection]/row") res.each do |bonus| - next if bonus.kind_of? Hpricot::Text bonuses << Reve::Classes::SkillBonus.new(bonus) if bonus['bonusType'] && bonus['bonusValue'] end skills << Reve::Classes::SkillTree.new(name,type_id,group_id,desc,rank,required_attribs,required_skills,bonuses) @@ -541,10 +544,10 @@ def character_medals(opts = { :characterid => nil }) h = compute_hash(args.merge(:url => @@character_medals_url)) return h if h xml = process_query(nil,opts[:url] || @@character_medals_url,true,args) - current = xml.search("/eveapi/result/rowset[@name=currentCorporation]/row").inject([]) do |cur,elem| + current = xml.search("/eveapi/result/rowset[@name='currentCorporation']/row").inject([]) do |cur,elem| cur << Reve::Classes::CharacterMedal.new(elem) end - other = xml.search("/eveapi/result/rowset[@name=otherCorporations]/row").inject([]) do |cur,elem| + other = xml.search("/eveapi/result/rowset[@name='otherCorporations']/row").inject([]) do |cur,elem| cur << Reve::Classes::CharacterMedal.new(elem) end Reve::Classes::CharacterMedals.new(current,other) @@ -563,7 +566,7 @@ def personal_faction_war_stats(opts = { :characterid => nil }) [ :factionID, :factionName, :enlisted, :currentRank, :highestRank, :killsYesterday, :killsLastWeek, :killsTotal, :victoryPointsYesterday, :victoryPointsLastWeek, :victoryPointsTotal ].each do |elem| - elems[elem.to_s] = xml.search("/eveapi/result/" + elem.to_s).first.inner_html + elems[elem.to_s] = xml.at("/eveapi/result/#{elem.to_s}").text end Reve::Classes::PersonalFactionWarParticpant.new(elems) end @@ -581,7 +584,7 @@ def corporate_faction_war_stats(opts = { :characterid => nil }) [ :factionID, :factionName, :enlisted, :pilots, :killsYesterday, :killsLastWeek, :killsTotal, :victoryPointsYesterday, :victoryPointsLastWeek, :victoryPointsTotal ].each do |elem| - elems[elem.to_s] = xml.search("/eveapi/result/" + elem.to_s).first.inner_html + elems[elem.to_s] = xml.at("/eveapi/result/#{elem.to_s}").text end Reve::Classes::CorporateFactionWarParticpant.new(elems) end @@ -603,7 +606,7 @@ def faction_war_stats(opts = {} ) totals = {} [ :killsYesterday, :killsLastWeek, :killsTotal, :victoryPointsYesterday, :victoryPointsLastWeek, :victoryPointsTotal ].each do |elem| - totals[elem.to_s] = xml.search("/eveapi/result/totals/" + elem.to_s).first.inner_html + totals[elem.to_s] = xml.at("/eveapi/result/totals/#{elem.to_s}").text end Reve::Classes::EveFactionWarStat.new(totals, wars, participants) end @@ -689,7 +692,7 @@ def skill_in_training(opts = {:characterid => nil}) xml = process_query(nil,opts[:url] || @@training_skill_url,true,args) xml.search("//result").each do |elem| for field in [ 'currentTQTime', 'trainingEndTime','trainingStartTime','trainingTypeID','trainingStartSP','trainingDestinationSP','trainingToLevel','skillInTraining' ] - h[field] = (elem/field.intern).inner_html + h[field] = (elem/field.intern).text end end Reve::Classes::SkillInTraining.new(h) @@ -732,9 +735,9 @@ def starbase_details(opts = { :characterid => nil, :starbaseid => nil }) return h if h xml = process_query(Reve::Classes::StarbaseDetails,opts[:url] || @@starbasedetail_url, true, args) - state = xml.search("/eveapi/result/state").inner_text - state_timestamp = xml.search("/eveapi/result/stateTimestamp").inner_text - online_timestamp = xml.search("/eveapi/result/onlineTimestamp").inner_text + state = xml.at("/eveapi/result/state").text + state_timestamp = xml.at("/eveapi/result/stateTimestamp").text + online_timestamp = xml.at("/eveapi/result/onlineTimestamp").text h = {'usageFlags' => 0, 'deployFlags' => 0, 'allowCorporationMembers' => 0, 'allowAllianceMembers' => 0, 'claimSovereignty' => 0} h.keys.each {|k| h[k] = xml.search("/eveapi/result/generalSettings/#{k}").inner_text } @@ -751,7 +754,7 @@ def starbase_details(opts = { :characterid => nil, :starbaseid => nil }) res = Hash.new { :state => :state, :stateTimestamp => :state_timestamp, :onlineTimestamp => :online_timestamp }.each do |k,v| - res[v] = xml.search("/eveapi/result/#{k.to_s}/").first.to_s.strip + res[v] = xml.at("/eveapi/result/#{k.to_s}").text end Reve::Classes::StarbaseDetails.new res, general_settings, combat_settings, fuel @@ -829,24 +832,25 @@ def corporation_sheet(opts = { :characterid => nil }) return h if h xml = process_query(nil,opts[:url] || @@corporation_sheet_url,true,args) - h = { 'graphicid' => 0, 'shape1' => 0, 'shape2' => 0, 'shape3' => 0, 'color1' => 0, 'color2' => 0, 'color3' => 0, } - h.keys.each { |k| h[k] = xml.search("//result/logo/" + k + "/").to_s.to_i } + h = { 'graphicID' => 0, 'shape1' => 0, 'shape2' => 0, 'shape3' => 0, 'color1' => 0, 'color2' => 0, 'color3' => 0, } + h.keys.each { |k| h[k] = xml.search("/eveapi/result/logo/#{k}").text.to_i } corporate_logo = Reve::Classes::CorporateLogo.new h - wallet_divisions = xml.search("//result/rowset[@name='walletDivisions']/").collect { |k| k if k.kind_of? Hpricot::Elem } - [ nil ] - divisions = xml.search("//result/rowset[@name='divisions']/").collect { |k| k if k.kind_of? Hpricot::Elem } - [ nil ] + # Take each wallet division out of the NodeSet so we're working with only the XML::Element + wallet_divisions = xml.search("/eveapi/result/rowset[@name='walletDivisions']/row").collect { |node| node } + divisions = xml.search("/eveapi/result/rowset[@name='divisions']/row").collect { |node| node } divisions.collect! { |d| Reve::Classes::CorporateDivision.new(d) } wallet_divisions.collect! { |w| Reve::Classes::WalletDivision.new(w) } # Map the XML names to our own names and assign them to the temporary # hash +res+ to pass to Reve::Classes::CorporationSheet#new res = Hash.new - { :corporationid => :id, :corporationname => :name, :ticker => :ticker, :ceoid => :ceo_id, - :ceoname => :ceo_name, :stationid => :station_id, :stationname => :station_name, - :description => :description, :url => :url, :allianceid => :alliance_id, - :alliancename => :alliance_name, :taxrate => :tax_rate, :membercount => :member_count, - :memberlimit => :member_limit, :shares => :shares }.each do |k,v| - res[v] = xml.search("//result/#{k.to_s}/").first.to_s.strip + { :corporationID => :id, :corporationName => :name, :ticker => :ticker, :ceoID => :ceo_id, + :ceoName => :ceo_name, :stationID => :station_id, :stationName => :station_name, + :description => :description, :url => :url, :allianceID => :alliance_id, + :allianceName => :alliance_name, :taxRate => :tax_rate, :memberCount => :member_count, + :memberLimit => :member_limit, :shares => :shares }.each do |k,v| + res[v] = xml.at("/eveapi/result/#{k.to_s}").text.to_s.strip rescue nil end Reve::Classes::CorporationSheet.new res, divisions, wallet_divisions, corporate_logo @@ -859,15 +863,15 @@ def corporate_member_security(opts = { :characterid => nil }) xml = process_query(nil,opts[:url] || @@corporation_member_security_url,true,args) cmc = Reve::Classes::CorporationMemberSecurity.new - xml.search("/eveapi/result/rowset[@name=members]/row").each do |member| + xml.search("/eveapi/result/rowset[@name='members']/row").each do |member| mem = Reve::Classes::CorporationMember.new(member) cmc.members << mem [:roles, :grantableRoles, :rolesAtHQ, :grantableRolesAtHQ, :rolesAtBase, :grantableRolesAtBase, :rolesAtOther, :grantableRolesAtOther].each do |rowset| - member.search("/rowset[@name=#{rowset.to_s}]/row").each do |row| + member.search("/rowset[@name='#{rowset.to_s}']/row").each do |row| mem.rsend(["#{rowset}"], [:push,Reve::Classes::CorporateRole.new(row)]) end end - member.search("/rowset[@name=titles]/row").each do |row| + member.search("/rowset[@name='titles']/row").each do |row| mem.rsend([:titles], [:push,Reve::Classes::CorporateTitle.new(row)]) end end @@ -885,16 +889,16 @@ def certificate_tree(opts = {}) xml = process_query(nil,opts[:url] || @@certificate_tree_url,true,args) tree = Reve::Classes::CertificateTree.new - xml.search("/eveapi/result/rowset[@name=categories]/row").each do |category| + xml.search("/eveapi/result/rowset[@name='categories']/row").each do |category| cat = Reve::Classes::CertificateCategory.new(category) - category.search("rowset[@name=classes]/row").each do |klass| + category.search("rowset[@name='classes']/row").each do |klass| kl = Reve::Classes::CertificateClass.new(klass) - klass.search("rowset[@name=certificates]/row").each do |certificate| + klass.search("rowset[@name='certificates']/row").each do |certificate| cert = Reve::Classes::Certificate.new(certificate) - certificate.search("rowset[@name=requiredSkills]/row").each do |skill| + certificate.search("rowset[@name='requiredSkills']/row").each do |skill| cert.required_skills << Reve::Classes::CertificateRequiredSkill.new(skill) end - certificate.search("rowset[@name=requiredCertificates]/row").each do |requiredcert| + certificate.search("rowset[@name='requiredCertificates']/row").each do |requiredcert| cert.required_certificates << Reve::Classes::CertificateRequiredCertificate.new(requiredcert) end kl.certificates << cert @@ -923,25 +927,25 @@ def character_sheet(opts = { :characterid => nil }) Reve::Classes::PerceptionEnhancer, Reve::Classes::WillpowerEnhancer ].each do |klass| xml_attr = klass.to_s.split("::").last.sub("Enhancer",'').downcase + "Bonus" - i = klass.new(xml.search("/eveapi/result/attributeEnhancers/#{xml_attr}").search("augmentatorName/").first.to_s, - xml.search("/eveapi/result/attributeEnhancers/#{xml_attr}").search("augmentatorValue/").first.to_s.to_i) + i = klass.new(xml.search("/eveapi/result/attributeEnhancers/#{xml_attr}").search("augmentatorName").first.text, + xml.search("/eveapi/result/attributeEnhancers/#{xml_attr}").search("augmentatorValue").first.text.to_i) cs.enhancers << i end [ 'characterID', 'name', 'race', 'bloodLine', 'ancestry', 'dob', 'gender','corporationName', 'corporationID','balance', 'cloneName', 'cloneSkillPoints' ].each do |field| - cs.send("#{field.downcase}=",xml.search("/eveapi/result/#{field}/").first.to_s) + cs.send("#{field.downcase}=",xml.search("/eveapi/result/#{field}").first.to_s) end [ 'intelligence','memory','charisma','perception','willpower' ].each do |attrib| - cs.send("#{attrib}=",xml.search("/eveapi/result/attributes/#{attrib}/").first.to_s.to_i) + cs.send("#{attrib}=",xml.search("/eveapi/result/attributes/#{attrib}").first.to_s.to_i) end - xml.search("rowset[@name=skills]/row").each do |elem| + xml.search("rowset[@name='skills']/row").each do |elem| cs.skills << Reve::Classes::Skill.new(elem) end - xml.search("rowset[@name=certificates]/row").each do |elem| + xml.search("rowset[@name='certificates']/row").each do |elem| cs.certificate_ids << elem['certificateID'].to_i end [ :corporationRolesAtHQ, :corporationRoles, :corporationRolesAtBase, :corporationRolesAtOther ].each do |role_kind| @@ -950,7 +954,7 @@ def character_sheet(opts = { :characterid => nil }) end end - xml.search("rowset[@name=corporationTitles]/row").each do |elem| + xml.search("rowset[@name='corporationTitles']/row").each do |elem| cs.corporate_titles << Reve::Classes::CorporateTitle.new(elem) end @@ -1005,8 +1009,9 @@ def personal_mail_messages(opts = { :characterid => nil }) end # Gets the bodies for mail messages. NB this API call does not - # return objects. It returns a hash with messageID strings as the keys - - # suitable for merging into a Reve::Classes::MailMessage object + # return objects. It returns a hash with messageID strings as the keys + # and message body as the key value. This hash is suitable for merging + # into a Reve::Classes::MailMessage object # # Note from the Eve API docs: # Bodies cannot be accessed if you have not called for their headers recently. @@ -1018,11 +1023,10 @@ def personal_mail_message_bodies(opts = { :ids => [] }) args = postfields(opts) h = compute_hash(args.merge(:url => @@personal_mail_message_bodies_url)) return h if h - just_xml = true - xml = process_query(Reve::Classes::MailMessage, opts[:url] || @@personal_mail_message_bodies_url,just_xml,args) + xml = process_query(Reve::Classes::MailMessage, opts[:url] || @@personal_mail_message_bodies_url,true,args) results = {} xml.search("//rowset/row").each do |el| - results[el.attributes['messageID']] = el.inner_text + results[el.attributes['messageID'].value] = el.text end results end diff --git a/lib/reve/classes.rb b/lib/reve/classes.rb index e630cd4..2092113 100644 --- a/lib/reve/classes.rb +++ b/lib/reve/classes.rb @@ -883,7 +883,7 @@ def initialize(h, divisions = [],wallet_divisions = [], logo =Reve::Classes::Cor @alliance_name = h[:alliance_name] rescue nil @tax_rate = h[:tax_rate].to_f @member_count = h[:member_count].to_i - @member_limit = h[:member_limit].to_i + @member_limit = h[:member_limit].to_i rescue 0 @shares = h[:shares].to_i end end @@ -1404,10 +1404,10 @@ def initialize(elem) #:nodoc: class StarbaseCombatSettings attr_reader :on_standings_drop, :on_status_drop, :on_aggression, :on_corporation_war def initialize(elem) #:nodoc: - @on_standings_drop = elem['onStandingDrop'].attr('standing').to_i - @on_status_drop = (elem['onStatusDrop'].attr('enabled') == '1' ? elem['onStatusDrop'].attr('standing').to_i : false) - @on_aggression = elem['onAggression'].attr('enabled') == '1' - @on_corporation_war = elem['onCorporationWar'].attr('enabled') == '1' + @on_standings_drop = elem['onStandingDrop'].attr('standing').value.to_i + @on_status_drop = (elem['onStatusDrop'].attr('enabled').value == '1' ? elem['onStatusDrop'].attr('standing').value.to_i : false) + @on_aggression = elem['onAggression'].attr('enabled').value == '1' + @on_corporation_war = elem['onCorporationWar'].attr('enabled').value == '1' end end diff --git a/lib/reve/processing_helpers.rb b/lib/reve/processing_helpers.rb index ca47041..f515884 100644 --- a/lib/reve/processing_helpers.rb +++ b/lib/reve/processing_helpers.rb @@ -5,9 +5,9 @@ module ProcessingHelpers def recur_through_assets(rows) assets = [] rows.each do |container| - unless container.empty? + unless container.children.empty? asset_container = Reve::Classes::AssetContainer.new(container) - asset_container.assets = self.recur_through_assets(container.search("/rowset/row")) + asset_container.assets = recur_through_assets(container.search("#{container.path}/rowset/row")) assets << asset_container else assets << Reve::Classes::Asset.new(container) @@ -163,7 +163,8 @@ def get_xml(source,opts) # Raises the proper exception (if there is one), otherwise it returns the # XML response. def check_exception(xml) - x = Hpricot::XML(xml) + raise ArgumentError.new("Got a nil XML document. What happened?") unless xml + x = Nokogiri::XML(xml) begin out = x.search("//error") # If this fails then there are some big problems with Hpricot#search ? rescue Exception => e @@ -181,7 +182,8 @@ def check_exception(xml) def save_xml(xml) path = build_save_filename FileUtils.mkdir_p(File.dirname(path)) - File.open(path,'w') { |f| f.print xml.to_original_html } + File.open(path,'w') { |f| xml.write_xml_to f} +# File.open(path,'w') { |f| f.print xml.to_xml } end def build_save_filename diff --git a/test/test_reve.rb b/test/test_reve.rb index c58927e..6d9c130 100644 --- a/test/test_reve.rb +++ b/test/test_reve.rb @@ -6,6 +6,7 @@ require 'fileutils' # for saving downloaded XML $LOAD_PATH << './lib' require 'reve' +require 'pp' @@ -86,9 +87,13 @@ def test_saving_xml_works @api.save_path = SAVE_PATH alliances = @api.alliances :url => File.join(XML_BASE,'alliances.xml') assert File.exists?(File.join(SAVE_PATH,'alliances',@api.cached_until.to_i.to_s + '.xml')) + # Force the documents to be read with Nokogiri and "standardized" into a + # uniform XML understood by Nokogiri. We don't really care if the documents + # are byte-for-byte the same, only if Nokogiri parses them the same. assert_equal( - File.open(File.join(XML_BASE,'alliances.xml')).read, - File.open(File.join(SAVE_PATH,'alliances',@api.cached_until.to_i.to_s + '.xml')).read) + Nokogiri::XML(File.open(File.join(XML_BASE,'alliances.xml')).read).to_xml, + Nokogiri::XML(File.open(File.join(SAVE_PATH, 'alliances', @api.cached_until.to_i.to_s + '.xml')).read).to_xml + ) end @@ -98,12 +103,12 @@ def test_saving_xml_when_save_path_is_nil assert ! File.exists?(File.join(SAVE_PATH,'alliances',@api.cached_until.to_i.to_s + '.xml')) end - # We want to see in the saved XML because that's what came from the source + # We want to see in the saved XML because that's what came from the source def test_saving_xml_with_bad_short_tag @api.save_path = SAVE_PATH @corpsheet = @api.corporation_sheet :url => File.join(XML_BASE,'corporation_sheet.xml') assert_equal "", @corpsheet.url - assert File.open(File.join(SAVE_PATH,'corporation_sheet',@api.cached_until.to_i.to_s + '.xml')).read.include?("") + assert File.open(File.join(SAVE_PATH,'corporation_sheet',@api.cached_until.to_i.to_s + '.xml')).read.include?("") end def test_saving_xml_when_404 @@ -939,6 +944,15 @@ def test_member_corporation_sheet_clean assert_kind_of Time, @api.cached_until assert_equal 7, sheet.divisions.size assert_equal 7, sheet.wallet_divisions.size + + assert_equal 0, sheet.logo.graphic_id + assert_equal 448, sheet.logo.shape_1 + assert_equal 0, sheet.logo.shape_2 + assert_equal 418, sheet.logo.shape_3 + assert_equal 681, sheet.logo.color_1 + assert_equal 676, sheet.logo.color_2 + assert_equal 0, sheet.logo.color_3 + end def test_nonmember_corporation_sheet_clean @@ -951,6 +965,16 @@ def test_nonmember_corporation_sheet_clean assert_kind_of Time, @api.cached_until assert_equal 0, sheet.divisions.size assert_equal 0, sheet.wallet_divisions.size + assert_equal 0, sheet.member_limit + + assert_equal 0, sheet.logo.graphic_id + assert_equal 531, sheet.logo.shape_1 + assert_equal 512, sheet.logo.shape_2 + assert_equal 0, sheet.logo.shape_3 + assert_equal 678, sheet.logo.color_1 + assert_equal 671, sheet.logo.color_2 + assert_equal 0, sheet.logo.color_3 + end def test_no_skill_in_training_clean @@ -1374,29 +1398,14 @@ def test_get_xml_from_filesystem assert_equal File.open(File.join(XML_BASE, 'skill_in_training-none.xml')).read, xmldoc end -=begin - def test_get_xml_from_web - xmldoc = @api.send(:get_xml, 'http://svn.crudvision.com/reve/trunk/test/xml/skill_in_training-none.xml', {} ) - assert_equal File.open(File.join(XML_BASE, 'skill_in_training-none.xml')).read, xmldoc - end -=end + def test_get_xml_from_filesystem_missing_file assert_raise Errno::ENOENT do xmldoc = @api.send(:get_xml, File.join(XML_BASE,rand.to_s), {} ) end end -=begin - # if this starts to fail make sure the 404 ErrorDocument includes '404 Not Found' - def test_get_xml_from_web_missing_file - begin - xmldoc = @api.send(:get_xml, 'http://svn.crudvision.com/reve/trunk/test/' + rand.to_s, {} ) - rescue Exception => e - assert e.kind_of?(Reve::Exceptions::ReveNetworkStatusException) - assert e.message.include?('404 Not Found') - end - end -=end + def test_format_url_request_one_arg req = @api.send(:format_url_request, { :a => "Hello" }) @@ -1437,7 +1446,8 @@ def test_reve_version # no need to test corporate cos they're the same. # TODO: Test with nested losses - def kills_cleanly(meth = :personal_kills,url = File.join(XML_BASE,'kills.xml')) + def kills_cleanly(meth = :personal_kills, url = File.join(XML_BASE,"kills.xml")) + # " kills = nil assert_nothing_raised do kills = @api.send(meth,{:url =>url}) From d5af901a832aae352d613de103a8b7f50433dd00 Mon Sep 17 00:00:00 2001 From: Lisa Seelye Date: Sat, 7 May 2016 14:59:03 -0400 Subject: [PATCH 2/4] Related to 28c2009: Forgot Gemfile.lock file --- Gemfile.lock | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5a7799b..739ed52 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,8 +2,10 @@ GEM remote: https://rubygems.org/ specs: docile (1.1.1) - hpricot (0.8.6) + mini_portile2 (2.0.0) multi_json (1.8.2) + nokogiri (1.6.7.2) + mini_portile2 (~> 2.0.0.rc2) simplecov (0.8.2) docile (~> 1.1.0) multi_json @@ -14,5 +16,8 @@ PLATFORMS ruby DEPENDENCIES - hpricot + nokogiri simplecov + +BUNDLED WITH + 1.11.2 From 7f63dc64404afb2fe61f73537ef49195e6d67858 Mon Sep 17 00:00:00 2001 From: Lisa Seelye Date: Sat, 7 May 2016 15:09:13 -0400 Subject: [PATCH 3/4] Clean up commented out Hpricot stuff & intending --- lib/reve.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/reve.rb b/lib/reve.rb index d069ca8..2566684 100644 --- a/lib/reve.rb +++ b/lib/reve.rb @@ -376,12 +376,8 @@ def skill_tree(opts = {}) required_attribs = [] pri = skill.search('requiredAttributes/primaryAttribute') sec = skill.search('requiredAttributes/secondaryAttribute') -# skill.search('requiredAttributes').each do |req| -# pri = req.search("doc.at(req.xpath + "/primaryAttribute") -# sec = doc.at(req.xpath + "/secondaryAttribute") - required_attribs << Reve::Classes::PrimaryAttribute.new(pri.text) - required_attribs << Reve::Classes::SecondaryAttribute.new(sec.text) -# end + required_attribs << Reve::Classes::PrimaryAttribute.new(pri.text) + required_attribs << Reve::Classes::SecondaryAttribute.new(sec.text) bonuses = [] res = skill.search("rowset[@name=skillBonusCollection]/row") res.each do |bonus| From 8d6243032b7fd757aae84998a5d69b5b5e702978 Mon Sep 17 00:00:00 2001 From: Lisa Seelye Date: Sat, 7 May 2016 15:09:30 -0400 Subject: [PATCH 4/4] Clean up test/test_reve.rb Don't need prettyprint. Don't need methods which are commented out (and do nothing!) --- test/test_reve.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/test_reve.rb b/test/test_reve.rb index 6d9c130..036c899 100644 --- a/test/test_reve.rb +++ b/test/test_reve.rb @@ -6,10 +6,6 @@ require 'fileutils' # for saving downloaded XML $LOAD_PATH << './lib' require 'reve' -require 'pp' - - - XML_BASE = File.join(File.dirname(__FILE__),'xml/') SAVE_PATH = File.join(File.dirname(__FILE__),'downloads') @@ -61,12 +57,6 @@ def test_makes_a_simple_hash assert_equal "xml/alliances.xml", h end -######Test moved to test_reve_failing.rb######### -# def test_charid_default_works_when_characterid_is_nil - # this line of code is wrong on so many levels. -# assert_equal("CharID", Reve::API.new('uid','key','CharID').send(:postfields,{})['characterid']) -# end - def test_makes_a_complex_hash Reve::API.corporate_wallet_trans_url = XML_BASE + 'market_transactions.xml' @api.userid = 999