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 +4 -4
- data/Gemfile +1 -0
- data/Guardfile +1 -0
- data/README.md +7 -5
- data/lib/diablo_api/career.rb +3 -0
- data/lib/diablo_api/item.rb +27 -0
- data/lib/diablo_api/models/data/item.rb +52 -44
- data/lib/diablo_api/models/profiles/career.rb +0 -4
- data/lib/diablo_api/version.rb +1 -1
- data/lib/diablo_api.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c414e771e4e7d3d73f023759986ebb2a7006cbe
|
4
|
+
data.tar.gz: 86f0cdb14ba7ba8e94c6cd8b998dd5f8b768c673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ac3dce1ca72e47459cf16c094ab22bdbb6da0cbd29d1d69ead02c454c3214666ec0459c38a5a439182105af6ba7377454fa0c99f1179f257a2a24ceb447ba67
|
7
|
+
data.tar.gz: 283ad4803891f0b50ae010cae1d50d01cf1469b0ff484f138b32f7920dea6361ebb66061c547488257aad701bc3108c70ce9347eea633c60897b5a629d0e552c
|
data/Gemfile
CHANGED
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
|
-
|
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
|
-
|
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/
|
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
|
data/lib/diablo_api/career.rb
CHANGED
@@ -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
|
-
@
|
13
|
+
@data['id']
|
6
14
|
end
|
7
15
|
|
8
16
|
def name
|
9
|
-
@
|
17
|
+
@data['name']
|
10
18
|
end
|
11
19
|
|
12
20
|
def icon
|
13
|
-
@
|
21
|
+
@data['icon']
|
14
22
|
end
|
15
23
|
|
16
|
-
def
|
17
|
-
@
|
24
|
+
def display_color
|
25
|
+
@data['displayColor']
|
18
26
|
end
|
19
27
|
|
20
|
-
def
|
21
|
-
@
|
28
|
+
def tooltip_params
|
29
|
+
@data['tooltipParams']
|
22
30
|
end
|
23
31
|
|
24
|
-
def
|
25
|
-
@
|
32
|
+
def required_level
|
33
|
+
@data['requiredLevel']
|
26
34
|
end
|
27
35
|
|
28
|
-
def
|
29
|
-
@
|
36
|
+
def item_level
|
37
|
+
@data['itemLevel']
|
30
38
|
end
|
31
39
|
|
32
|
-
def
|
33
|
-
@
|
40
|
+
def stack_size_max
|
41
|
+
@data['stackSizeMax']
|
34
42
|
end
|
35
43
|
|
36
|
-
def
|
37
|
-
@
|
44
|
+
def bonus_affixes
|
45
|
+
@data['bonusAffixes']
|
38
46
|
end
|
39
47
|
|
40
|
-
def
|
41
|
-
@
|
48
|
+
def bonus_affixes_max
|
49
|
+
@data['bonusAffixesMax']
|
42
50
|
end
|
43
51
|
|
44
|
-
def
|
45
|
-
@
|
52
|
+
def account_bound
|
53
|
+
@data['accountBound']
|
46
54
|
end
|
47
55
|
|
48
|
-
def
|
49
|
-
@
|
56
|
+
def flavor_text
|
57
|
+
@data['flavorText']
|
50
58
|
end
|
51
59
|
|
52
|
-
def
|
53
|
-
@
|
60
|
+
def type_name
|
61
|
+
@data['typeName']
|
54
62
|
end
|
55
63
|
|
56
64
|
def type
|
57
|
-
@
|
65
|
+
@data['type']
|
58
66
|
end
|
59
67
|
|
60
|
-
def
|
61
|
-
@
|
68
|
+
def damage_range
|
69
|
+
@data['damageRange']
|
62
70
|
end
|
63
71
|
|
64
72
|
def slots
|
65
|
-
@
|
73
|
+
@data['slots']
|
66
74
|
end
|
67
75
|
|
68
76
|
def attributes
|
69
|
-
@
|
77
|
+
@data['attributes']
|
70
78
|
end
|
71
79
|
|
72
|
-
def
|
73
|
-
@
|
80
|
+
def attributes_raw
|
81
|
+
@data['attributesRaw']
|
74
82
|
end
|
75
83
|
|
76
|
-
def
|
77
|
-
@
|
84
|
+
def random_affixes
|
85
|
+
@data['randomAffixes']
|
78
86
|
end
|
79
87
|
|
80
88
|
def gems
|
81
|
-
@
|
89
|
+
@data['gems']
|
82
90
|
end
|
83
91
|
|
84
|
-
def
|
85
|
-
@
|
92
|
+
def socket_effects
|
93
|
+
@data['socketEffects']
|
86
94
|
end
|
87
95
|
|
88
|
-
def
|
89
|
-
@
|
96
|
+
def crafted_by
|
97
|
+
@data['craftedBy']
|
90
98
|
end
|
91
99
|
|
92
|
-
def
|
93
|
-
@
|
100
|
+
def season_required_to_drop
|
101
|
+
@data['seasonRequiredToDrop']
|
94
102
|
end
|
95
103
|
|
96
|
-
def
|
97
|
-
@
|
104
|
+
def is_season_required_to_drop
|
105
|
+
@data['isSeasonRequiredToDrop']
|
98
106
|
end
|
99
107
|
|
100
108
|
def description
|
101
|
-
@
|
109
|
+
@data['description']
|
102
110
|
end
|
103
111
|
|
104
|
-
def
|
105
|
-
@
|
112
|
+
def block_chance
|
113
|
+
@data['blockChance']
|
106
114
|
end
|
107
115
|
end
|
108
116
|
end
|
data/lib/diablo_api/version.rb
CHANGED
data/lib/diablo_api.rb
CHANGED
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.
|
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-
|
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
|