riot_lol_api 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99acab5f7d14ce06c29520afb7a02e281c44dd9d
4
+ data.tar.gz: 093011263f54196eb6cb88bcefa873e271eee233
5
+ SHA512:
6
+ metadata.gz: 5b4e3d403982c2a5783fa5d0868326633ed44cd7633a834126177ebb10456bef61b3378dcc0cbc326ab4e6d3282fe196b41a117812fc59632ec723e6cccc412d
7
+ data.tar.gz: 1b321fad05bfc50119b4600ab84b8fe9c255b00ef1c6b238d10ae61100e54e1fb6b37ed0516a3a9bda5da38918946037f3637413e1656bce517089c85c8862ec
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in riot_lol_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 francois_blanchard
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,33 @@
1
+ # RiotLolApi
2
+
3
+ RIOT LOL API
4
+
5
+ ## Status
6
+
7
+ In work ...
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'riot_lol_api'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install riot_lol_api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( http://github.com/<my-github-username>/riot_lol_api/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,58 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ module RiotLolApi
5
+ class Client
6
+
7
+ # attr
8
+ # - region
9
+ def initialize(options = {})
10
+ options.each do |key, value|
11
+ self.class.send(:attr_accessor, key.to_sym)
12
+ instance_variable_set("@#{key}", value)
13
+ end
14
+ end
15
+
16
+ def self.get url
17
+ unless RiotLolApi::TOKEN.nil?
18
+ response = HTTParty.get(url, :query => {:api_key => RiotLolApi::TOKEN})
19
+ case response.code
20
+ when 200
21
+ JSON.parse(response.body)
22
+ when 404
23
+ puts "Error server"
24
+ nil
25
+ when 500...600
26
+ puts "ERROR #{response.code}"
27
+ nil
28
+ end
29
+ else
30
+ puts "No TOKEN, you have to define RiotLolApi::TOKEN"
31
+ nil
32
+ end
33
+ end
34
+
35
+ def get_summoner_by_name name
36
+ name = name.downcase
37
+ name.strip!
38
+ response = Client.get("https://prod.api.pvp.net/api/lol/#{@region}/v1.4/summoner/by-name/#{name}")
39
+ unless response.nil?
40
+ summoner = response[name]
41
+ RiotLolApi::Model::Summoner.new(:id_summoner => summoner["id"],:name => summoner["name"],:profile_icon_id => summoner["profileIconId"],:summoner_level => summoner["summonerLevel"],:revision_date_str => '',:revision_date => summoner["revisionDate"],:region => @region)
42
+ else
43
+ nil
44
+ end
45
+ end
46
+
47
+ def get_summoner_by_id id
48
+ response = Client.get("https://prod.api.pvp.net/api/lol/#{@region}/v1.4/summoner/#{id}")
49
+ unless response.nil?
50
+ summoner = response[id.to_s]
51
+ RiotLolApi::Model::Summoner.new(:id_summoner => summoner["id"],:name => summoner["name"],:profile_icon_id => summoner["profileIconId"],:summoner_level => summoner["summonerLevel"],:revision_date_str => '',:revision_date => summoner["revisionDate"],:region => @region)
52
+ else
53
+ nil
54
+ end
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,19 @@
1
+ require 'riot_lol_api/model/player'
2
+ require 'riot_lol_api/model/stat'
3
+
4
+ module RiotLolApi
5
+ module Model
6
+ class Game
7
+
8
+ # attr :champion_id, :create_date, :create_date_str, :fellow_players, :game_id, :game_mode, :game_type, :level, :map_id, :spell1, :spell2, :stats, :sub_type, :team_id
9
+
10
+ def initialize(options = {})
11
+ options.each do |key, value|
12
+ self.class.send(:attr_accessor, key.to_sym)
13
+ instance_variable_set("@#{key}", value)
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ require 'riot_lol_api/model/talent'
2
+
3
+ module RiotLolApi
4
+ module Model
5
+ class Mastery
6
+
7
+ # attr :id_mastery, :name, :current, :talents
8
+
9
+ def initialize(options = {})
10
+ options.each do |key, value|
11
+ self.class.send(:attr_accessor, key.to_sym)
12
+ instance_variable_set("@#{key}", value)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module RiotLolApi
2
+ module Model
3
+ class Player
4
+
5
+ # attr :summoner_id, :team_id, :champion_id
6
+
7
+ def initialize(options = {})
8
+ options.each do |key, value|
9
+ self.class.send(:attr_accessor, key.to_sym)
10
+ instance_variable_set("@#{key}", value)
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'riot_lol_api/model/slot'
2
+
3
+ module RiotLolApi
4
+ module Model
5
+ class Rune
6
+
7
+ # attr :id_rune, :name, :current, :slots
8
+
9
+ def initialize(options = {})
10
+ options.each do |key, value|
11
+ self.class.send(:attr_accessor, key.to_sym)
12
+ instance_variable_set("@#{key}", value)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module RiotLolApi
2
+ module Model
3
+ class Slot
4
+
5
+ # attr :id_slot, :rank
6
+
7
+ def initialize(options = {})
8
+ options.each do |key, value|
9
+ self.class.send(:attr_accessor, key.to_sym)
10
+ instance_variable_set("@#{key}", value)
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module RiotLolApi
2
+ module Model
3
+ class Stat
4
+
5
+ # attr
6
+ # :totalDamageDealtToChampions :goldEarned :item2 :item1 :wardPlaced :totalDamageTaken :item0 :physicalDamageDealtPlayer :totalUnitsHealed :level :magicDamageDealtToChampions :magicDamageDealtPlayer :assists :magicDamageTaken :numDeaths :totalTimeCrowdControlDealt :physicalDamageTaken :win :team :sightWardsBought :totalDamageDealt :totalHeal :item4 :item3 :item6 :minionsKilled :timePlayed :physicalDamageDealtToChampions :trueDamageTaken :goldSpent
7
+
8
+ def initialize(options = {})
9
+ options.each do |key, value|
10
+ self.class.send(:attr_accessor, key.to_sym)
11
+ instance_variable_set("@#{key}", value)
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,86 @@
1
+ module RiotLolApi
2
+ module Model
3
+ class Summoner
4
+
5
+ # attr :id_summoner, :name, :profile_icon_id, :summoner_level, :revision_date_str, :revision_date, :region
6
+
7
+ def initialize(options = {})
8
+ options.each do |key, value|
9
+ self.class.send(:attr_accessor, key.to_sym)
10
+ instance_variable_set("@#{key}", value)
11
+ end
12
+ end
13
+
14
+ def masteries
15
+ response = Client.get("https://prod.api.pvp.net/api/lol/#{@region}/v1.4/summoner/#{@id_summoner}/masteries")
16
+ unless response.nil?
17
+ masteries = response[self.id_summoner.to_s]['pages']
18
+ # masteries
19
+ tab_masteries = Array.new
20
+ masteries.each do |mastery|
21
+ # talents
22
+ tab_talents = Array.new
23
+ unless mastery['masteries'].nil?
24
+ mastery['masteries'].each do |talent|
25
+ tab_talents << RiotLolApi::Model::Talent.new(:id_talent => talent['id'], :rank => talent['rank'])
26
+ end
27
+ end
28
+ tab_masteries << RiotLolApi::Model::Mastery.new(:id_mastery => mastery["id"], :name => mastery["name"], :current => mastery["current"], :talents => tab_talents)
29
+ end
30
+ tab_masteries
31
+ else
32
+ nil
33
+ end
34
+ end
35
+
36
+ def runes
37
+ response = Client.get("https://prod.api.pvp.net/api/lol/#{@region}/v1.4/summoner/#{@id_summoner}/runes")
38
+ unless response.nil?
39
+ runes = response[self.id_summoner.to_s]['pages']
40
+ # runes
41
+ tab_runes = Array.new
42
+ runes.each do |rune|
43
+ # talents
44
+ tab_slots = Array.new
45
+ unless rune['slots'].nil?
46
+ rune['slots'].each do |slot|
47
+ tab_slots << RiotLolApi::Model::Slot.new(:id_slot => slot['runeId'], :rank => slot['runeSlotId'])
48
+ end
49
+ end
50
+ tab_runes << RiotLolApi::Model::Rune.new(:id_rune => rune["id"], :name => rune["name"], :current => rune["current"], :slots => tab_slots)
51
+ end
52
+
53
+ tab_runes
54
+ else
55
+ nil
56
+ end
57
+ end
58
+
59
+ def games
60
+ response = Client.get("https://prod.api.pvp.net/api/lol/#{@region}/v1.3/game/by-summoner/#{@id_summoner}/recent")
61
+ unless response.nil?
62
+ games = response['games']
63
+
64
+ tab_games = Array.new
65
+ games.each do |game|
66
+
67
+ tab_fellow_players = Array.new
68
+ game['fellowPlayers'].each do |fellow_player|
69
+ tab_fellow_players << RiotLolApi::Model::Player.new(:summoner_id => fellow_player['summonerId'], :team_id => fellow_player['teamId'], :champion_id => fellow_player['championId'])
70
+ end
71
+
72
+ stat = game['stats']
73
+ tab_stats = RiotLolApi::Model::Stat.new(:total_damage_dealt_to_champions => stat['totalDamageDealtToChampions'], :gold_earned => stat['goldEarned'], :item2 => stat['item2'], :item1 => stat['item1'], :ward_placed => stat['wardPlaced'], :total_damage_taken => stat['totalDamageTaken'], :item0 => stat['item0'], :physical_damage_dealt_player => stat['physicalDamageDealtPlayer'], :total_units_healed => stat['totalUnitsHealed'], :level => stat['level'], :magic_damage_dealt_to_champions => stat['magicDamageDealtToChampions'], :magic_damage_dealt_player => stat['magicDamageDealtPlayer'], :assists => stat['assists'], :magic_damage_taken => stat['magicDamageTaken'], :num_deaths => stat['numDeaths'], :total_time_crowd_control_dealt => stat['totalTimeCrowdControlDealt'], :physical_damage_taken => stat['physicalDamageTaken'], :win => stat['win'], :team => stat['team'], :sight_wards_bought => stat['sightWardsBought'], :total_damage_dealt => stat['totalDamageDealt'], :total_heal => stat['totalHeal'], :item4 => stat['item4'], :item3 => stat['item3'], :item6 => stat['item6'], :minions_killed => stat['minionsKilled'], :time_played => stat['timePlayed'], :physical_damage_dealt_to_champions => stat['physicalDamageDealtToChampions'], :true_damage_taken => stat['trueDamageTaken'], :gold_spent => stat['goldSpent'])
74
+
75
+ tab_games << RiotLolApi::Model::Game.new(:champion_id => game['championId'], :invalid => game['invalid'], :ip_earned => game['ipEarned'], :create_date => game['createDate'], :create_date_str => '', :fellow_players => tab_fellow_players, :game_id => game['gameId'], :game_mode => game['gameMode'], :game_type => game['gameType'], :level => game['level'], :map_id => game['mapId'], :spell1 => game['spell1'], :spell2 => game['spell2'], :stats => tab_stats, :sub_type => game['subType'], :team_id => game['teamId'])
76
+ end
77
+
78
+ tab_games
79
+ else
80
+ nil
81
+ end
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,16 @@
1
+ module RiotLolApi
2
+ module Model
3
+ class Talent
4
+
5
+ # attr :id_talent, :rank
6
+
7
+ def initialize(options = {})
8
+ options.each do |key, value|
9
+ self.class.send(:attr_accessor, key.to_sym)
10
+ instance_variable_set("@#{key}", value)
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ require 'riot_lol_api/model/summoner'
2
+ require 'riot_lol_api/model/mastery'
3
+ require 'riot_lol_api/model/rune'
4
+ require 'riot_lol_api/model/game'
5
+
6
+ module RiotLolApi
7
+ module Model
8
+
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module RiotLolApi
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,7 @@
1
+ require "riot_lol_api/version"
2
+ require "riot_lol_api/client"
3
+ require "riot_lol_api/model"
4
+
5
+ module RiotLolApi
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'riot_lol_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "riot_lol_api"
8
+ spec.version = RiotLolApi::VERSION
9
+ spec.authors = ["francois_blanchard"]
10
+ spec.email = ["francois.blanchard1@gmail.com"]
11
+ spec.summary = %q{Riot games api}
12
+ spec.description = %q{Riot games api wrapper for ruby}
13
+ spec.homepage = "https://github.com/francois-blanchard/riot_lol_api"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.14.1"
24
+ spec.add_development_dependency "factory_girl"
25
+ spec.add_development_dependency "webmock"
26
+
27
+ spec.add_dependency "httparty"
28
+ end
data/spec/.DS_Store ADDED
Binary file
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :client, :class => RiotLolApi::Client do
3
+ region "euw"
4
+ initialize_with { new(:region => region) }
5
+ end
6
+ end
@@ -0,0 +1,20 @@
1
+ FactoryGirl.define do
2
+ factory :game, :class => RiotLolApi::Model::Game do
3
+ game_id 1462450355
4
+ invalid false
5
+ game_mode "CLASSIC"
6
+ game_type "MATCHED_GAME"
7
+ sub_type "NORMAL"
8
+ map_id 1
9
+ team_id 200
10
+ champion_id 44
11
+ spell1 4
12
+ spell2 7
13
+ level 30
14
+ ip_earned 52
15
+ create_date 1399415779754
16
+ fellow_players []
17
+ stats []
18
+ initialize_with { new(:game_id => game_id, :invalid => invalid, :game_mode => game_mode, :game_type => game_type, :sub_type => sub_type, :map_id => map_id, :team_id => team_id, :champion_id => champion_id, :spell1 => spell1, :spell2 => spell2, :level => level, :ip_earned => ip_earned, :create_date => create_date) }
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ factory :mastery, :class => RiotLolApi::Model::Mastery do
3
+ id_mastery 37482369
4
+ name "support"
5
+ current false
6
+ talents nil
7
+ initialize_with { new(:id_mastery => id_mastery, :name => name, :current => current, :talents => talents) }
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ factory :rune, :class => RiotLolApi::Model::Rune do
3
+ id_rune 37482369
4
+ name "support"
5
+ current false
6
+ slots nil
7
+ initialize_with { new(:id_rune => id_rune, :name => name, :current => current, :slots => slots) }
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ FactoryGirl.define do
2
+ factory :summoner, :class => RiotLolApi::Model::Summoner do
3
+ id_summoner 20639710
4
+ name "PacoLoco"
5
+ profile_icon_id 8
6
+ summoner_level 30
7
+ revision_date_str ''
8
+ revision_date 1398345588000
9
+ region "euw"
10
+ initialize_with { new(:id_summoner => id_summoner, :name => name, :profile_icon_id => profile_icon_id, :summoner_level => summoner_level, :revision_date_str => revision_date_str, :revision_date => revision_date, :region => region) }
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Access-Control-Allow-Headers: Content-Type
3
+ Access-Control-Allow-Methods: GET, POST, DELETE, PUT
4
+ Access-Control-Allow-Origin: *
5
+ Content-Type: application/json; charset=UTF-8
6
+ Date: Mon, 05 May 2014 17:08:17 GMT
7
+ Server: Jetty(9.1.1.v20140108)
8
+ Vary: Accept-Encoding, User-Agent
9
+ Content-Length: 112
10
+ Connection: keep-alive
11
+
12
+ {"20639710":{"id":20639710,"name":"PacoLoco","profileIconId":8,"summonerLevel":30,"revisionDate":1398345588000}}
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Access-Control-Allow-Headers: Content-Type
3
+ Access-Control-Allow-Methods: GET, POST, DELETE, PUT
4
+ Access-Control-Allow-Origin: *
5
+ Content-Type: application/json; charset=UTF-8
6
+ Date: Sun, 27 Apr 2014 10:55:27 GMT
7
+ Server: Jetty(9.1.1.v20140108)
8
+ Vary: Accept-Encoding, User-Agent
9
+ Content-Length: 112
10
+ Connection: keep-alive
11
+
12
+ {"pacoloco":{"id":20639710,"name":"PacoLoco","profileIconId":8,"summonerLevel":30,"revisionDate":1398345588000}}
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Access-Control-Allow-Headers: Content-Type
3
+ Access-Control-Allow-Methods: GET, POST, DELETE, PUT
4
+ Access-Control-Allow-Origin: *
5
+ Content-Type: application/json; charset=UTF-8
6
+ Date: Wed, 07 May 2014 16:56:22 GMT
7
+ Server: Jetty(9.1.1.v20140108)
8
+ Vary: Accept-Encoding, User-Agent
9
+ transfer-encoding: chunked
10
+ Connection: keep-alive
11
+
12
+ {"games":[{"gameId":1462450355,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"NORMAL","mapId":1,"teamId":200,"championId":44,"spell1":4,"spell2":7,"level":30,"ipEarned":52,"createDate":1399415779754,"fellowPlayers":[{"summonerId":228437,"teamId":200,"championId":102},{"summonerId":25235641,"teamId":100,"championId":48}],"stats":{"level":13,"goldEarned":5969,"numDeaths":2,"minionsKilled":10,"goldSpent":5630,"totalDamageDealt":19848,"totalDamageTaken":16127,"team":200,"win":false,"physicalDamageDealtPlayer":7116,"magicDamageDealtPlayer":12732,"physicalDamageTaken":7806,"magicDamageTaken":8069,"timePlayed":1597,"totalHeal":9241,"totalUnitsHealed":4,"assists":8,"item0":3301,"item1":2049,"item2":3047,"item3":3110,"item4":1057,"item6":3340,"sightWardsBought":1,"magicDamageDealtToChampions":3100,"physicalDamageDealtToChampions":1230,"totalDamageDealtToChampions":4330,"trueDamageTaken":252,"wardPlaced":14,"totalTimeCrowdControlDealt":602}}]}
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Access-Control-Allow-Headers: Content-Type
3
+ Access-Control-Allow-Methods: GET, POST, DELETE, PUT
4
+ Access-Control-Allow-Origin: *
5
+ Content-Type: application/json; charset=UTF-8
6
+ Date: Mon, 05 May 2014 17:29:33 GMT
7
+ Server: Jetty(9.1.1.v20140108)
8
+ Vary: Accept-Encoding, User-Agent
9
+ Content-Length: 2660
10
+ Connection: keep-alive
11
+
12
+ {"20639710":{"summonerId":20639710,"pages":[{"id":37482369,"name":"support","current":false,"masteries":[{"id":4212,"rank":2},{"id":4233,"rank":3}]},{"id":37482370,"name":"jungler","current":false,"masteries":[{"id":4233,"rank":3},{"id":4242,"rank":1}]}]}}
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Access-Control-Allow-Headers: Content-Type
3
+ Access-Control-Allow-Methods: GET, POST, DELETE, PUT
4
+ Access-Control-Allow-Origin: *
5
+ Content-Type: application/json; charset=UTF-8
6
+ Date: Mon, 05 May 2014 23:05:58 GMT
7
+ Server: Jetty(9.1.1.v20140108)
8
+ Vary: Accept-Encoding, User-Agent
9
+ Content-Length: 2053
10
+ Connection: keep-alive
11
+
12
+ {"20639710":{"summonerId":20639710,"pages":[{"id":6182779,"name":"ad","current":true,"slots":[{"runeSlotId":1,"runeId":5253},{"runeSlotId":2,"runeId":5253}]},{"id":6182780,"name":"ap","current":false,"slots":[{"runeSlotId":1,"runeId":5245},{"runeSlotId":2,"runeId":5245}]}]}}
@@ -0,0 +1,168 @@
1
+ require 'spec_helper'
2
+ require 'riot_lol_api'
3
+ require 'pp'
4
+
5
+ describe RiotLolApi::Client do
6
+
7
+ describe "get_summoner_by_name" do
8
+
9
+ before(:each) do
10
+ # Create client
11
+ client = FactoryGirl.build(:client)
12
+ name = "pacoloco"
13
+
14
+ api_response = File.read 'spec/mock_response/get_summoner_by_name.json'
15
+ stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/#{name}?api_key=#{RiotLolApi::TOKEN}").to_return(api_response)
16
+
17
+ @summoner_test = client.get_summoner_by_name(name)
18
+ end
19
+
20
+ it "should get summoner object" do
21
+ expect(@summoner_test).to be_a RiotLolApi::Model::Summoner
22
+ end
23
+
24
+ it "should good attributes" do
25
+ summoner = FactoryGirl.build(:summoner)
26
+
27
+ expect(@summoner_test.id_summoner).to eq(summoner.id_summoner)
28
+ expect(@summoner_test.name).to eq(summoner.name)
29
+ expect(@summoner_test.profile_icon_id).to eq(summoner.profile_icon_id)
30
+ expect(@summoner_test.summoner_level).to eq(summoner.summoner_level)
31
+ expect(@summoner_test.revision_date_str).to eq(summoner.revision_date_str)
32
+ expect(@summoner_test.revision_date).to eq(summoner.revision_date)
33
+ expect(@summoner_test.region).to eq(summoner.region)
34
+ end
35
+ end
36
+
37
+ describe "get_summoner_by_id" do
38
+
39
+ before(:each) do
40
+ # Create client
41
+ client = FactoryGirl.build(:client)
42
+ id = 20639710
43
+
44
+ api_response = File.read 'spec/mock_response/get_summoner_by_id.json'
45
+ stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.4/summoner/#{id}?api_key=#{RiotLolApi::TOKEN}").to_return(api_response)
46
+
47
+ @summoner_test = client.get_summoner_by_id(id)
48
+ end
49
+
50
+ it "should get summoner object" do
51
+ expect(@summoner_test).to be_a RiotLolApi::Model::Summoner
52
+ end
53
+
54
+ it "should good attributes" do
55
+ summoner = FactoryGirl.build(:summoner)
56
+
57
+ expect(@summoner_test.id_summoner).to eq(summoner.id_summoner)
58
+ expect(@summoner_test.name).to eq(summoner.name)
59
+ expect(@summoner_test.profile_icon_id).to eq(summoner.profile_icon_id)
60
+ expect(@summoner_test.summoner_level).to eq(summoner.summoner_level)
61
+ expect(@summoner_test.revision_date_str).to eq(summoner.revision_date_str)
62
+ expect(@summoner_test.revision_date).to eq(summoner.revision_date)
63
+ expect(@summoner_test.region).to eq(summoner.region)
64
+ end
65
+ end
66
+
67
+ describe "get summoner masteries" do
68
+
69
+ before(:each) do
70
+ # Create summoner
71
+ summoner = FactoryGirl.build(:summoner)
72
+
73
+ api_response = File.read 'spec/mock_response/get_summoner_masteries_by_id.json'
74
+ stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.4/summoner/#{summoner.id_summoner}/masteries?api_key=#{RiotLolApi::TOKEN}").to_return(api_response)
75
+
76
+ @mastery_test = summoner.masteries
77
+ end
78
+
79
+ it "should good attributes" do
80
+ tab_mastery = Array.new
81
+ tab_mastery << FactoryGirl.build(:mastery, :id_mastery => 37482369, :name => "support", :current => false, :talents => [RiotLolApi::Model::Talent.new(:id_talent => 4212,:rank => 2),RiotLolApi::Model::Talent.new(:id_talent => 4233,:rank => 3)])
82
+ tab_mastery << FactoryGirl.build(:mastery, :id_mastery => 37482370, :name => "jungler", :current => false, :talents => [RiotLolApi::Model::Talent.new(:id_talent => 4233,:rank => 3),RiotLolApi::Model::Talent.new(:id_talent => 4242,:rank => 1)])
83
+
84
+ @mastery_test.each_with_index do |mastery,i|
85
+ expect(mastery.id_mastery).to eq(tab_mastery[i].id_mastery)
86
+ expect(mastery.name).to eq(tab_mastery[i].name)
87
+ expect(mastery.current).to eq(tab_mastery[i].current)
88
+ mastery.talents.each_with_index do |talent,j|
89
+ expect(talent.id_talent).to eq(tab_mastery[i].talents[j].id_talent)
90
+ expect(talent.rank).to eq(tab_mastery[i].talents[j].rank)
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+ describe "get summoner runes" do
97
+
98
+ before(:each) do
99
+ # Create summoner
100
+ summoner = FactoryGirl.build(:summoner)
101
+
102
+ api_response = File.read 'spec/mock_response/get_summoner_runes_by_id.json'
103
+ stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.4/summoner/#{summoner.id_summoner}/runes?api_key=#{RiotLolApi::TOKEN}").to_return(api_response)
104
+
105
+ @rune_test = summoner.runes
106
+ end
107
+
108
+ it "should good attributes" do
109
+ tab_runes = Array.new
110
+ tab_runes << FactoryGirl.build(:rune, :id_rune => 6182779, :name => "ad", :current => true, :slots => [RiotLolApi::Model::Slot.new(:id_slot => 5253,:rank => 1),RiotLolApi::Model::Slot.new(:id_slot => 5253,:rank => 2)])
111
+ tab_runes << FactoryGirl.build(:rune, :id_rune => 6182780, :name => "ap", :current => false, :slots => [RiotLolApi::Model::Slot.new(:id_slot => 5245,:rank => 1),RiotLolApi::Model::Slot.new(:id_slot => 5245,:rank => 2)])
112
+
113
+ @rune_test.each_with_index do |rune,i|
114
+ expect(rune.id_rune).to eq(tab_runes[i].id_rune)
115
+ expect(rune.name).to eq(tab_runes[i].name)
116
+ expect(rune.current).to eq(tab_runes[i].current)
117
+ rune.slots.each_with_index do |slot,j|
118
+ expect(slot.id_slot).to eq(tab_runes[i].slots[j].id_slot)
119
+ expect(slot.rank).to eq(tab_runes[i].slots[j].rank)
120
+ end
121
+ end
122
+ end
123
+ end
124
+
125
+ describe "get summoner games" do
126
+
127
+ before(:each) do
128
+ # Create summoner
129
+ summoner = FactoryGirl.build(:summoner)
130
+
131
+ api_response = File.read 'spec/mock_response/get_summoner_games_by_id.json'
132
+ stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/game/by-summoner/#{summoner.id_summoner}/recent?api_key=#{RiotLolApi::TOKEN}").to_return(api_response)
133
+
134
+ @game_tests = summoner.games
135
+ end
136
+
137
+ it "should good attributes" do
138
+ game = FactoryGirl.build(:game, :fellow_players => [RiotLolApi::Model::Player.new(:summoner_id => 228437,:team_id => 200, :champion_id => 102),RiotLolApi::Model::Player.new(:summoner_id => 25235641,:team_id => 100, :champion_id => 48)], :stats => RiotLolApi::Model::Stat.new(:level => 13, :goldEarned => 5969, :numDeaths => 2, :minionsKilled => 10, :goldSpent => 5630, :totalDamageDealt => 19848, :totalDamageTaken => 16127, :team => 200, :win => false, :physicalDamageDealtPlayer => 7116, :magicDamageDealtPlayer => 12732, :physicalDamageTaken => 7806, :magicDamageTaken => 8069, :timePlayed => 1597, :totalHeal => 9241, :totalUnitsHealed => 4, :assists => 8, :item0 => 3301, :item1 => 2049, :item2 => 3047, :item3 => 3110, :item4 => 1057, :item6 => 3340, :sightWardsBought => 1, :magicDamageDealtToChampions => 3100, :physicalDamageDealtToChampions => 1230, :totalDamageDealtToChampions => 4330, :trueDamageTaken => 252, :wardPlaced => 14, :totalTimeCrowdControlDealt => 602))
139
+
140
+ @game_tests.each do |game_test|
141
+ expect(game_test.game_id).to eq(game.game_id)
142
+ expect(game_test.invalid).to eq(game.invalid)
143
+ expect(game_test.game_mode).to eq(game.game_mode)
144
+ expect(game_test.game_type).to eq(game.game_type)
145
+ expect(game_test.sub_type).to eq(game.sub_type)
146
+ expect(game_test.map_id).to eq(game.map_id)
147
+ expect(game_test.team_id).to eq(game.team_id)
148
+ expect(game_test.champion_id).to eq(game.champion_id)
149
+ expect(game_test.spell1).to eq(game.spell1)
150
+ expect(game_test.spell2).to eq(game.spell2)
151
+ expect(game_test.level).to eq(game.level)
152
+ expect(game_test.ip_earned).to eq(game.ip_earned)
153
+ expect(game_test.create_date).to eq(game.create_date)
154
+
155
+ game_test.fellow_players.each_with_index do |fellow_player, i|
156
+ expect(fellow_player.summoner_id).to eq(game.fellow_players[i].summoner_id)
157
+ expect(fellow_player.team_id).to eq(game.fellow_players[i].team_id)
158
+ expect(fellow_player.champion_id).to eq(game.fellow_players[i].champion_id)
159
+ end
160
+
161
+ expect(game_test.stats.level).to eq(game.stats.level)
162
+ # ...
163
+ end
164
+ end
165
+
166
+ end
167
+
168
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler/setup'
2
+ require 'riot_lol_api' # and any other gems you need
3
+ require 'webmock/rspec'
4
+ require 'factory_girl'
5
+
6
+ RiotLolApi::TOKEN = "KEY"
7
+
8
+ Bundler.setup
9
+ FactoryGirl.find_definitions
10
+
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+ config.order = 'random'
16
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riot_lol_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - francois_blanchard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-21 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
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: factory_girl
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: httparty
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Riot games api wrapper for ruby
98
+ email:
99
+ - francois.blanchard1@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".DS_Store"
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - lib/.DS_Store
112
+ - lib/riot_lol_api.rb
113
+ - lib/riot_lol_api/client.rb
114
+ - lib/riot_lol_api/model.rb
115
+ - lib/riot_lol_api/model/game.rb
116
+ - lib/riot_lol_api/model/mastery.rb
117
+ - lib/riot_lol_api/model/player.rb
118
+ - lib/riot_lol_api/model/rune.rb
119
+ - lib/riot_lol_api/model/slot.rb
120
+ - lib/riot_lol_api/model/stat.rb
121
+ - lib/riot_lol_api/model/summoner.rb
122
+ - lib/riot_lol_api/model/talent.rb
123
+ - lib/riot_lol_api/version.rb
124
+ - riot_lol_api.gemspec
125
+ - spec/.DS_Store
126
+ - spec/factories/client.rb
127
+ - spec/factories/game.rb
128
+ - spec/factories/mastery.rb
129
+ - spec/factories/rune.rb
130
+ - spec/factories/summoner.rb
131
+ - spec/mock_response/get_summoner_by_id.json
132
+ - spec/mock_response/get_summoner_by_name.json
133
+ - spec/mock_response/get_summoner_games_by_id.json
134
+ - spec/mock_response/get_summoner_masteries_by_id.json
135
+ - spec/mock_response/get_summoner_runes_by_id.json
136
+ - spec/riot_lol_api_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage: https://github.com/francois-blanchard/riot_lol_api
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.2.2
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Riot games api
162
+ test_files:
163
+ - spec/.DS_Store
164
+ - spec/factories/client.rb
165
+ - spec/factories/game.rb
166
+ - spec/factories/mastery.rb
167
+ - spec/factories/rune.rb
168
+ - spec/factories/summoner.rb
169
+ - spec/mock_response/get_summoner_by_id.json
170
+ - spec/mock_response/get_summoner_by_name.json
171
+ - spec/mock_response/get_summoner_games_by_id.json
172
+ - spec/mock_response/get_summoner_masteries_by_id.json
173
+ - spec/mock_response/get_summoner_runes_by_id.json
174
+ - spec/riot_lol_api_spec.rb
175
+ - spec/spec_helper.rb