rito_api 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e7b0419fd5e570039a9f1956e9c555e228afd98
4
+ data.tar.gz: c98b96ff460f032ef9e004084a3326a1700db22b
5
+ SHA512:
6
+ metadata.gz: 57ae8cee5444681a6ba1130c4ab833084560fc42601b496209345c4eb12c3d4c4f3555005147ed53a606ef6510b24cfc2b56195910df4fdaab4758e27def99c9
7
+ data.tar.gz: f5649a767b4d62dbc17c3f947ec7e47355eb6dc9b4f4c4590132a24db7b06b364fc3d92df99b4968810caf5ebd4f7ffc7d08699c93354664573143e3f4ddd3b6
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at manish.shahi@mnsu.edu. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rito_api.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rito_api (0.1.0)
5
+ fileutils (~> 1.0, >= 1.0.2)
6
+ httparty (~> 0.16.1)
7
+ moneta (~> 1.0)
8
+ redis (~> 4.0, >= 4.0.1)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ diff-lcs (1.3)
14
+ fileutils (1.0.2)
15
+ httparty (0.16.2)
16
+ multi_xml (>= 0.5.2)
17
+ moneta (1.0.0)
18
+ multi_xml (0.6.0)
19
+ rake (10.5.0)
20
+ redis (4.0.1)
21
+ rspec (3.7.0)
22
+ rspec-core (~> 3.7.0)
23
+ rspec-expectations (~> 3.7.0)
24
+ rspec-mocks (~> 3.7.0)
25
+ rspec-core (3.7.1)
26
+ rspec-support (~> 3.7.0)
27
+ rspec-expectations (3.7.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.7.0)
30
+ rspec-mocks (3.7.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.7.0)
33
+ rspec-support (3.7.1)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ bundler (~> 1.16)
40
+ rake (~> 10.0)
41
+ rito_api!
42
+ rspec (~> 3.0)
43
+
44
+ BUNDLED WITH
45
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Manish Shahi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # RitoApi
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rito_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rito_api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rito_api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rito_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the RitoApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rito_api/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rito_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,74 @@
1
+ Dir[File.dirname(__FILE__) + '/requests/*.rb'].each {|file| require file } # Subclass.rb
2
+ require 'moneta'
3
+ require 'redis'
4
+ module RitoApi
5
+
6
+ class Client # Setting up a client to make request to league of legends api.
7
+ attr_accessor :region
8
+
9
+ def initialize(api_key, region, cache = false, ttl = 1) # Initializes the client.
10
+ @api_key = api_key
11
+ @region = region
12
+ @ttl = ttl
13
+ unless cache
14
+ @cache_store = nil
15
+ else
16
+ @cache_store = Moneta.new(:Redis, expires: @ttl) # ttl = time till the cache expires [Defaults to 1 as 0 means never expire.]
17
+ # @cache_store.clear
18
+ end
19
+ end
20
+
21
+ def close # Closes the client.
22
+ unless @cache_store.nil?
23
+ @cache_store.clear
24
+ end
25
+ end
26
+
27
+ def change_region(region) # Changes region after the client is already initialized.
28
+ @region = region
29
+ end
30
+
31
+ def summoner # Creates a new instance of summoner class. Used to make request relating to summoner. Check requests/summoner.rb for methods.
32
+ RitoApi::Requests::Summoner.new(@api_key, @region, @cache_store)
33
+ end
34
+
35
+ def challenger # Creates a new instance of challenger class. Used to make request relating to summoner. Check requests/challenger.rb for methods.
36
+ RitoApi::Requests::Challenger.new(@api_key, @region, @cache_store)
37
+ end
38
+
39
+ def champion # Creates a new instance of champion class. Used to make request relating to champion. Check requests/champion.rb for methods.
40
+ RitoApi::Requests::Champion.new(@api_key, @region, @cache_store)
41
+ end
42
+
43
+ def matches
44
+ RitoApi::Requests::Match.new(@api_key, @region, @cache_store)
45
+ end
46
+
47
+ def item
48
+ RitoApi::Requests::Item.new(@api_key, @region, @cache_store)
49
+ end
50
+
51
+ end
52
+ end
53
+
54
+
55
+ # client = RitoApi::Client.new('RGAPI-89538f52-2141-443c-aaaa-9cb0d44ea380', 'na', true, 5)
56
+ # summoner = client.summoner
57
+ # puts summoner.find('rockerturner')
58
+ # puts summoner.find('catdg')
59
+ # puts summoner.find('r0ckerm4n', 300)
60
+ # puts client.find('rockerturner')
61
+ # puts client.find(ign)
62
+ # client.close
63
+ # puts client.request_url("lol/summoner/v3/summoners/by-name/rockerturner")
64
+ # puts client.summoner.cache_store.nil?
65
+
66
+ # puts client.summoner.find('rockerturner')
67
+ # if client.cache?
68
+ # puts 'yes'
69
+ # else
70
+ # puts 'no'
71
+ # end
72
+ # client.cache_store
73
+ # puts client.summoner.cached?('rockerturner')
74
+
@@ -0,0 +1,79 @@
1
+ require 'uri'
2
+ require 'httparty'
3
+ module RitoApi
4
+ # Request Module that handles every requests.
5
+ module Requests
6
+ attr_accessor :region
7
+ class Base # Every other request class inherits from this class.
8
+
9
+ def initialize(api_key, region, cache_store) # Initializing
10
+ @api_key = api_key
11
+ @region = region
12
+ @cache_store = cache_store
13
+
14
+ end
15
+
16
+
17
+ def cached?(key)
18
+ unless @cache_store.nil?
19
+ @cache_store.key?(key)
20
+ end
21
+ end
22
+
23
+ def region_tag
24
+ region_tag = { :na => 'na1',
25
+ :eune => 'eun1',
26
+ :euw => 'euw1',
27
+ :jp => 'jp1',
28
+ :kr => 'kr',
29
+ :lan => 'la1',
30
+ :las => 'la2',
31
+ :br => 'br1',
32
+ :oce => 'oc1',
33
+ :tr => 'tr1',
34
+ :ru => 'ru',
35
+ :pbe => 'pbe1' }
36
+ return region_tag[@region.downcase.to_sym]
37
+ end
38
+
39
+ def base_url
40
+ return "https://#{region_tag}.api.riotgames.com/"
41
+ end
42
+
43
+ def request_url(pUrl)
44
+ return URI.encode("#{base_url}#{pUrl}?api_key=#{@api_key}")
45
+ end
46
+
47
+ def clean_url(url)
48
+ return url.split('?')[0]
49
+ end
50
+
51
+ def make_request(url, ttl)
52
+ unless @cache_store.nil?
53
+ return @cache_store.fetch(clean_url(url)){@cache_store.store(clean_url(url), symbolize(HTTParty.get(url).parsed_response), expires: ttl)}
54
+ else
55
+ return symbolize(HTTParty.get(url).parsed_response)
56
+ end
57
+ end
58
+
59
+ def symbolize(object)
60
+ if object.is_a?Hash
61
+ symbolized = Hash[object.map { |k, v| [k.to_sym, symbolize(v)] }]
62
+ return symbolized
63
+ elsif object.is_a?Array
64
+ symbolized = []
65
+ object.each {|x| symbolized.push(Hash[x.map { |k, v| [k.to_sym, symbolize(v)] }])}
66
+ return symbolized
67
+ end
68
+ return object
69
+ end
70
+
71
+ def leagueVer
72
+ HTTParty.get('https://ddragon.leagueoflegends.com/api/versions.json').parsed_response[0]
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,24 @@
1
+ module RitoApi
2
+
3
+ module Requests
4
+
5
+ class Challenger < Base
6
+
7
+ def solo_queue(count = 0, ttl = @ttl) # Not passing an argument / passing string (unless string is number)/ 0 => returns all 200 results.
8
+ payCheck = make_request(request_url("/lol/league/v3/challengerleagues/by-queue/RANKED_SOLO_5x5"), ttl)[:entries]
9
+ payLoad= []
10
+ if count.to_i <= 0 || count.to_i >200
11
+ return payCheck
12
+ else
13
+ payCheck.sort!{|x, y| y[:leaguePoints] <=> x[:leaguePoints]}
14
+ (0...count).each{|x| payLoad.push(payCheck[x])}
15
+ return payLoad
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,168 @@
1
+ module RitoApi
2
+ module Requests
3
+ class Champion < Base
4
+
5
+ def get_name(id)
6
+ champNames = {
7
+ '266' => 'Aatrox',
8
+ '103' => 'Ahri',
9
+ '84' => 'Akali',
10
+ '12' => 'Alistar',
11
+ '32' => 'Amumu',
12
+ '34' => 'Anivia',
13
+ '1' => 'Annie',
14
+ '22' => 'Ashe',
15
+ '136' => 'AurelionSol',
16
+ '268' => 'Azir',
17
+ '432' => 'Bard',
18
+ '53' => 'Blitzcrank',
19
+ '63' => 'Brand',
20
+ '201' => 'Braum',
21
+ '51' => 'Caitlyn',
22
+ '164' => 'Camille',
23
+ '69' => 'Cassiopeia',
24
+ '31' => 'Chogath',
25
+ '42' => 'Corki',
26
+ '122' => 'Darius',
27
+ '131' => 'Diana',
28
+ '36' => 'DrMundo',
29
+ '119' => 'Draven',
30
+ '245' => 'Ekko',
31
+ '60' => 'Elise',
32
+ '28' => 'Evelynn',
33
+ '81' => 'Ezreal',
34
+ '9' => 'Fiddlesticks',
35
+ '114' => 'Fiora',
36
+ '105' => 'Fizz',
37
+ '3' => 'Galio',
38
+ '41' => 'Gangplank',
39
+ '86' => 'Garen',
40
+ '150' => 'Gnar',
41
+ '79' => 'Gragas',
42
+ '104' => 'Graves',
43
+ '120' => 'Hecarim',
44
+ '74' => 'Heimerdinger',
45
+ '420' => 'Illaoi',
46
+ '427' => 'Ivern',
47
+ '39' => 'Irelia',
48
+ '40' => 'Janna',
49
+ '59' => 'JarvanIV',
50
+ '24' => 'Jax',
51
+ '126' => 'Jayce',
52
+ '202' => 'Jhin',
53
+ '222' => 'Jinx',
54
+ '145' => 'Kaisa',
55
+ '429' => 'Kalista',
56
+ '43' => 'Karma',
57
+ '30' => 'Karthus',
58
+ '38' => 'Kassadin',
59
+ '55' => 'Katarina',
60
+ '10' => 'Kayle',
61
+ '141' => 'Kayn',
62
+ '85' => 'Kennen',
63
+ '121' => 'Khazix',
64
+ '203' => 'Kindred',
65
+ '240' => 'Kled',
66
+ '96' => 'KogMaw',
67
+ '7' => 'Leblanc',
68
+ '64' => 'LeeSin',
69
+ '89' => 'Leona',
70
+ '127' => 'Lissandra',
71
+ '236' => 'Lucian',
72
+ '117' => 'Lulu',
73
+ '99' => 'Lux',
74
+ '54' => 'Malphite',
75
+ '90' => 'Malzahar',
76
+ '57' => 'Maokai',
77
+ '11' => 'MasterYi',
78
+ '21' => 'MissFortune',
79
+ '82' => 'Mordekaiser',
80
+ '25' => 'Morgana',
81
+ '267' => 'Nami',
82
+ '75' => 'Nasus',
83
+ '111' => 'Nautilus',
84
+ '76' => 'Nidalee',
85
+ '56' => 'Nocturne',
86
+ '20' => 'Nunu',
87
+ '2' => 'Olaf',
88
+ '61' => 'Orianna',
89
+ '516' => 'Ornn',
90
+ '80' => 'Pantheon',
91
+ '78' => 'Poppy',
92
+ '133' => 'Quinn',
93
+ '497' => 'Rakan',
94
+ '33' => 'Rammus',
95
+ '421' => 'RekSai',
96
+ '58' => 'Renekton',
97
+ '107' => 'Rengar',
98
+ '92' => 'Riven',
99
+ '68' => 'Rumble',
100
+ '13' => 'Ryze',
101
+ '113' => 'Sejuani',
102
+ '35' => 'Shaco',
103
+ '98' => 'Shen',
104
+ '102' => 'Shyvana',
105
+ '27' => 'Singed',
106
+ '14' => 'Sion',
107
+ '15' => 'Sivir',
108
+ '72' => 'Skarner',
109
+ '37' => 'Sona',
110
+ '16' => 'Soraka',
111
+ '50' => 'Swain',
112
+ '134' => 'Syndra',
113
+ '223' => 'TahmKench',
114
+ '163' => 'Taliyah',
115
+ '91' => 'Talon',
116
+ '44' => 'Taric',
117
+ '17' => 'Teemo',
118
+ '412' => 'Thresh',
119
+ '18' => 'Tristana',
120
+ '48' => 'Trundle',
121
+ '23' => 'Tryndamere',
122
+ '4' => 'TwistedFate',
123
+ '29' => 'Twitch',
124
+ '77' => 'Udyr',
125
+ '6' => 'Urgot',
126
+ '110' => 'Varus',
127
+ '67' => 'Vayne',
128
+ '45' => 'Veigar',
129
+ '161' => 'Velkoz',
130
+ '254' => 'Vi',
131
+ '112' => 'Viktor',
132
+ '8' => 'Vladimir',
133
+ '106' => 'Volibear',
134
+ '19' => 'Warwick',
135
+ '62' => 'MonkeyKing',
136
+ '498' => 'Xayah',
137
+ '101' => 'Xerath',
138
+ '5' => 'XinZhao',
139
+ '157' => 'Yasuo',
140
+ '83' => 'Yorick',
141
+ '154' => 'Zac',
142
+ '238' => 'Zed',
143
+ '115' => 'Ziggs',
144
+ '26' => 'Zilean',
145
+ '142' => 'Zoe',
146
+ '143' => 'Zyra'}
147
+ return champNames[id.to_s]
148
+ end
149
+
150
+ def icon(champName)
151
+ icon = "https://ddragon.leagueoflegends.com/cdn/#{leagueVer}/img/champion/#{champName}.png"
152
+ return icon
153
+ end
154
+
155
+ def points(points)
156
+ if points.to_i < 1000
157
+ return points
158
+ elsif points.to_i >= 1000 and points.to_i < 1000000
159
+ fixed = points.to_f/1000.0
160
+ return ('%.1f' % fixed).to_s + ' K'
161
+ elsif points.to_i >= 1000000
162
+ fixed = points.to_f/1000000.0
163
+ return ('%.1f' % fixed).to_s + ' M'
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,44 @@
1
+ module RitoApi
2
+
3
+ module Requests
4
+
5
+ class Item < Base
6
+
7
+ def get_icon(id)
8
+
9
+ return "https://ddragon.leagueoflegends.com/cdn/#{leagueVer}/img/item/#{id}.png"
10
+
11
+ end
12
+
13
+ def spells_icon(id)
14
+
15
+ spells = {
16
+ 34 =>'SummonerSiegeChampSelect2',
17
+ 12 =>'SummonerTeleport',
18
+ 33 =>'SummonerSiegeChampSelect1',
19
+ 3 =>'SummonerExhaust',
20
+ 21 =>'SummonerBarrier',
21
+ 13 =>'SummonerMana',
22
+ 39 =>'SummonerSnowURFSnowball_Mark',
23
+ 4 =>'SummonerFlash',
24
+ 32 =>'SummonerSnowball',
25
+ 14 =>'SummonerDot',
26
+ 36 =>'SummonerDarkStarChampSelect2',
27
+ 35 =>'SummonerDarkStarChampSelect1',
28
+ 30 =>'SummonerPoroRecall',
29
+ 6 =>'SummonerHaste',
30
+ 7 =>'SummonerHeal',
31
+ 31 =>'SummonerPoroThrow',
32
+ 1 =>'SummonerBoost',
33
+ 11 =>'SummonerSmite',
34
+ }
35
+
36
+ return "https://ddragon.leagueoflegends.com/cdn/#{leagueVer}/img/spell/#{spells[id]}.png"
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,51 @@
1
+ module RitoApi
2
+
3
+ module Requests
4
+
5
+ class Match < Base
6
+
7
+ def get(matchId, ttl = @ttl)
8
+
9
+ return make_request(request_url("lol/match/v3/matches/#{matchId}"), ttl)
10
+
11
+ end
12
+
13
+ def get_bans(matchId, ttl = @ttl)
14
+ payCheck = get(matchId, ttl)[:teams]
15
+ bans = []
16
+ payCheck.each {|x| bans.push(x[:bans])}
17
+ return bans
18
+ end
19
+
20
+ def get_players(matchId, ttl = @ttl)
21
+ get(matchId, ttl)[:participantIdentities]
22
+ end
23
+
24
+ def stats(matchId, ttl = @ttl)
25
+ get(matchId, ttl)[:participants]
26
+ end
27
+
28
+ def player_stats(matchId, championId, ttl = @ttl)
29
+ playerStats = {}
30
+ stats(matchId, ttl).each do |pStats|
31
+ if pStats[:championId] == championId
32
+ playerStats = pStats
33
+ end
34
+ end
35
+ return playerStats
36
+ end
37
+
38
+ def player_identities(matchId, participantId, ttl = @ttl)
39
+ playerIdentity={}
40
+ get_players(matchId, ttl).each do |player|
41
+ if player[:participantId] == participantId
42
+ playerIdentity = player
43
+ end
44
+ end
45
+ return playerIdentity
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,100 @@
1
+ module RitoApi
2
+
3
+ module Requests
4
+
5
+ class Summoner < Base
6
+
7
+ def find(ign, ttl = @ttl) # Finds summoner using the summonerName.
8
+ return make_request(request_url("lol/summoner/v3/summoners/by-name/#{ign}"), ttl)
9
+ end
10
+
11
+ def find_by_summonerID(id, ttl = @ttl) # Finds summoner using summonerID. [Not encouraged method to be used, unless under the hood.]
12
+ return make_request(request_url("lol/summoner/v3/summoners/#{id}"), ttl)
13
+ end
14
+
15
+ def find_by_accountID(id, ttl = @ttl) # Finds summoner using accountID. [Don't use unless absolutely necessary]
16
+ return make_request(request_url("lol/summoner/v3/summoners/by-account/#{id}"), ttl)
17
+ end
18
+
19
+ def rank_info(ign, ttl = @ttl)
20
+ unless ign.is_a?Numeric
21
+ return make_request(request_url("lol/league/v3/positions/by-summoner/#{find(ign)[:id]}"), ttl)
22
+ else
23
+ return make_request(request_url("lol/league/v3/positions/by-summoner/#{ign}"), ttl)
24
+ end
25
+ end
26
+
27
+ def solo(ign, ttl = @ttl)
28
+ rank = {}
29
+ rank_info(ign,ttl).each do |r|
30
+ if r[:queueType] == 'RANKED_SOLO_5x5'
31
+ rank = r
32
+ end
33
+ end
34
+ return rank
35
+ end
36
+
37
+ def flex(ign, ttl = @ttl)
38
+ rank = {}
39
+ rank_info(ign,ttl).each do |r|
40
+ if r[:queueType] == 'RANKED_FLEX_SR'
41
+ rank = r
42
+ end
43
+ end
44
+ return rank
45
+ end
46
+
47
+ def tt(ign, ttl = @ttl)
48
+ rank = {}
49
+ rank_info(ign,ttl).each do |r|
50
+ if r[:queueType] == 'RANKED_FLEX_TT'
51
+ rank = r
52
+ end
53
+ end
54
+ return rank
55
+ end
56
+
57
+ def recent_matches(ign, ttl = @ttl)
58
+ return make_request(request_url("lol/match/v3/matchlists/by-account/#{find(ign)[:accountId]}/recent"), ttl)
59
+ end
60
+
61
+ def top_positions(ign, ttl = @ttl)
62
+ positions=[]
63
+ recent_matches(ign, ttl)[:matches].each do |x|
64
+
65
+ if x[:lane] == 'BOTTOM'
66
+ positions.push(x[:role])
67
+ else
68
+ positions.push(x[:lane])
69
+ end
70
+ end
71
+ positions = Hash[positions.group_by(&:itself).map {|k,v| [k, v.size] }]
72
+ return (positions.sort_by{|k,v|v}.reverse.map{|k,v| k}).values_at(0,1)
73
+ end
74
+
75
+ def icon(iconId)
76
+ icon = "https://ddragon.leagueoflegends.com/cdn/#{leagueVer}/img/profileicon/#{iconId.to_i}.png"
77
+ return icon
78
+ end
79
+
80
+ def champion_mastery(ign, count = 0, ttl= @ttl)
81
+ unless ign.is_a?Numeric
82
+ mastery = make_request(request_url("lol/champion-mastery/v3/champion-masteries/by-summoner/#{find(ign)[:id]}"), ttl)
83
+ else
84
+ mastery = make_request(request_url("lol/champion-mastery/v3/champion-masteries/by-summoner/#{ign}"), ttl)
85
+ end
86
+ topChamps=[]
87
+
88
+ if count.to_i <= 0 or count.to_i >= mastery.size
89
+ return mastery
90
+ else
91
+ (0...count.to_i).each{|x| topChamps.push(mastery[x])}
92
+ return topChamps
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,3 @@
1
+ module RitoApi
2
+ VERSION = "0.1.0"
3
+ end
data/lib/rito_api.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "rito_api/version"
2
+ require "rito_api/client"
3
+ module RitoApi
4
+ # Your code goes here...
5
+ end
data/rito_api.gemspec ADDED
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rito_api/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rito_api"
8
+ spec.version = RitoApi::VERSION
9
+ spec.authors = ["Manish Shahi"]
10
+ spec.email = ["manish.shahi@mnsu.edu"]
11
+
12
+ spec.summary = %q{A gem that wraps Riots API into RUBY}
13
+ spec.description = %q{All the API calls are made into functions and methods.}
14
+ spec.homepage = "https://github.com/maniSHahi/rito_api"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.16"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+
37
+ spec.add_runtime_dependency "httparty", "~> 0.16.1"
38
+ spec.add_runtime_dependency 'moneta', '~> 1.0'
39
+ spec.add_runtime_dependency 'fileutils', '~> 1.0', '>= 1.0.2'
40
+ spec.add_runtime_dependency 'redis', '~> 4.0', '>= 4.0.1'
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rito_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Manish Shahi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.16.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.16.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: moneta
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fileutils
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.0.2
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.0'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 1.0.2
103
+ - !ruby/object:Gem::Dependency
104
+ name: redis
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '4.0'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 4.0.1
113
+ type: :runtime
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '4.0'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 4.0.1
123
+ description: All the API calls are made into functions and methods.
124
+ email:
125
+ - manish.shahi@mnsu.edu
126
+ executables: []
127
+ extensions: []
128
+ extra_rdoc_files: []
129
+ files:
130
+ - ".gitignore"
131
+ - ".travis.yml"
132
+ - CODE_OF_CONDUCT.md
133
+ - Gemfile
134
+ - Gemfile.lock
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - bin/console
139
+ - bin/setup
140
+ - lib/rito_api.rb
141
+ - lib/rito_api/client.rb
142
+ - lib/rito_api/requests/base.rb
143
+ - lib/rito_api/requests/challenger.rb
144
+ - lib/rito_api/requests/champion.rb
145
+ - lib/rito_api/requests/item.rb
146
+ - lib/rito_api/requests/match.rb
147
+ - lib/rito_api/requests/summoner.rb
148
+ - lib/rito_api/version.rb
149
+ - rito_api.gemspec
150
+ homepage: https://github.com/maniSHahi/rito_api
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.6.8
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: A gem that wraps Riots API into RUBY
174
+ test_files: []