diablo_api 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d046ef4858a3236fc086d2e235072e830049b656
4
- data.tar.gz: 14917d5e467877afc0661a304dfd1acfaa2e62d1
3
+ metadata.gz: 458f7a00b6060966b65ab4893bbd854fc18fe04c
4
+ data.tar.gz: 519f513f6a22d5488ed579b02c72d67f1f43c7bf
5
5
  SHA512:
6
- metadata.gz: 41c459ecece56634cd0b74d2184e835ac4127c2f61ec6554ed99d13e659bad33d60dd80673caba4005f12d3fcdfcc8e814173323e4c1edd783e98975186b6b11
7
- data.tar.gz: 520b92ed50742e3adb13d1cb68c05983a31f01d79e187b00c7e5e96f25b70fa4e2e8390d3b85bec1c84bee56598ba4250f6ed8907c34dbada38914d6fd503307
6
+ metadata.gz: 688f028e0fc382d9ebcd3bb6406f5f062f4170137632ad2b543d9e56b043377fa6d3fbf195a3b2b6d3f752d31021710fc853a7965182e3f4ef714885abc49c08
7
+ data.tar.gz: e47bdd75e02fe52478156847bf16cb836cf8b240f1e5eecae4d1009f0c8468d843e705ac0e3ba0daee6ee8adae55d15910d5d5e3d75315a5aeeed9025584b212
data/Guardfile CHANGED
@@ -20,4 +20,9 @@ guard :rspec, all_after_pass: false, all_on_start: false, cmd: 'bundle exec rspe
20
20
  watch('spec/lib/diablo_api_spec.rb')
21
21
  watch('spec/lib/diablo_api/career_spec.rb')
22
22
  watch('spec/lib/diablo_api/hero_spec.rb')
23
+ watch('spec/lib/diablo_api/converter_spec.rb')
24
+ watch('spec/lib/diablo_api/icons/item_spec.rb')
25
+ watch('spec/lib/diablo_api/icons/paperdoll_spec.rb')
26
+ watch('spec/lib/diablo_api/icons/portrait_spec.rb')
27
+ watch('spec/lib/diablo_api/icons/skill_spec.rb')
23
28
  end
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # DiabloApi
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/diablo_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Work in Progress
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,10 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ Work in Progress
24
+
25
+ DiabloApi::Config.configure {}
26
+ DiabloApi::Career.new('eu', 'de_DE', 'Jimmi#2787')
26
27
 
27
28
  ## Development
28
29
 
@@ -38,4 +39,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
38
39
  ## License
39
40
 
40
41
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
@@ -13,13 +13,8 @@ module DiabloApi
13
13
  attr_accessor :api_key
14
14
 
15
15
  def initialize
16
- @api_key = ENV["DIABLO_API_KEY"] || YAML.load_file('config/api_key.yaml')['API_KEY']
16
+ @api_key = ENV['DIABLO_API_KEY'] || YAML.load_file('config/api_key.yaml')['API_KEY']
17
17
  end
18
18
  end
19
19
  end
20
20
  end
21
-
22
- # require 'diablo_api'
23
- # DiabloApi::Config.configure do |config
24
- # cconfig.api_key = "my-new-key"
25
- # end
@@ -0,0 +1,18 @@
1
+ module DiabloApi
2
+ module Converter
3
+ def self.gender_number(gender)
4
+ case gender.to_s
5
+ when '0'
6
+ 'male'
7
+ when '1'
8
+ 'female'
9
+ when 'female'
10
+ 'female'
11
+ when 'male'
12
+ 'male'
13
+ else
14
+ fail ArgumentError, "No match for gender: #{gender}"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -19,8 +19,7 @@ module DiabloApi
19
19
  end
20
20
 
21
21
  def build_url
22
-
23
- "https://#{@region}.api.battle.net/d3/profile/#{URI.escape(@battle_tag)}/hero/#{@hero_id}?locale=#{@locale}&apikey=#{DiabloApi::Config.configuration.api_key}"
22
+ "https://#{@region}.api.battle.net/d3/profile/#{URI.escape(@battle_tag)}/hero/#{@hero_id}?locale=#{@locale}&apikey=#{DiabloApi::Config.configuration.api_key}"
24
23
  end
25
24
  end
26
25
  end
@@ -0,0 +1,13 @@
1
+ module DiabloApi
2
+ module Icons
3
+ module Item
4
+ def self.small(icon)
5
+ "http://media.blizzard.com/d3/icons/items/small/#{icon}.png"
6
+ end
7
+
8
+ def self.large(icon)
9
+ "http://media.blizzard.com/d3/icons/items/large/#{icon}.png"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module DiabloApi
2
+ module Icons
3
+ module Paperdoll
4
+ @convert = DiabloApi::Converter
5
+ def self.original(region, hero_class, gender)
6
+ "http://#{region}.battle.net/d3/static/images/profile/hero/paperdoll/#{hero_class}-#{@convert.gender_number gender}.jpg"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ module DiabloApi
2
+ module Icons
3
+ module Portrait
4
+ @convert = DiabloApi::Converter
5
+
6
+ def self.small(hero_class, gender)
7
+ "http://media.blizzard.com/d3/icons/portraits/21/#{hero_class.delete('-')}_#{@convert.gender_number gender}.png"
8
+ end
9
+
10
+ def self.middle(hero_class, gender)
11
+ "http://media.blizzard.com/d3/icons/portraits/42/#{hero_class.delete('-')}_#{@convert.gender_number gender}.png"
12
+ end
13
+
14
+ def self.large(hero_class, gender)
15
+ "http://media.blizzard.com/d3/icons/portraits/64/#{hero_class.delete('-')}_#{@convert.gender_number gender}.png"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module DiabloApi
2
+ module Icons
3
+ module Skill
4
+ def self.small(icon)
5
+ "http://media.blizzard.com/d3/icons/skills/21/#{icon}.png"
6
+ end
7
+
8
+ def self.middle(icon)
9
+ "http://media.blizzard.com/d3/icons/skills/42/#{icon}.png"
10
+ end
11
+
12
+ def self.large(icon)
13
+ "http://media.blizzard.com/d3/icons/skills/64/#{icon}.png"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,109 +1,109 @@
1
1
  module DiabloApi
2
2
  module Data
3
3
  module Item
4
- def id
5
- @date['id']
6
- end
4
+ def id
5
+ @date['id']
6
+ end
7
7
 
8
- def name
9
- @date['name']
10
- end
8
+ def name
9
+ @date['name']
10
+ end
11
11
 
12
- def icon
13
- @date['icon']
14
- end
12
+ def icon
13
+ @date['icon']
14
+ end
15
15
 
16
- def displayColor
17
- @date['displayColor']
18
- end
16
+ def displayColor
17
+ @date['displayColor']
18
+ end
19
19
 
20
- def tooltipParams
21
- @date['tooltipParams']
22
- end
20
+ def tooltipParams
21
+ @date['tooltipParams']
22
+ end
23
23
 
24
- def requiredLevel
25
- @date['requiredLevel']
26
- end
24
+ def requiredLevel
25
+ @date['requiredLevel']
26
+ end
27
27
 
28
- def itemLevel
29
- @date['itemLevel']
30
- end
28
+ def itemLevel
29
+ @date['itemLevel']
30
+ end
31
31
 
32
- def stackSizeMax
33
- @date['stackSizeMax']
34
- end
32
+ def stackSizeMax
33
+ @date['stackSizeMax']
34
+ end
35
35
 
36
- def bonusAffixes
37
- @date['bonusAffixes']
38
- end
36
+ def bonusAffixes
37
+ @date['bonusAffixes']
38
+ end
39
39
 
40
- def bonusAffixesMax
41
- @date['bonusAffixesMax']
42
- end
40
+ def bonusAffixesMax
41
+ @date['bonusAffixesMax']
42
+ end
43
43
 
44
- def accountBound
45
- @date['accountBound']
46
- end
44
+ def accountBound
45
+ @date['accountBound']
46
+ end
47
47
 
48
- def flavorText
49
- @date['flavorText']
50
- end
48
+ def flavorText
49
+ @date['flavorText']
50
+ end
51
51
 
52
- def typeName
53
- @date['typeName']
54
- end
52
+ def typeName
53
+ @date['typeName']
54
+ end
55
55
 
56
- def type
57
- @date['type']
58
- end
56
+ def type
57
+ @date['type']
58
+ end
59
59
 
60
- def damageRange
61
- @date['damageRange']
62
- end
60
+ def damageRange
61
+ @date['damageRange']
62
+ end
63
63
 
64
- def slots
65
- @date['slots']
66
- end
64
+ def slots
65
+ @date['slots']
66
+ end
67
67
 
68
- def attributes
69
- @date['attributes']
70
- end
68
+ def attributes
69
+ @date['attributes']
70
+ end
71
71
 
72
- def attributesRaw
73
- @date['attributesRaw']
74
- end
72
+ def attributesRaw
73
+ @date['attributesRaw']
74
+ end
75
75
 
76
- def randomAffixes
77
- @date['randomAffixes']
78
- end
76
+ def randomAffixes
77
+ @date['randomAffixes']
78
+ end
79
79
 
80
- def gems
81
- @date['gems']
82
- end
80
+ def gems
81
+ @date['gems']
82
+ end
83
83
 
84
- def socketEffects
85
- @date['socketEffects']
86
- end
84
+ def socketEffects
85
+ @date['socketEffects']
86
+ end
87
87
 
88
- def craftedBy
89
- @date['craftedBy']
90
- end
88
+ def craftedBy
89
+ @date['craftedBy']
90
+ end
91
91
 
92
- def seasonRequiredToDrop
93
- @date['seasonRequiredToDrop']
94
- end
92
+ def seasonRequiredToDrop
93
+ @date['seasonRequiredToDrop']
94
+ end
95
95
 
96
- def isSeasonRequiredToDrop
97
- @date['isSeasonRequiredToDrop']
98
- end
96
+ def isSeasonRequiredToDrop
97
+ @date['isSeasonRequiredToDrop']
98
+ end
99
99
 
100
- def description
101
- @date['description']
102
- end
100
+ def description
101
+ @date['description']
102
+ end
103
103
 
104
- def blockChance
105
- @date['blockChance']
106
- end
104
+ def blockChance
105
+ @date['blockChance']
106
+ end
107
107
  end
108
108
  end
109
109
  end
@@ -1,3 +1,3 @@
1
1
  module DiabloApi
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/diablo_api.rb CHANGED
@@ -1,15 +1,9 @@
1
- require "diablo_api/version"
2
- require "diablo_api/config"
3
- require "diablo_api/career"
4
- require "diablo_api/hero"
1
+ require 'diablo_api/version'
2
+ require 'diablo_api/config'
3
+ require 'diablo_api/career'
4
+ require 'diablo_api/hero'
5
+ require 'diablo_api/converter'
5
6
 
6
7
  module DiabloApi
7
- # def self.career(region, locale, battle_tag)
8
- # data = data(region, locale, battle_tag)
9
- # ::Models::Career.new(data)
10
- # end
11
- #
12
- # def self.data(region, locale, battle_tag)
13
- # @data ||= Data.new(region, locale, battle_tag)
14
- # end
8
+
15
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diablo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmi
@@ -75,14 +75,15 @@ files:
75
75
  - lib/diablo_api.rb
76
76
  - lib/diablo_api/career.rb
77
77
  - lib/diablo_api/config.rb
78
+ - lib/diablo_api/converter.rb
78
79
  - lib/diablo_api/hero.rb
80
+ - lib/diablo_api/icons/item.rb
81
+ - lib/diablo_api/icons/paperdoll.rb
82
+ - lib/diablo_api/icons/portrait.rb
83
+ - lib/diablo_api/icons/skill.rb
79
84
  - lib/diablo_api/models/data/artisan.rb
80
85
  - lib/diablo_api/models/data/follower.rb
81
86
  - lib/diablo_api/models/data/item.rb
82
- - lib/diablo_api/models/icons/item.rb
83
- - lib/diablo_api/models/icons/skill.rb
84
- - lib/diablo_api/models/profile/career.rb
85
- - lib/diablo_api/models/profile/hero.rb
86
87
  - lib/diablo_api/models/profiles/career.rb
87
88
  - lib/diablo_api/models/profiles/hero.rb
88
89
  - lib/diablo_api/version.rb
@@ -1,12 +0,0 @@
1
- module DiabloApi
2
- module Icons
3
- module Item
4
- def small(icon)
5
- url = 'http://media.blizzard.com/d3/icons/items/small/' << icon << '.png'
6
- end
7
- def large(icon)
8
- url = 'http://media.blizzard.com/d3/icons/items/large/' << icon << '.png'
9
- end
10
- end
11
- end
12
- end
@@ -1,15 +0,0 @@
1
- module DiabloApi
2
- module Icons
3
- module Skill
4
- def small(icon)
5
- url = 'http://media.blizzard.com/d3/icons/skills/21/' << icon << '.png'
6
- end
7
- def middle(icon)
8
- url = 'http://media.blizzard.com/d3/icons/skills/42/' << icon << '.png'
9
- end
10
- def large(icon)
11
- url = 'http://media.blizzard.com/d3/icons/skills/64/' << icon << '.png'
12
- end
13
- end
14
- end
15
- end
@@ -1,114 +0,0 @@
1
- require 'yaml'
2
- require 'open-uri'
3
- require 'json'
4
-
5
- module DiabloApi
6
- module Profile
7
- module Career
8
- def main_data
9
- ignore = %w(Hash Array)
10
- md = {}
11
- @data.each do |k, v|
12
- md[k] = v unless ignore.include? v.class.to_s
13
- end
14
- md
15
- end
16
-
17
- def battle_tag
18
- @data['battleTag']
19
- end
20
-
21
- def paragon_level
22
- @data['paragonLevel']
23
- end
24
-
25
- def paragon_level_hardcore
26
- @data['paragonLevelHardcore']
27
- end
28
-
29
- def paragon_level_season
30
- @data['paragonLevelSeason']
31
- end
32
-
33
- def paragon_level_season_hardcore
34
- @data['paragonLevelSeasonHardcore']
35
- end
36
-
37
- def guild_name
38
- @data['guildName']
39
- end
40
-
41
- def heroes
42
- @data['heroes']
43
- end
44
-
45
- def last_hero_played
46
- @data['lastHeroPlayed']
47
- end
48
-
49
- def last_updated
50
- @data['lastUpdated']
51
- end
52
-
53
- def kills
54
- @data['kills']
55
- end
56
-
57
- def highest_hardcore_level
58
- @data['highestHardcoreLevel']
59
- end
60
-
61
- def time_played
62
- @data['timePlayed']
63
- end
64
-
65
- def progression
66
- @data['progression']
67
- end
68
-
69
- def fallen_heroes
70
- @data['fallenHeroes']
71
- end
72
-
73
- def blacksmith
74
- @data['blacksmith']
75
- end
76
-
77
- def jeweler
78
- @data['jeweler']
79
- end
80
-
81
- def mystic
82
- @data['mystic']
83
- end
84
-
85
- def blacksmith_hardcore
86
- @data['blacksmithHardcore']
87
- end
88
-
89
- def jeweler_hardcore
90
- @data['jewelerHardcore']
91
- end
92
-
93
- def mystic_hardcore
94
- @data['mysticHardcore']
95
- end
96
-
97
- def blacksmith_season
98
- @data['blacksmithSeason']
99
- end
100
-
101
- def jeweler_season
102
- @data['jewelerSeason']
103
- end
104
-
105
- def mystic_season
106
- @data['mysticSeason']
107
- end
108
-
109
- def seasonal_profiles
110
- @data['seasonalProfiles']
111
- end
112
- end
113
- end
114
- end
@@ -1,89 +0,0 @@
1
- require 'yaml'
2
- require 'open-uri'
3
-
4
- module DiabloApi
5
- module Profile
6
- module Hero
7
- def main_data
8
- ignore = %w(Hash Array)
9
- md = {}
10
- @data.each do |k, v|
11
- md[k] = v unless ignore.include? v.class.to_s
12
- end
13
- md
14
- end
15
-
16
- def id
17
- @data['id']
18
- end
19
-
20
- def name
21
- @data['name']
22
- end
23
-
24
- def class
25
- @data['class']
26
- end
27
-
28
- def gender
29
- @data['gender']
30
- end
31
-
32
- def level
33
- @data['level']
34
- end
35
-
36
- def kills
37
- @data['kills']
38
- end
39
-
40
- def paragon_level
41
- @data['paragonLevel']
42
- end
43
-
44
- def hardcore
45
- @data['hardcore']
46
- end
47
-
48
- def seasonal
49
- @data['seasonal']
50
- end
51
-
52
- def seasonCreated
53
- @data['seasonCreated']
54
- end
55
-
56
- def skills
57
- @data['skills']
58
- end
59
-
60
- def items
61
- @data['items']
62
- end
63
-
64
- def followers
65
- @data['followers']
66
- end
67
-
68
- def legendaryPowers
69
- @data['legendaryPowers']
70
- end
71
-
72
- def stats
73
- @data['stats']
74
- end
75
-
76
- def progression
77
- @data['progression']
78
- end
79
-
80
- def dead
81
- @data['dead']
82
- end
83
-
84
- def last_updated
85
- @data['last-updated']
86
- end
87
- end
88
- end
89
- end