starcraft2 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/fixtures/vcr_cassettes/achievements.yml +3688 -4
- data/fixtures/vcr_cassettes/rewards.yml +5858 -2
- data/lib/sc2/client.rb +18 -2
- data/spec/sc2/client_spec.rb +48 -18
- metadata +3 -4
- data/sc2.gemspec +0 -22
data/lib/sc2/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module SC2
|
2
2
|
class Client
|
3
3
|
ACHIEVEMENTS_PATH = "/api/sc2/data/achievements"
|
4
|
+
REWARDS_PATH = "/api/sc2/data/rewards"
|
4
5
|
|
5
6
|
attr_accessor :locale, :host
|
6
7
|
|
@@ -14,6 +15,10 @@ module SC2
|
|
14
15
|
Achievement.build_achievements(achievements_data)
|
15
16
|
end
|
16
17
|
|
18
|
+
def rewards
|
19
|
+
Reward.build_rewards(rewards_data)
|
20
|
+
end
|
21
|
+
|
17
22
|
private
|
18
23
|
|
19
24
|
def achievements_data
|
@@ -21,8 +26,19 @@ module SC2
|
|
21
26
|
end
|
22
27
|
|
23
28
|
def achievements_url
|
24
|
-
|
25
|
-
|
29
|
+
"http://" + host + ACHIEVEMENTS_PATH + locale_param
|
30
|
+
end
|
31
|
+
|
32
|
+
def rewards_data
|
33
|
+
HTTParty.get(rewards_url).body
|
34
|
+
end
|
35
|
+
|
36
|
+
def rewards_url
|
37
|
+
"http://" + host + REWARDS_PATH + locale_param
|
38
|
+
end
|
39
|
+
|
40
|
+
def locale_param
|
41
|
+
locale.nil? ? '' : "?locale=#{locale}"
|
26
42
|
end
|
27
43
|
end
|
28
44
|
end
|
data/spec/sc2/client_spec.rb
CHANGED
@@ -11,35 +11,65 @@ describe SC2::Client do
|
|
11
11
|
it 'should store the achievements url' do
|
12
12
|
SC2::Client::ACHIEVEMENTS_PATH.should == '/api/sc2/data/achievements'
|
13
13
|
end
|
14
|
-
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
it 'should store the rewards url' do
|
16
|
+
SC2::Client::REWARDS_PATH.should == '/api/sc2/data/rewards'
|
17
|
+
end
|
19
18
|
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
describe ".initialize" do
|
21
|
+
it 'should store the locale' do
|
22
|
+
@options = { :locale => 'en_US' }
|
23
|
+
client.locale.should == 'en_US'
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
client.
|
26
|
+
it 'should store the host' do
|
27
|
+
@options = { :host => 'someserver.com'}
|
28
|
+
client.host.should == 'someserver.com'
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
describe ".achievements" do
|
33
|
+
it 'should return an array of achievements' do
|
34
|
+
VCR.use_cassette('achievements') do
|
35
|
+
client.achievements.class.should == Array
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return items of type SC2::Achievement' do
|
40
|
+
VCR.use_cassette('achievements') do
|
41
|
+
client.achievements.first.class.should == SC2::Achievement
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return achievements in the correct locale" do
|
46
|
+
@options.merge!({:locale => "pt_BR"})
|
47
|
+
|
48
|
+
VCR.use_cassette('achievements') do
|
49
|
+
client.achievements.first.title.should == "TCT Destruidor"
|
50
|
+
end
|
35
51
|
end
|
36
52
|
end
|
37
53
|
|
38
|
-
|
39
|
-
|
54
|
+
describe ".rewards" do
|
55
|
+
it 'should return an array of rewards' do
|
56
|
+
VCR.use_cassette('rewards') do
|
57
|
+
client.rewards.class.should == Array
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should return items of type SC2::Reward' do
|
62
|
+
VCR.use_cassette('rewards') do
|
63
|
+
client.rewards.first.class.should == SC2::Reward
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return rewards in the correct locale" do
|
68
|
+
@options.merge!({:locale => "pt_BR"})
|
40
69
|
|
41
|
-
|
42
|
-
|
70
|
+
VCR.use_cassette('rewards') do
|
71
|
+
client.rewards.first.title.should == "Kachinsky"
|
72
|
+
end
|
43
73
|
end
|
44
74
|
end
|
45
75
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starcraft2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -114,7 +114,6 @@ files:
|
|
114
114
|
- lib/sc2/loader.rb
|
115
115
|
- lib/sc2/reward.rb
|
116
116
|
- lib/starcraft2.rb
|
117
|
-
- sc2.gemspec
|
118
117
|
- spec/sc2/achievement_spec.rb
|
119
118
|
- spec/sc2/client_spec.rb
|
120
119
|
- spec/sc2/reward_spec.rb
|
@@ -133,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
132
|
version: '0'
|
134
133
|
segments:
|
135
134
|
- 0
|
136
|
-
hash:
|
135
|
+
hash: 2678161590067484758
|
137
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
137
|
none: false
|
139
138
|
requirements:
|
@@ -142,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
141
|
version: '0'
|
143
142
|
segments:
|
144
143
|
- 0
|
145
|
-
hash:
|
144
|
+
hash: 2678161590067484758
|
146
145
|
requirements: []
|
147
146
|
rubyforge_project:
|
148
147
|
rubygems_version: 1.8.25
|
data/sc2.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
Gem::Specification.new do |gem|
|
3
|
-
gem.add_dependency 'httparty'
|
4
|
-
|
5
|
-
gem.authors = ["Josh Ellithorpe", "James Fickel", "Jan Hein Hoogstad"]
|
6
|
-
gem.email = ["quest@mac.com"]
|
7
|
-
gem.description = %q{A small SC2 api wrapper}
|
8
|
-
gem.summary = %q{A small SC2 api wrapper}
|
9
|
-
gem.homepage = ""
|
10
|
-
|
11
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
-
gem.files = `git ls-files`.split("\n")
|
13
|
-
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
14
|
-
gem.name = "starcraft2"
|
15
|
-
gem.require_paths = ["lib"]
|
16
|
-
gem.version = "0.0.1"
|
17
|
-
|
18
|
-
gem.add_development_dependency 'rspec', '~> 2.6.0'
|
19
|
-
gem.add_development_dependency 'rake'
|
20
|
-
gem.add_development_dependency 'vcr'
|
21
|
-
gem.add_development_dependency 'webmock', '1.11'
|
22
|
-
end
|