ruby-lol 0.9.9 → 0.9.10
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 +4 -4
- data/README.md +33 -0
- data/lib/lol/client.rb +5 -0
- data/lib/lol/league_request.rb +1 -1
- data/lib/lol/request.rb +1 -2
- data/lib/lol/static_request.rb +66 -0
- data/lib/lol/version.rb +1 -1
- data/spec/fixtures/v1/get-champion-by-id.json +952 -0
- data/spec/fixtures/v1/get-champion.json +708 -0
- data/spec/fixtures/v1/get-item-by-id.json +5 -0
- data/spec/fixtures/v1/get-item.json +982 -0
- data/spec/fixtures/v1/get-mastery-by-id.json +9 -0
- data/spec/fixtures/v1/get-mastery.json +1359 -0
- data/spec/fixtures/v1/get-realm.json +18 -0
- data/spec/fixtures/v1/get-rune-by-id.json +22 -0
- data/spec/fixtures/v1/get-rune.json +6465 -0
- data/spec/fixtures/v1/get-summoner-spell-by-id.json +64 -0
- data/spec/fixtures/v1/get-summoner-spell.json +657 -0
- data/spec/fixtures/v1.1/get-champion.json +1512 -1
- data/spec/fixtures/v1.2/get-ranked_stats.json +1448 -1
- data/spec/fixtures/v1.2/get-stats.json +115 -1
- data/spec/fixtures/v1.3/get-game.json +1040 -1
- data/spec/fixtures/v1.3/get-summoner-by-name.json +16 -1
- data/spec/fixtures/v1.3/get-summoner-masteries.json +2316 -1
- data/spec/fixtures/v1.3/get-summoner-name.json +4 -1
- data/spec/fixtures/v1.3/get-summoner-runes.json +6374 -1
- data/spec/fixtures/v1.3/get-summoner.json +16 -1
- data/spec/lol/client_spec.rb +12 -0
- data/spec/lol/request_spec.rb +0 -9
- data/spec/lol/static_request_spec.rb +93 -0
- metadata +27 -2
@@ -1 +1,16 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"30743211": {
|
3
|
+
"id": 30743211,
|
4
|
+
"name": "intinig",
|
5
|
+
"profileIconId": 599,
|
6
|
+
"summonerLevel": 30,
|
7
|
+
"revisionDate": 1390360425000
|
8
|
+
},
|
9
|
+
"33249714": {
|
10
|
+
"id": 33249714,
|
11
|
+
"name": "intinir",
|
12
|
+
"profileIconId": 26,
|
13
|
+
"summonerLevel": 30,
|
14
|
+
"revisionDate": 1390538264000
|
15
|
+
}
|
16
|
+
}
|
data/spec/lol/client_spec.rb
CHANGED
@@ -93,6 +93,18 @@ describe Client do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
+
describe "#static" do
|
97
|
+
it "returns an instance of StaticRequest" do
|
98
|
+
expect(subject.static).to be_a(StaticRequest)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "initializes the StaticRequest with the current API key and region" do
|
102
|
+
expect(StaticRequest).to receive(:new).with(subject.api_key, subject.region)
|
103
|
+
|
104
|
+
subject.static
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
96
108
|
describe "#api_key" do
|
97
109
|
it "returns an api key" do
|
98
110
|
expect(subject.api_key).to eq("foo")
|
data/spec/lol/request_spec.rb
CHANGED
@@ -59,15 +59,6 @@ describe Request do
|
|
59
59
|
expect(subject.api_url("bar")).to eq("http://prod.api.pvp.net/api/lol/euw/v1.1/bar?api_key=api_key")
|
60
60
|
end
|
61
61
|
|
62
|
-
it "has lol if url is different from v2.1" do
|
63
|
-
expect(subject.api_url("foo")).to eq("http://prod.api.pvp.net/api/lol/euw/v1.1/foo?api_key=api_key")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "does not have lol only url is v2.1" do
|
67
|
-
expect(Request).to receive(:api_version).at_least(:once).and_return("v2.1")
|
68
|
-
expect(subject.api_url("foo")).to eq("http://prod.api.pvp.net/api/euw/v2.1/foo?api_key=api_key")
|
69
|
-
end
|
70
|
-
|
71
62
|
it "optionally accept query string parameters" do
|
72
63
|
expect(subject.api_url("foo", a: 'b')).to eq("http://prod.api.pvp.net/api/lol/euw/v1.1/foo?a=b&api_key=api_key")
|
73
64
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "lol"
|
3
|
+
|
4
|
+
include Lol
|
5
|
+
|
6
|
+
describe StaticRequest do
|
7
|
+
describe "api_version" do
|
8
|
+
it "is v1" do
|
9
|
+
expect(StaticRequest.api_version).to eq("v1")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:request) { StaticRequest.new "api_key", "euw" }
|
14
|
+
|
15
|
+
describe "api_url" do
|
16
|
+
it "contains a static-data path component" do
|
17
|
+
expect(request.api_url("foo")).to eq("http://prod.api.pvp.net/api/lol/static-data/euw/v1/foo?api_key=api_key")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
StaticRequest::STANDARD_ENDPOINTS.each do |endpoint|
|
22
|
+
describe "##{endpoint}" do
|
23
|
+
it "returns a Proxy" do
|
24
|
+
expect(request.send(endpoint).class).to eq(StaticRequest::Proxy)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#get" do
|
28
|
+
it "proxies get to StaticRequest with the correct endpoint" do
|
29
|
+
expect(request).to receive(:get).with(endpoint, anything, anything)
|
30
|
+
|
31
|
+
request.send(endpoint).get
|
32
|
+
end
|
33
|
+
|
34
|
+
context "without_id" do
|
35
|
+
let(:fixtures) { load_fixture("#{endpoint.dasherize}", StaticRequest.api_version, "get") }
|
36
|
+
|
37
|
+
subject do
|
38
|
+
expect(request).to receive(:perform_request)
|
39
|
+
.with(request.api_url("#{endpoint.dasherize}"))
|
40
|
+
.and_return(fixtures)
|
41
|
+
|
42
|
+
request.send(endpoint).get
|
43
|
+
end
|
44
|
+
|
45
|
+
it "returns an Array" do
|
46
|
+
expect(subject).to be_an(Array)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns an Array of OpenStructs" do
|
50
|
+
expect(subject.map(&:class).uniq).to eq([OpenStruct])
|
51
|
+
end
|
52
|
+
|
53
|
+
it "fetches #{endpoint} from the API" do
|
54
|
+
expect(subject.size).to eq(fixtures["data"].size)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "with_id" do
|
59
|
+
let(:id) { 1 }
|
60
|
+
let(:fixtures) { load_fixture("#{endpoint.dasherize}-by-id", StaticRequest.api_version, "get") }
|
61
|
+
|
62
|
+
subject do
|
63
|
+
expect(request).to receive(:perform_request)
|
64
|
+
.with(request.api_url("#{endpoint.dasherize}/#{id}"))
|
65
|
+
.and_return(fixtures)
|
66
|
+
|
67
|
+
request.send(endpoint).get(id)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "returns an OpenStruct" do
|
71
|
+
expect(subject).to be_an(OpenStruct)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "realm" do
|
79
|
+
let(:fixtures) { load_fixture("realm", StaticRequest.api_version, "get") }
|
80
|
+
|
81
|
+
subject do
|
82
|
+
expect(request).to receive(:perform_request)
|
83
|
+
.with(request.api_url("realm"))
|
84
|
+
.and_return(fixtures)
|
85
|
+
|
86
|
+
request.send("realm").get
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns an OpenStruct" do
|
90
|
+
expect(subject).to be_an(OpenStruct)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
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.10
|
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-02-
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -281,6 +281,7 @@ files:
|
|
281
281
|
- lib/lol/rune.rb
|
282
282
|
- lib/lol/rune_page.rb
|
283
283
|
- lib/lol/rune_slot.rb
|
284
|
+
- lib/lol/static_request.rb
|
284
285
|
- lib/lol/stats_request.rb
|
285
286
|
- lib/lol/summoner.rb
|
286
287
|
- lib/lol/summoner_request.rb
|
@@ -302,6 +303,17 @@ files:
|
|
302
303
|
- spec/fixtures/v1.3/get-summoner-name.json
|
303
304
|
- spec/fixtures/v1.3/get-summoner-runes.json
|
304
305
|
- spec/fixtures/v1.3/get-summoner.json
|
306
|
+
- spec/fixtures/v1/get-champion-by-id.json
|
307
|
+
- spec/fixtures/v1/get-champion.json
|
308
|
+
- spec/fixtures/v1/get-item-by-id.json
|
309
|
+
- spec/fixtures/v1/get-item.json
|
310
|
+
- spec/fixtures/v1/get-mastery-by-id.json
|
311
|
+
- spec/fixtures/v1/get-mastery.json
|
312
|
+
- spec/fixtures/v1/get-realm.json
|
313
|
+
- spec/fixtures/v1/get-rune-by-id.json
|
314
|
+
- spec/fixtures/v1/get-rune.json
|
315
|
+
- spec/fixtures/v1/get-summoner-spell-by-id.json
|
316
|
+
- spec/fixtures/v1/get-summoner-spell.json
|
305
317
|
- spec/fixtures/v2.2/get-team.json
|
306
318
|
- spec/fixtures/v2.3/get-league.json
|
307
319
|
- spec/lol/champion_request_spec.rb
|
@@ -325,6 +337,7 @@ files:
|
|
325
337
|
- spec/lol/rune_page_spec.rb
|
326
338
|
- spec/lol/rune_slot_spec.rb
|
327
339
|
- spec/lol/rune_spec.rb
|
340
|
+
- spec/lol/static_request_spec.rb
|
328
341
|
- spec/lol/stats_request_spec.rb
|
329
342
|
- spec/lol/summoner_request_spec.rb
|
330
343
|
- spec/lol/summoner_spec.rb
|
@@ -371,6 +384,17 @@ test_files:
|
|
371
384
|
- spec/fixtures/v1.3/get-summoner-name.json
|
372
385
|
- spec/fixtures/v1.3/get-summoner-runes.json
|
373
386
|
- spec/fixtures/v1.3/get-summoner.json
|
387
|
+
- spec/fixtures/v1/get-champion-by-id.json
|
388
|
+
- spec/fixtures/v1/get-champion.json
|
389
|
+
- spec/fixtures/v1/get-item-by-id.json
|
390
|
+
- spec/fixtures/v1/get-item.json
|
391
|
+
- spec/fixtures/v1/get-mastery-by-id.json
|
392
|
+
- spec/fixtures/v1/get-mastery.json
|
393
|
+
- spec/fixtures/v1/get-realm.json
|
394
|
+
- spec/fixtures/v1/get-rune-by-id.json
|
395
|
+
- spec/fixtures/v1/get-rune.json
|
396
|
+
- spec/fixtures/v1/get-summoner-spell-by-id.json
|
397
|
+
- spec/fixtures/v1/get-summoner-spell.json
|
374
398
|
- spec/fixtures/v2.2/get-team.json
|
375
399
|
- spec/fixtures/v2.3/get-league.json
|
376
400
|
- spec/lol/champion_request_spec.rb
|
@@ -394,6 +418,7 @@ test_files:
|
|
394
418
|
- spec/lol/rune_page_spec.rb
|
395
419
|
- spec/lol/rune_slot_spec.rb
|
396
420
|
- spec/lol/rune_spec.rb
|
421
|
+
- spec/lol/static_request_spec.rb
|
397
422
|
- spec/lol/stats_request_spec.rb
|
398
423
|
- spec/lol/summoner_request_spec.rb
|
399
424
|
- spec/lol/summoner_spec.rb
|