1 Commits

Author SHA1 Message Date
danijoo
dfb74df805 raw stashed files 2014-03-26 09:46:26 +01:00
16 changed files with 38 additions and 319 deletions

View File

@@ -9,11 +9,6 @@ Sightstone
Sightstone is a ruby wrapper for riots league of legends developer api ([http://developer.riotgames.com](http://developer.riotgames.com)). Please note that you need an api key from riot in order to use this gem.
Discontinued
-------
This project isn't under development anymore!
Installation
-------
Just install the gem:

View File

@@ -75,7 +75,7 @@ class SummonerModule < SightstoneBaseModule
def names(ids, optional={})
region = optional[:region] || @sightstone.region
ids = ids.join(',')
uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids}/name"
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids}/name"
response = _get_api_response(uri)
_parse_response(response) { |resp|
data = JSON.parse(resp)
@@ -103,7 +103,7 @@ class SummonerModule < SightstoneBaseModule
else
summoner
end
uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{id}/runes"
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{id}/runes"
response = _get_api_response(uri)
_parse_response(response) { |resp|
data = JSON.parse(resp)
@@ -131,7 +131,7 @@ class SummonerModule < SightstoneBaseModule
summoner
end
}
uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids.join(',')}/runes"
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids.join(',')}/runes"
response = _get_api_response(uri)
_parse_response(response) { |resp|
data = JSON.parse(resp)
@@ -158,7 +158,7 @@ class SummonerModule < SightstoneBaseModule
else
summoner
end
uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{id}/masteries"
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{id}/masteries"
response = _get_api_response(uri)
_parse_response(response) { |resp|
data = JSON.parse(resp)
@@ -186,7 +186,7 @@ class SummonerModule < SightstoneBaseModule
end
}
uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids.join(',')}/masteries"
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids.join(',')}/masteries"
response = _get_api_response(uri)
_parse_response(response) { |resp|
data = JSON.parse(resp)

View File

@@ -1,56 +0,0 @@
require 'spec_helper'
module Sightstone
describe GameModule do
before :each do
@module = GameModule.new(Sightstone.new("api_key", "euw"))
end
describe "#new" do
it "should initialize a GameModule" do
@module.should be_instance_of GameModule
end
end
describe "#recent" do
before :each do
raw_response = File.new("spec/modules/raw_responses/game_v1.3_euw.response")
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/game/by-summoner/summoner_id/recent?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
end
it "should return a list of recent games for the default region" do
history = @module.recent("summoner_id")
history.should be_instance_of MatchHistory
end
it "should return a recent games for given region" do
@module.instance_variable_set("@sightstone", Sightstone.new("api_key", "na"))
history = @module.recent("summoner_id", {region: "euw"})
history.should be_instance_of MatchHistory
end
it "should evaluate codeblocks" do
games = []
@module.recent("summoner_id") do |history|
games = history.games
end
games.each do |game|
game.should be_instance_of HistoryGame
end
end
end
end
end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=UTF-8
Date: Wed, 26 Mar 2014 08:43:26 GMT
Server: Jetty(9.1.1.v20140108)
Content-Length: 983
Connection: keep-alive
[{"playerOrTeamId":"TEAM-b8dbeb70-83b0-11e3-b41c-782bcb497d6f","playerOrTeamName":"H Fettarme Vollmilch","leagueName":"Heimerdinger's Archons","queueType":"RANKED_TEAM_3x3","tier":"BRONZE","rank":"I","leaguePoints":75,"wins":4,"isHotStreak":false,"isVeteran":false,"isFreshBlood":false,"isInactive":true,"lastPlayed":-1},{"playerOrTeamId":"30447079","playerOrTeamName":"danijoo","leagueName":"Elise's Horde","queueType":"RANKED_SOLO_5x5","tier":"SILVER","rank":"II","leaguePoints":0,"wins":57,"isHotStreak":false,"isVeteran":true,"isFreshBlood":false,"isInactive":false,"lastPlayed":-1},{"playerOrTeamId":"TEAM-ffbaccc0-b8c0-11e2-b67a-782bcb497d6f","playerOrTeamName":"EloStechers","leagueName":"Kayle's Patriots","queueType":"RANKED_TEAM_3x3","tier":"BRONZE","rank":"II","leaguePoints":100,"wins":9,"isHotStreak":true,"isVeteran":false,"isFreshBlood":false,"isInactive":false,"miniSeries":{"target":2,"wins":1,"losses":0,"timeLeftToPlayMillis":-1,"progress":"WNN"},"lastPlayed":-1}]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +0,0 @@
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=UTF-8
Date: Wed, 26 Mar 2014 09:49:05 GMT
Server: Jetty(9.1.1.v20140108)
Vary: Accept-Encoding, User-Agent
Content-Length: 41
Connection: keep-alive
{"30492244":"Pippu","30447079":"danijoo"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +0,0 @@
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=UTF-8
Date: Wed, 26 Mar 2014 09:50:46 GMT
Server: Jetty(9.1.1.v20140108)
Vary: Accept-Encoding, User-Agent
Content-Length: 112
Connection: keep-alive
{"danijoo":{"id":30447079,"name":"danijoo","profileIconId":551,"summonerLevel":30,"revisionDate":1395768855000}}

View File

@@ -1,12 +0,0 @@
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=UTF-8
Date: Wed, 26 Mar 2014 09:53:17 GMT
Server: Jetty(9.1.1.v20140108)
Vary: Accept-Encoding, User-Agent
Content-Length: 233
Connection: keep-alive
{"danijoo":{"id":30447079,"name":"danijoo","profileIconId":551,"summonerLevel":30,"revisionDate":1395768855000},"ismirknuelle":{"id":22151489,"name":"ismirknuelle","profileIconId":583,"summonerLevel":30,"revisionDate":1395768855000}}

View File

@@ -1,169 +0,0 @@
require 'spec_helper'
module Sightstone
describe SummonerModule do
before :each do
@module = SummonerModule.new(Sightstone.new("api_key", "euw"))
end
describe "#new" do
it "should initialize a SummonerModule" do
@module.should be_instance_of SummonerModule
end
end
describe "#masterybook" do
before :each do
raw_response = File.new("spec/modules/raw_responses/summoner_v1.3_masterybook.response")
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/summoner/summoner_id/masteries?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
end
it "should return a mastery book" do
@module.masterybook("summoner_id").should be_instance_of MasteryBook
end
it "should evaluate the codeblock" do
@module.masterybook("summoner_id") { |book|
book.should be_instance_of MasteryBook
}
end
end
describe "#masterybooks" do
before :each do
raw_response = File.new("spec/modules/raw_responses/summoner_v1.3_masterybooks.response")
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/summoner/summonerid1,summonerid2/masteries?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
end
it "should return the books of 2 summoners" do
books = @module.masterybooks(["summonerid1","summonerid2"])
books.should be_instance_of Hash
books.each do |key, book|
book.should be_instance_of MasteryBook
end
end
it "should evaluate the codeblock" do
@module.masterybooks(["summonerid1", "summonerid2"]) { |books|
books.each do |key, book|
book.should be_instance_of MasteryBook
end
}
end
end
describe "#names" do
before :each do
raw_response = File.new("spec/modules/raw_responses/summoner_v1.3_names.response")
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/summoner/1,2,3/name?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
end
it "should return a list of names" do
@module.names([1,2,3]).should be_instance_of Hash
@module.names([1,2,3]) { |names|
names.each do |id, name|
id.should be_instance_of Fixnum
name.should be_instance_of String
end
}
end
end
describe "#runebook" do
before :each do
raw_response = File.new("spec/modules/raw_responses/summoner_v1.3_runebook.response")
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/summoner/summoner_id/runes?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
end
it "should return a rune book" do
@module.runebook("summoner_id").should be_instance_of RuneBook
end
it "should evaluate the codeblock" do
@module.runebook("summoner_id") { |book|
book.should be_instance_of RuneBook
}
end
end
describe "#runebooks" do
before :each do
raw_response = File.new("spec/modules/raw_responses/summoner_v1.3_runebooks.response")
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/summoner/summonerid1,summonerid2/runes?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
end
it "should return the books of 2 summoners" do
books = @module.runebooks(["summonerid1", "summonerid2"])
books.should be_instance_of Hash
books.each do |key, book|
book.should be_instance_of RuneBook
end
end
it "should evaluate the codeblock" do
@module.runebooks(["summonerid1", "summonerid2"]) { |books|
books.each do |key, book|
book.should be_instance_of RuneBook
end
}
end
end
describe "#summoner" do
before :each do
raw_response = File.new("spec/modules/raw_responses/summoner_v1.3_summoner.response").read
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/summoner/by-name/name?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/summoner/1?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
end
it "should return a summoner by name" do
@module.summoner("name").should be_instance_of Summoner
end
it "should return a summoner by id" do
@module.summoner(1).should be_instance_of Summoner
end
end
describe "#summoners" do
before :each do
raw_response = File.new("spec/modules/raw_responses/summoner_v1.3_summoners.response")
stub_request(:get, "https://prod.api.pvp.net/api/lol/euw/v1.3/summoner/by-name/name1,name2?api_key=api_key").
with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}).
to_return(raw_response)
end
it "should return multiple summoners" do
@summoners = @module.summoners(['name1', 'name2'])
@summoners.should be_instance_of Hash
@summoners.each do |key, value|
key.should satisfy {|key| (key.is_a? Fixnum or key.is_a? String) }
value.should be_instance_of Summoner
end
end
end
end
end