wowget 0.1.10 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/wowget/spell.rb +7 -7
- metadata +1 -1
data/lib/wowget/spell.rb
CHANGED
@@ -14,7 +14,7 @@ module Wowget
|
|
14
14
|
|
15
15
|
def initialize(spell_id)
|
16
16
|
begin
|
17
|
-
url = open("http://www.wowhead.com/spell=#{spell_id}")
|
17
|
+
url = open("http://www.wowhead.com/spell=#{spell_id}")
|
18
18
|
rescue
|
19
19
|
not_found = true
|
20
20
|
end
|
@@ -27,7 +27,7 @@ module Wowget
|
|
27
27
|
self.name = spell_xml.css('div.text h1').inner_text.strip.to_s
|
28
28
|
|
29
29
|
if spell_xml.css('table#spelldetails td span.q4 a').length == 1
|
30
|
-
self.item_id = spell_xml.css('table#spelldetails td span.q4 a').attribute('href').content.
|
30
|
+
self.item_id = spell_xml.css('table#spelldetails td span.q4 a').attribute('href').content.match(/\/item=([0-9]+)/)[1].to_i
|
31
31
|
end
|
32
32
|
|
33
33
|
# reagents
|
@@ -35,17 +35,17 @@ module Wowget
|
|
35
35
|
self.reagents = []
|
36
36
|
reagents = spell_xml.css("h3:contains('Reagents')+table.iconlist tr td")
|
37
37
|
reagents.each do |r|
|
38
|
-
item_id = r.css("span a").attribute('href').content.
|
39
|
-
quantity = r.content.
|
38
|
+
item_id = r.css("span a").attribute('href').content.match(/\/item=([0-9]+)/)[1].to_i
|
39
|
+
quantity = r.content.match(/\(([0-9]+)\)$/)[1].to_i
|
40
40
|
self.reagents.push({:item => Wowget::Item.new(item_id), :quantity => quantity})
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
# profession
|
45
45
|
unless self.item_id.nil?
|
46
|
-
|
47
|
-
self.profession =
|
48
|
-
self.skill =
|
46
|
+
matches = spell_xml.xpath("//script[contains(., 'Markup')]").inner_text.match(/\[ul\]\[li\](.+?)\[\/li\]/)[1].match(/Requires (.+?) \(([0-9]+?)\)/)
|
47
|
+
self.profession = matches[1]
|
48
|
+
self.skill = matches[2].to_i
|
49
49
|
|
50
50
|
self.profession_id = case self.profession
|
51
51
|
when "Alchemy" then 1
|