battle_pet 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/pet_ability.rb CHANGED
@@ -1,11 +1,11 @@
1
- class PetAbility
2
- attr_accessor :id, :name, :type, :cooldown, :rounds
3
-
4
- def initialize(params)
5
- @id = params["id"]
6
- @name = params["name"]
7
- @type = PetType.find(params["petTypeId"])
8
- @cooldown = params["cooldown"]
9
- @rounds = params["rounds"]
10
- end
11
- end
1
+ class PetAbility
2
+ attr_accessor :id, :name, :type, :cooldown, :rounds
3
+
4
+ def initialize(params)
5
+ @id = params["id"]
6
+ @name = params["name"]
7
+ @type = PetType.find(params["petTypeId"])
8
+ @cooldown = params["cooldown"]
9
+ @rounds = params["rounds"]
10
+ end
11
+ end
data/lib/pet_type.rb CHANGED
@@ -1,16 +1,16 @@
1
- class PetType
2
- PET_TYPES = { 0 => 'Humanoid',
3
- 1 => 'Dragonkin',
4
- 2 => 'Flying',
5
- 3 => 'Undead',
6
- 4 => 'Critter',
7
- 5 => 'Magical',
8
- 6 => 'Elemental',
9
- 7 => 'Beast',
10
- 8 => 'Aquatic',
11
- 9 => 'Mechanical' }
12
-
13
- def self.find(type_id)
14
- PET_TYPES[type_id]
15
- end
16
- end
1
+ class PetType
2
+ PET_TYPES = { 0 => 'Humanoid',
3
+ 1 => 'Dragonkin',
4
+ 2 => 'Flying',
5
+ 3 => 'Undead',
6
+ 4 => 'Critter',
7
+ 5 => 'Magical',
8
+ 6 => 'Elemental',
9
+ 7 => 'Beast',
10
+ 8 => 'Aquatic',
11
+ 9 => 'Mechanical' }
12
+
13
+ def self.find(type_id)
14
+ PET_TYPES[type_id]
15
+ end
16
+ end
@@ -1,8 +1,32 @@
1
- require 'test/unit'
2
- require 'battle_pet'
3
-
4
- class BattlePetTest < Test::Unit::TestCase
5
- def test_truth
6
- assert true
7
- end
8
- end
1
+ # encoding: utf-8
2
+ require 'test/unit'
3
+ require 'battle_pet'
4
+
5
+ class BattlePetTest < Test::Unit::TestCase
6
+
7
+ def test_parse_data_from_api
8
+ assert_equal JSON.parse(File.read(File.join(File.dirname(__FILE__), 'data/mechanical_squirrel_us.json'))),
9
+ BattlePet.parse_data_from_api(39, :us)
10
+ end
11
+
12
+ def test_host
13
+ assert_equal 'us.battle.net', BattlePet.host(:us)
14
+ assert_equal 'www.battlenet.com.cn', BattlePet.host(:cn)
15
+ assert_equal 'us.battle.net', BattlePet.host(:ca)
16
+ end
17
+
18
+ def test_find_name
19
+ assert_equal '机械松鼠', BattlePet.find_name(39, :cn)
20
+ assert_equal 'Adder', BattlePet.find_name(635, :us)
21
+ assert_equal nil, BattlePet.find_name(1, :cn)
22
+ assert_equal nil, BattlePet.find_name(39, :ca)
23
+ end
24
+
25
+ def test_check_patch
26
+ (1..864).to_a.sample(5) { |i| assert_equal '5.0', BattlePet.check_patch(i) }
27
+ (865..1013).to_a.sample(5) { |i| assert_equal '5.1', BattlePet.check_patch(i) }
28
+ (1014..1213).to_a.sample(5) { |i| assert_equal '5.2', BattlePet.check_patch(i) }
29
+ (1213..1400).to_a.sample(5) { |i| assert_equal '5.3', BattlePet.check_patch(i) }
30
+ end
31
+
32
+ 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.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: