ruby-lol 0.9.12 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/demo/demo.rb +132 -6
- data/lib/lol/champion.rb +1 -22
- data/lib/lol/champion_request.rb +18 -4
- data/lib/lol/client.rb +2 -0
- data/lib/lol/game.rb +5 -1
- data/lib/lol/{talent.rb → mastery.rb} +2 -6
- data/lib/lol/mastery_page.rb +5 -5
- data/lib/lol/request.rb +10 -2
- data/lib/lol/rune_slot.rb +9 -7
- data/lib/lol/stats_request.rb +1 -1
- data/lib/lol/summoner_request.rb +1 -1
- data/lib/lol/version.rb +1 -1
- data/spec/api_version_spec.rb +3 -3
- data/spec/fixtures/v1.2/get-champion-266.json +8 -0
- data/spec/fixtures/v1.2/get-champion.json +1 -0
- data/spec/fixtures/v1.3/get-ranked_stats.json +1 -0
- data/spec/fixtures/v1.3/get-stats.json +1 -0
- data/spec/fixtures/v1.3/get-summoner-masteries.json +1318 -1318
- data/spec/fixtures/v1.3/get-summoner-runes.json +4086 -4086
- data/spec/fixtures/v1.4/get-summoner-by-name.json +1 -0
- data/spec/fixtures/v1.4/get-summoner-masteries.json +898 -0
- data/spec/fixtures/v1.4/get-summoner-name.json +1 -0
- data/spec/fixtures/v1.4/get-summoner-runes.json +2547 -0
- data/spec/fixtures/v1.4/get-summoner.json +1 -0
- data/spec/lol/champion_request_spec.rb +28 -11
- data/spec/lol/champion_spec.rb +1 -1
- data/spec/lol/client_spec.rb +25 -24
- data/spec/lol/game_spec.rb +1 -1
- data/spec/lol/mastery_page_spec.rb +4 -4
- data/spec/lol/{talent_spec.rb → mastery_spec.rb} +2 -2
- data/spec/lol/model_spec.rb +1 -1
- data/spec/lol/request_spec.rb +6 -1
- data/spec/lol/rune_page_spec.rb +1 -1
- data/spec/lol/rune_slot_spec.rb +0 -10
- metadata +23 -8
- data/lib/lol/rune.rb +0 -23
- data/spec/lol/rune_spec.rb +0 -17
@@ -0,0 +1 @@
|
|
1
|
+
{"30743211":{"id":30743211,"name":"intinig","profileIconId":616,"summonerLevel":30,"revisionDate":1396368924000}}
|
@@ -11,22 +11,39 @@ describe ChampionRequest do
|
|
11
11
|
describe "get" do
|
12
12
|
let(:request) { ChampionRequest.new "api_key", "euw" }
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
context "specifying an id" do
|
15
|
+
subject do
|
16
|
+
expect(request).to receive(:perform_request).with(request.api_url("champion/266", "freeToPlay" => false)).and_return(load_fixture("champion-266", ChampionRequest.api_version, "get"))
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
request.get :id => 266
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
it "returns a champion" do
|
22
|
+
expect(subject).to be_a(Champion)
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
context "getting all" do
|
27
|
+
subject do
|
28
|
+
expect(request).to receive(:perform_request).with(request.api_url("champion", "freeToPlay" => false)).and_return(load_fixture("champion", ChampionRequest.api_version, "get"))
|
29
|
+
|
30
|
+
request.get
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns an array" do
|
34
|
+
expect(subject).to be_a(Array)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns an array of champions" do
|
38
|
+
expect(subject.map {|e| e.class}.uniq).to eq([Champion])
|
39
|
+
end
|
40
|
+
|
41
|
+
it "fetches champions from the API" do
|
42
|
+
expect(subject.size).to eq(load_fixture("champion", ChampionRequest.api_version, "get")["champions"].size)
|
43
|
+
end
|
27
44
|
|
28
|
-
it "fetches champions from the API" do
|
29
|
-
expect(subject.size).to eq(load_fixture("champion", ChampionRequest.api_version, "get")["champions"].size)
|
30
45
|
end
|
46
|
+
|
47
|
+
|
31
48
|
end
|
32
49
|
end
|
data/spec/lol/champion_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Champion do
|
|
8
8
|
let(:valid_attributes) { { id: 1 } }
|
9
9
|
end
|
10
10
|
|
11
|
-
%w(id
|
11
|
+
%w(id active bot_enabled free_to_play bot_mm_enabled ranked_play_enabled).each do |attribute|
|
12
12
|
describe "#{attribute} attribute" do
|
13
13
|
it_behaves_like 'plain attribute' do
|
14
14
|
let(:attribute) { attribute }
|
data/spec/lol/client_spec.rb
CHANGED
@@ -19,30 +19,31 @@ describe Client do
|
|
19
19
|
expect(subject.region).to eq("euw")
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
client
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
22
|
+
context "caching" do
|
23
|
+
let(:client) { Client.new "foo", redis: "redis://dummy-url" }
|
24
|
+
let(:real_redis) { Client.new "foo", redis: "redis://localhost:6379" }
|
25
|
+
|
26
|
+
it "sets caching if redis is specified in the options" do
|
27
|
+
expect(client.cached?).to be_true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "sets a default ttl of 15 * 60s" do
|
31
|
+
expect(client.ttl).to eq(15*60)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "accepts a custom ttl" do
|
35
|
+
client = Client.new "foo", redis: "redis://dummy-url", ttl: 10
|
36
|
+
expect(client.ttl).to eq(10)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "instantiates a redis client if redis is in the options" do
|
40
|
+
expect(real_redis.instance_variable_get(:@redis)).to be_a(Redis)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "passes the redis_store to the request" do
|
44
|
+
champion_request = real_redis.champion
|
45
|
+
expect(champion_request.cache_store).to eq(real_redis.cache_store)
|
46
|
+
end
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
data/spec/lol/game_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Game do
|
|
8
8
|
let(:valid_attributes) { { game_id: 1 } }
|
9
9
|
end
|
10
10
|
|
11
|
-
%w(champion_id game_id game_mode game_type invalid level map_id spell1 spell2 sub_type team_id).each do |attribute|
|
11
|
+
%w(champion_id game_id game_mode game_type invalid ip_earned level map_id spell1 spell2 sub_type team_id).each do |attribute|
|
12
12
|
describe "#{attribute} attribute" do
|
13
13
|
it_behaves_like 'plain attribute' do
|
14
14
|
let(:attribute) { attribute }
|
@@ -15,14 +15,14 @@ describe MasteryPage do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe "#
|
19
|
-
let(:fixture) { load_fixture("summoner-masteries",
|
20
|
-
let(:
|
18
|
+
describe "#masteries" do
|
19
|
+
let(:fixture) { load_fixture("summoner-masteries", SummonerRequest.api_version, "get") }
|
20
|
+
let(:masteries) { fixture["30743211"]["pages"].first["masteries"] }
|
21
21
|
|
22
22
|
subject { MasteryPage.new fixture["30743211"]["pages"].first }
|
23
23
|
|
24
24
|
it "is populated by talents" do
|
25
|
-
expect(subject.
|
25
|
+
expect(subject.masteries.size).to eq(masteries.size)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -3,12 +3,12 @@ require "lol"
|
|
3
3
|
|
4
4
|
include Lol
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe Mastery do
|
7
7
|
it_behaves_like 'Lol model' do
|
8
8
|
let(:valid_attributes) { { id: 1 } }
|
9
9
|
end
|
10
10
|
|
11
|
-
%w(id
|
11
|
+
%w(id rank).each do |attribute|
|
12
12
|
it_behaves_like "plain attribute" do
|
13
13
|
let(:attribute) { attribute }
|
14
14
|
let(:attribute_value) { "asd" }
|
data/spec/lol/model_spec.rb
CHANGED
data/spec/lol/request_spec.rb
CHANGED
@@ -75,7 +75,7 @@ describe Request do
|
|
75
75
|
let(:fake_redis) { FakeRedis.new }
|
76
76
|
let(:request) { Request.new "api_key", "euw", {redis: fake_redis, ttl: 60, cached: true }}
|
77
77
|
before :each do
|
78
|
-
expect(request.class).to receive(:get).with("/foo").and_return({foo: "bar"})
|
78
|
+
expect(request.class).to receive(:get).with("/foo").and_return({foo: "bar"}).at_least(:once)
|
79
79
|
first_result = request.perform_request "/foo"
|
80
80
|
end
|
81
81
|
|
@@ -93,6 +93,11 @@ describe Request do
|
|
93
93
|
it "sets ttl" do
|
94
94
|
expect(fake_redis.get("/foo:ttl")).to eq(60)
|
95
95
|
end
|
96
|
+
|
97
|
+
it "uses clean urls" do
|
98
|
+
expect(request).to receive(:clean_url).at_least(:once)
|
99
|
+
request.perform_request "/foo"
|
100
|
+
end
|
96
101
|
end
|
97
102
|
end
|
98
103
|
|
data/spec/lol/rune_page_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe RunePage do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#slots" do
|
19
|
-
let(:fixture) { load_fixture("summoner-runes",
|
19
|
+
let(:fixture) { load_fixture("summoner-runes", SummonerRequest.api_version, "get") }
|
20
20
|
let(:slots) { fixture["30743211"]["pages"].first["slots"] }
|
21
21
|
|
22
22
|
subject { RunePage.new fixture["30743211"]["pages"].first }
|
data/spec/lol/rune_slot_spec.rb
CHANGED
@@ -13,14 +13,4 @@ describe RuneSlot do
|
|
13
13
|
let(:attribute_value) { "asd" }
|
14
14
|
end
|
15
15
|
|
16
|
-
describe "#rune" do
|
17
|
-
let(:fixture) { load_fixture("summoner-runes", "v1.3", "get") }
|
18
|
-
let(:rune) { fixture["30743211"]["pages"].first["slots"].first["rune"] }
|
19
|
-
|
20
|
-
subject { RuneSlot.new fixture["30743211"]["pages"].first["slots"].first }
|
21
|
-
|
22
|
-
it "is a Rune object" do
|
23
|
-
expect(subject.rune).to be_a(Rune)
|
24
|
-
end
|
25
|
-
end
|
26
16
|
end
|
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.9.
|
4
|
+
version: 0.9.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Intini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -283,6 +283,7 @@ files:
|
|
283
283
|
- lib/lol/league.rb
|
284
284
|
- lib/lol/league_entry.rb
|
285
285
|
- lib/lol/league_request.rb
|
286
|
+
- lib/lol/mastery.rb
|
286
287
|
- lib/lol/mastery_page.rb
|
287
288
|
- lib/lol/match_summary.rb
|
288
289
|
- lib/lol/mini_series.rb
|
@@ -292,14 +293,12 @@ files:
|
|
292
293
|
- lib/lol/ranked_statistics_summary.rb
|
293
294
|
- lib/lol/request.rb
|
294
295
|
- lib/lol/roster.rb
|
295
|
-
- lib/lol/rune.rb
|
296
296
|
- lib/lol/rune_page.rb
|
297
297
|
- lib/lol/rune_slot.rb
|
298
298
|
- lib/lol/static_request.rb
|
299
299
|
- lib/lol/stats_request.rb
|
300
300
|
- lib/lol/summoner.rb
|
301
301
|
- lib/lol/summoner_request.rb
|
302
|
-
- lib/lol/talent.rb
|
303
302
|
- lib/lol/team.rb
|
304
303
|
- lib/lol/team_member.rb
|
305
304
|
- lib/lol/team_request.rb
|
@@ -309,14 +308,23 @@ files:
|
|
309
308
|
- spec/acceptance_spec.rb
|
310
309
|
- spec/api_version_spec.rb
|
311
310
|
- spec/fixtures/v1.1/get-champion.json
|
311
|
+
- spec/fixtures/v1.2/get-champion-266.json
|
312
|
+
- spec/fixtures/v1.2/get-champion.json
|
312
313
|
- spec/fixtures/v1.2/get-ranked_stats.json
|
313
314
|
- spec/fixtures/v1.2/get-stats.json
|
314
315
|
- spec/fixtures/v1.3/get-game.json
|
316
|
+
- spec/fixtures/v1.3/get-ranked_stats.json
|
317
|
+
- spec/fixtures/v1.3/get-stats.json
|
315
318
|
- spec/fixtures/v1.3/get-summoner-by-name.json
|
316
319
|
- spec/fixtures/v1.3/get-summoner-masteries.json
|
317
320
|
- spec/fixtures/v1.3/get-summoner-name.json
|
318
321
|
- spec/fixtures/v1.3/get-summoner-runes.json
|
319
322
|
- spec/fixtures/v1.3/get-summoner.json
|
323
|
+
- spec/fixtures/v1.4/get-summoner-by-name.json
|
324
|
+
- spec/fixtures/v1.4/get-summoner-masteries.json
|
325
|
+
- spec/fixtures/v1.4/get-summoner-name.json
|
326
|
+
- spec/fixtures/v1.4/get-summoner-runes.json
|
327
|
+
- spec/fixtures/v1.4/get-summoner.json
|
320
328
|
- spec/fixtures/v1/get-champion-by-id.json
|
321
329
|
- spec/fixtures/v1/get-champion.json
|
322
330
|
- spec/fixtures/v1/get-item-by-id.json
|
@@ -341,6 +349,7 @@ files:
|
|
341
349
|
- spec/lol/league_request_spec.rb
|
342
350
|
- spec/lol/league_spec.rb
|
343
351
|
- spec/lol/mastery_page_spec.rb
|
352
|
+
- spec/lol/mastery_spec.rb
|
344
353
|
- spec/lol/match_summary_spec.rb
|
345
354
|
- spec/lol/mini_series_spec.rb
|
346
355
|
- spec/lol/model_spec.rb
|
@@ -351,12 +360,10 @@ files:
|
|
351
360
|
- spec/lol/roster_spec.rb
|
352
361
|
- spec/lol/rune_page_spec.rb
|
353
362
|
- spec/lol/rune_slot_spec.rb
|
354
|
-
- spec/lol/rune_spec.rb
|
355
363
|
- spec/lol/static_request_spec.rb
|
356
364
|
- spec/lol/stats_request_spec.rb
|
357
365
|
- spec/lol/summoner_request_spec.rb
|
358
366
|
- spec/lol/summoner_spec.rb
|
359
|
-
- spec/lol/talent_spec.rb
|
360
367
|
- spec/lol/team_member_spec.rb
|
361
368
|
- spec/lol/team_request_spec.rb
|
362
369
|
- spec/lol/team_spec.rb
|
@@ -391,14 +398,23 @@ test_files:
|
|
391
398
|
- spec/acceptance_spec.rb
|
392
399
|
- spec/api_version_spec.rb
|
393
400
|
- spec/fixtures/v1.1/get-champion.json
|
401
|
+
- spec/fixtures/v1.2/get-champion-266.json
|
402
|
+
- spec/fixtures/v1.2/get-champion.json
|
394
403
|
- spec/fixtures/v1.2/get-ranked_stats.json
|
395
404
|
- spec/fixtures/v1.2/get-stats.json
|
396
405
|
- spec/fixtures/v1.3/get-game.json
|
406
|
+
- spec/fixtures/v1.3/get-ranked_stats.json
|
407
|
+
- spec/fixtures/v1.3/get-stats.json
|
397
408
|
- spec/fixtures/v1.3/get-summoner-by-name.json
|
398
409
|
- spec/fixtures/v1.3/get-summoner-masteries.json
|
399
410
|
- spec/fixtures/v1.3/get-summoner-name.json
|
400
411
|
- spec/fixtures/v1.3/get-summoner-runes.json
|
401
412
|
- spec/fixtures/v1.3/get-summoner.json
|
413
|
+
- spec/fixtures/v1.4/get-summoner-by-name.json
|
414
|
+
- spec/fixtures/v1.4/get-summoner-masteries.json
|
415
|
+
- spec/fixtures/v1.4/get-summoner-name.json
|
416
|
+
- spec/fixtures/v1.4/get-summoner-runes.json
|
417
|
+
- spec/fixtures/v1.4/get-summoner.json
|
402
418
|
- spec/fixtures/v1/get-champion-by-id.json
|
403
419
|
- spec/fixtures/v1/get-champion.json
|
404
420
|
- spec/fixtures/v1/get-item-by-id.json
|
@@ -423,6 +439,7 @@ test_files:
|
|
423
439
|
- spec/lol/league_request_spec.rb
|
424
440
|
- spec/lol/league_spec.rb
|
425
441
|
- spec/lol/mastery_page_spec.rb
|
442
|
+
- spec/lol/mastery_spec.rb
|
426
443
|
- spec/lol/match_summary_spec.rb
|
427
444
|
- spec/lol/mini_series_spec.rb
|
428
445
|
- spec/lol/model_spec.rb
|
@@ -433,12 +450,10 @@ test_files:
|
|
433
450
|
- spec/lol/roster_spec.rb
|
434
451
|
- spec/lol/rune_page_spec.rb
|
435
452
|
- spec/lol/rune_slot_spec.rb
|
436
|
-
- spec/lol/rune_spec.rb
|
437
453
|
- spec/lol/static_request_spec.rb
|
438
454
|
- spec/lol/stats_request_spec.rb
|
439
455
|
- spec/lol/summoner_request_spec.rb
|
440
456
|
- spec/lol/summoner_spec.rb
|
441
|
-
- spec/lol/talent_spec.rb
|
442
457
|
- spec/lol/team_member_spec.rb
|
443
458
|
- spec/lol/team_request_spec.rb
|
444
459
|
- spec/lol/team_spec.rb
|
data/lib/lol/rune.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Lol
|
2
|
-
class Rune < Model
|
3
|
-
# @!attribute [r] id
|
4
|
-
# @return [Fixnum] Rune id
|
5
|
-
attr_reader :id
|
6
|
-
|
7
|
-
# @!attribute [r] name
|
8
|
-
# @return [String] Rune name
|
9
|
-
attr_reader :name
|
10
|
-
|
11
|
-
# @!attribute [r] description
|
12
|
-
# @return [String] Rune description
|
13
|
-
attr_reader :description
|
14
|
-
|
15
|
-
# @!attribute [r] tier
|
16
|
-
# @return [Fixnum] Rune tier
|
17
|
-
attr_reader :tier
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_writer :id, :name, :description, :tier
|
22
|
-
end
|
23
|
-
end
|
data/spec/lol/rune_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "lol"
|
3
|
-
|
4
|
-
include Lol
|
5
|
-
|
6
|
-
describe Rune do
|
7
|
-
it_behaves_like 'Lol model' do
|
8
|
-
let(:valid_attributes) { { id: 1 } }
|
9
|
-
end
|
10
|
-
|
11
|
-
%w(id name description tier).each do |attribute|
|
12
|
-
it_behaves_like "plain attribute" do
|
13
|
-
let(:attribute) { attribute }
|
14
|
-
let(:attribute_value) { "asd" }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|