battlenet-api 0.3.0 → 0.3.1
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 +4 -4
- data/battlenet-api.gemspec +1 -0
- data/lib/battlenet/api.rb +0 -2
- data/lib/battlenet/api/client.rb +4 -1
- data/lib/battlenet/api/version.rb +1 -1
- data/lib/battlenet/api/wow_client.rb +19 -26
- data/lib/battlenet/modules/wow/item.rb +1 -1
- data/lib/battlenet/modules/wow/spell.rb +2 -2
- data/spec/battlenetapi_spec.rb +9 -13
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1171469170368aa608c174bbfa4811ae1691f64
|
4
|
+
data.tar.gz: 294f0a5f031bb452b0f775c4287e5c12946fef67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd7db73c41e97aebd1c7acc6dc5148a6bcc10de5ed2076122a86a2bdbbd9cabefc61393041cb99d743dcc3a2b45dcba3401271501cef6a6ea37524f2e75659e5
|
7
|
+
data.tar.gz: 497adf45736781823b0c623d10ef9ec7dfb2176a902cd8b345e4beecfe588d9d5149d807254555d3775c7231f2d6bd94022dda07e973d8f7c08a021c6c17b9a5
|
data/battlenet-api.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "httparty", "~> 0.13"
|
22
22
|
spec.add_runtime_dependency "oauth2", "~> 1.0"
|
23
|
+
spec.add_runtime_dependency "addressable", "~> 2.3"
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/battlenet/api.rb
CHANGED
data/lib/battlenet/api/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'battlenet/api/version'
|
2
2
|
require 'battlenet/api/api_response'
|
3
3
|
require 'httparty'
|
4
|
+
require 'addressable/uri'
|
4
5
|
|
5
6
|
module Battlenet
|
6
7
|
|
@@ -30,6 +31,8 @@ module Battlenet
|
|
30
31
|
'kr.api.battle.net'
|
31
32
|
when :tw
|
32
33
|
'tw.api.battle.net'
|
34
|
+
when :cn
|
35
|
+
'api.battlenet.com.cn'
|
33
36
|
else
|
34
37
|
raise "Invalid region: #{region.to_s}"
|
35
38
|
end
|
@@ -37,7 +40,7 @@ module Battlenet
|
|
37
40
|
|
38
41
|
def endpoint
|
39
42
|
raise "Invalid Game Endpoint" if @endpoint == nil
|
40
|
-
@endpoint
|
43
|
+
Addressable::URI.encode(@endpoint)
|
41
44
|
end
|
42
45
|
|
43
46
|
def get(path, params = {})
|
@@ -13,8 +13,6 @@ require 'battlenet/modules/wow/recipe'
|
|
13
13
|
require 'battlenet/modules/wow/spell'
|
14
14
|
require 'battlenet/modules/wow/data'
|
15
15
|
|
16
|
-
#Dir[File.expand_path('../modules/wow/*.rb', __FILE__)].each{|f| require f}
|
17
|
-
|
18
16
|
module Battlenet
|
19
17
|
|
20
18
|
class WOWClient < Client
|
@@ -27,65 +25,60 @@ module Battlenet
|
|
27
25
|
end
|
28
26
|
|
29
27
|
def character_profile(options = {})
|
30
|
-
|
31
|
-
Battlenet::WOW::CharacterProfile.new(opts)
|
28
|
+
merge_options_and_return_obj(options, Battlenet::WOW::CharacterProfile)
|
32
29
|
end
|
33
30
|
|
34
31
|
def guild_profile(options = {})
|
35
|
-
|
36
|
-
Battlenet::WOW::GuildProfile.new(opts)
|
32
|
+
merge_options_and_return_obj(options, Battlenet::WOW::GuildProfile)
|
37
33
|
end
|
38
34
|
|
39
35
|
def item(options = {})
|
40
|
-
|
41
|
-
Battlenet::WOW::Item.new(opts)
|
36
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Item)
|
42
37
|
end
|
43
38
|
|
44
39
|
def item_set(options = {})
|
45
|
-
|
46
|
-
Battlenet::WOW::ItemSet.new(opts)
|
40
|
+
merge_options_and_return_obj(options, Battlenet::WOW::ItemSet)
|
47
41
|
end
|
48
42
|
|
49
43
|
def achievement(options = {})
|
50
|
-
|
51
|
-
Battlenet::WOW::Achievement.new(opts)
|
44
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Achievement)
|
52
45
|
end
|
53
46
|
|
54
47
|
def auction(options = {})
|
55
|
-
|
56
|
-
Battlenet::WOW::Auction.new(opts)
|
48
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Auction)
|
57
49
|
end
|
58
50
|
|
59
51
|
def pvp_leaderboard(options = {})
|
60
|
-
|
61
|
-
Battlenet::WOW::PVPLeaderboard.new(opts)
|
52
|
+
merge_options_and_return_obj(options, Battlenet::WOW::PVPLeaderboard)
|
62
53
|
end
|
63
54
|
|
64
55
|
def quest(options = {})
|
65
|
-
|
66
|
-
Battlenet::WOW::Quest.new(opts)
|
56
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Quest)
|
67
57
|
end
|
68
58
|
|
69
59
|
def realm(options = {})
|
70
|
-
|
71
|
-
Battlenet::WOW::Realm.new(opts)
|
60
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Realm)
|
72
61
|
end
|
73
62
|
|
74
63
|
def recipe(options = {})
|
75
|
-
|
76
|
-
Battlenet::WOW::Recipe.new(opts)
|
64
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Recipe)
|
77
65
|
end
|
78
66
|
|
79
67
|
def spell(options = {})
|
80
|
-
|
81
|
-
Battlenet::WOW::Spell.new(opts)
|
68
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Spell)
|
82
69
|
end
|
83
70
|
|
84
71
|
def data(options = {})
|
85
|
-
|
86
|
-
Battlenet::WOW::Data.new(opts)
|
72
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Data)
|
87
73
|
end
|
88
74
|
|
75
|
+
private
|
76
|
+
|
77
|
+
def merge_options_and_return_obj(options, obj)
|
78
|
+
opts = options.merge({:client => self})
|
79
|
+
obj.new(opts)
|
80
|
+
end
|
81
|
+
|
89
82
|
end
|
90
83
|
|
91
84
|
end
|
data/spec/battlenetapi_spec.rb
CHANGED
@@ -1,21 +1,17 @@
|
|
1
1
|
require 'battlenet/api'
|
2
2
|
|
3
3
|
describe Battlenet::Client do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
context "when special characters are in realm names" do
|
5
|
+
before do
|
6
|
+
Battlenet.configure do |config|
|
7
|
+
config.api_key = 'test-api'
|
8
|
+
config.region = :eu
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Battlenet.configure do |config|
|
14
|
-
config.region = :us
|
12
|
+
it "should escape spaces in realm names" do
|
13
|
+
c = Battlenet::Client.new({domain: 'http://www.test.com', endpoint: "/emerald dream/mal'ganis"})
|
14
|
+
expect(c.endpoint).to eq('/emerald%20dream/mal\'ganis')
|
15
15
|
end
|
16
|
-
|
17
|
-
b = Battlenet.WOWClient
|
18
|
-
expect(b.region).to eq(:us)
|
19
|
-
|
20
16
|
end
|
21
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: battlenet-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- goodcodeguy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: addressable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.3'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
160
|
version: '0'
|
147
161
|
requirements: []
|
148
162
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.4.5.1
|
150
164
|
signing_key:
|
151
165
|
specification_version: 4
|
152
166
|
summary: Battlenet Client API
|