wowget 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/wowget/spell.rb +10 -3
  2. data/spec/spell_spec.rb +1 -1
  3. 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
- 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.match(/\/item=([0-9]+)/)[1].to_i
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
- quantity = r.content.match(/\(([0-9]+)\)$/)[1].to_i
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
@@ -9,8 +9,8 @@ describe Wowget::Spell do
9
9
  it "should have a spell name" do
10
10
  spell.name.should == "Battlelord's Plate Boots"
11
11
  end
12
-
13
12
  end
13
+
14
14
 
15
15
  describe "With a recipe" do
16
16
  spell = Wowget::Spell.new(63188)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wowget
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Darlow