wowheadr 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/wowheadr/entity/item.rb +3 -0
- data/lib/wowheadr/entity/spell.rb +3 -0
- data/lib/wowheadr/support/entity_method_mapper.rb +15 -0
- data/lib/wowheadr/uri/rel.rb +6 -0
- data/lib/wowheadr/version.rb +1 -1
- data/test/wowheadr/entity/item_test.rb +10 -0
- data/test/wowheadr/entity/spell_test.rb +10 -0
- metadata +5 -4
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Wowhead provides the ability to customize links to various entities on their sit
|
|
25
25
|
|
26
26
|
For example, to get the `rel` attribute for a link to a "Bloodied Arcanite Reaper" (http://www.wowhead.com/item=42943) tuned for a level 25 character, you can use:
|
27
27
|
|
28
|
-
zinwrath = Wowheadr::Entity::Item.
|
28
|
+
zinwrath = Wowheadr::Entity::Item.id(42943).level(25).to_s
|
29
29
|
|
30
30
|
(Calling `to_s` on any `Entity` class returns the text that should be placed in the `rel` attribute of your link, as shown:)
|
31
31
|
|
@@ -33,7 +33,7 @@ For example, to get the `rel` attribute for a link to a "Bloodied Arcanite Reape
|
|
33
33
|
|
34
34
|
You can add enchants, gems, sockets, other set pieces, and more to an `Item`:
|
35
35
|
|
36
|
-
Wowheadr::Entity::Item.
|
36
|
+
Wowheadr::Entity::Item.id(25697).gems(23121).enchant(2647).pieces(25695, 25696, 25697)
|
37
37
|
|
38
38
|
### Spells
|
39
39
|
|
data/lib/wowheadr/entity/item.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'wowheadr/uri/rel'
|
2
|
+
require 'wowheadr/support/entity_method_mapper'
|
2
3
|
|
3
4
|
module Wowheadr
|
4
5
|
module Entity
|
@@ -8,6 +9,7 @@ module Wowheadr
|
|
8
9
|
# http://www.wowhead.com/tooltips#related-advanced-usage
|
9
10
|
class Item
|
10
11
|
include Wowheadr::URI::Rel
|
12
|
+
include Wowheadr::Support::EntityMethodMapper
|
11
13
|
|
12
14
|
# Create a new Item and optionally pass in the ID,
|
13
15
|
# which automatically calls #item on the new object.
|
@@ -24,6 +26,7 @@ module Wowheadr
|
|
24
26
|
def item(id)
|
25
27
|
self.set(:item, id)
|
26
28
|
end
|
29
|
+
alias :id :item
|
27
30
|
|
28
31
|
# Set the character's level, useful for heirloom items.
|
29
32
|
def level(level)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'wowheadr/uri/rel'
|
2
|
+
require 'wowheadr/support/entity_method_mapper'
|
2
3
|
|
3
4
|
module Wowheadr
|
4
5
|
module Entity
|
@@ -8,6 +9,7 @@ module Wowheadr
|
|
8
9
|
# http://www.wowhead.com/tooltips#related-advanced-usage
|
9
10
|
class Spell
|
10
11
|
include Wowheadr::URI::Rel
|
12
|
+
include Wowheadr::Support::EntityMethodMapper
|
11
13
|
|
12
14
|
# Create a new Spell and optionally pass in the ID,
|
13
15
|
# which automatically calls #spell on the new object.
|
@@ -24,6 +26,7 @@ module Wowheadr
|
|
24
26
|
def spell(id)
|
25
27
|
self.set(:spell, id)
|
26
28
|
end
|
29
|
+
alias :id :spell
|
27
30
|
|
28
31
|
# Set the character's level, useful for spell scaling.
|
29
32
|
def level(level)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Wowheadr
|
2
|
+
module Support
|
3
|
+
module EntityMethodMapper
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def method_missing(method_sym, *args, &block)
|
10
|
+
self.new.send(method_sym, *args, &block)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/wowheadr/uri/rel.rb
CHANGED
@@ -37,6 +37,12 @@ module Wowheadr
|
|
37
37
|
end.join "&"
|
38
38
|
end
|
39
39
|
|
40
|
+
def self.method_missing(method_sym, *args, &block)
|
41
|
+
if self.respond_to? method_sym
|
42
|
+
self.call method_sym, args, block
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
40
46
|
protected
|
41
47
|
|
42
48
|
# Protected self.new to keep from being instantiated
|
data/lib/wowheadr/version.rb
CHANGED
@@ -6,11 +6,21 @@ class ItemTest < Test::Unit::TestCase
|
|
6
6
|
@item = Wowheadr::Entity::Item.new
|
7
7
|
end
|
8
8
|
|
9
|
+
def test_no_object
|
10
|
+
item = Wowheadr::Entity::Item.lvl(10).ench(501)
|
11
|
+
assert_equal "lvl=10&ench=501", item.to_s
|
12
|
+
end
|
13
|
+
|
9
14
|
def test_item
|
10
15
|
@item.item(12345)
|
11
16
|
assert_equal "item=12345", @item.to_s
|
12
17
|
end
|
13
18
|
|
19
|
+
def test_id
|
20
|
+
@item.id(12345)
|
21
|
+
assert_equal "item=12345", @item.to_s
|
22
|
+
end
|
23
|
+
|
14
24
|
def test_new_item
|
15
25
|
item = Wowheadr::Entity::Item.new(12345).level(10)
|
16
26
|
assert_equal "item=12345&lvl=10", item.to_s
|
@@ -6,11 +6,21 @@ class SpellTest < Test::Unit::TestCase
|
|
6
6
|
@spell = Wowheadr::Entity::Spell.new
|
7
7
|
end
|
8
8
|
|
9
|
+
def test_no_object
|
10
|
+
spell = Wowheadr::Entity::Spell.id(51234).lvl(10)
|
11
|
+
assert_equal "spell=51234&lvl=10", spell.to_s
|
12
|
+
end
|
13
|
+
|
9
14
|
def test_spell
|
10
15
|
@spell.spell(33878)
|
11
16
|
assert_equal "spell=33878", @spell.to_s
|
12
17
|
end
|
13
18
|
|
19
|
+
def test_id
|
20
|
+
@spell.id(33878)
|
21
|
+
assert_equal "spell=33878", @spell.to_s
|
22
|
+
end
|
23
|
+
|
14
24
|
def test_new_spell
|
15
25
|
spell = Wowheadr::Entity::Spell.new(33878).level(10)
|
16
26
|
assert_equal "spell=33878&lvl=10", spell.to_s
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brandon Tilley
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-29 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/wowheadr.rb
|
36
36
|
- lib/wowheadr/entity/item.rb
|
37
37
|
- lib/wowheadr/entity/spell.rb
|
38
|
+
- lib/wowheadr/support/entity_method_mapper.rb
|
38
39
|
- lib/wowheadr/uri.rb
|
39
40
|
- lib/wowheadr/uri/rel.rb
|
40
41
|
- lib/wowheadr/version.rb
|
@@ -74,7 +75,7 @@ rubyforge_project:
|
|
74
75
|
rubygems_version: 1.3.7
|
75
76
|
signing_key:
|
76
77
|
specification_version: 3
|
77
|
-
summary: wowheadr 0.0.
|
78
|
+
summary: wowheadr 0.0.5
|
78
79
|
test_files:
|
79
80
|
- test/wowheadr/entity/item_test.rb
|
80
81
|
- test/wowheadr/entity/spell_test.rb
|