lol_api 1.0.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 +7 -0
- data/.gitignore +22 -0
- data/.guardfile +11 -0
- data/.travis.yml +6 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +10 -0
- data/lib/lol_api/client.rb +105 -0
- data/lib/lol_api/configuration.rb +15 -0
- data/lib/lol_api/connection.rb +32 -0
- data/lib/lol_api/types/champion.rb +95 -0
- data/lib/lol_api/types/dtos/image.rb +33 -0
- data/lib/lol_api/types/dtos/info.rb +25 -0
- data/lib/lol_api/types/dtos/participant.rb +419 -0
- data/lib/lol_api/types/dtos/participant_identity.rb +19 -0
- data/lib/lol_api/types/dtos/passive.rb +27 -0
- data/lib/lol_api/types/dtos/player.rb +22 -0
- data/lib/lol_api/types/dtos/recommended.rb +38 -0
- data/lib/lol_api/types/dtos/skin.rb +20 -0
- data/lib/lol_api/types/dtos/spell.rb +98 -0
- data/lib/lol_api/types/dtos/stat.rb +19 -0
- data/lib/lol_api/types/dtos/team.rb +57 -0
- data/lib/lol_api/types/dtos/timeline.rb +180 -0
- data/lib/lol_api/types/history_match.rb +61 -0
- data/lib/lol_api/types/item.rb +126 -0
- data/lib/lol_api/types/mastery.rb +39 -0
- data/lib/lol_api/types/match.rb +43 -0
- data/lib/lol_api/types/summoner.rb +26 -0
- data/lib/lol_api/types/summoner_masteries.rb +66 -0
- data/lib/lol_api/types/summoner_runes.rb +69 -0
- data/lib/lol_api/utils/inspectable.rb +10 -0
- data/lib/lol_api/version.rb +3 -0
- data/lib/lol_api.rb +12 -0
- data/lol_api.gemspec +29 -0
- data/spec/champion_spec.rb +48 -0
- data/spec/client_spec.rb +67 -0
- data/spec/delegation_spec.rb +5 -0
- data/spec/factories.rb +43 -0
- data/spec/fixtures/champion.json +843 -0
- data/spec/fixtures/history.json +127 -0
- data/spec/fixtures/item.json +62 -0
- data/spec/fixtures/mastery.json +25 -0
- data/spec/fixtures/match.json +12167 -0
- data/spec/fixtures/match_details.json +13548 -0
- data/spec/fixtures/summoner.json +7 -0
- data/spec/fixtures/summoner_masteries.json +143 -0
- data/spec/fixtures/summoner_runes.json +132 -0
- data/spec/history_spec.rb +280 -0
- data/spec/item_spec.rb +96 -0
- data/spec/mastery_spec.rb +27 -0
- data/spec/match_details_spec.rb +72 -0
- data/spec/participant_spec.rb +153 -0
- data/spec/participant_timeline_spec.rb +80 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/summoner_spec.rb +120 -0
- data/spec/team_spec.rb +38 -0
- data/spec/timeline_spec.rb +101 -0
- metadata +236 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef0a8b5e7ed60500088d33228b0c9ae4add79ab7
|
4
|
+
data.tar.gz: 210a0a4b69f626f6503a70d189fef46faa407398
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8fb677e6c90897b8e580b07a5118d43300b7d52e92370b6ac8f2949ebe6c48b5f6d769887921f2d73d2bf30d64882c560e18e218aa8a911d16e1083e02877c43
|
7
|
+
data.tar.gz: 898d6fdbb7dab9bb8579cb79a8843cdc56db5867bf76a6f608a793c30587b1e5b522ee1c0dfde9fed9167fc73b7598cf4a0a2562f4ec1b73102a1698fde70813
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.guardfile
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 eankorins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# LeagueApi
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'league_api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install league_api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/league_api/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'lol_api/configuration'
|
2
|
+
require 'lol_api/connection'
|
3
|
+
|
4
|
+
require 'lol_api/types/champion'
|
5
|
+
require 'lol_api/types/item'
|
6
|
+
require 'lol_api/types/mastery'
|
7
|
+
require 'lol_api/types/match'
|
8
|
+
require 'lol_api/types/summoner'
|
9
|
+
require 'lol_api/types/summoner_masteries'
|
10
|
+
require 'lol_api/types/summoner_runes'
|
11
|
+
|
12
|
+
module LolApi
|
13
|
+
class Client
|
14
|
+
attr_reader :config
|
15
|
+
|
16
|
+
def initialize(options = {})
|
17
|
+
@config = Configuration.new(options)
|
18
|
+
end
|
19
|
+
def configure
|
20
|
+
yield config
|
21
|
+
end
|
22
|
+
def connection
|
23
|
+
@connection ||= Connection.new
|
24
|
+
end
|
25
|
+
def champions(options ={})
|
26
|
+
response = run_request('global', 'champion', options, 'static-data', 'euw', '', 'v1.2')
|
27
|
+
|
28
|
+
if response && (champions = response["data"])
|
29
|
+
champions.map do | champ |
|
30
|
+
Champion.new(champ[1])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
def champion_by_id(id, options = {})
|
35
|
+
response = run_request('global','champion', options, 'static-data', 'euw', id.to_s, 'v1.2')
|
36
|
+
Champion.new(response) if response["id"]
|
37
|
+
end
|
38
|
+
def items(options = {})
|
39
|
+
response = run_request('global','item', options, 'static-data', 'euw', '', 'v1.2')
|
40
|
+
|
41
|
+
if response && (items = response['data'])
|
42
|
+
items.map do |item|
|
43
|
+
Item.new(item[1])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def item_by_id(id, options = {})
|
49
|
+
response = run_request('global','item', options, 'static-data', 'euw', id.to_s, 'v1.2')
|
50
|
+
Item.new(response) if response["id"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def match_details(id, timeline = true)
|
54
|
+
response = run_request('euw', 'match', {:includeTimeline => timeline}, '', 'euw', id.to_s, 'v2.2')
|
55
|
+
Match.new(response) if response['region']
|
56
|
+
end
|
57
|
+
|
58
|
+
def history_by_id(id)
|
59
|
+
response = run_request('euw','matchhistory', {}, '', "euw", id.to_s, "v2.2")
|
60
|
+
if matches = response['matches']
|
61
|
+
matches.map do |match|
|
62
|
+
HistoryMatch.new(match)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
def masteries(options = {})
|
67
|
+
response = run_request('global', 'mastery', options, 'static-data', 'euw', '', 'v1.2')
|
68
|
+
if response && masteries = response['data']
|
69
|
+
masteries.map do |mastery|
|
70
|
+
Mastery.new(mastery)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def mastery_by_id(id=0, options = {})
|
76
|
+
response = run_request('global', 'mastery', options, 'static-data', 'euw', id, 'v1.2')
|
77
|
+
Mastery.new(response) if response["id"]
|
78
|
+
end
|
79
|
+
|
80
|
+
def summoner_by_name(name)
|
81
|
+
response = run_request('euw', 'summoner/by-name', {}, '', 'euw', name, 'v1.4')
|
82
|
+
Summoner.new(response[name]) if response[name]
|
83
|
+
end
|
84
|
+
|
85
|
+
def summoner_by_id(id)
|
86
|
+
response = run_request('euw', 'summoner', {}, '', 'euw', id, 'v1.4')
|
87
|
+
Summoner.new(response[id.to_s]) if response[id.to_s]
|
88
|
+
end
|
89
|
+
|
90
|
+
def summoner_masteries(id)
|
91
|
+
response = run_request('euw', 'summoner', {}, '', 'euw', id.to_s << "/masteries", 'v1.4')
|
92
|
+
SummonerMasteries.new(response[id.to_s]) if response[id.to_s]
|
93
|
+
end
|
94
|
+
|
95
|
+
def summoner_runes(id)
|
96
|
+
response = run_request('euw', 'summoner', {}, '', 'euw', id.to_s << "/runes", 'v1.4')
|
97
|
+
SummonerRunes.new(response[id.to_s]) if response[id.to_s]
|
98
|
+
end
|
99
|
+
|
100
|
+
def run_request(prefix, method, options = {}, interface='static-data' , region = 'euw', id = '', version = 'v1.2')
|
101
|
+
url = "https://#{prefix}.api.pvp.net/api/lol#{("/" << interface) unless interface == ''}/#{region}/#{version}/#{method}/#{id}"
|
102
|
+
connection.request(:get, url, options.merge(api_key: config.api_key))
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
|
5
|
+
module LolApi
|
6
|
+
class Connection
|
7
|
+
def initialize
|
8
|
+
@faraday = Faraday.new do |faraday|
|
9
|
+
faraday.response :json
|
10
|
+
faraday.adapter Faraday.default_adapter
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def request(method, url, options = {})
|
15
|
+
option_string = options.map{ |a,b| a.to_s << "=" << b.to_s }.join("&")
|
16
|
+
final_url = url << "?" << option_string
|
17
|
+
|
18
|
+
puts final_url
|
19
|
+
response = @faraday.public_send(method) do |request|
|
20
|
+
begin
|
21
|
+
request.url(url, options)
|
22
|
+
rescue => e
|
23
|
+
puts e
|
24
|
+
sleep(2)
|
25
|
+
request(method, url, options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
response.body
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'lol_api/utils/inspectable'
|
2
|
+
require 'lol_api/types/dtos/stat'
|
3
|
+
require 'lol_api/types/dtos/info'
|
4
|
+
require 'lol_api/types/dtos/passive'
|
5
|
+
require 'lol_api/types/dtos/recommended'
|
6
|
+
require 'lol_api/types/dtos/skin'
|
7
|
+
require 'lol_api/types/dtos/spell'
|
8
|
+
module LolApi
|
9
|
+
class Champion
|
10
|
+
include Utils::Inspectable
|
11
|
+
attr_reader :raw_champion
|
12
|
+
|
13
|
+
def initialize(raw_champion)
|
14
|
+
@raw_champion = raw_champion
|
15
|
+
end
|
16
|
+
|
17
|
+
def id
|
18
|
+
raw_champion['id'].to_i
|
19
|
+
end
|
20
|
+
|
21
|
+
def title
|
22
|
+
raw_champion['title']
|
23
|
+
end
|
24
|
+
def name
|
25
|
+
raw_champion['name']
|
26
|
+
end
|
27
|
+
def key
|
28
|
+
raw_champion["key"]
|
29
|
+
end
|
30
|
+
def stats
|
31
|
+
if raw_stats = raw_champion['stats'].to_a
|
32
|
+
raw_stats.map do |stat|
|
33
|
+
Stat.new(stat)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def enemy_tips
|
39
|
+
raw_champion["enemytips"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def ally_tips
|
43
|
+
raw_champion["allytips"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def blurb
|
47
|
+
raw_champion['blurb']
|
48
|
+
end
|
49
|
+
|
50
|
+
def lore
|
51
|
+
raw_champion['lore']
|
52
|
+
end
|
53
|
+
|
54
|
+
def partype
|
55
|
+
raw_champion['partype']
|
56
|
+
end
|
57
|
+
|
58
|
+
def tags
|
59
|
+
raw_champion['tags']
|
60
|
+
end
|
61
|
+
|
62
|
+
def image
|
63
|
+
Image.new(raw_champion['image']) if raw_champion['image']
|
64
|
+
end
|
65
|
+
|
66
|
+
def info
|
67
|
+
Info.new(raw_champion['info']) if raw_champion['info']
|
68
|
+
end
|
69
|
+
|
70
|
+
def passive
|
71
|
+
Passive.new(raw_champion['passive']) if raw_champion['passive']
|
72
|
+
end
|
73
|
+
|
74
|
+
def spells
|
75
|
+
raw_champion['spells']
|
76
|
+
end
|
77
|
+
|
78
|
+
def recommended
|
79
|
+
if recommended = raw_champion['recommended']
|
80
|
+
recommended.map do |item|
|
81
|
+
Recommended.new(item)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def skins
|
87
|
+
if skins = raw_champion['skins']
|
88
|
+
skins.map do |item|
|
89
|
+
Skin.new(item)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'lol_api/utils/inspectable'
|
2
|
+
module LolApi
|
3
|
+
class Image
|
4
|
+
include Utils::Inspectable
|
5
|
+
attr_reader :raw_image
|
6
|
+
|
7
|
+
def initialize(raw_image)
|
8
|
+
@raw_image = raw_image
|
9
|
+
end
|
10
|
+
|
11
|
+
def full
|
12
|
+
raw_image['full']
|
13
|
+
end
|
14
|
+
def group
|
15
|
+
raw_image['group']
|
16
|
+
end
|
17
|
+
def height
|
18
|
+
raw_image['h']
|
19
|
+
end
|
20
|
+
def width
|
21
|
+
raw_image['w']
|
22
|
+
end
|
23
|
+
def x
|
24
|
+
raw_image['x']
|
25
|
+
end
|
26
|
+
def y
|
27
|
+
raw_image['y']
|
28
|
+
end
|
29
|
+
def sprite
|
30
|
+
raw_image['sprite']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'lol_api/utils/inspectable'
|
2
|
+
module LolApi
|
3
|
+
class Info
|
4
|
+
include Utils::Inspectable
|
5
|
+
attr_reader :raw_info
|
6
|
+
|
7
|
+
def initialize(raw_info)
|
8
|
+
@raw_info = raw_info
|
9
|
+
end
|
10
|
+
|
11
|
+
def attack
|
12
|
+
raw_info['info']
|
13
|
+
end
|
14
|
+
|
15
|
+
def defense
|
16
|
+
raw_info['defense']
|
17
|
+
end
|
18
|
+
def difficulty
|
19
|
+
raw_info['difficulty']
|
20
|
+
end
|
21
|
+
def magic
|
22
|
+
raw_info['magic']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|