battlenet-api 0.2.0 → 0.2.1

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: 2f6009e021ba8b5d67293b21b656dea571e959eb
4
- data.tar.gz: 8abe07468e5d82506dd1d7122b639da784bbd9cd
3
+ metadata.gz: 9ecdb5774de9edcb34ab00edd30e7860e6a39aa5
4
+ data.tar.gz: a195dd18da70851049ac3b383d9d0aa85fc15d39
5
5
  SHA512:
6
- metadata.gz: 7031729ba3fe8595c0c256bc2ce5b71bab92379419b82ad715ac76e90778148737df8690a714251f74c16454ee995f1a645b2b8a97ba017ac0ca135aae75c1aa
7
- data.tar.gz: e48e5d71bc7af0633c32ba4787340aec1aac3aa73562f5ea0d18eb5daaa909d140d533cb958296e64ba217b25930823312fcd39c07e9a3738ac9b769fd80dc4b
6
+ metadata.gz: 7211cd747464e9629b52afa718c563bd14633244bd41cec7eb2c7d789adc3bdec4e41c5e397bc3f950d69bb5338ec060a8b196cd15c1451c9b384e205e12dee2
7
+ data.tar.gz: 42b651525a21eba9d339abc56337f44a8adb0103fd2e90937822aa72e629db6b47ecc08e2bb7cc299e1aead06950bd59d35873493357dbe5ee9fa8d32f116325
@@ -0,0 +1,24 @@
1
+ module Battlenet
2
+ class APIResponse
3
+
4
+ def initialize(options={})
5
+ @data = []
6
+ @client = options[:client]
7
+ end
8
+
9
+ def get_data
10
+ unless @client.nil?
11
+ @data = @client.get "/character/#{@realm}/#{@character_name}"
12
+ end
13
+ end
14
+
15
+ def method_missing *args
16
+ if @data.has_key? args[0].to_s
17
+ @data[args[0].to_s]
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -1,4 +1,5 @@
1
1
  require 'battlenet/api/version'
2
+ require 'battlenet/api/api_response'
2
3
  require 'httparty'
3
4
 
4
5
  module Battlenet
@@ -9,8 +10,6 @@ module Battlenet
9
10
  attr_accessor *Configuration::OPTIONS_KEYS
10
11
 
11
12
  def initialize(options={})
12
-
13
- options = Battlenet.options.merge(client_defaults)
14
13
  options = Battlenet.options.merge(options)
15
14
 
16
15
  Configuration::OPTIONS_KEYS.each do |key|
@@ -1,7 +1,6 @@
1
- require 'battlenet/api/client'
1
+ require File.expand_path('../client', __FILE__)
2
2
 
3
- require 'battlenet/modules/d3/profile'
4
- require 'battlenet/modules/d3/data'
3
+ Dir[File.expand_path('../../modules/d3/*.rb', __FILE__)].each{|f| require f}
5
4
 
6
5
  module Battlenet
7
6
 
@@ -9,8 +8,11 @@ module Battlenet
9
8
 
10
9
  include Battlenet::D3
11
10
 
12
- def client_defaults
13
- { :endpoint => '/d3', :region => :us }
11
+ def initialize(options = {})
12
+ client_settings = { :endpoint => '/d3' }
13
+ client_settings = client_settings.merge(options)
14
+
15
+ super(client_settings)
14
16
  end
15
17
 
16
18
  end
@@ -10,10 +10,13 @@ module Battlenet
10
10
 
11
11
  include Battlenet::SC2
12
12
 
13
- def client_defaults
14
- { :endpoint => '/sc2', :region => :us }
13
+ def initialize(options = {})
14
+ client_settings = { :endpoint => '/sc2' }
15
+ client_settings = client_settings.merge(options)
16
+
17
+ super(client_settings)
15
18
  end
16
19
 
17
20
  end
18
-
21
+
19
22
  end
@@ -1,5 +1,5 @@
1
1
  module Battlenet
2
2
  module Api
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -17,11 +17,13 @@ require 'battlenet/modules/wow/data'
17
17
  module Battlenet
18
18
 
19
19
  class WOWClient < Client
20
-
21
20
  include Battlenet::WOW
22
21
 
23
- def client_defaults
24
- { :endpoint => '/wow', :region => :us }
22
+ def initialize(options = {})
23
+ client_settings = { :endpoint => '/wow' }
24
+ client_settings = client_settings.merge(options)
25
+
26
+ super(client_settings)
25
27
  end
26
28
 
27
29
  end
@@ -8,4 +8,4 @@ module Battlenet
8
8
  get "/achievement/#{id}", options
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -0,0 +1,18 @@
1
+ module Battlenet
2
+ module WOW
3
+ class CharacterProfile < Battlenet::APIResponse
4
+
5
+ attr_accessor :name, :realm, :battlegroup, :klass, :race,
6
+ :gender, :level, :achievementPoints, :thumbnail,
7
+ :calcClass, :totalHonorableKills
8
+
9
+ def initialize(options={})
10
+ @realm = options.delete(:realm)
11
+ @character_name = options.delete(:character_name)
12
+
13
+ super(options)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,7 @@
1
1
  require 'uri'
2
2
 
3
+ Dir[File.expand_path('../character/*.rb', __FILE__)].each{|f| require f}
4
+
3
5
  module Battlenet
4
6
  module WOW
5
7
  def character_profile(realm, character_name, options = {})
@@ -111,4 +113,4 @@ module Battlenet
111
113
  character_profile(realm, character_name, options)
112
114
  end
113
115
  end
114
- end
116
+ end
@@ -1,11 +1,21 @@
1
1
  require 'battlenet/api'
2
2
 
3
3
  describe Battlenet::Client do
4
- before(:all) do
4
+ it "should allow you to configure it for a valid region" do
5
5
  Battlenet.configure do |config|
6
6
  config.api_key = 'test-api'
7
- config.region = :us
7
+ config.region = :eu
8
+ end
9
+
10
+ a = Battlenet.WOWClient
11
+ expect(a.region).to eq(:eu)
12
+
13
+ Battlenet.configure do |config|
14
+ config.region = :us
8
15
  end
9
- end
10
16
 
17
+ b = Battlenet.WOWClient
18
+ expect(b.region).to eq(:us)
19
+
20
+ end
11
21
  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.2.0
4
+ version: 0.2.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-11-16 00:00:00.000000000 Z
11
+ date: 2014-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -95,6 +95,7 @@ files:
95
95
  - battlenet-api.gemspec
96
96
  - examples/example_oauth.rb
97
97
  - lib/battlenet/api.rb
98
+ - lib/battlenet/api/api_response.rb
98
99
  - lib/battlenet/api/client.rb
99
100
  - lib/battlenet/api/configuration.rb
100
101
  - lib/battlenet/api/d3_client.rb
@@ -110,6 +111,7 @@ files:
110
111
  - lib/battlenet/modules/wow/auction_data_status.rb
111
112
  - lib/battlenet/modules/wow/battlepet.rb
112
113
  - lib/battlenet/modules/wow/challenge_mode.rb
114
+ - lib/battlenet/modules/wow/character/character_profile.rb
113
115
  - lib/battlenet/modules/wow/character_profile.rb
114
116
  - lib/battlenet/modules/wow/data.rb
115
117
  - lib/battlenet/modules/wow/guild.rb