diablo_api 0.3.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67d892607284cbfd481222e4e35f79b1fee3f805
4
- data.tar.gz: 48d32278eaff0a10f9c1f1bc2ed45640ee2dab1a
3
+ metadata.gz: 17d33728f1644edd5ec2f75f26db27b58965dd32
4
+ data.tar.gz: 39b170ed1afbcb8e659015297828dc9f74501197
5
5
  SHA512:
6
- metadata.gz: 15e3e0244fd281d99fdc46b1e4dd37ee52c97997063f3dbf983c3363e9d11c1827d07fdd1cc827b5ada2f8071bce314f119b796b4f9e752fe20305946b6a8b4e
7
- data.tar.gz: c1d84cd308bbeb4e6a8b59fee3e53a007d91e5b916a43f6c97f49647ae7ce31f02fecd152ce4a80cb2254a5ea96c800ba2b555c5b37a97f0c9ddaf83810df88d
6
+ metadata.gz: de269fb7dd63d4f7a011c6f82fcec2fe2d882b9cec4fbf31c40be0ffd6668394d172359c23aea7d0990fcb94461c5b7b52b03f9c7254224c86dc3812ba8cac75
7
+ data.tar.gz: 426ffe99a1d37df650e1561eab9281fa78fb988f02d9356430943cb6ee81c6c4dc54e3e79202d977ece46ea290743b2021d36fde9aedf9a3a23e4d6d6facdf2f
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'json'
7
+ gem 'activesupport', '~> 4.2.4'
7
8
 
8
9
  group :development do
9
10
  gem 'guard'
@@ -2,9 +2,12 @@ require 'yaml'
2
2
  require 'open-uri'
3
3
  require 'json'
4
4
  require 'diablo_api/models/profiles/career'
5
+ require 'diablo_api/helper/converter'
5
6
  module DiabloApi
6
7
  class Career
7
8
  include DiabloApi::Profiles::Career
9
+ include DiabloApi::Helper::Converter
10
+
8
11
  attr_reader :region, :locale, :battle_tag, :data
9
12
 
10
13
  def initialize(region, locale, battle_tag)
@@ -16,8 +19,8 @@ module DiabloApi
16
19
 
17
20
  private
18
21
 
19
- def fetch
20
- @data = JSON.load(open(build_url).read)
22
+ def fetch
23
+ @data = convert_hash_keys(JSON.load(open(build_url).read))
21
24
  end
22
25
 
23
26
  def build_url
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'active_support/all'
3
+
4
+ module DiabloApi
5
+ module Helper
6
+ module Converter
7
+
8
+ def convert_hash_keys(value)
9
+ case value
10
+ when Array
11
+ value.map { |v| convert_hash_keys(v) }
12
+ when Hash
13
+ Hash[value.map { |k, v| [underscore_key(k), convert_hash_keys(v)] }]
14
+ else
15
+ value
16
+ end
17
+ end
18
+
19
+ def underscore_key(k)
20
+ k.to_s.underscore.to_sym
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -1,7 +1,11 @@
1
1
  require 'diablo_api/models/profiles/hero'
2
+ require 'diablo_api/helper/converter'
3
+
2
4
  module DiabloApi
3
5
  class Hero
4
6
  include DiabloApi::Profiles::Hero
7
+ include DiabloApi::Helper::Converter
8
+
5
9
  attr_reader :region, :locale, :battle_tag, :hero_id, :data
6
10
 
7
11
  def initialize(region, locale, battle_tag, hero_id)
@@ -15,7 +19,7 @@ module DiabloApi
15
19
  private
16
20
 
17
21
  def fetch
18
- @data = JSON.load(open(build_url).read)
22
+ @data = convert_hash_keys(JSON.load(open(build_url).read))
19
23
  end
20
24
 
21
25
  def build_url
@@ -11,99 +11,99 @@ module DiabloApi
11
11
  end
12
12
 
13
13
  def battle_tag
14
- @data['battleTag']
14
+ @data[:battle_tag]
15
15
  end
16
16
 
17
17
  def paragon_level
18
- @data['paragonLevel']
18
+ @data[:paragon_level]
19
19
  end
20
20
 
21
21
  def paragon_level_hardcore
22
- @data['paragonLevelHardcore']
22
+ @data[:paragon_level_hardcore]
23
23
  end
24
24
 
25
25
  def paragon_level_season
26
- @data['paragonLevelSeason']
26
+ @data[:paragon_level_season]
27
27
  end
28
28
 
29
29
  def paragon_level_season_hardcore
30
- @data['paragonLevelSeasonHardcore']
30
+ @data[:paragon_level_season_hardcore]
31
31
  end
32
32
 
33
33
  def guild_name
34
- @data['guildName']
34
+ @data[:guild_name]
35
35
  end
36
36
 
37
37
  def heroes
38
- @data['heroes']
38
+ @data[:heroes]
39
39
  end
40
40
 
41
41
  def last_hero_played
42
- @data['lastHeroPlayed']
42
+ @data[:last_hero_played]
43
43
  end
44
44
 
45
45
  def last_updated
46
- @data['lastUpdated']
46
+ @data[:last_updated]
47
47
  end
48
48
 
49
49
  def kills
50
- @data['kills']
50
+ @data[:kills]
51
51
  end
52
52
 
53
53
  def highest_hardcore_level
54
- @data['highestHardcoreLevel']
54
+ @data[:highest_hardcore_level]
55
55
  end
56
56
 
57
57
  def time_played
58
- @data['timePlayed']
58
+ @data[:time_played]
59
59
  end
60
60
 
61
61
  def progression
62
- @data['progression']
62
+ @data[:progression]
63
63
  end
64
64
 
65
65
  def fallen_heroes
66
- @data['fallenHeroes']
66
+ @data[:fallen_heroes]
67
67
  end
68
68
 
69
69
  def blacksmith
70
- @data['blacksmith']
70
+ @data[:blacksmith]
71
71
  end
72
72
 
73
73
  def jeweler
74
- @data['jeweler']
74
+ @data[:jeweler]
75
75
  end
76
76
 
77
77
  def mystic
78
- @data['mystic']
78
+ @data[:mystic]
79
79
  end
80
80
 
81
81
  def blacksmith_hardcore
82
- @data['blacksmithHardcore']
82
+ @data[:blacksmith_hardcore]
83
83
  end
84
84
 
85
85
  def jeweler_hardcore
86
- @data['jewelerHardcore']
86
+ @data[:jeweler_hardcore]
87
87
  end
88
88
 
89
89
  def mystic_hardcore
90
- @data['mysticHardcore']
90
+ @data[:mystic_hardcore]
91
91
  end
92
92
 
93
93
  def blacksmith_season
94
- @data['blacksmithSeason']
94
+ @data[:blacksmith_season]
95
95
  end
96
96
 
97
97
  def jeweler_season
98
- @data['jewelerSeason']
98
+ @data[:jeweler_season]
99
99
  end
100
100
 
101
101
  def mystic_season
102
- @data['mysticSeason']
102
+ @data[:mystic_season]
103
103
  end
104
104
 
105
105
  def seasonal_profiles
106
- @data['seasonalProfiles']
106
+ @data[:seasonal_profiles]
107
107
  end
108
108
  end
109
109
  end
@@ -14,75 +14,75 @@ module DiabloApi
14
14
  end
15
15
 
16
16
  def id
17
- @data['id']
17
+ @data[:id]
18
18
  end
19
19
 
20
20
  def name
21
- @data['name']
21
+ @data[:name]
22
22
  end
23
23
 
24
24
  def class
25
- @data['class']
25
+ @data[:class]
26
26
  end
27
27
 
28
28
  def gender
29
- @data['gender']
29
+ @data[:gender]
30
30
  end
31
31
 
32
32
  def level
33
- @data['level']
33
+ @data[:level]
34
34
  end
35
35
 
36
36
  def kills
37
- @data['kills']
37
+ @data[:kills]
38
38
  end
39
39
 
40
40
  def paragon_level
41
- @data['paragonLevel']
41
+ @data[:paragon_level]
42
42
  end
43
43
 
44
44
  def hardcore
45
- @data['hardcore']
45
+ @data[:hardcore]
46
46
  end
47
47
 
48
48
  def seasonal
49
- @data['seasonal']
49
+ @data[:seasonal]
50
50
  end
51
51
 
52
52
  def season_created
53
- @data['seasonCreated']
53
+ @data[:season_created]
54
54
  end
55
55
 
56
56
  def skills
57
- @data['skills']
57
+ @data[:skills]
58
58
  end
59
59
 
60
60
  def items
61
- @data['items']
61
+ @data[:items]
62
62
  end
63
63
 
64
64
  def followers
65
- @data['followers']
65
+ @data[:followers]
66
66
  end
67
67
 
68
68
  def legendary_powers
69
- @data['legendaryPowers']
69
+ @data[:legendary_powers]
70
70
  end
71
71
 
72
72
  def stats
73
- @data['stats']
73
+ @data[:stats]
74
74
  end
75
75
 
76
76
  def progression
77
- @data['progression']
77
+ @data[:progression]
78
78
  end
79
79
 
80
80
  def dead
81
- @data['dead']
81
+ @data[:dead]
82
82
  end
83
83
 
84
84
  def last_updated
85
- @data['last-updated']
85
+ @data[:last_updated]
86
86
  end
87
87
  end
88
88
  end
@@ -1,3 +1,3 @@
1
1
  module DiabloApi
2
- VERSION = '0.3.2'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diablo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-15 00:00:00.000000000 Z
11
+ date: 2015-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,6 +76,7 @@ files:
76
76
  - lib/diablo_api/career.rb
77
77
  - lib/diablo_api/config.rb
78
78
  - lib/diablo_api/converter.rb
79
+ - lib/diablo_api/helper/converter.rb
79
80
  - lib/diablo_api/hero.rb
80
81
  - lib/diablo_api/icons/item.rb
81
82
  - lib/diablo_api/icons/paperdoll.rb