diablo_api 0.2.0 → 0.3.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: 458f7a00b6060966b65ab4893bbd854fc18fe04c
4
- data.tar.gz: 519f513f6a22d5488ed579b02c72d67f1f43c7bf
3
+ metadata.gz: 2c414e771e4e7d3d73f023759986ebb2a7006cbe
4
+ data.tar.gz: 86f0cdb14ba7ba8e94c6cd8b998dd5f8b768c673
5
5
  SHA512:
6
- metadata.gz: 688f028e0fc382d9ebcd3bb6406f5f062f4170137632ad2b543d9e56b043377fa6d3fbf195a3b2b6d3f752d31021710fc853a7965182e3f4ef714885abc49c08
7
- data.tar.gz: e47bdd75e02fe52478156847bf16cb836cf8b240f1e5eecae4d1009f0c8468d843e705ac0e3ba0daee6ee8adae55d15910d5d5e3d75315a5aeeed9025584b212
6
+ metadata.gz: 7ac3dce1ca72e47459cf16c094ab22bdbb6da0cbd29d1d69ead02c454c3214666ec0459c38a5a439182105af6ba7377454fa0c99f1179f257a2a24ceb447ba67
7
+ data.tar.gz: 283ad4803891f0b50ae010cae1d50d01cf1469b0ff484f138b32f7920dea6361ebb66061c547488257aad701bc3108c70ce9347eea633c60897b5a629d0e552c
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in diablo_api.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'json'
6
7
 
7
8
  group :development do
8
9
  gem 'guard'
data/Guardfile CHANGED
@@ -20,6 +20,7 @@ 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/item_spec.rb')
23
24
  watch('spec/lib/diablo_api/converter_spec.rb')
24
25
  watch('spec/lib/diablo_api/icons/item_spec.rb')
25
26
  watch('spec/lib/diablo_api/icons/paperdoll_spec.rb')
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # DiabloApi
2
2
 
3
- Work in Progress
3
+ This gem use the Blizzard API to get Informations about Diablo 3 characters and items.
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,20 +20,22 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Work in Progress
23
+ 1. Create a developer account on [Blizzards developer portal](https://dev.battle.net/)
24
+ 2. save the developer key do a config file.
25
+ 3. take the data :)
26
+
24
27
 
25
28
  DiabloApi::Config.configure {}
26
29
  DiabloApi::Career.new('eu', 'de_DE', 'Jimmi#2787')
30
+ DiabloApi::Hero.new('eu', 'de_DE', 'Jimmi#2787', '58924397')
27
31
 
28
32
  ## Development
29
33
 
30
34
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
35
 
32
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
-
34
36
  ## Contributing
35
37
 
36
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/diablo_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/swamirama/diablo_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
37
39
 
38
40
 
39
41
  ## License
@@ -1,3 +1,6 @@
1
+ require 'yaml'
2
+ require 'open-uri'
3
+ require 'json'
1
4
  require 'diablo_api/models/profiles/career'
2
5
  module DiabloApi
3
6
  class Career
@@ -0,0 +1,27 @@
1
+ require 'yaml'
2
+ require 'open-uri'
3
+ require 'json'
4
+ require 'diablo_api/models/data/item'
5
+ module DiabloApi
6
+ class Item
7
+ include DiabloApi::Data::Item
8
+ attr_reader :region, :locale, :item_id, :data
9
+
10
+ def initialize(region, locale, item_id)
11
+ @region = region
12
+ @locale = locale
13
+ @item_id = item_id
14
+ fetch
15
+ end
16
+
17
+ private
18
+
19
+ def fetch
20
+ @data = JSON.load(open(build_url).read)
21
+ end
22
+
23
+ def build_url
24
+ "https://#{@region}.api.battle.net/d3/data/item/#{@item_id}?locale=#{@locale}&apikey=#{DiabloApi::Config.configuration.api_key}"
25
+ end
26
+ end
27
+ end
@@ -1,108 +1,116 @@
1
1
  module DiabloApi
2
2
  module Data
3
3
  module Item
4
+ def main_data
5
+ ignore = %w(Hash Array)
6
+ md = {}
7
+ @data.each do |k, v|
8
+ md[k] = v unless ignore.include? v.class.to_s
9
+ end
10
+ md
11
+ end
4
12
  def id
5
- @date['id']
13
+ @data['id']
6
14
  end
7
15
 
8
16
  def name
9
- @date['name']
17
+ @data['name']
10
18
  end
11
19
 
12
20
  def icon
13
- @date['icon']
21
+ @data['icon']
14
22
  end
15
23
 
16
- def displayColor
17
- @date['displayColor']
24
+ def display_color
25
+ @data['displayColor']
18
26
  end
19
27
 
20
- def tooltipParams
21
- @date['tooltipParams']
28
+ def tooltip_params
29
+ @data['tooltipParams']
22
30
  end
23
31
 
24
- def requiredLevel
25
- @date['requiredLevel']
32
+ def required_level
33
+ @data['requiredLevel']
26
34
  end
27
35
 
28
- def itemLevel
29
- @date['itemLevel']
36
+ def item_level
37
+ @data['itemLevel']
30
38
  end
31
39
 
32
- def stackSizeMax
33
- @date['stackSizeMax']
40
+ def stack_size_max
41
+ @data['stackSizeMax']
34
42
  end
35
43
 
36
- def bonusAffixes
37
- @date['bonusAffixes']
44
+ def bonus_affixes
45
+ @data['bonusAffixes']
38
46
  end
39
47
 
40
- def bonusAffixesMax
41
- @date['bonusAffixesMax']
48
+ def bonus_affixes_max
49
+ @data['bonusAffixesMax']
42
50
  end
43
51
 
44
- def accountBound
45
- @date['accountBound']
52
+ def account_bound
53
+ @data['accountBound']
46
54
  end
47
55
 
48
- def flavorText
49
- @date['flavorText']
56
+ def flavor_text
57
+ @data['flavorText']
50
58
  end
51
59
 
52
- def typeName
53
- @date['typeName']
60
+ def type_name
61
+ @data['typeName']
54
62
  end
55
63
 
56
64
  def type
57
- @date['type']
65
+ @data['type']
58
66
  end
59
67
 
60
- def damageRange
61
- @date['damageRange']
68
+ def damage_range
69
+ @data['damageRange']
62
70
  end
63
71
 
64
72
  def slots
65
- @date['slots']
73
+ @data['slots']
66
74
  end
67
75
 
68
76
  def attributes
69
- @date['attributes']
77
+ @data['attributes']
70
78
  end
71
79
 
72
- def attributesRaw
73
- @date['attributesRaw']
80
+ def attributes_raw
81
+ @data['attributesRaw']
74
82
  end
75
83
 
76
- def randomAffixes
77
- @date['randomAffixes']
84
+ def random_affixes
85
+ @data['randomAffixes']
78
86
  end
79
87
 
80
88
  def gems
81
- @date['gems']
89
+ @data['gems']
82
90
  end
83
91
 
84
- def socketEffects
85
- @date['socketEffects']
92
+ def socket_effects
93
+ @data['socketEffects']
86
94
  end
87
95
 
88
- def craftedBy
89
- @date['craftedBy']
96
+ def crafted_by
97
+ @data['craftedBy']
90
98
  end
91
99
 
92
- def seasonRequiredToDrop
93
- @date['seasonRequiredToDrop']
100
+ def season_required_to_drop
101
+ @data['seasonRequiredToDrop']
94
102
  end
95
103
 
96
- def isSeasonRequiredToDrop
97
- @date['isSeasonRequiredToDrop']
104
+ def is_season_required_to_drop
105
+ @data['isSeasonRequiredToDrop']
98
106
  end
99
107
 
100
108
  def description
101
- @date['description']
109
+ @data['description']
102
110
  end
103
111
 
104
- def blockChance
105
- @date['blockChance']
112
+ def block_chance
113
+ @data['blockChance']
106
114
  end
107
115
  end
108
116
  end
@@ -1,7 +1,3 @@
1
- require 'yaml'
2
- require 'open-uri'
3
- require 'json'
4
-
5
1
  module DiabloApi
6
2
  module Profiles
7
3
  module Career
@@ -1,3 +1,3 @@
1
1
  module DiabloApi
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/diablo_api.rb CHANGED
@@ -2,6 +2,7 @@ require 'diablo_api/version'
2
2
  require 'diablo_api/config'
3
3
  require 'diablo_api/career'
4
4
  require 'diablo_api/hero'
5
+ require 'diablo_api/item'
5
6
  require 'diablo_api/converter'
6
7
 
7
8
  module DiabloApi
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.2.0
4
+ version: 0.3.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-14 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,7 @@ files:
81
81
  - lib/diablo_api/icons/paperdoll.rb
82
82
  - lib/diablo_api/icons/portrait.rb
83
83
  - lib/diablo_api/icons/skill.rb
84
+ - lib/diablo_api/item.rb
84
85
  - lib/diablo_api/models/data/artisan.rb
85
86
  - lib/diablo_api/models/data/follower.rb
86
87
  - lib/diablo_api/models/data/item.rb