ruby-lol 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lol/current_game_request.rb +1 -1
- data/lib/lol/request.rb +2 -0
- data/lib/lol/version.rb +1 -1
- data/spec/lol/current_game_request_spec.rb +2 -2
- data/spec/lol/request_spec.rb +7 -0
- data/spec/support/helpers.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d75f0fb485dab7a2d3a470defd488b77c74072b
|
4
|
+
data.tar.gz: e0a5ffc51ed377c3f703e727d17fc3008e0afbee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3e13fde1d60a6dda503d731d9174e728def81d92096f71a08c24922452fdeba26b55ec52c922d8ebf19946adfb29303d1bd4c2ab01e457b2df9cc9d191499f0
|
7
|
+
data.tar.gz: 5a013dc8d2150ce1b571cac10d323d62e6997a77b830a826becdf96bf669f29c7f18cca949cd4e0ff60433b886b719e6cce090ada7fb6333a41ac163eb0f529b
|
@@ -9,7 +9,7 @@ module Lol
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def spectator_game_info platform_id, summoner_id
|
12
|
-
url = api_url "getSpectatorGameInfo/#{
|
12
|
+
url = api_url "getSpectatorGameInfo/#{platform_id}/#{summoner_id}"
|
13
13
|
DynamicModel.new perform_request(url)
|
14
14
|
end
|
15
15
|
end
|
data/lib/lol/request.rb
CHANGED
@@ -3,6 +3,7 @@ require "active_support/core_ext/object/to_query"
|
|
3
3
|
|
4
4
|
module Lol
|
5
5
|
class NotFound < StandardError; end
|
6
|
+
class TooManyRequests < StandardError; end
|
6
7
|
class InvalidCacheStore < StandardError; end
|
7
8
|
|
8
9
|
# Encapsulates common methods for all requests
|
@@ -64,6 +65,7 @@ module Lol
|
|
64
65
|
response = self.class.get(url)
|
65
66
|
if response.respond_to?(:code) && !(200...300).include?(response.code)
|
66
67
|
raise NotFound.new("404 Not Found") if response.not_found?
|
68
|
+
raise TooManyRequests.new('429 Rate limit exceeded') if response.code == 429
|
67
69
|
raise InvalidAPIResponse.new(url, response)
|
68
70
|
end
|
69
71
|
|
data/lib/lol/version.rb
CHANGED
@@ -35,13 +35,13 @@ describe Lol::CurrentGameRequest do
|
|
35
35
|
|
36
36
|
it 'returns a DynamicModel' do
|
37
37
|
stub_request subject, 'current-game', expected_url
|
38
|
-
expect(subject.spectator_game_info
|
38
|
+
expect(subject.spectator_game_info 'EUW1', '1').to be_a DynamicModel
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'gives the response to DynamicModel' do
|
42
42
|
allow(subject).to receive(:perform_request).with(instance_of(String)).and_return 'a'
|
43
43
|
expect(Lol::DynamicModel).to receive(:new).with('a').and_return 'foo'
|
44
|
-
subject.spectator_game_info
|
44
|
+
subject.spectator_game_info 'EUW1', '1'
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/spec/lol/request_spec.rb
CHANGED
@@ -33,6 +33,7 @@ describe Request do
|
|
33
33
|
describe "#perform_request" do
|
34
34
|
|
35
35
|
let(:error401) { error_401 }
|
36
|
+
let(:error429) { error_429 }
|
36
37
|
|
37
38
|
it "calls HTTParty get" do
|
38
39
|
expect(subject.class).to receive(:get).and_return(error401)
|
@@ -51,6 +52,12 @@ describe Request do
|
|
51
52
|
expect { subject.perform_request "foo?api_key=asd"}.to raise_error(NotFound)
|
52
53
|
end
|
53
54
|
|
55
|
+
it 'handles 429' do
|
56
|
+
expect(error429).to receive(:respond_to?).and_return(true)
|
57
|
+
expect(subject.class).to receive(:get).and_return(error429)
|
58
|
+
expect { subject.perform_request "foo?api_key=asd"}.to raise_error(TooManyRequests)
|
59
|
+
end
|
60
|
+
|
54
61
|
context "caching" do
|
55
62
|
before :all do
|
56
63
|
class FakeRedis < Redis
|
data/spec/support/helpers.rb
CHANGED
@@ -29,6 +29,15 @@ module Helpers
|
|
29
29
|
response
|
30
30
|
end
|
31
31
|
|
32
|
+
def error_429
|
33
|
+
response = {"status" => {"message" => "Foo", "status_code" => 429}}
|
34
|
+
response.send :instance_eval do
|
35
|
+
def code; 429; end
|
36
|
+
def not_found?; false; end
|
37
|
+
end
|
38
|
+
response
|
39
|
+
end
|
40
|
+
|
32
41
|
def summoners
|
33
42
|
{
|
34
43
|
"euw" => "30743211",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Intini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|