wowget 0.2.0 → 0.2.1
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 +10 -3
- data/spec/spell_spec.rb +1 -1
- metadata +1 -1
data/lib/wowget/spell.rb
CHANGED
@@ -26,8 +26,9 @@ module Wowget
|
|
26
26
|
else
|
27
27
|
self.name = spell_xml.css('div.text h1').inner_text.strip.to_s
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
# does this spell produce an item? if so, what item_id?
|
30
|
+
if spell_xml.css('table#spelldetails th#icontab-icon1 + td span a').length == 1
|
31
|
+
self.item_id = spell_xml.css('table#spelldetails th#icontab-icon1 + td span a').attribute('href').content.match(/\/item=([0-9]+)/)[1].to_i
|
31
32
|
end
|
32
33
|
|
33
34
|
# reagents
|
@@ -36,7 +37,13 @@ module Wowget
|
|
36
37
|
reagents = spell_xml.css("h3:contains('Reagents')+table.iconlist tr td")
|
37
38
|
reagents.each do |r|
|
38
39
|
item_id = r.css("span a").attribute('href').content.match(/\/item=([0-9]+)/)[1].to_i
|
39
|
-
|
40
|
+
quantity_match = r.content.match(/\(([0-9]+)\)$/)
|
41
|
+
if quantity_match.nil?
|
42
|
+
quantity = 1
|
43
|
+
else
|
44
|
+
quantity = quantity_match[1].to_i
|
45
|
+
end
|
46
|
+
|
40
47
|
self.reagents.push({:item => Wowget::Item.new(item_id), :quantity => quantity})
|
41
48
|
end
|
42
49
|
end
|
data/spec/spell_spec.rb
CHANGED