wow_community_api 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,12 +5,16 @@ module WowCommunityApi
5
5
  # TODO: make this configurable?
6
6
  DEFAULT_REGION = Regions::US
7
7
 
8
- def self.region(name)
9
- self.base_uri "#{name}.battle.net/api/wow"
8
+ def self.region
9
+ @@region
10
10
  end
11
- base_uri region(DEFAULT_REGION)
11
+ def self.region=(path)
12
+ @@region = "http://#{path}/api/wow"
13
+ end
14
+ self.region = DEFAULT_REGION
12
15
 
13
16
  def self.get(path, options = {})
17
+ base_uri self.region
14
18
  results = super(URI.encode(path), options)
15
19
  results.parsed_response.to_ostruct if results.response.code == "200"
16
20
  end
@@ -1,8 +1,9 @@
1
1
  module WowCommunityApi
2
2
  class Regions
3
- US = "us"
4
- EU = "eu"
5
- KR = "kr"
6
- TW = "tw"
3
+ US = "us.battle.net"
4
+ EU = "eu.battle.net"
5
+ KR = "kr.battle.net"
6
+ TW = "tw.battle.net"
7
+ CN = "www.battlenet.com.cn"
7
8
  end
8
9
  end
@@ -1,3 +1,3 @@
1
1
  module WowCommunityApi
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -2,19 +2,37 @@ require 'spec_helper'
2
2
 
3
3
  describe BattleNet do
4
4
  describe "#region" do
5
- before(:each) { BattleNet.region(Regions::US) }
5
+ before(:each) { BattleNet.region = Regions::US }
6
6
 
7
7
  it "sets the base uri to a region" do
8
- BattleNet.region(Regions::US).should == "http://us.battle.net/api/wow"
9
- BattleNet.region(Regions::EU).should == "http://eu.battle.net/api/wow"
10
- BattleNet.region(Regions::KR).should == "http://kr.battle.net/api/wow"
11
- BattleNet.region(Regions::TW).should == "http://tw.battle.net/api/wow"
8
+ BattleNet.region = Regions::US
9
+ BattleNet.region.should == "http://us.battle.net/api/wow"
10
+
11
+ BattleNet.region = Regions::EU
12
+ BattleNet.region.should == "http://eu.battle.net/api/wow"
13
+
14
+ BattleNet.region = Regions::KR
15
+ BattleNet.region.should == "http://kr.battle.net/api/wow"
16
+
17
+ BattleNet.region = Regions::TW
18
+ BattleNet.region.should == "http://tw.battle.net/api/wow"
19
+
20
+ BattleNet.region = Regions::CN
21
+ BattleNet.region.should == "http://www.battlenet.com.cn/api/wow"
12
22
  end
13
23
 
14
24
  it "defaults to US region" do
15
25
  BattleNet::DEFAULT_REGION.should == Regions::US
16
26
  end
17
27
 
28
+ it "can switch regions" do
29
+ BattleNet.region = Regions::EU
30
+ BattleNet.region.should == Realm.region
31
+
32
+ BattleNet.region = Regions::KR
33
+ BattleNet.region.should == Realm.region
34
+ end
35
+
18
36
  it "returns nil for 404 not found error" do
19
37
  stub_error 'http://us.battle.net/api/wow/xyz', 404
20
38
 
data/spec/regions_spec.rb CHANGED
@@ -3,19 +3,23 @@ require 'spec_helper'
3
3
  describe Regions do
4
4
  describe "valid regions" do
5
5
  it "supports the united states" do
6
- Regions::US.should == "us"
6
+ Regions::US.should == "us.battle.net"
7
7
  end
8
8
 
9
9
  it "supports europe" do
10
- Regions::EU.should == "eu"
10
+ Regions::EU.should == "eu.battle.net"
11
11
  end
12
12
 
13
13
  it "supports korea" do
14
- Regions::KR.should == "kr"
14
+ Regions::KR.should == "kr.battle.net"
15
15
  end
16
16
 
17
17
  it "supports taiwan" do
18
- Regions::TW.should == "tw"
18
+ Regions::TW.should == "tw.battle.net"
19
+ end
20
+
21
+ it "supports china" do
22
+ Regions::CN.should == "www.battlenet.com.cn"
19
23
  end
20
24
  end
21
25
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wow_community_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 8
10
- version: 0.0.8
5
+ version: 0.1.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - eddie cianci
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-07-22 00:00:00 -04:00
19
- default_executable:
13
+ date: 2011-07-23 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: httparty
@@ -26,9 +20,6 @@ dependencies:
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
23
  version: "0"
33
24
  type: :runtime
34
25
  version_requirements: *id001
@@ -40,9 +31,6 @@ dependencies:
40
31
  requirements:
41
32
  - - ">="
42
33
  - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
34
  version: "0"
47
35
  type: :runtime
48
36
  version_requirements: *id002
@@ -54,9 +42,6 @@ dependencies:
54
42
  requirements:
55
43
  - - ">="
56
44
  - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
45
  version: "0"
61
46
  type: :development
62
47
  version_requirements: *id003
@@ -68,9 +53,6 @@ dependencies:
68
53
  requirements:
69
54
  - - ">="
70
55
  - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
56
  version: "0"
75
57
  type: :development
76
58
  version_requirements: *id004
@@ -82,9 +64,6 @@ dependencies:
82
64
  requirements:
83
65
  - - ">="
84
66
  - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
67
  version: "0"
89
68
  type: :development
90
69
  version_requirements: *id005
@@ -132,7 +111,6 @@ files:
132
111
  - spec/regions_spec.rb
133
112
  - spec/spec_helper.rb
134
113
  - wow_community_api.gemspec
135
- has_rdoc: true
136
114
  homepage: http://github.com/defeated/wow_community_api
137
115
  licenses: []
138
116
 
@@ -146,23 +124,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
124
  requirements:
147
125
  - - ">="
148
126
  - !ruby/object:Gem::Version
149
- hash: 3
150
- segments:
151
- - 0
152
127
  version: "0"
153
128
  required_rubygems_version: !ruby/object:Gem::Requirement
154
129
  none: false
155
130
  requirements:
156
131
  - - ">="
157
132
  - !ruby/object:Gem::Version
158
- hash: 3
159
- segments:
160
- - 0
161
133
  version: "0"
162
134
  requirements: []
163
135
 
164
136
  rubyforge_project: wow_community_api
165
- rubygems_version: 1.6.2
137
+ rubygems_version: 1.8.5
166
138
  signing_key:
167
139
  specification_version: 3
168
140
  summary: World of Warcraft Community Platform API