ruby-lol 0.10.0 → 0.11.0

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: 80975c214c65f114acf7846992d778c29b6ccb79
4
- data.tar.gz: 29d6e7696ad53cec98676cc5e7a40c56c964975f
3
+ metadata.gz: 9d75f0fb485dab7a2d3a470defd488b77c74072b
4
+ data.tar.gz: e0a5ffc51ed377c3f703e727d17fc3008e0afbee
5
5
  SHA512:
6
- metadata.gz: 040cb68693bc9d598925e81ecb08701f40e8af9b36bb669203310fad0447a8d843da2d9c9740697ca2c2d78a67e4a33d5192ae36fa922372be2e908cc806dd4a
7
- data.tar.gz: 15d4c5af75898c02b8006399aae26dfb97cb9eb3830e9f6ded1fd0c72edc5da951f641c65ef0273124951956fcbf9bbe37e0e5a1584a7871571d36f46826a125
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/#{region.upcase}#{platform_id}/#{summoner_id}"
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
@@ -1,3 +1,3 @@
1
1
  module Lol
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -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 1, '1').to be_a DynamicModel
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 1, '1'
44
+ subject.spectator_game_info 'EUW1', '1'
45
45
  end
46
46
  end
47
47
  end
@@ -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
@@ -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.10.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-02-09 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler