wowget 0.2.1 → 0.2.2
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 +30 -27
- data/spec/spell_spec.rb +18 -1
- metadata +1 -1
data/lib/wowget/spell.rb
CHANGED
@@ -30,6 +30,35 @@ module Wowget
|
|
30
30
|
if spell_xml.css('table#spelldetails th#icontab-icon1 + td span a').length == 1
|
31
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
|
32
32
|
end
|
33
|
+
|
34
|
+
# profession
|
35
|
+
unless self.item_id.nil?
|
36
|
+
prof_markup = spell_xml.xpath("//script[contains(., 'Markup')]")
|
37
|
+
|
38
|
+
unless prof_markup.empty?
|
39
|
+
matches = prof_markup.inner_text.match(/\[ul\]\[li\](.+?)\[\/li\]/)[1].match(/Requires (.+?) \(([0-9]+?)\)/)
|
40
|
+
self.profession = matches[1]
|
41
|
+
self.profession_id = case self.profession
|
42
|
+
when "Alchemy" then 1
|
43
|
+
when "Blacksmithing" then 2
|
44
|
+
when "Cooking" then 3
|
45
|
+
when "Enchanting" then 4
|
46
|
+
when "Engineering" then 5
|
47
|
+
when "First Aid" then 6
|
48
|
+
when "Jewelcrafting" then 7
|
49
|
+
when "Leatherworking" then 8
|
50
|
+
when "Mining" then 9
|
51
|
+
when "Tailoring" then 10
|
52
|
+
when "Yes" then 11
|
53
|
+
when "No" then 12
|
54
|
+
when "Fishing" then 13
|
55
|
+
when "Herbalism" then 14
|
56
|
+
when "Inscription" then 15
|
57
|
+
when "Archaeology" then 16
|
58
|
+
end
|
59
|
+
self.skill = matches[2].to_i
|
60
|
+
end
|
61
|
+
end
|
33
62
|
|
34
63
|
# reagents
|
35
64
|
if spell_xml.css("h3:contains('Reagents')").length == 1
|
@@ -42,38 +71,12 @@ module Wowget
|
|
42
71
|
quantity = 1
|
43
72
|
else
|
44
73
|
quantity = quantity_match[1].to_i
|
74
|
+
quantity += 1 if self.profession.nil? # see http://www.wowhead.com/spell=49244#comments:id=448843
|
45
75
|
end
|
46
|
-
|
47
76
|
self.reagents.push({:item => Wowget::Item.new(item_id), :quantity => quantity})
|
48
77
|
end
|
49
78
|
end
|
50
79
|
|
51
|
-
# profession
|
52
|
-
unless self.item_id.nil?
|
53
|
-
matches = spell_xml.xpath("//script[contains(., 'Markup')]").inner_text.match(/\[ul\]\[li\](.+?)\[\/li\]/)[1].match(/Requires (.+?) \(([0-9]+?)\)/)
|
54
|
-
self.profession = matches[1]
|
55
|
-
self.skill = matches[2].to_i
|
56
|
-
|
57
|
-
self.profession_id = case self.profession
|
58
|
-
when "Alchemy" then 1
|
59
|
-
when "Blacksmithing" then 2
|
60
|
-
when "Cooking" then 3
|
61
|
-
when "Enchanting" then 4
|
62
|
-
when "Engineering" then 5
|
63
|
-
when "First Aid" then 6
|
64
|
-
when "Jewelcrafting" then 7
|
65
|
-
when "Leatherworking" then 8
|
66
|
-
when "Mining" then 9
|
67
|
-
when "Tailoring" then 10
|
68
|
-
when "Yes" then 11
|
69
|
-
when "No" then 12
|
70
|
-
when "Fishing" then 13
|
71
|
-
when "Herbalism" then 14
|
72
|
-
when "Inscription" then 15
|
73
|
-
when "Archaeology" then 16
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
80
|
end
|
78
81
|
end
|
79
82
|
|
data/spec/spell_spec.rb
CHANGED
@@ -11,7 +11,24 @@ describe Wowget::Spell do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
describe "With a non-profession spell" do
|
15
|
+
spell = Wowget::Spell.new(49244)
|
16
|
+
|
17
|
+
it "should have a spell name" do
|
18
|
+
spell.name.should == "Create Eternal Fire"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have the correct quantity of reagents" do
|
22
|
+
spell.reagents[0][:quantity].should == 10
|
23
|
+
end
|
24
|
+
|
25
|
+
it "shouldn't have any profession" do
|
26
|
+
spell.profession_id.should == nil and
|
27
|
+
spell.profession.should == nil and
|
28
|
+
spell.skill.should == nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
15
32
|
describe "With a recipe" do
|
16
33
|
spell = Wowget::Spell.new(63188)
|
17
34
|
|