league_of_legends 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/league_of_legends.gemspec +3 -0
- data/lib/league_of_legends/api.rb +2 -2
- data/lib/league_of_legends/dto/player_stats_summary_list.rb +2 -1
- data/lib/league_of_legends/request/all.rb +1 -0
- data/lib/league_of_legends/request/champion.rb +46 -0
- data/lib/league_of_legends/request/mapper.rb +4 -1
- data/lib/league_of_legends/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/api_spec_champions.yml +46 -0
- data/spec/fixtures/vcr_cassettes/api_spec_summoner_stats_summary.yml +46 -0
- data/spec/fixtures/vcr_cassettes/champion_spec_f2p.yml +46 -0
- data/spec/fixtures/vcr_cassettes/summary_spec_stats_by_summoner.yml +46 -0
- data/spec/league_of_legends/api_spec.rb +10 -6
- data/spec/league_of_legends/request/champion_spec.rb +33 -0
- data/spec/league_of_legends/request/mapper_spec.rb +2 -0
- data/spec/league_of_legends/request/stats/by_summoner/summary_spec.rb +4 -2
- data/spec/setup_vcr.rb +6 -0
- metadata +63 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aee1eefe05daf8e323f53035ef34e2101d7644a0
|
4
|
+
data.tar.gz: 00661785cdfbe4c54b9a6c89e67ef9695439bca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 421dfdc2975c3ac35fb14cc11530e217da467c060acdf4829978e3ce82d8066b82b55e4058071a2152e5a8da54dca13738779675df7ccf7e8eb25e949250111d
|
7
|
+
data.tar.gz: efc9fb5d4d82ca1d45988e7bae7780ef3677f77e8e018422bea3a6e399f2eca8187319a53b7483b2d29d5802d2f964994ee5c12a349e7a45f3c275e6f5b3c601
|
data/README.md
CHANGED
@@ -26,11 +26,14 @@ The gem is still a work in progress and has limited functionality.
|
|
26
26
|
lol_api = ::LeagueOfLegends::Api.new <api key>
|
27
27
|
|
28
28
|
# get all available request types
|
29
|
-
lol_api.
|
29
|
+
lol_api.available_requests
|
30
30
|
|
31
31
|
# execute a request
|
32
32
|
result_dto = lol_api.get(:summoner_stats_summary, <summoner id>)
|
33
33
|
|
34
|
+
# total number of victories
|
35
|
+
result_dto.player_stat_summaries.map(&:wins).reduce(&:+)
|
36
|
+
|
34
37
|
|
35
38
|
In this example, the DTO returned is a `::LeagueOfLegends::DTO::PlayerStatsSummaryList`.
|
36
39
|
|
data/league_of_legends.gemspec
CHANGED
@@ -23,4 +23,7 @@ This product is not endorsed, certified or otherwise approved in any way by Riot
|
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.5"
|
25
25
|
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec", "~> 2.14.1"
|
27
|
+
spec.add_development_dependency "vcr", "~> 2.8"
|
28
|
+
spec.add_development_dependency "webmock", ">= 1.8.0", "< 1.16"
|
26
29
|
end
|
@@ -44,7 +44,7 @@ module ::LeagueOfLegends
|
|
44
44
|
raise ArgumentError.new 'wrong number of arguments (0 for 1)'
|
45
45
|
when String
|
46
46
|
if key =~ /^\h{8}(-\h{4}){3}-\h{12}$/
|
47
|
-
@key = key
|
47
|
+
@key = key.chomp
|
48
48
|
else
|
49
49
|
raise ArgumentError.new 'key with incorrect format'
|
50
50
|
end
|
@@ -57,7 +57,7 @@ module ::LeagueOfLegends
|
|
57
57
|
require 'uri'
|
58
58
|
|
59
59
|
if base_url =~ /^#{URI::regexp}$/o
|
60
|
-
@base_url = base_url
|
60
|
+
@base_url = base_url.chomp
|
61
61
|
else
|
62
62
|
raise ArgumentError.new 'expected a valid URL'
|
63
63
|
end
|
@@ -13,8 +13,9 @@ module ::LeagueOfLegends
|
|
13
13
|
|
14
14
|
def initialize json
|
15
15
|
attributes = build_attributes json
|
16
|
+
|
16
17
|
@summoner_id = attributes[:summonerId].to_i
|
17
|
-
@player_stat_summaries = attributes[:playerStatSummaries].map do |pss|
|
18
|
+
@player_stat_summaries = attributes[:playerStatSummaries].to_a.map do |pss|
|
18
19
|
::LeagueOfLegends::DTO::PlayerStatsSummary.new(pss)
|
19
20
|
end
|
20
21
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'league_of_legends/request/base'
|
2
|
+
require 'league_of_legends/dto/champion'
|
3
|
+
|
4
|
+
module ::LeagueOfLegends
|
5
|
+
module Request
|
6
|
+
class Champion < ::LeagueOfLegends::Request::Base
|
7
|
+
|
8
|
+
attr_reader :free_to_play
|
9
|
+
|
10
|
+
def initialize api, free_to_play, options = {}
|
11
|
+
super(api, options)
|
12
|
+
@free_to_play = parse_f2p free_to_play
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.dto_class
|
16
|
+
::LeagueOfLegends::DTO::ChampionList
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def base_url
|
22
|
+
super << "champion"
|
23
|
+
end
|
24
|
+
|
25
|
+
def url_parameters
|
26
|
+
if free_to_play.nil?
|
27
|
+
super
|
28
|
+
else
|
29
|
+
super << "freeToPlay=#{free_to_play}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def parse_f2p f2p
|
36
|
+
case f2p
|
37
|
+
when TrueClass, FalseClass
|
38
|
+
f2p.to_s
|
39
|
+
else
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://prod.api.pvp.net/api/lol/euw/v1.1/champion?api_key=a1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1&freeToPlay=true
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- prod.api.pvp.net
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Access-Control-Allow-Headers:
|
24
|
+
- Content-Type
|
25
|
+
Access-Control-Allow-Methods:
|
26
|
+
- GET, POST, DELETE, PUT
|
27
|
+
Access-Control-Allow-Origin:
|
28
|
+
- '*'
|
29
|
+
Content-Type:
|
30
|
+
- application/json;charset=UTF-8
|
31
|
+
Date:
|
32
|
+
- Wed, 29 Jan 2014 18:20:21 GMT
|
33
|
+
Server:
|
34
|
+
- Jetty(9.1.0.v20131115)
|
35
|
+
X-Newrelic-App-Data:
|
36
|
+
- PxQFWFFSDwQTVVdUBAgPUkYdFGQHBDcQUQxLA1tMXV1dORYzVBBGBxdCdhUSEVFRRRAEPhhQRw84HlpcDjpMB0UVZE1OCRoDb0paCVAMQwsLWBVNVk0IHwRKUlsPBwMjSQUaHlNKQVZVAApbCAsBUwJWXANXAwBAOQ==
|
37
|
+
Content-Length:
|
38
|
+
- '1879'
|
39
|
+
Connection:
|
40
|
+
- keep-alive
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"champions":[{"id":22,"name":"Ashe","active":true,"attackRank":7,"defenseRank":3,"magicRank":2,"difficultyRank":4,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true},{"id":114,"name":"Fiora","active":true,"attackRank":10,"defenseRank":4,"magicRank":2,"difficultyRank":5,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":126,"name":"Jayce","active":true,"attackRank":8,"defenseRank":4,"magicRank":3,"difficultyRank":8,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":85,"name":"Kennen","active":true,"attackRank":6,"defenseRank":4,"magicRank":7,"difficultyRank":5,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":117,"name":"Lulu","active":true,"attackRank":4,"defenseRank":5,"magicRank":7,"difficultyRank":7,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":56,"name":"Nocturne","active":true,"attackRank":9,"defenseRank":5,"magicRank":2,"difficultyRank":6,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":80,"name":"Pantheon","active":true,"attackRank":9,"defenseRank":4,"magicRank":3,"difficultyRank":5,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":133,"name":"Quinn","active":true,"attackRank":9,"defenseRank":4,"magicRank":2,"difficultyRank":7,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":37,"name":"Sona","active":true,"attackRank":5,"defenseRank":2,"magicRank":8,"difficultyRank":1,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true},{"id":5,"name":"XinZhao","active":true,"attackRank":8,"defenseRank":6,"magicRank":3,"difficultyRank":3,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true}]}'
|
44
|
+
http_version:
|
45
|
+
recorded_at: Wed, 29 Jan 2014 18:20:21 GMT
|
46
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://prod.api.pvp.net/api/lol/euw/v1.2/stats/by-summoner/50519866/summary?api_key=a1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- prod.api.pvp.net
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Access-Control-Allow-Headers:
|
24
|
+
- Content-Type
|
25
|
+
Access-Control-Allow-Methods:
|
26
|
+
- GET, POST, DELETE, PUT
|
27
|
+
Access-Control-Allow-Origin:
|
28
|
+
- '*'
|
29
|
+
Content-Type:
|
30
|
+
- application/json;charset=UTF-8
|
31
|
+
Date:
|
32
|
+
- Wed, 29 Jan 2014 18:20:20 GMT
|
33
|
+
Server:
|
34
|
+
- Jetty(9.1.0.v20131115)
|
35
|
+
X-Newrelic-App-Data:
|
36
|
+
- PxQFWFFSDwQTVVdUBAgPUkYdFGQHBDcQUQxLA1tMXV1dORYzVBBGBxdCdhUSEVFRRRAEPhhQRw84HlpcDjpMB0UVZE1OCRoAb0pKFVAVQD5LVE5MFRZVXl8KBBBrHkQTCVxZXQcUKgZsTUsXVVVVQEpHFVEfUR9SSgYHU1NXCAsAVk1PBh0VAAAAUFIGB1EHAFVeUFpZFm8=
|
37
|
+
Content-Length:
|
38
|
+
- '676'
|
39
|
+
Connection:
|
40
|
+
- keep-alive
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"summonerId":50519866,"playerStatSummaries":[{"playerStatSummaryType":"CoopVsAI","wins":14,"modifyDate":1389972770000,"aggregatedStats":{"totalChampionKills":84,"totalMinionKills":1678,"totalTurretsKilled":32,"totalNeutralMinionsKilled":347,"totalAssists":86}},{"playerStatSummaryType":"OdinUnranked","wins":0,"modifyDate":1389972770000,"aggregatedStats":{}},{"playerStatSummaryType":"Unranked","wins":17,"modifyDate":1390734105000,"aggregatedStats":{"totalChampionKills":251,"totalMinionKills":2195,"totalTurretsKilled":42,"totalNeutralMinionsKilled":473,"totalAssists":167}},{"playerStatSummaryType":"Unranked3x3","wins":0,"modifyDate":1389972770000,"aggregatedStats":{}}]}'
|
44
|
+
http_version:
|
45
|
+
recorded_at: Wed, 29 Jan 2014 18:20:21 GMT
|
46
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://prod.api.pvp.net/api/lol/euw/v1.1/champion?api_key=a1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1&freeToPlay=true
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- prod.api.pvp.net
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Access-Control-Allow-Headers:
|
24
|
+
- Content-Type
|
25
|
+
Access-Control-Allow-Methods:
|
26
|
+
- GET, POST, DELETE, PUT
|
27
|
+
Access-Control-Allow-Origin:
|
28
|
+
- '*'
|
29
|
+
Content-Type:
|
30
|
+
- application/json;charset=UTF-8
|
31
|
+
Date:
|
32
|
+
- Wed, 29 Jan 2014 18:27:07 GMT
|
33
|
+
Server:
|
34
|
+
- Jetty(9.1.0.v20131115)
|
35
|
+
X-Newrelic-App-Data:
|
36
|
+
- PxQFWFFSDwQTVVdUBAgPUkYdFGQHBDcQUQxLA1tMXV1dORYzVBBGBxdCdhUSEVFRRRAEPhhQRw84HlpcDjpMB0UVZE1OCRoDb0paCVAMQwsLWBVNVk0IHwRKVVUCBA4jSQUaHlNKQQQBWwhXDQ0DUwBdWllSVwdAOQ==
|
37
|
+
Content-Length:
|
38
|
+
- '1879'
|
39
|
+
Connection:
|
40
|
+
- keep-alive
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"champions":[{"id":22,"name":"Ashe","active":true,"attackRank":7,"defenseRank":3,"magicRank":2,"difficultyRank":4,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true},{"id":114,"name":"Fiora","active":true,"attackRank":10,"defenseRank":4,"magicRank":2,"difficultyRank":5,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":126,"name":"Jayce","active":true,"attackRank":8,"defenseRank":4,"magicRank":3,"difficultyRank":8,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":85,"name":"Kennen","active":true,"attackRank":6,"defenseRank":4,"magicRank":7,"difficultyRank":5,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":117,"name":"Lulu","active":true,"attackRank":4,"defenseRank":5,"magicRank":7,"difficultyRank":7,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":56,"name":"Nocturne","active":true,"attackRank":9,"defenseRank":5,"magicRank":2,"difficultyRank":6,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":80,"name":"Pantheon","active":true,"attackRank":9,"defenseRank":4,"magicRank":3,"difficultyRank":5,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":133,"name":"Quinn","active":true,"attackRank":9,"defenseRank":4,"magicRank":2,"difficultyRank":7,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":37,"name":"Sona","active":true,"attackRank":5,"defenseRank":2,"magicRank":8,"difficultyRank":1,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true},{"id":5,"name":"XinZhao","active":true,"attackRank":8,"defenseRank":6,"magicRank":3,"difficultyRank":3,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true}]}'
|
44
|
+
http_version:
|
45
|
+
recorded_at: Wed, 29 Jan 2014 18:27:07 GMT
|
46
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://prod.api.pvp.net/api/lol/euw/v1.2/stats/by-summoner/50519866/summary?api_key=a1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- prod.api.pvp.net
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Access-Control-Allow-Headers:
|
24
|
+
- Content-Type
|
25
|
+
Access-Control-Allow-Methods:
|
26
|
+
- GET, POST, DELETE, PUT
|
27
|
+
Access-Control-Allow-Origin:
|
28
|
+
- '*'
|
29
|
+
Content-Type:
|
30
|
+
- application/json;charset=UTF-8
|
31
|
+
Date:
|
32
|
+
- Wed, 29 Jan 2014 18:28:16 GMT
|
33
|
+
Server:
|
34
|
+
- Jetty(9.1.0.v20131115)
|
35
|
+
X-Newrelic-App-Data:
|
36
|
+
- PxQFWFFSDwQTVVdUBAgPUkYdFGQHBDcQUQxLA1tMXV1dORYzVBBGBxdCdhUSEVFRRRAEPhhQRw84HlpcDjpMB0UVZE1OCRoAb0pKFVAVQD5LVE5MFRZVXl8KBBBrHkQTCVxZXQcUKgZsTUsXVVVVQEpHFVEfUR9SSgYHUFNbCwQJXE1PBh0VBV1TAQFTXwYAUgReAV0IFm8=
|
37
|
+
Content-Length:
|
38
|
+
- '676'
|
39
|
+
Connection:
|
40
|
+
- keep-alive
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"summonerId":50519866,"playerStatSummaries":[{"playerStatSummaryType":"CoopVsAI","wins":14,"modifyDate":1389972770000,"aggregatedStats":{"totalChampionKills":84,"totalMinionKills":1678,"totalTurretsKilled":32,"totalNeutralMinionsKilled":347,"totalAssists":86}},{"playerStatSummaryType":"OdinUnranked","wins":0,"modifyDate":1389972770000,"aggregatedStats":{}},{"playerStatSummaryType":"Unranked","wins":17,"modifyDate":1390734105000,"aggregatedStats":{"totalChampionKills":251,"totalMinionKills":2195,"totalTurretsKilled":42,"totalNeutralMinionsKilled":473,"totalAssists":167}},{"playerStatSummaryType":"Unranked3x3","wins":0,"modifyDate":1389972770000,"aggregatedStats":{}}]}'
|
44
|
+
http_version:
|
45
|
+
recorded_at: Wed, 29 Jan 2014 18:28:16 GMT
|
46
|
+
recorded_with: VCR 2.8.0
|
@@ -1,13 +1,13 @@
|
|
1
|
+
require 'setup_vcr'
|
1
2
|
require 'league_of_legends/api'
|
2
3
|
|
3
4
|
describe ::LeagueOfLegends::Api do
|
4
5
|
|
5
|
-
let(:api) { ::LeagueOfLegends::Api.new '
|
6
|
-
' }
|
6
|
+
let(:api) { ::LeagueOfLegends::Api.new 'a1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1' }
|
7
7
|
|
8
8
|
it "has access to an API key" do
|
9
|
-
|
10
|
-
expect(api.key).to eq
|
9
|
+
expect(api.key).to be_an_instance_of String
|
10
|
+
expect(api.key.length).to eq 36
|
11
11
|
end
|
12
12
|
|
13
13
|
it "has a base url" do
|
@@ -19,8 +19,12 @@ describe ::LeagueOfLegends::Api do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "can send requests and receive a response" do
|
22
|
-
|
23
|
-
|
22
|
+
VCR.use_cassette('api_spec summoner_stats_summary') do
|
23
|
+
expect(api.get(:summoner_stats_summary, 50519866)).to be_an_instance_of ::LeagueOfLegends::DTO::PlayerStatsSummaryList
|
24
|
+
end
|
25
|
+
VCR.use_cassette('api_spec champions') do
|
26
|
+
expect(api.get(:champions, true)).to be_an_instance_of ::LeagueOfLegends::DTO::ChampionList
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'league_of_legends/api'
|
2
|
+
require 'league_of_legends/request/champion'
|
3
|
+
require 'league_of_legends/dto/champion_list'
|
4
|
+
|
5
|
+
describe ::LeagueOfLegends::Request::Champion do
|
6
|
+
|
7
|
+
let(:api) { ::LeagueOfLegends::Api.new 'a1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1' }
|
8
|
+
|
9
|
+
def request f2p
|
10
|
+
described_class.new(api, f2p)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "has the required parameters" do
|
14
|
+
expect(described_class.dto_class).to eq ::LeagueOfLegends::DTO::ChampionList
|
15
|
+
expect(described_class.version).to eq 'v1.1'
|
16
|
+
expect(request(true).region).to eq 'euw'
|
17
|
+
expect(request(true).api_key).to be_an_instance_of String
|
18
|
+
expect(request(true).api_key.length).to eq 36
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has optional parameters" do
|
22
|
+
[[true, 'true'], [false, 'false'], ['x', nil]].each do |f2p|
|
23
|
+
expect(request(f2p.first).free_to_play).to eq f2p.last
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can be sent and get a response" do
|
28
|
+
VCR.use_cassette('champion_spec f2p') do
|
29
|
+
expect(request(true).response).to be_an_instance_of ::LeagueOfLegends::DTO::ChampionList
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -5,6 +5,8 @@ describe ::LeagueOfLegends::Request::Mapper do
|
|
5
5
|
it "knows the class for certain requests" do
|
6
6
|
req = described_class.get :summoner_stats_summary
|
7
7
|
expect(req).to eq ::LeagueOfLegends::Request::Stats::BySummoner::Summary
|
8
|
+
req = described_class.get :champions
|
9
|
+
expect(req).to eq ::LeagueOfLegends::Request::Champion
|
8
10
|
end
|
9
11
|
|
10
12
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'league_of_legends/request/stats/by_summoner/summary'
|
2
2
|
|
3
|
+
|
3
4
|
describe ::LeagueOfLegends::Request::Stats::BySummoner::Summary do
|
4
5
|
|
5
6
|
let(:api) { ::LeagueOfLegends::Api.new 'a1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1' }
|
@@ -17,8 +18,9 @@ describe ::LeagueOfLegends::Request::Stats::BySummoner::Summary do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
it "can be sent and get a response" do
|
20
|
-
|
21
|
-
|
21
|
+
VCR.use_cassette('summary_spec stats by_summoner') do
|
22
|
+
expect(request.response).to be_an_instance_of ::LeagueOfLegends::DTO::PlayerStatsSummaryList
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
end
|
data/spec/setup_vcr.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: league_of_legends
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francisco Orvalho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,54 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.14.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.14.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.8.0
|
76
|
+
- - <
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '1.16'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.8.0
|
86
|
+
- - <
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.16'
|
41
89
|
description: |-
|
42
90
|
This gem implements the League Of Legends API (currently in open beta). It will continue to be updated as the API evolves.
|
43
91
|
Please see the README at https://github.com/forvalho/league_of_legends/blob/master/README.md
|
@@ -65,9 +113,14 @@ files:
|
|
65
113
|
- lib/league_of_legends/dto/player_stats_summary_list.rb
|
66
114
|
- lib/league_of_legends/request/all.rb
|
67
115
|
- lib/league_of_legends/request/base.rb
|
116
|
+
- lib/league_of_legends/request/champion.rb
|
68
117
|
- lib/league_of_legends/request/mapper.rb
|
69
118
|
- lib/league_of_legends/request/stats/by_summoner/summary.rb
|
70
119
|
- lib/league_of_legends/version.rb
|
120
|
+
- spec/fixtures/vcr_cassettes/api_spec_champions.yml
|
121
|
+
- spec/fixtures/vcr_cassettes/api_spec_summoner_stats_summary.yml
|
122
|
+
- spec/fixtures/vcr_cassettes/champion_spec_f2p.yml
|
123
|
+
- spec/fixtures/vcr_cassettes/summary_spec_stats_by_summoner.yml
|
71
124
|
- spec/league_of_legends/api_spec.rb
|
72
125
|
- spec/league_of_legends/dto/aggregated_stats_spec.rb
|
73
126
|
- spec/league_of_legends/dto/base_spec.rb
|
@@ -76,8 +129,10 @@ files:
|
|
76
129
|
- spec/league_of_legends/dto/player_stats_summary_list_spec.rb
|
77
130
|
- spec/league_of_legends/dto/player_stats_summary_spec.rb
|
78
131
|
- spec/league_of_legends/request/base_spec.rb
|
132
|
+
- spec/league_of_legends/request/champion_spec.rb
|
79
133
|
- spec/league_of_legends/request/mapper_spec.rb
|
80
134
|
- spec/league_of_legends/request/stats/by_summoner/summary_spec.rb
|
135
|
+
- spec/setup_vcr.rb
|
81
136
|
homepage: http://github.com/forvalho/league_of_legends
|
82
137
|
licenses:
|
83
138
|
- MIT
|
@@ -103,6 +158,10 @@ signing_key:
|
|
103
158
|
specification_version: 4
|
104
159
|
summary: Implementation of the LoL API
|
105
160
|
test_files:
|
161
|
+
- spec/fixtures/vcr_cassettes/api_spec_champions.yml
|
162
|
+
- spec/fixtures/vcr_cassettes/api_spec_summoner_stats_summary.yml
|
163
|
+
- spec/fixtures/vcr_cassettes/champion_spec_f2p.yml
|
164
|
+
- spec/fixtures/vcr_cassettes/summary_spec_stats_by_summoner.yml
|
106
165
|
- spec/league_of_legends/api_spec.rb
|
107
166
|
- spec/league_of_legends/dto/aggregated_stats_spec.rb
|
108
167
|
- spec/league_of_legends/dto/base_spec.rb
|
@@ -111,6 +170,8 @@ test_files:
|
|
111
170
|
- spec/league_of_legends/dto/player_stats_summary_list_spec.rb
|
112
171
|
- spec/league_of_legends/dto/player_stats_summary_spec.rb
|
113
172
|
- spec/league_of_legends/request/base_spec.rb
|
173
|
+
- spec/league_of_legends/request/champion_spec.rb
|
114
174
|
- spec/league_of_legends/request/mapper_spec.rb
|
115
175
|
- spec/league_of_legends/request/stats/by_summoner/summary_spec.rb
|
176
|
+
- spec/setup_vcr.rb
|
116
177
|
has_rdoc:
|