battle_pet 0.2.4 → 0.2.5
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/battle_pet.rb +6 -1
- data/test/test_battle_pet.rb +17 -0
- metadata +2 -2
data/lib/battle_pet.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
class BattlePet
|
6
|
-
attr_accessor :id, :name, :description, :source, :type, :creature, :abilities, :added_in_patch
|
6
|
+
attr_accessor :id, :name, :description, :source, :type, :creature, :abilities, :added_in_patch, :icon
|
7
7
|
|
8
8
|
REGION_HOSTS = { us: 'us.battle.net',
|
9
9
|
eu: 'eu.battle.net',
|
@@ -20,6 +20,10 @@ class BattlePet
|
|
20
20
|
@can_battle
|
21
21
|
end
|
22
22
|
|
23
|
+
def icon_url
|
24
|
+
"http://media.blizzard.com/wow/icons/56/#{icon}.jpg"
|
25
|
+
end
|
26
|
+
|
23
27
|
protected
|
24
28
|
|
25
29
|
def self.parse_data_from_api(id, locale)
|
@@ -31,6 +35,7 @@ class BattlePet
|
|
31
35
|
@id = data["speciesId"]
|
32
36
|
@name = data["name"]
|
33
37
|
@description = data["description"]
|
38
|
+
@icon = data["icon"]
|
34
39
|
@source = BattlePet.parse_source data["source"], locale
|
35
40
|
@can_battle = data["canBattle"]
|
36
41
|
@type = Type.find data["petTypeId"]
|
data/test/test_battle_pet.rb
CHANGED
@@ -3,6 +3,19 @@ require 'test/unit'
|
|
3
3
|
require 'battle_pet'
|
4
4
|
|
5
5
|
class BattlePetTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@pet = BattlePet.new(1150)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_initialize
|
11
|
+
assert_equal 1150, @pet.id
|
12
|
+
assert_equal "Ashstone Core", @pet.name
|
13
|
+
assert_equal "The cooled core of Golemagg, it appears to retain some semi-sentient properties.", @pet.description
|
14
|
+
assert_equal "inv_elemental_eternal_shadow", @pet.icon
|
15
|
+
assert_equal({ 'Drop' => 'Golemagg the Incinerator', 'Zone' => 'Molten Core' }, @pet.source)
|
16
|
+
assert_equal true, @pet.can_battle?
|
17
|
+
assert_equal 68666, @pet.creature
|
18
|
+
end
|
6
19
|
|
7
20
|
def test_parse_data_from_api
|
8
21
|
assert_equal JSON.parse(File.read(File.join(File.dirname(__FILE__), 'data/mechanical_squirrel_us.json'))),
|
@@ -39,4 +52,8 @@ class BattlePetTest < Test::Unit::TestCase
|
|
39
52
|
assert_equal "90", BattlePet.parse_cost('90 ')
|
40
53
|
end
|
41
54
|
|
55
|
+
def test_icon_url
|
56
|
+
assert_equal "http://media.blizzard.com/wow/icons/56/inv_elemental_eternal_shadow.jpg", @pet.icon_url
|
57
|
+
end
|
58
|
+
|
42
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: battle_pet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple gem to get data from WoW BattlePet API
|
15
15
|
email: zwt315@163.com
|