wowheadr 0.0.3 → 0.0.4

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/README.md CHANGED
@@ -10,29 +10,39 @@ Generating URLs
10
10
 
11
11
  You can generate URLs for (currently) items, achievements, and spells, providing you know the ID for the entity you want a URL for. Use the methods in `Wowheadr::URI` to generate the URLs. For example, to generate a URL for the item "Bloodied Prison Shank" (http://www.wowhead.com/item=43659), you would use:
12
12
 
13
- Wowheadr::URI.item(43659)
13
+ gift = Wowheadr::URI.item(43659)
14
14
 
15
- And, to generate a URL for the ability "Path of Frost" (http://www.wowhead.com/spell=3714), you would use:
15
+ And, to generate a URL for the ability "Bear Form" (http://www.wowhead.com/spell=5487), you would use:
16
16
 
17
- Wowheadr::URI.spell(3714)
17
+ sum_durids = Wowheadr::URI.spell(5487)
18
18
 
19
19
  Advanced Usage
20
20
  --------------
21
21
 
22
- Wowhead provides the ability to customize links to various entities on their site using the `rel` property of the HTML link tag. Wowheadr supports this via the `Wowheadr::Entity` classes. (Currently, only `Item` is available.)
22
+ Wowhead provides the ability to customize links to various entities on their site using the `rel` property of the HTML link tag. Wowheadr supports this via the `Wowheadr::Entity` classes. (Currently, only `Item` and `Spell` are available.)
23
+
24
+ ### Items
23
25
 
24
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:
25
27
 
26
- Wowheadr::Entity::Item.new(42943).level(25).to_s
28
+ zinwrath = Wowheadr::Entity::Item.new(42943).level(25).to_s
27
29
 
28
30
  (Calling `to_s` on any `Entity` class returns the text that should be placed in the `rel` attribute of your link, as shown:)
29
31
 
30
- <a hef="http://non-wowhead-site.com" rel="item=42943&amp;lvl=25">Got an awesome new item for my character</a>
32
+ <a hef="http://www.warcraftmovies.com/movieview.php?id=7558" rel="item=42943&amp;lvl=25">Arcanite Reaper, HOOOOO</a>
31
33
 
32
- You can add enchants, gems, sockets, other set pieces, and more to an `Entity`:
34
+ You can add enchants, gems, sockets, other set pieces, and more to an `Item`:
33
35
 
34
36
  Wowheadr::Entity::Item.new(25697).gems(23121).enchant(2647).pieces(25695, 25696, 25697)
35
37
 
38
+ ### Spells
39
+
40
+ Spells work similarly. You can change the level using the `level()` method (for spell scaling), and you can use the `buff()` method to cause the tooltip to show the buff or debuff the spell causes rather than the spell itself.
41
+
42
+ man_angle = Wowheadr::Entity::Spell.new(33878).level(10).to_s
43
+ level_ten_rel = man_angle.level(10).to_s
44
+ debuff_rel = man_angle.buff(true).to_s
45
+
36
46
  More Awesomeness
37
47
  ----------------
38
48
 
@@ -32,7 +32,7 @@ module Wowheadr
32
32
  alias :lvl :level
33
33
 
34
34
  # Whether or not to show the tooltip for the buff the spell provides,
35
- # rathern than for the spell itself.
35
+ # rather than for the spell itself.
36
36
  def buff(buff)
37
37
  self.set(:buff, buff)
38
38
  end
@@ -9,7 +9,7 @@ module Wowheadr
9
9
  # tag by calling +to_s+ on the object.
10
10
  #
11
11
  # The methods to modify the data inside a Rel is protected, and a Rel
12
- # object can not be instantiated--instead, subclasses of Rel which
12
+ # object can not be instantiated--instead, subclasses of Rel (which
13
13
  # represent specific Wowhead entries with known rel attributes) should
14
14
  # be created and used instead.
15
15
  module Rel
data/lib/wowheadr/uri.rb CHANGED
@@ -3,16 +3,30 @@ module Wowheadr
3
3
  BASE_URL = "http://www.wowhead.com/"
4
4
  JAVASCRIPT = "http://static.wowhead.com/widgets/power.js"
5
5
 
6
- def self.item(id)
7
- "#{BASE_URL}item=#{id}"
6
+ # Return a URL for an entity on the wowhead.com site.
7
+ # For example, self.url(:item, 43659) generates
8
+ # http://www.wowhead.com/item=43659.
9
+ #
10
+ # To generate a URL for a different subdomain, pass the subdomain
11
+ # (such as "ptr") as the optional third parameter.
12
+ def self.url(entity, id, subdomain = nil)
13
+ base_url = subdomain.nil? ? BASE_URL : BASE_URL.gsub("www", subdomain.to_s)
14
+ "#{base_url}#{entity.to_s}=#{id.to_s}"
8
15
  end
9
16
 
10
- def self.achievement(id)
11
- "#{BASE_URL}achievement=#{id}"
17
+ # Shortcut for self.url(:item, ...)
18
+ def self.item(id, subdomain = nil)
19
+ url(:item, id, subdomain)
12
20
  end
13
21
 
14
- def self.spell(id)
15
- "#{BASE_URL}spell=#{id}"
22
+ # Shortcut for self.url(:achievement, ...)
23
+ def self.achievement(id, subdomain = nil)
24
+ url(:achievement, id, subdomain)
25
+ end
26
+
27
+ # Shortcut for self.url(:spell, ...)
28
+ def self.spell(id, subdomain = nil)
29
+ url(:spell, id, subdomain)
16
30
  end
17
31
  end
18
32
  end
@@ -1,3 +1,3 @@
1
1
  module Wowheadr
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/test/wowheadr/uri.rb CHANGED
@@ -10,11 +10,31 @@ class URITest < Test::Unit::TestCase
10
10
  assert_equal Wowheadr::URI.item(12345), "http://www.wowhead.com/item=12345"
11
11
  end
12
12
 
13
+ def test_item_url_subdomain
14
+ assert_equal Wowheadr::URI.item(12345, 'ptr'), "http://ptr.wowhead.com/item=12345"
15
+ end
16
+
13
17
  def test_achievement_url
14
18
  assert_equal Wowheadr::URI.achievement(12345), "http://www.wowhead.com/achievement=12345"
15
19
  end
16
20
 
21
+ def test_achievement_url_subdomain
22
+ assert_equal Wowheadr::URI.achievement(12345, 'ptr'), "http://ptr.wowhead.com/achievement=12345"
23
+ end
24
+
17
25
  def test_spell_url
18
26
  assert_equal Wowheadr::URI.spell(12345), "http://www.wowhead.com/spell=12345"
19
27
  end
20
- end
28
+
29
+ def test_spell_url_subdomain
30
+ assert_equal Wowheadr::URI.spell(12345, 'ptr'), "http://ptr.wowhead.com/spell=12345"
31
+ end
32
+
33
+ def test_manual_url
34
+ assert_equal Wowheadr::URI.url(:npc, 48935), "http://www.wowhead.com/npc=48935"
35
+ end
36
+
37
+ def test_manual_url_subdomain
38
+ assert_equal Wowheadr::URI.url(:npc, 48935, 'ptr'), "http://ptr.wowhead.com/npc=48935"
39
+ end
40
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brandon Tilley
@@ -74,7 +74,7 @@ rubyforge_project:
74
74
  rubygems_version: 1.3.7
75
75
  signing_key:
76
76
  specification_version: 3
77
- summary: wowheadr 0.0.3
77
+ summary: wowheadr 0.0.4
78
78
  test_files:
79
79
  - test/wowheadr/entity/item_test.rb
80
80
  - test/wowheadr/entity/spell_test.rb