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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a316e32b012140e2b53da8b7e7608cf794d08ed
4
- data.tar.gz: dc4ecf71a16d9c6c7c9553f9b2d0814aff508656
3
+ metadata.gz: a1171469170368aa608c174bbfa4811ae1691f64
4
+ data.tar.gz: 294f0a5f031bb452b0f775c4287e5c12946fef67
5
5
  SHA512:
6
- metadata.gz: b65070319198a863fd5e8110f42d6ca1e9de6d6b73f8c06cb3d9391eb7a791fc61bd752a69bf638073593fd68bdacf006b338576f1ca4b9df866a40c9a426331
7
- data.tar.gz: 5029706a8cbab86b241a855100f96032b8c19a1146bd1fc0b8c10b73e6a29cf3b3505d9b4824151b6fac2471f22c2063f3d8537f4fc7f7b684d755a8d482e918
6
+ metadata.gz: cd7db73c41e97aebd1c7acc6dc5148a6bcc10de5ed2076122a86a2bdbbd9cabefc61393041cb99d743dcc3a2b45dcba3401271501cef6a6ea37524f2e75659e5
7
+ data.tar.gz: 497adf45736781823b0c623d10ef9ec7dfb2176a902cd8b345e4beecfe588d9d5149d807254555d3775c7231f2d6bd94022dda07e973d8f7c08a021c6c17b9a5
@@ -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"
@@ -6,8 +6,6 @@ require File.expand_path('../api/wow_client', __FILE__)
6
6
  require File.expand_path('../api/d3_client', __FILE__)
7
7
  require File.expand_path('../api/sc2_client', __FILE__)
8
8
 
9
-
10
-
11
9
  module Battlenet
12
10
  extend Configuration
13
11
 
@@ -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 = {})
@@ -1,5 +1,5 @@
1
1
  module Battlenet
2
2
  module Api
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
- opts = options.merge({:client => self})
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
@@ -3,7 +3,7 @@ module Battlenet
3
3
  class Item < Battlenet::APIResponse
4
4
 
5
5
  def initialize(options={})
6
- @realm = options.delete(:item)
6
+ @item = options.delete(:item)
7
7
 
8
8
  @endpoint = "/item/#{@item}"
9
9
 
@@ -3,9 +3,9 @@ module Battlenet
3
3
  class Spell < Battlenet::APIResponse
4
4
 
5
5
  def initialize(options={})
6
- @realm = options.delete(:spell)
6
+ @spell = options.delete(:spell)
7
7
 
8
- @endpoint = "/item/#{@spell}"
8
+ @endpoint = "/spell/#{@spell}"
9
9
 
10
10
  super(options)
11
11
  end
@@ -1,21 +1,17 @@
1
1
  require 'battlenet/api'
2
2
 
3
3
  describe Battlenet::Client do
4
- it "should allow you to configure it for a valid region" do
5
- Battlenet.configure do |config|
6
- config.api_key = 'test-api'
7
- config.region = :eu
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
- a = Battlenet.WOWClient
11
- expect(a.region).to eq(:eu)
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.0
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: 2014-12-16 00:00:00.000000000 Z
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.2.2
163
+ rubygems_version: 2.4.5.1
150
164
  signing_key:
151
165
  specification_version: 4
152
166
  summary: Battlenet Client API