wowheadr 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,41 @@
1
+ require 'wowheadr/uri/rel'
2
+
3
+ module Wowheadr
4
+ module Entity
5
+ # Wowheadr::Entity::Spell represents a +rel+ entry in an HTML link tag to
6
+ # specify details about the spell being linked to. A list of key/value
7
+ # combinations can be found at
8
+ # http://www.wowhead.com/tooltips#related-advanced-usage
9
+ class Spell
10
+ include Wowheadr::URI::Rel
11
+
12
+ # Create a new Spell and optionally pass in the ID,
13
+ # which automatically calls #spell on the new object.
14
+ def initialize(id = nil)
15
+ super()
16
+ unless id.nil?
17
+ self.spell(id)
18
+ end
19
+ self
20
+ end
21
+
22
+ # Set the item ID for the spell. Useful if the +href+ attribute of the
23
+ # link does not lead to the spell's URL on wowhead.com (custom URLs).
24
+ def spell(id)
25
+ self.set(:spell, id)
26
+ end
27
+
28
+ # Set the character's level, useful for spell scaling.
29
+ def level(level)
30
+ self.set(:lvl, level)
31
+ end
32
+ alias :lvl :level
33
+
34
+ # Whether or not to show the tooltip for the buff the spell provides,
35
+ # rathern than for the spell itself.
36
+ def buff(buff)
37
+ self.set(:buff, buff)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module Wowheadr
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/wowheadr.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'wowheadr/version'
2
2
  require 'wowheadr/entity/item'
3
+ require 'wowheadr/entity/spell'
3
4
  require 'wowheadr/uri'
4
5
  require 'wowheadr/uri/rel'
@@ -0,0 +1,38 @@
1
+ require 'test/unit'
2
+ require 'wowheadr/entity/spell'
3
+
4
+ class SpellTest < Test::Unit::TestCase
5
+ def setup
6
+ @spell = Wowheadr::Entity::Spell.new
7
+ end
8
+
9
+ def test_spell
10
+ @spell.spell(33878)
11
+ assert_equal "spell=33878", @spell.to_s
12
+ end
13
+
14
+ def test_new_spell
15
+ spell = Wowheadr::Entity::Spell.new(33878).level(10)
16
+ assert_equal "spell=33878&amp;lvl=10", spell.to_s
17
+ end
18
+
19
+ def test_level
20
+ @spell.level(10)
21
+ assert_equal "lvl=10", @spell.to_s
22
+ end
23
+
24
+ def test_lvl
25
+ @spell.lvl(10)
26
+ assert_equal "lvl=10", @spell.to_s
27
+ end
28
+
29
+ def test_buff
30
+ @spell.buff(true)
31
+ assert_equal "buff", @spell.to_s
32
+ end
33
+
34
+ def test_chaining
35
+ @spell.level(10).buff(true)
36
+ assert_equal "lvl=10&amp;buff", @spell.to_s
37
+ end
38
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brandon Tilley
@@ -34,10 +34,12 @@ files:
34
34
  - Rakefile
35
35
  - lib/wowheadr.rb
36
36
  - lib/wowheadr/entity/item.rb
37
+ - lib/wowheadr/entity/spell.rb
37
38
  - lib/wowheadr/uri.rb
38
39
  - lib/wowheadr/uri/rel.rb
39
40
  - lib/wowheadr/version.rb
40
41
  - test/wowheadr/entity/item_test.rb
42
+ - test/wowheadr/entity/spell_test.rb
41
43
  - test/wowheadr/uri.rb
42
44
  - test/wowheadr/uri/rel_test.rb
43
45
  - wowheadr.gemspec
@@ -72,8 +74,9 @@ rubyforge_project:
72
74
  rubygems_version: 1.3.7
73
75
  signing_key:
74
76
  specification_version: 3
75
- summary: wowheadr 0.0.2
77
+ summary: wowheadr 0.0.3
76
78
  test_files:
77
79
  - test/wowheadr/entity/item_test.rb
80
+ - test/wowheadr/entity/spell_test.rb
78
81
  - test/wowheadr/uri.rb
79
82
  - test/wowheadr/uri/rel_test.rb