ruby_gg 0.1.2 → 0.1.3
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/Gemfile.lock +1 -1
- data/README.md +9 -2
- data/lib/ruby_gg/challenger.rb +6 -6
- data/lib/ruby_gg/champion.rb +17 -0
- data/lib/ruby_gg/summoner.rb +32 -21
- data/lib/ruby_gg/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e890a95fd6752c8bffc5e93c9135d4589670a175
|
4
|
+
data.tar.gz: 739939c7ce90866c35cdea5577e8074fc4e6596f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa819f6a50942943c7cd81e89996c88a8bf26e3c4dbd9c6985f29b4350a91f7d82534ad8e1e32866a66fcd0ff42d8b99c3600e7a2ae248e6bb0ae9eb5f50b1fc
|
7
|
+
data.tar.gz: 2a31f157e60693196b10542d12bb62e3292c28a7aabcadaed04ea35aad23b844076d6012ceec83aab333e1e35e82d1c8de0204e98763fae3bf0570b76daa35fd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Create new instace of the Client:
|
|
28
28
|
client = RubyGg::Client.new(api_key, region)
|
29
29
|
# api_key is your league_api_key and region is the region you want.
|
30
30
|
```
|
31
|
-
|
31
|
+
Gets list of challenger players
|
32
32
|
By default paramater passed in is zero (which returns back all 200 challengers).
|
33
33
|
However you can pass in interger or string of an integer to get set number of results (1-200 or it'll return all 200).
|
34
34
|
```ruby
|
@@ -37,13 +37,20 @@ However you can pass in interger or string of an integer to get set number of re
|
|
37
37
|
client.challenger.solo_queue # This returns all 200.
|
38
38
|
client.challenger.solo_queue(iamidiot) # This will still return all 200.
|
39
39
|
```
|
40
|
-
Gets
|
40
|
+
Gets summoners information (for data types check league api documentation). returnType is hashValue.
|
41
41
|
returnType = {:user => {userDto}, :solo => {soloDto}, :flex => {flexDto}, :tt => {ttDto}}
|
42
42
|
```ruby
|
43
43
|
client.summoner.get_user(id) #Where id can be int or str.
|
44
44
|
You can check for id from client.challenger.solo_queue()[0][:playerOrTeamId] # Gives the id for first challenger player in the list returned.
|
45
45
|
```
|
46
|
+
Gets summoners Champion Masteries (returns hashValue).
|
47
|
+
returnType = [{"playerId"=>72859900, "championId"=>53, "championLevel"=>1, "championPoints"=>124, "lastPlayTime"=>1475296559000, "championPointsSinceLastLevel"=>124, "championPointsUntilNextLevel"=>1676, "chestGranted"=>false, "tokensEarned"=>0}]
|
46
48
|
|
49
|
+
```ruby
|
50
|
+
client.summoner.champion_mastery(id, count) # where id and count both can be str or int. Id is summoner's ID, and count is number of data you want back (it is sorted according to most mastery points).
|
51
|
+
client.summoner.champion_mastery(id, 3) # returns 3 top mastery points champs.
|
52
|
+
You can check for id from client.challenger.solo_queue()[0][:playerOrTeamId] # Gives the id for first challenger player in the list returned.
|
53
|
+
```
|
47
54
|
## Development
|
48
55
|
|
49
56
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/ruby_gg/challenger.rb
CHANGED
@@ -13,16 +13,16 @@ module RubyGg
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def solo_queue (size = 0) # Not passing an argument / passing string (unless string is number)/ 0 => returns all 200 results.
|
16
|
+
payCheck = (HTTParty.get("#{@base_url}#{@challenger_url}RANKED_SOLO_5x5?api_key=#{@api_key}").parsed_response)['entries']
|
16
17
|
if size.to_i == 0 || size.to_i >200
|
17
|
-
size =
|
18
|
+
size = payCheck.size
|
18
19
|
else
|
19
20
|
size = size.to_i
|
20
21
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return payload
|
22
|
+
payLoad = []
|
23
|
+
payCheck.sort!{|x, y| y['leaguePoints'] <=> x['leaguePoints']}
|
24
|
+
(0...size).each {|x| payLoad.push(player_dto(payCheck[x]))}
|
25
|
+
return payLoad
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
module RubyGg
|
4
|
+
|
5
|
+
class Champion
|
6
|
+
attr_reader :champion_url
|
7
|
+
|
8
|
+
def initialize(api_key, region) #Initializing the Challenger Instance.
|
9
|
+
@api_key = api_key
|
10
|
+
@region = region
|
11
|
+
@base_url = "https://#{@region}.api.riotgames.com"
|
12
|
+
@champion_url = "/lol/league/v3/challengerleagues/by-queue/"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/lib/ruby_gg/summoner.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "httparty"
|
2
|
-
|
2
|
+
require 'uri'
|
3
3
|
module RubyGg
|
4
4
|
|
5
5
|
class Summoner
|
@@ -12,57 +12,68 @@ module RubyGg
|
|
12
12
|
@base_url = "https://#{@region}.api.riotgames.com"
|
13
13
|
@rank_url = '/lol/league/v3/positions/by-summoner/'
|
14
14
|
@profile_url = '/lol/summoner/v3/summoners/'
|
15
|
+
@top_champions = '/lol/champion-mastery/v3/champion-masteries/by-summoner/'
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
def find(name)
|
19
|
+
userPayload = HTTParty.get(URI.encode("#{@base_url}#{@profile_url}by-name/#{name}?api_key=#{@api_key}")).parsed_response
|
20
|
+
summonerInfo = {}
|
21
|
+
summonerInfo[:user] = get_user(userPayload['id'])
|
22
|
+
summonerInfo[:top_champions] = get_top_champions(userPayload['id'])
|
23
|
+
summonerInfo[:solo] = get_solo(userPayload['id'])
|
24
|
+
summonerInfo[:flex] = get_flex(userPayload['id'])
|
25
|
+
summonerInfo[:tt] = get_tt(userPayload['id'])
|
26
|
+
return summonerInfo
|
27
|
+
end
|
28
|
+
|
29
|
+
def champion_mastery(id, count = 0)
|
30
|
+
mastery = HTTParty.get("#{@base_url}#{@top_champions}#{id.to_i}?api_key=#{@api_key}").parsed_response
|
31
|
+
topChamps = []
|
32
|
+
if not count.to_i <= 0 or mastery.size == count.to_i
|
33
|
+
(0...count.to_i).each {|x| topChamps.push(mastery[x])}
|
34
|
+
return topChamps
|
35
|
+
else
|
36
|
+
return mastery
|
37
|
+
end
|
38
|
+
|
24
39
|
end
|
25
40
|
|
26
|
-
private
|
27
41
|
def get_user(id)
|
28
|
-
|
42
|
+
userPayload = HTTParty.get("#{@base_url}#{@profile_url}#{id.to_i}?api_key=#{@api_key}").parsed_response
|
29
43
|
user = {}
|
30
|
-
|
44
|
+
userPayload.each{|k,v| user[k.to_sym] = v}
|
31
45
|
return user
|
32
46
|
end
|
33
47
|
|
34
|
-
private
|
35
48
|
def get_solo(id)
|
36
|
-
|
49
|
+
rankPayload = HTTParty.get("#{@base_url}#{@rank_url}#{id.to_i}?api_key=#{@api_key}").parsed_response
|
37
50
|
solo = {}
|
38
51
|
@solo = nil
|
39
|
-
|
52
|
+
rankPayload.each{|x| @solo = rankPayload.index(x) if x['queueType'].eql?'RANKED_SOLO_5x5'}
|
40
53
|
if not @solo.nil?
|
41
|
-
(
|
54
|
+
(rankPayload[@solo]).each {|k,v| solo[k.to_sym] = v if not "queueType".eql?k or "playerOrTeamName".eql?k or "playerOrTeamId".eql?k}
|
42
55
|
end
|
43
56
|
return solo
|
44
57
|
end
|
45
58
|
|
46
|
-
private
|
47
59
|
def get_flex(id)
|
48
60
|
rank_payload = HTTParty.get("#{@base_url}#{@rank_url}#{id.to_i}?api_key=#{@api_key}").parsed_response
|
49
61
|
flex = {}
|
50
62
|
@flex = nil
|
51
|
-
rank_payload.each{|x| @
|
63
|
+
rank_payload.each{|x| @flex = rank_payload.index(x) if x['queueType'].eql?'RANKED_FLEX_SR'}
|
52
64
|
if not @flex.nil?
|
53
65
|
(rank_payload[@flex]).each {|k,v| flex[k.to_sym] = v if not "queueType".eql?k or "playerOrTeamName".eql?k or "playerOrTeamId".eql?k}
|
54
66
|
end
|
55
67
|
return flex
|
56
68
|
end
|
57
69
|
|
58
|
-
private
|
59
70
|
def get_tt(id)
|
60
|
-
|
71
|
+
rankPayload = HTTParty.get("#{@base_url}#{@rank_url}#{id.to_i}?api_key=#{@api_key}").parsed_response
|
61
72
|
tt = {}
|
62
73
|
@tt = nil
|
63
|
-
|
74
|
+
rankPayload.each{|x| @tt = rankPayload.index(x) if x['queueType'].eql?'RANKED_TT_SR'}
|
64
75
|
if not @tt.nil?
|
65
|
-
(
|
76
|
+
(rankPayload[@tt]).each {|k,v| tt[k.to_sym] = v if not "queueType".eql?k or "playerOrTeamName".eql?k or "playerOrTeamId".eql?k}
|
66
77
|
end
|
67
78
|
return tt
|
68
79
|
end
|
data/lib/ruby_gg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_gg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manish Shahi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- bin/setup
|
87
87
|
- lib/ruby_gg.rb
|
88
88
|
- lib/ruby_gg/challenger.rb
|
89
|
+
- lib/ruby_gg/champion.rb
|
89
90
|
- lib/ruby_gg/client.rb
|
90
91
|
- lib/ruby_gg/summoner.rb
|
91
92
|
- lib/ruby_gg/version.rb
|