d3api 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ spec/cassettes/*
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Build
2
- Status](https://travis-ci.org/phereford/d3api.png)](https://travis-ci.org/phereford/d3api)
2
+ Status](https://travis-ci.org/phereford/d3api.png?branch=master)](https://travis-ci.org/phereford/d3api)
3
3
  [![Code
4
4
  Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/phereford/d3api)
5
5
 
@@ -48,15 +48,16 @@ This will return a Career object with json values. I tried my best to
48
48
  implement nice methods to get through the values such as:
49
49
  ```
50
50
  @career.heroes #=> returns an array of heroes
51
- @career.lastHeroPlayed #=> returns the id of last hero played
52
- @career.lastUpdated
51
+ @career.last_hero_played #=> returns the id of last hero played
52
+ @careerlast_updated.
53
53
  @career.artisans #=> returns a hash of your arisan information
54
- @career.kills['monsters'] #=> returns an integer
54
+ @career.monster_kills #=> returns an integer
55
55
  ```
56
56
 
57
57
  There is a ton of data gleaned from the career object. Just look at
58
58
  [Blizzard's Diablo 3 api docs](https://github.com/Blizzard/d3-api-docs)
59
- for more information.
59
+ for more information. You can also look through the respc tests to get a
60
+ better idea of what the methods are to utilize.
60
61
 
61
62
  ### Hero
62
63
 
@@ -70,7 +71,7 @@ To get a user's Diablo 3 hero, you need to know 4 things:
70
71
  @hero = D3api::Hero.new :us, 'yojymbu', '1249', '30255685' #=>
71
72
  returns hero object
72
73
  @hero.name #=> Returns name of character
73
- @hero.heroClass #=> Returns class of character
74
+ @hero.hero_class #=> Returns class of character
74
75
  @hero.skills #=> returns an array of hashes for active and passive
75
76
  skills
76
77
  @hero.items #=> returns an array of hashes
@@ -111,7 +112,6 @@ If you have any comments questions or concerns, please let me know.
111
112
  ## ToDos
112
113
  1. Implement Authentication per Blizzards protocol (allow 10,000
113
114
  unsigned requests or 50,000 signed requests).
114
- 2. Rspec tests for api calls.
115
115
 
116
116
  ## Contributing
117
117
 
@@ -23,4 +23,6 @@ Gem::Specification.new do |gem|
23
23
 
24
24
  gem.add_development_dependency 'rspec', '2.12.0'
25
25
  gem.add_development_dependency 'vcr', '~> 2.4.0'
26
+ gem.add_development_dependency 'pry'
27
+ gem.add_development_dependency 'simplecov'
26
28
  end
@@ -5,7 +5,19 @@ module D3api
5
5
 
6
6
  autoload :BaseModel, 'd3api/base_model'
7
7
  autoload :Career, 'd3api/career'
8
+
8
9
  autoload :Hero, 'd3api/hero'
10
+ autoload :HeroSet, 'd3api/hero_set'
11
+
12
+ autoload :EquippedItem, 'd3api/equipped_item'
13
+ autoload :EquippedItemSet, 'd3api/equipped_item_set'
14
+
15
+ autoload :HeroSkills, 'd3api/hero_skills'
16
+
17
+ autoload :HeroFollowerSet, 'd3api/hero_follower_set'
18
+ autoload :HeroFollower, 'd3api/hero_follower'
19
+
20
+ autoload :Skill, 'd3api/skill'
9
21
  autoload :Item, 'd3api/item'
10
22
  autoload :Follower, 'd3api/follower'
11
23
  autoload :Artisan, 'd3api/artisan'
@@ -1,15 +1,25 @@
1
1
  module D3api
2
2
  class Artisan < BaseModel
3
- include D3api::Request
3
+ attr_accessor :slug, :name, :portrait, :training
4
4
 
5
- def initialize(region, artisan_type)
5
+ def initialize(region=:us, artisan_type)
6
6
  json_response = find(region, artisan_type)
7
7
 
8
- super json_response
8
+ values = super json_response
9
+
10
+ set_method(values)
9
11
  end
10
12
 
13
+ private
11
14
  def find(region, artisan_type)
12
- get(:us, "data/artisan/#{artisan_type}")
15
+ get(region, "data/artisan/#{artisan_type}")
16
+ end
17
+
18
+ def set_method(values)
19
+ self.slug = values['slug']
20
+ self.name = values['name']
21
+ self.portrait = values['portrait']
22
+ self.training = nil
13
23
  end
14
24
  end
15
25
  end
@@ -1,23 +1,9 @@
1
1
  module D3api
2
2
  class BaseModel
3
- extend D3api::Request
3
+ include D3api::Request
4
4
 
5
- attr_accessor :value
6
-
7
- def initialize(value)
8
- @value = value
9
- parsed_values = JSON.parse(value)
10
- fields = parsed_values.keys.inject([]) do |result, element|
11
- result << element.to_sym
12
- end
13
-
14
- fields.each do |field|
15
- field = :heroClass if field == :class
16
-
17
- self.class.send(:define_method, field) do
18
- parsed_values[field.to_s]
19
- end
20
- end
5
+ def initialize(values)
6
+ JSON.parse(values)
21
7
  end
22
8
  end
23
9
  end
@@ -1,15 +1,45 @@
1
1
  module D3api
2
2
  class Career < BaseModel
3
- include D3api::Request
3
+ attr_accessor :last_hero_played, :heroes, :last_updated,
4
+ :artisans, :hardcore_artisans, :monster_kills,
5
+ :elite_kills, :hardcore_monster_kills,
6
+ :barbarian_time_played, :demon_hunter_time_played,
7
+ :monk_time_played, :witch_doctor_time_played,
8
+ :wizard_time_played, :fallen_heroes, :battle_tag,
9
+ :progression, :hardcore_progression
4
10
 
5
11
  def initialize(region, battletag_name, battletag_code)
6
12
  json_response = find(region, battletag_name, battletag_code)
7
13
 
8
- super json_response
14
+ values = super(json_response)
15
+
16
+ set_method(values)
17
+
9
18
  end
10
19
 
20
+ private
11
21
  def find(region, battletag_name, battletag_code)
12
22
  get(region, "profile/#{battletag_name}-#{battletag_code}/")
13
23
  end
24
+
25
+ def set_method(values)
26
+ self.last_hero_played = values['lastHeroPlayed']
27
+ self.heroes ||= D3api::HeroSet.new(values['heroes']).hero_set
28
+ self.last_updated = Time.at(values['lastUpdated'])
29
+ self.artisans = values['artisans']
30
+ self.hardcore_artisans = values['hardcoreArtisans']
31
+ self.monster_kills = values['kills']['monsters']
32
+ self.elite_kills = values['kills']['elites']
33
+ self.hardcore_monster_kills = values['kills']['hardcoreMonsters']
34
+ self.barbarian_time_played = values['timePlayed']['barbarian']
35
+ self.demon_hunter_time_played = values['timePlayed']['demon-hunter']
36
+ self.monk_time_played = values['timePlayed']['monk']
37
+ self.witch_doctor_time_played = values['timePlayed']['witch-doctor']
38
+ self.wizard_time_played = values['timePlayed']['wizard']
39
+ self.fallen_heroes = nil
40
+ self.battle_tag = values['battleTag']
41
+ self.progression = nil
42
+ self.hardcore_progression = nil
43
+ end
14
44
  end
15
45
  end
@@ -9,7 +9,6 @@ module D3api
9
9
  c.request :url_encoded
10
10
  c.request :json
11
11
  c.response :json
12
- c.response :logger
13
12
  c.adapter Faraday.default_adapter
14
13
  end
15
14
  end
@@ -0,0 +1,23 @@
1
+ module D3api
2
+ class EquippedItem
3
+ attr_accessor :location, :name, :icon, :display_color,
4
+ :tooltip_params, :id
5
+
6
+ def initialize(array)
7
+ location = array[0]
8
+ attributes = array[1]
9
+
10
+ set_method(location, attributes)
11
+ end
12
+
13
+ private
14
+ def set_method(location, attributes)
15
+ self.location = location
16
+ self.id = attributes['id']
17
+ self.name = attributes['name']
18
+ self.icon = attributes['icon']
19
+ self.display_color = attributes['displayColor']
20
+ self.tooltip_params = attributes['tooltipParams']
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module D3api
2
+ class EquippedItemSet
3
+ attr_accessor :item_set
4
+
5
+ def initialize(*array)
6
+ equipped_items = []
7
+
8
+ array[0].each do |item|
9
+ equipped_items << EquippedItem.new(item)
10
+ end
11
+
12
+ set_method(equipped_items)
13
+ end
14
+
15
+ private
16
+ def set_method(equipped_items)
17
+ self.item_set = equipped_items
18
+ end
19
+ end
20
+ end
@@ -1,15 +1,25 @@
1
1
  module D3api
2
2
  class Follower < BaseModel
3
- include D3api::Request
3
+ attr_accessor :slug, :name, :portrait, :skills
4
4
 
5
5
  def initialize(region, follower_type)
6
6
  json_response = find(region, follower_type)
7
7
 
8
- super json_response
8
+ values = super json_response
9
+
10
+ set_method(values)
9
11
  end
10
12
 
13
+ private
11
14
  def find(region, follower_type)
12
- get(:us, "data/follower/#{follower_type}")
15
+ get(region, "data/follower/#{follower_type}")
16
+ end
17
+
18
+ def set_method(values)
19
+ self.slug = values['slug']
20
+ self.name = values['name']
21
+ self.portrait = values['portrait']
22
+ self.skills = nil
13
23
  end
14
24
  end
15
25
  end
@@ -1,15 +1,54 @@
1
1
  module D3api
2
2
  class Hero < BaseModel
3
3
  include D3api::Request
4
+ attr_accessor :id, :name, :hero_class, :gender,
5
+ :level, :hardcore, :last_updated,
6
+ :items, :active_skills, :passive_skills,
7
+ :followers
4
8
 
5
9
  def initialize(region, battletag_name, battletag_id, hero_id)
6
10
  json_response = find(region, battletag_name, battletag_id, hero_id)
7
11
 
8
- super json_response
12
+ values = super json_response
13
+
14
+ set_method(values)
9
15
  end
10
16
 
17
+ # stats class
18
+ # progress class
19
+ private
11
20
  def find(region, battletag_name, battletag_id, hero_id)
12
21
  get(region, "profile/#{battletag_name}-#{battletag_id}/hero/#{hero_id}")
13
22
  end
23
+
24
+ def set_method(values)
25
+ self.id = values['id']
26
+ self.name = values['name']
27
+ self.hero_class = values['class']
28
+ self.gender = determine_gender(values['gender'])
29
+ self.level = values['level']
30
+ self.hardcore = values['hardcore']
31
+ self.last_updated = Time.at(values['last-updated'])
32
+ self.items ||= D3api::EquippedItemSet
33
+ .new(values['items'])
34
+ .item_set
35
+ self.active_skills ||= D3api::HeroSkills
36
+ .new('active', values['skills']['active'])
37
+ .skill_set
38
+ self.passive_skills ||= D3api::HeroSkills
39
+ .new('passive', values['skills']['passive'])
40
+ .skill_set
41
+ self.followers ||= D3api::HeroFollowerSet
42
+ .new(values['followers'])
43
+ .follower_set
44
+ end
45
+
46
+ def determine_gender(gender)
47
+ if gender == 0
48
+ 'Male'
49
+ else
50
+ 'Female'
51
+ end
52
+ end
14
53
  end
15
54
  end
@@ -0,0 +1,22 @@
1
+ module D3api
2
+ class HeroFollower
3
+ attr_accessor :follower_type, :slug, :level,
4
+ :items, :skills
5
+
6
+ def initialize(follower_type, attributes)
7
+ follower_type = follower_type
8
+ attributes = attributes
9
+
10
+ set_method(follower_type, attributes)
11
+ end
12
+
13
+ private
14
+ def set_method(follower_type, attributes)
15
+ self.follower_type = follower_type
16
+ self.slug = attributes['slug']
17
+ self.level = attributes['level']
18
+ self.items ||= EquippedItemSet.new(attributes['items']).item_set
19
+ self.skills = nil
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module D3api
2
+ class HeroFollowerSet
3
+ attr_accessor :follower_set
4
+
5
+ def initialize(follower_array)
6
+ followers = []
7
+
8
+ follower_array.each do |follower|
9
+ followers << D3api::HeroFollower.new(follower[0], follower[1])
10
+ end
11
+
12
+ set_method(followers)
13
+ end
14
+
15
+ private
16
+ def set_method(followers)
17
+ self.follower_set ||= followers
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module D3api
2
+ class HeroSet
3
+ attr_accessor :hero_set
4
+
5
+ def initialize(array)
6
+ heroes = []
7
+ array.each do |character|
8
+ heroes << character
9
+ end
10
+
11
+ set_method(heroes)
12
+ end
13
+
14
+ private
15
+ def set_method(heroes)
16
+ self.hero_set = heroes
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module D3api
2
+ class HeroSkills
3
+ attr_accessor :skill_set
4
+
5
+ def initialize(skill_type, *attributes)
6
+ skill_set = []
7
+ attributes[0].each do |attribute|
8
+ skill_set << Skill.new(skill_type, attribute)
9
+ end
10
+
11
+ set_method(skill_set)
12
+ end
13
+
14
+ private
15
+ def set_method(skill_set)
16
+ self.skill_set = skill_set
17
+ end
18
+ end
19
+ end
@@ -1,15 +1,46 @@
1
1
  module D3api
2
2
  class Item < BaseModel
3
- include D3api::Request
3
+ attr_accessor :name, :icon, :tooltip_params, :display_color,
4
+ :required_level, :item_level, :bonus_affixes,
5
+ :attributes, :min_dps, :max_dps, :min_attacks_per_second,
6
+ :max_attacks_per_second, :socket_effects, :salvage
4
7
 
5
8
  def initialize(region, item_hash)
6
9
  json_response = find(region, item_hash)
7
10
 
8
- super json_response
11
+ values = super json_response
12
+
13
+ set_method(values)
9
14
  end
10
15
 
16
+ private
11
17
  def find(region, item_hash)
12
18
  get(region, "data/item/#{item_hash}")
13
19
  end
20
+
21
+ def set_method(values)
22
+ self.name = values['name']
23
+ self.icon = values['icon']
24
+ self.tooltip_params = values['tooltipParams']
25
+ self.display_color = values['displayColor']
26
+ self.required_level = values['requiredLevel']
27
+ self.item_level = values['itemLevel']
28
+ self.bonus_affixes = values['bonusAffixes']
29
+ self.attributes = values['attributes']
30
+
31
+ unless weapon(values)
32
+ self.min_dps = values['dps']['min']
33
+ self.max_dps = values['dps']['max']
34
+ self.min_attacks_per_second = values['attacksPerSecond']['min']
35
+ self.max_attacks_per_second = values['attacksPerSecond']['max']
36
+ end
37
+
38
+ self.salvage = nil
39
+ self.socket_effects = nil
40
+ end
41
+
42
+ def weapon(values)
43
+ values['dps'] == nil
44
+ end
14
45
  end
15
46
  end
@@ -0,0 +1,38 @@
1
+ module D3api
2
+ class Skill
3
+ attr_accessor :skill_type, :skill_slug, :skill_name, :skill_icon,
4
+ :skill_tooltip_url, :skill_description,
5
+ :skill_simple_description, :rune_slug, :rune_type,
6
+ :rune_name, :rune_description, :rune_simple_description,
7
+ :rune_tooltip_params, :rune_order
8
+
9
+ def initialize(skill_type, attributes)
10
+ skill_type = skill_type
11
+ skill = attributes['skill']
12
+ rune = attributes['rune']
13
+
14
+ set_method(skill_type, skill, rune)
15
+ end
16
+
17
+ private
18
+ def set_method(skill_type, skill, rune)
19
+ self.skill_type = skill_type
20
+ self.skill_slug = skill['slug']
21
+ self.skill_name = skill['name']
22
+ self.skill_icon = skill['icon']
23
+ self.skill_tooltip_url = skill['tooltipUrl']
24
+ self.skill_description = skill['description']
25
+ self.skill_simple_description = skill['simpleDescription']
26
+
27
+ if skill_type == 'active'
28
+ self.rune_slug = rune['slug']
29
+ self.rune_type = rune['type']
30
+ self.rune_name = rune['name']
31
+ self.rune_description = rune['description']
32
+ self.rune_simple_description = rune['simpleDescription']
33
+ self.rune_tooltip_params = rune['tooltipParams']
34
+ self.rune_order = rune['order']
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module D3api
2
- VERSION = '0.0.4'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -1,31 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe D3api::Artisan, '.new' do
3
+ describe D3api::Artisan do
4
4
  use_vcr_cassette
5
+ subject { D3api::Artisan.new(:us, 'blacksmith') }
5
6
 
6
- it 'returns a response' do
7
- @artisan = D3api::Artisan.new(:us, 'blacksmith')
8
- @artisan.should_not be_nil
9
- end
10
- end
11
-
12
- describe D3api::Artisan, 'top level hash methods from BaseModel' do
13
- subject { @artisan = D3api::Artisan.new(:us, 'blacksmith') }
14
- use_vcr_cassette
15
-
16
- it 'returns an array for .training' do
17
- subject.training.should be_kind_of(Array)
18
- end
19
-
20
- it 'returns a string for .slug' do
21
- subject.slug.should be_kind_of(String)
7
+ after do
8
+ VCR.eject_cassette
22
9
  end
23
10
 
24
- it 'returns a string for .name' do
25
- subject.name.should be_kind_of(String)
11
+ context '.new' do
12
+ it { should_not be_nil }
26
13
  end
27
14
 
28
- it 'returns a string for .potrait' do
29
- subject.potrait.should be_kind_of(String)
15
+ context '#set_method' do
16
+ its(:slug) { should eql 'blacksmith' }
17
+ its(:name) { should eql 'Blacksmith' }
18
+ its(:portrait) { should eql 'pt_blacksmith' }
19
+ its(:training) { should be nil }
30
20
  end
31
21
  end
@@ -1,59 +1,34 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe D3api::Career, '.new' do
3
+ describe D3api::Career do
4
4
  use_vcr_cassette
5
-
6
- it 'returns a response' do
7
- @career = D3api::Career.new(:us, 'yojymbu', '1249')
8
- @career.should_not be_nil
9
- end
10
- end
11
-
12
- describe D3api::Career, 'top level hash methods from BaseModel' do
13
- use_vcr_cassette
14
- subject { @career = D3api::Career.new(:us, 'yojymbu', '1249') }
15
-
16
- it 'returns an array for .heroes' do
17
- subject.heroes.should be_kind_of(Array)
18
- end
19
-
20
- it 'returns a hero id for .lastHeroPlayed' do
21
- subject.lastHeroPlayed.to_i.should be_kind_of(Integer)
22
- end
23
-
24
- it 'returns a string of numbers for .lastUpdated' do
25
- subject.lastUpdated.should be_kind_of(Integer)
26
- end
27
-
28
- it 'returns an array for .artisans' do
29
- subject.artisans.should be_kind_of(Array)
30
- end
31
-
32
- it 'returns an array for .hardcoreArtisans' do
33
- subject.hardcoreArtisans.should be_kind_of(Array)
34
- end
35
-
36
- it 'returns a hash for .kills' do
37
- subject.kills.should be_kind_of(Hash)
38
- end
39
-
40
- it 'returns a hash for .timePlayed' do
41
- subject.timePlayed.should be_kind_of(Hash)
42
- end
43
-
44
- it 'returns an array for .fallenHeroes' do
45
- subject.fallenHeroes.should be_kind_of(Array)
46
- end
47
-
48
- it 'returns a string for .battleTag' do
49
- subject.battleTag.should be_kind_of(String)
50
- end
51
-
52
- it 'returns an array for .progression' do
53
- subject.progression.should be_kind_of(Array)
54
- end
55
-
56
- it 'returns an array for .hardcoreProgression' do
57
- subject.hardcoreProgression.should be_kind_of(Array)
5
+ subject { D3api::Career.new(:us, 'yojymbu', '1249') }
6
+
7
+ after do
8
+ VCR.eject_cassette
9
+ end
10
+
11
+ context '.new' do
12
+ it { should_not be nil }
13
+ end
14
+
15
+ context '#set_method' do
16
+ its(:last_hero_played) { should be_kind_of(Integer) }
17
+ its(:heroes) { should be_kind_of(Array) }
18
+ its(:last_updated) { should be_kind_of(Time) }
19
+ its(:artisans) { should be_kind_of(Array) }
20
+ its(:hardcore_artisans) { should be_kind_of(Array) }
21
+ its(:monster_kills) { should be_kind_of(Integer) }
22
+ its(:elite_kills) { should be_kind_of(Integer) }
23
+ its(:hardcore_monster_kills) { should be_kind_of(Integer) }
24
+ its(:barbarian_time_played) { should be_kind_of(Float) }
25
+ its(:demon_hunter_time_played) { should be_kind_of(Float) }
26
+ its(:monk_time_played) { should be_kind_of(Float) }
27
+ its(:witch_doctor_time_played) { should be_kind_of(Float) }
28
+ its(:wizard_time_played) { should be_kind_of(Float) }
29
+ its(:fallen_heroes) { should be nil }
30
+ its(:battle_tag) { should eql 'Yojymbu#1249' }
31
+ its(:progression) { should be nil }
32
+ its(:hardcore_progression) { should be nil }
58
33
  end
59
34
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe D3api::EquippedItemSet do
4
+ subject { D3api::EquippedItemSet.new(
5
+ {'head' =>
6
+ {'id' => 'Helm_104',
7
+ 'name' => 'Abyssal Visage',
8
+ 'icon' => 'helm_104_barbarian_male',
9
+ 'displayColor' => 'yellow',
10
+ 'tooltipParams' => 'item/Cj4Ite7E6QkSBwgEFTr1Tl0d0pJdSR0wjxxFHb1b6EgdhgJj6iILCAAVy_4BABgKICAwDTjIA0AASAtQDGD_Axj01PfUC1ACWAA'},
11
+ 'torso'=>
12
+ {'id' => 'ChestArmor_102',
13
+ 'name' => 'Cleansing Mail',
14
+ 'icon' => 'chestarmor_102_barbarian_male',
15
+ 'displayColor' => 'yellow',
16
+ 'tooltipParams' => 'item/CowBCNvS4ewCEgcIBBXqHRlgHRrEUXQdt8Ji6h2eI7xIHQRFP-IiCwgAFcf-AQAYFCAeMAk43AJAAEgGUAxg_QNqJQoMCAAQ5_mb84CAgIA7EhUIm7'}
17
+ }
18
+ )}
19
+
20
+ context '#set_method' do
21
+ its(:item_set) { should be_kind_of(Array) }
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe D3api::EquippedItem do
4
+ subject { D3api::EquippedItem.new(
5
+ [ 'head', {'id' => 'Helm_104',
6
+ 'name' => 'Abyssal Visage',
7
+ 'icon' => 'helm_104_barbarian_male',
8
+ 'displayColor' => 'yellow',
9
+ 'tooltipParams' =>
10
+ 'item/Cj4Ite7E6QkSBwgEFTr1Tl0d0pJdSR0wjxxFHb1b6EgdhgJj6iILCAAVy_4BABgKICAwDTjIA0AASAtQDGD_Axj01PfUC1ACWAA' }
11
+ ]
12
+ ) }
13
+
14
+ context '#set_method' do
15
+ its(:location) { should eql 'head' }
16
+ its(:id) { should eql 'Helm_104' }
17
+ its(:name) { should eql 'Abyssal Visage' }
18
+ its(:icon) { should eql 'helm_104_barbarian_male' }
19
+ its(:display_color) { should eql 'yellow' }
20
+ its(:tooltip_params) { should eql 'item/Cj4Ite7E6QkSBwgEFTr1Tl0d0pJdSR0wjxxFHb1b6EgdhgJj6iILCAAVy_4BABgKICAwDTjIA0AASAtQDGD_Axj01PfUC1ACWAA' }
21
+ end
22
+ end
@@ -1,10 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe D3api::Follower, '.new' do
3
+ describe D3api::Follower do
4
4
  use_vcr_cassette
5
+ subject { D3api::Follower.new(:us, 'scoundrel') }
5
6
 
6
- it 'returns a response' do
7
- @follower = D3api::Follower.new
8
- @follower.should_not be_nil
7
+ after do
8
+ VCR.eject_cassette
9
+ end
10
+
11
+ context '.new' do
12
+ it { should_not be nil }
13
+ end
14
+
15
+ context '#set_method' do
16
+ its(:slug) { should eql 'scoundrel' }
17
+ its(:name) { should eql 'Scoundrel' }
18
+ its(:portrait) { should eql 'scoundrel' }
19
+ its(:skills) { should be nil }
9
20
  end
10
21
  end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe D3api::HeroFollowerSet do
4
+ subject { D3api::HeroFollowerSet.new(
5
+ {'templar'=>
6
+ {'slug' => 'templar',
7
+ 'level' => 8,
8
+ 'items' =>
9
+ {'mainHand' =>
10
+ {'id' => 'Spear_001',
11
+ 'name' => 'Javelin',
12
+ 'icon' => 'spear_001_demonhunter_male',
13
+ 'displayColor' => 'white',
14
+ 'tooltipParams' => 'item/ChkI6MLF7A4SBwgEFQsX9vkwCTiqA0AAYKoDGOmjz2A'},
15
+ 'offHand'=>
16
+ {'id' => 'Shield_001',
17
+ 'name' => 'Buckler',
18
+ 'icon' => 'shield_001_demonhunter_male',
19
+ 'displayColor' => 'white',
20
+ 'tooltipParams' => 'item/ChkIsIumtgkSBwgEFYkDO2wwCTjmBEAAYOYEGJKO2MMN'}},
21
+ 'stats' => {'goldFind' => 0, 'magicFind' => 0, 'experienceBonus' => 0},
22
+ 'skills'=>
23
+ [{'skill'=>
24
+ {'slug'=> 'heal',
25
+ 'name' => 'Heal',
26
+ 'icon' => 'templar_heal_110',
27
+ 'level' => 5,
28
+ 'tooltipUrl' => 'skill/templar/heal',
29
+ 'description' => 'Heals you and the Templar for 4651 Life.\r\n\r\nCooldown: 30 seconds',
30
+ 'simpleDescription' => 'Heals you and the Templar.',
31
+ 'skillCalcId' => 'a'}},
32
+ {},
33
+ {},
34
+ {}]}}
35
+ )
36
+ }
37
+
38
+ context '#set_method' do
39
+ its(:follower_set) { should be_kind_of(Array) }
40
+ end
41
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe D3api::HeroFollower do
4
+ subject { D3api::HeroFollower.new('templar',
5
+ {'slug' => 'templar',
6
+ 'level' => 8,
7
+ 'items'=>
8
+ {'mainHand' =>
9
+ {'id' => 'Spear_001',
10
+ 'name' => 'Javelin',
11
+ 'icon' => 'spear_001_demonhunter_male',
12
+ 'displayColor' => 'white',
13
+ 'tooltipParams' => 'item/ChkI6MLF7A4SBwgEFQsX9vkwCTiqA0AAYKoDGOmjz2A'},
14
+ 'offHand'=>
15
+ {'id' => 'Shield_001',
16
+ 'name' => 'Buckler',
17
+ 'icon' => 'shield_001_demonhunter_male',
18
+ 'displayColor' => 'white',
19
+ 'tooltipParams' => 'item/ChkIsIumtgkSBwgEFYkDO2wwCTjmBEAAYOYEGJKO2MMN'}},
20
+ 'stats'=>{'goldFind' => 0, 'magicFind' => 0, 'experienceBonus' => 0},
21
+ 'skills'=>
22
+ [{'skill'=>
23
+ {'slug' => 'heal',
24
+ 'name' => 'Heal',
25
+ 'icon' => 'templar_heal_110',
26
+ 'level' => 5,
27
+ 'tooltipUrl' => 'skill/templar/heal',
28
+ 'description' => 'Heals you and the Templar for 4651 Life.\r\n\r\nCooldown: 30 seconds',
29
+ 'simpleDescription' => 'Heals you and the Templar.',
30
+ 'skillCalcId' => 'a'}},
31
+ {},
32
+ {},
33
+ {}]}
34
+ )
35
+ }
36
+
37
+ context '#set_method' do
38
+ its(:follower_type) { should eql 'templar' }
39
+ its(:slug) { should eql 'templar'}
40
+ its(:level) { should eql 8 }
41
+ its(:items) { should be_kind_of(Array) }
42
+ its(:skills) { should be nil }
43
+ end
44
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe D3api::HeroSet do
4
+ subject { D3api::HeroSet.new(
5
+ )
6
+ }
7
+
8
+ context '#set_method' do
9
+
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe D3api::HeroSkills do
4
+ subject { D3api::HeroSkills.new('active', [{'skill' =>
5
+ {'slug' => 'cleave',
6
+ 'name' => 'Cleave',
7
+ 'icon' => 'barbarian_cleave',
8
+ 'level' => 3,
9
+ 'categorySlug' => 'primary',
10
+ 'tooltipUrl' => 'skill/barbarian/cleave',
11
+ 'description' => 'Generate: 5 Fury per attack\r\n\r\nSwing your weapon in a wide arc to deal 140% weapon damage to all enemies caught in the swing.',
12
+ 'simpleDescription' => 'Generate: 5 Fury per attack\r\n\r\nSwing your weapon in an arc and strike multiple enemies.',
13
+ 'skillCalcId' => 'b'},
14
+ 'rune'=>
15
+ {'slug' => 'cleave-c',
16
+ 'type' => 'c',
17
+ 'name' => 'Scattering Blast',
18
+ 'level' => 30,
19
+ 'description' => 'On Critical Hits, knock enemies back 9 yards and inflict 60% weapon damage to enemies where they land.',
20
+ 'simpleDescription' => 'Critical Hits cause Knockback, and enemies deal additional damage where they land.',
21
+ 'tooltipParams' => 'rune/cleave/c',
22
+ 'skillCalcId' => 'b',
23
+ 'order' => 2}}]
24
+ )
25
+ }
26
+
27
+ context '#set_method' do
28
+ its(:skill_set) { should be_kind_of(Array) }
29
+ end
30
+ end
@@ -1,10 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe D3api::Hero, '.new' do
3
+ describe D3api::Hero do
4
4
  use_vcr_cassette
5
+ subject { D3api::Hero.new(:us, 'yojymbu', '1249', '30255685') }
5
6
 
6
- it 'returns a response' do
7
- @hero = D3api::Hero.new(:us, 'yojymbu', '1249', '30255685')
8
- @hero.should_not be_nil
7
+ after do
8
+ VCR.eject_cassette
9
+ end
10
+
11
+ context '.new' do
12
+ it { should_not be nil }
13
+ end
14
+
15
+ context '#set_method' do
16
+ its(:id) { should eql 30255685 }
17
+ its(:name) { should eql 'Belgan' }
18
+ its(:hero_class) { should eql 'barbarian' }
19
+ its(:gender) { should eql 'Male' }
20
+ its(:level) { should eql 45 }
21
+ its(:hardcore) { should be_kind_of(TrueClass) }
22
+ its(:last_updated) { should be_kind_of(Time) }
23
+ its(:active_skills) { should be_kind_of(Array) }
24
+ its(:passive_skills) { should be_kind_of(Array) }
25
+ its(:items) { should be_kind_of(Array) }
26
+ its(:followers) { should be_kind_of(Array) }
9
27
  end
10
28
  end
@@ -1,10 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe D3api::Item, '.new' do
3
+ describe D3api::Item do
4
4
  use_vcr_cassette
5
+ subject { D3api::Item.new(:us, 'ChkIsp-JsQsSBwgEFRaK1aUwCTiYBEAAYJgEGNPX06ILUAhYAA') }
5
6
 
6
- it 'returns a response' do
7
- @item = D3api::Item.new(:us, 'ChkIsp-JsQsSBwgEFRaK1aUwCTiYBEAAYJgEGNPX06ILUAhYAA')
8
- @item.should_not be_nil
7
+ after do
8
+ VCR.eject_cassette
9
+ end
10
+
11
+ context '.new' do
12
+ it { should_not be nil}
13
+ end
14
+
15
+ context 'set_method' do
16
+ its(:name) { should eql 'Cloth Pants' }
17
+ its(:icon) { should eql 'pants_001_monk_male' }
18
+ its(:display_color) { should be_kind_of(String) }
19
+ its(:tooltip_params) { should eql 'item/ChkIsp-JsQsSBwgEFRaK1aUwCTiYBEAAYJgEGNPX06ILUAhYAA' }
20
+ its(:required_level) { should eql 1 }
21
+ its(:item_level) { should eql 2 }
22
+ its(:bonus_affixes) { should eql 0 }
23
+ its(:min_dps) { should raise_error }
24
+ its(:max_dps) { should raise_error }
25
+ its(:min_attacks_per_second) { should raise_error }
26
+ its(:max_attacks_per_second) { should raise_error }
27
+ its(:attributes) { should be_kind_of(Array) }
28
+ its(:socket_effects) { should be nil }
29
+ its(:salvage) { should be nil }
9
30
  end
10
31
  end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe D3api::Skill do
4
+ subject { D3api::Skill.new('active', {'skill' =>
5
+ {'slug' => 'cleave',
6
+ 'name' => 'Cleave',
7
+ 'icon' => 'barbarian_cleave',
8
+ 'level' => 3,
9
+ 'categorySlug' => 'primary',
10
+ 'tooltipUrl' => 'skill/barbarian/cleave',
11
+ 'description' => 'Generate: 5 Fury per attack\r\n\r\nSwing your weapon in a wide arc to deal 140% weapon damage to all enemies caught in the swing.',
12
+ 'simpleDescription' => 'Generate: 5 Fury per attack\r\n\r\nSwing your weapon in an arc and strike multiple enemies.',
13
+ 'skillCalcId' => 'b'},
14
+ 'rune'=>
15
+ {'slug' => 'cleave-c',
16
+ 'type' => 'c',
17
+ 'name' => 'Scattering Blast',
18
+ 'level' => 30,
19
+ 'description' => 'On Critical Hits, knock enemies back 9 yards and inflict 60% weapon damage to enemies where they land.',
20
+ 'simpleDescription' => 'Critical Hits cause Knockback, and enemies deal additional damage where they land.',
21
+ 'tooltipParams' => 'rune/cleave/c',
22
+ 'skillCalcId' => 'b',
23
+ 'order' => 2}}
24
+ )
25
+ }
26
+
27
+ context '#set_method' do
28
+ its(:skill_type) { should eql 'active' }
29
+ its(:skill_slug) { should eql 'cleave' }
30
+ its(:skill_name) { should eql 'Cleave' }
31
+ its(:skill_icon) { should eql 'barbarian_cleave' }
32
+ its(:skill_tooltip_url) { should eql 'skill/barbarian/cleave' }
33
+ its(:skill_description) { should eql 'Generate: 5 Fury per attack\r\n\r\nSwing your weapon in a wide arc to deal 140% weapon damage to all enemies caught in the swing.' }
34
+ its(:skill_simple_description) { should eql 'Generate: 5 Fury per attack\r\n\r\nSwing your weapon in an arc and strike multiple enemies.' }
35
+ its(:rune_slug) { should eql 'cleave-c' }
36
+ its(:rune_type) { should eql 'c' }
37
+ its(:rune_name) { should eql 'Scattering Blast' }
38
+ its(:rune_description) { should eql 'On Critical Hits, knock enemies back 9 yards and inflict 60% weapon damage to enemies where they land.' }
39
+ its(:rune_simple_description) { should eql 'Critical Hits cause Knockback, and enemies deal additional damage where they land.' }
40
+ its(:rune_tooltip_params) { should eql 'rune/cleave/c' }
41
+ its(:rune_order) { should eql 2 }
42
+ end
43
+ end
@@ -1,6 +1,9 @@
1
1
  require 'd3api'
2
2
  require 'rspec'
3
3
  require 'vcr'
4
+ require 'simplecov'
5
+
6
+ SimpleCov.start
4
7
 
5
8
  VCR.configure do |config|
6
9
  config.cassette_library_dir = 'spec/cassettes'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: d3api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
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-01-10 00:00:00.000000000 Z
12
+ date: 2013-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -91,6 +91,38 @@ dependencies:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: 2.4.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: pry
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
94
126
  description: Diablo 3 API ruby wrapper
95
127
  email:
96
128
  - phereford@gmail.com
@@ -113,23 +145,47 @@ files:
113
145
  - lib/d3api/career.rb
114
146
  - lib/d3api/configuration.rb
115
147
  - lib/d3api/connection.rb
148
+ - lib/d3api/equipped_item.rb
149
+ - lib/d3api/equipped_item_set.rb
116
150
  - lib/d3api/follower.rb
117
151
  - lib/d3api/hero.rb
152
+ - lib/d3api/hero_follower.rb
153
+ - lib/d3api/hero_follower_set.rb
154
+ - lib/d3api/hero_set.rb
155
+ - lib/d3api/hero_skills.rb
118
156
  - lib/d3api/item.rb
119
157
  - lib/d3api/request.rb
158
+ - lib/d3api/skill.rb
120
159
  - lib/d3api/version.rb
121
160
  - spec/.DS_Store
122
161
  - spec/cassettes/D3api_Artisan.yml
162
+ - spec/cassettes/D3api_Artisan_new.yml
163
+ - spec/cassettes/D3api_Artisan_top_level_hash_methods_from_BaseModel.yml
123
164
  - spec/cassettes/D3api_Career.yml
165
+ - spec/cassettes/D3api_Career_new.yml
166
+ - spec/cassettes/D3api_Career_top_level_hash_methods_from_BaseModel.yml
124
167
  - spec/cassettes/D3api_Follower.yml
168
+ - spec/cassettes/D3api_Follower_new.yml
169
+ - spec/cassettes/D3api_Follower_top_level_hash_to_methods.yml
125
170
  - spec/cassettes/D3api_Hero.yml
171
+ - spec/cassettes/D3api_Hero_new.yml
172
+ - spec/cassettes/D3api_Hero_top_level_hash_to_methods.yml
126
173
  - spec/cassettes/D3api_Item.yml
174
+ - spec/cassettes/D3api_Item_new.yml
175
+ - spec/cassettes/D3api_Item_top_level_hash_to_methods.yml
127
176
  - spec/d3api/.DS_Store
128
177
  - spec/d3api/artisan_spec.rb
129
178
  - spec/d3api/career_spec.rb
179
+ - spec/d3api/equipped_item_set_spec.rb
180
+ - spec/d3api/equipped_item_spec.rb
130
181
  - spec/d3api/follower_spec.rb
182
+ - spec/d3api/hero_follower_set_spec.rb
183
+ - spec/d3api/hero_follower_spec.rb
184
+ - spec/d3api/hero_set_spec.rb
185
+ - spec/d3api/hero_skills_spec.rb
131
186
  - spec/d3api/hero_spec.rb
132
187
  - spec/d3api/item_spec.rb
188
+ - spec/d3api/skills_spec.rb
133
189
  - spec/spec_helper.rb
134
190
  homepage: https://github.com/phereford/d3api
135
191
  licenses: []
@@ -145,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
201
  version: '0'
146
202
  segments:
147
203
  - 0
148
- hash: 796898765737275423
204
+ hash: -1160581402281800813
149
205
  required_rubygems_version: !ruby/object:Gem::Requirement
150
206
  none: false
151
207
  requirements:
@@ -154,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
210
  version: '0'
155
211
  segments:
156
212
  - 0
157
- hash: 796898765737275423
213
+ hash: -1160581402281800813
158
214
  requirements: []
159
215
  rubyforge_project:
160
216
  rubygems_version: 1.8.24
@@ -164,14 +220,31 @@ summary: Blizzard's Diablo 3 API
164
220
  test_files:
165
221
  - spec/.DS_Store
166
222
  - spec/cassettes/D3api_Artisan.yml
223
+ - spec/cassettes/D3api_Artisan_new.yml
224
+ - spec/cassettes/D3api_Artisan_top_level_hash_methods_from_BaseModel.yml
167
225
  - spec/cassettes/D3api_Career.yml
226
+ - spec/cassettes/D3api_Career_new.yml
227
+ - spec/cassettes/D3api_Career_top_level_hash_methods_from_BaseModel.yml
168
228
  - spec/cassettes/D3api_Follower.yml
229
+ - spec/cassettes/D3api_Follower_new.yml
230
+ - spec/cassettes/D3api_Follower_top_level_hash_to_methods.yml
169
231
  - spec/cassettes/D3api_Hero.yml
232
+ - spec/cassettes/D3api_Hero_new.yml
233
+ - spec/cassettes/D3api_Hero_top_level_hash_to_methods.yml
170
234
  - spec/cassettes/D3api_Item.yml
235
+ - spec/cassettes/D3api_Item_new.yml
236
+ - spec/cassettes/D3api_Item_top_level_hash_to_methods.yml
171
237
  - spec/d3api/.DS_Store
172
238
  - spec/d3api/artisan_spec.rb
173
239
  - spec/d3api/career_spec.rb
240
+ - spec/d3api/equipped_item_set_spec.rb
241
+ - spec/d3api/equipped_item_spec.rb
174
242
  - spec/d3api/follower_spec.rb
243
+ - spec/d3api/hero_follower_set_spec.rb
244
+ - spec/d3api/hero_follower_spec.rb
245
+ - spec/d3api/hero_set_spec.rb
246
+ - spec/d3api/hero_skills_spec.rb
175
247
  - spec/d3api/hero_spec.rb
176
248
  - spec/d3api/item_spec.rb
249
+ - spec/d3api/skills_spec.rb
177
250
  - spec/spec_helper.rb