namespaced all classes to Sightstone::Classname

This commit is contained in:
danijoo
2014-01-07 09:34:24 +01:00
parent bc1a75d53a
commit 8b36c94076
24 changed files with 63 additions and 29 deletions

View File

@@ -17,6 +17,8 @@ require 'sightstone/modules/datadragon_module'
# @attr [LeagueModule] League module to call the leagues api # @attr [LeagueModule] League module to call the leagues api
# @attr [StatsModule] Stats module to call the stats api # @attr [StatsModule] Stats module to call the stats api
# @attr [TeamModule] Team module to call the team api # @attr [TeamModule] Team module to call the team api
module Sightstone
class Sightstone class Sightstone
attr_accessor :region attr_accessor :region
@@ -53,3 +55,6 @@ class SightstoneConnectionException < SightstoneApiException; end
# Raised when the RateLimit has been exceeded (api returns http error code 429) # Raised when the RateLimit has been exceeded (api returns http error code 429)
class RateLimitExceededException < SightstoneApiException; end class RateLimitExceededException < SightstoneApiException; end
end

View File

@@ -1,3 +1,4 @@
module Sightstone
# Class to represent a champion # Class to represent a champion
# @attr [Boolean] active determines if champion is active # @attr [Boolean] active determines if champion is active
# @attr [Integer] attackRank attack rank # @attr [Integer] attackRank attack rank
@@ -28,3 +29,4 @@ class Champion
end end
end end
end

View File

@@ -1,3 +1,4 @@
module Sightstone
# Class to represent a league # Class to represent a league
# @attr [String] name name of the league # @attr [String] name name of the league
# @attr [String] queue queue Type (can be: RANKED_SOLO_5x5, RANKED_TEAM_3x3, RANKED_TEAM_5x5) # @attr [String] queue queue Type (can be: RANKED_SOLO_5x5, RANKED_TEAM_3x3, RANKED_TEAM_5x5)
@@ -69,3 +70,4 @@ class MiniSeries
@timeLeftToPlayMillis = data['timeLeftToPlayMillis'] @timeLeftToPlayMillis = data['timeLeftToPlayMillis']
end end
end end
end

View File

@@ -1,3 +1,4 @@
module Sightstone
# Class to represent the masterybook of a summoner # Class to represent the masterybook of a summoner
# @attr [Numeric] summonerId id of the summoner # @attr [Numeric] summonerId id of the summoner
# @attr [Array<MasteryPage>] pages of the masterybook # @attr [Array<MasteryPage>] pages of the masterybook
@@ -46,3 +47,4 @@ class Talent
@rank = data['rank'] @rank = data['rank']
end end
end end
end

View File

@@ -1,4 +1,4 @@
module Sightstone
# match history of a summoner # match history of a summoner
# @attr [Fixnum] summonerId ID of the summoner # @attr [Fixnum] summonerId ID of the summoner
# @attr [Array<HistoryGame>] games unsorted list of recently played games # @attr [Array<HistoryGame>] games unsorted list of recently played games
@@ -90,3 +90,4 @@ class Stat
end end
end end
end end
end

View File

@@ -1,6 +1,6 @@
require 'sightstone/champion' require 'sightstone/champion'
require 'sightstone/modules/sightstone_base_module' require 'sightstone/modules/sightstone_base_module'
module Sightstone
# Module to provide calls to the summoner api # Module to provide calls to the summoner api
class ChampionModule < SightstoneBaseModule class ChampionModule < SightstoneBaseModule
@@ -31,3 +31,4 @@ class ChampionModule < SightstoneBaseModule
} }
end end
end end
end

View File

@@ -1,5 +1,5 @@
require 'sightstone/modules/sightstone_base_module' require 'sightstone/modules/sightstone_base_module'
module Sightstone
class DatadragonModule < SightstoneBaseModule class DatadragonModule < SightstoneBaseModule
def initialize(sightstone) def initialize(sightstone)
@@ -23,3 +23,4 @@ class DatadragonModule < SightstoneBaseModule
end end
end

View File

@@ -1,7 +1,7 @@
require 'sightstone/modules/sightstone_base_module' require 'sightstone/modules/sightstone_base_module'
require 'sightstone/summoner' require 'sightstone/summoner'
require 'sightstone/match_history' require 'sightstone/match_history'
module Sightstone
# module to access the game api # module to access the game api
class GameModule < SightstoneBaseModule class GameModule < SightstoneBaseModule
@@ -36,3 +36,4 @@ class GameModule < SightstoneBaseModule
end end
end

View File

@@ -2,6 +2,7 @@ require 'sightstone/modules/sightstone_base_module'
require 'sightstone/summoner' require 'sightstone/summoner'
require 'sightstone/league' require 'sightstone/league'
module Sightstone
# module to provide calls to the league api # module to provide calls to the league api
class LeagueModule < SightstoneBaseModule class LeagueModule < SightstoneBaseModule
def initialize(sightstone) def initialize(sightstone)
@@ -38,3 +39,4 @@ class LeagueModule < SightstoneBaseModule
end end
end end
end

View File

@@ -1,5 +1,5 @@
require 'open-uri' require 'open-uri'
module Sightstone
# Base class of the api modules # Base class of the api modules
# @abstract # @abstract
class SightstoneBaseModule class SightstoneBaseModule
@@ -23,16 +23,18 @@ class SightstoneBaseModule
if response_code == 200 if response_code == 200
block.call(response.body) block.call(response.body)
elsif response_code == 404 elsif response_code == 404
raise Sightstone::SummonerNotFoundException raise SummonerNotFoundException
elsif response_code == 500 elsif response_code == 500
raise Sightstone::SightstoneConnectionException raise SightstoneConnectionException
elsif response_code == 429 elsif response_code == 429
raise Sightstone::RateLimitExceededException raise RateLimitExceededException
elsif response_code == 401 elsif response_code == 401
raise Sightstone::InvalidApiKeyException raise InvalidApiKeyException
else else
raise Sightstone::SightstoneApiException 'Unknown error occured' raise SightstoneApiException 'Unknown error occured'
end end
end end
end end
end

View File

@@ -1,8 +1,9 @@
require 'sightstone/modules/sightstone_base_module' require 'sightstone/modules/sightstone_base_module'
require 'sightstone/summoner' require 'sightstone/summoner'
require 'sightstone/player_stats_summary' require 'sightstone/player_stats_summary'
require 'sightstone/ranked_stats' require 'sightstone/ranked_stats'
module Sightstone
# Module to receive stats # Module to receive stats
class StatsModule < SightstoneBaseModule class StatsModule < SightstoneBaseModule
def initialize(sightstone) def initialize(sightstone)
@@ -72,3 +73,4 @@ class StatsModule < SightstoneBaseModule
end end
end end
end

View File

@@ -4,6 +4,7 @@ require 'sightstone/masterybook'
require 'sightstone/runebook' require 'sightstone/runebook'
require 'open-uri' require 'open-uri'
module Sightstone
# Module to provide calls to the summoner api # Module to provide calls to the summoner api
class SummonerModule < SightstoneBaseModule class SummonerModule < SightstoneBaseModule
@@ -107,3 +108,4 @@ class SummonerModule < SightstoneBaseModule
} }
end end
end end
end

View File

@@ -2,6 +2,7 @@ require 'sightstone/modules/sightstone_base_module'
require 'sightstone/summoner' require 'sightstone/summoner'
require 'sightstone/team' require 'sightstone/team'
module Sightstone
# module to make calls to the team api # module to make calls to the team api
class TeamModule < SightstoneBaseModule class TeamModule < SightstoneBaseModule
def initialize(sightstone) def initialize(sightstone)
@@ -38,3 +39,4 @@ class TeamModule < SightstoneBaseModule
end end
end end
end

View File

@@ -1,4 +1,4 @@
module Sightstone
# summary of player statistic # summary of player statistic
# @attr [Fixnum] summonerId ID of the summoner # @attr [Fixnum] summonerId ID of the summoner
# @attr [Array<PlayerStatSummary] array of stat summaries for player with given id # @attr [Array<PlayerStatSummary] array of stat summaries for player with given id
@@ -36,3 +36,4 @@ class PlayerStatSummary
end end
end end
end end
end

View File

@@ -1,3 +1,4 @@
module Sightstone
# Ranked stats of a summoner # Ranked stats of a summoner
# @attr [Fixnum] modifyDate date of last modification # @attr [Fixnum] modifyDate date of last modification
# @attr [Fixnum] summonerId id of the summoner # @attr [Fixnum] summonerId id of the summoner
@@ -20,3 +21,4 @@ class RankedStats
end end
end end
end end
end

View File

@@ -1,3 +1,4 @@
module Sightstone
# Class to represent the runebook of a summoner # Class to represent the runebook of a summoner
# @attr [Numeric] summonerId id of the summoner # @attr [Numeric] summonerId id of the summoner
# @attr [Array<RunePage>] pages of the runebook # @attr [Array<RunePage>] pages of the runebook
@@ -48,3 +49,4 @@ class Rune
@tier = data['tier'] @tier = data['tier']
end end
end end
end

View File

@@ -1,3 +1,4 @@
module Sightstone
# Class to represent a summoner # Class to represent a summoner
# @attr [String] name name # @attr [String] name name
# @attr [Long] id summoner id (used for other calls) # @attr [Long] id summoner id (used for other calls)
@@ -19,3 +20,4 @@ class Summoner
end end
end

View File

@@ -1,3 +1,4 @@
module Sightstone
# A Team # A Team
# @attr [Fixnum] createDate UNIX timestamp of team creation # @attr [Fixnum] createDate UNIX timestamp of team creation
# @attr [String] fullId id of the team # @attr [String] fullId id of the team
@@ -113,3 +114,4 @@ class TeamHistoryGame
@opposingTeamKills = data['opposingTeamKills'] @opposingTeamKills = data['opposingTeamKills']
end end
end end
end

View File

@@ -1,7 +1,7 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = 'sightstone' s.name = 'sightstone'
s.version = '1.1.1' s.version = '1.2.0'
s.date = '2014-01-05' s.date = '2014-01-07'
s.summary = 'Ruby wrapper for riots league of legends api' s.summary = 'Ruby wrapper for riots league of legends api'
s.description = s.summary s.description = s.summary
s.authors = ["Daniel Bauer"] s.authors = ["Daniel Bauer"]

View File

@@ -33,7 +33,7 @@ class ChampionModuleTest < BaseTest
end end
def _check_champion(champ) def _check_champion(champ)
assert_instance_of(Champion, champ) assert_instance_of(Sightstone::Champion, champ)
assert_instance_of(Fixnum, champ.attackRank) assert_instance_of(Fixnum, champ.attackRank)
assert_instance_of(Fixnum, champ.defenseRank) assert_instance_of(Fixnum, champ.defenseRank)
assert_instance_of(String, champ.name) assert_instance_of(String, champ.name)

View File

@@ -13,7 +13,7 @@ class GameModuleTest < BaseTest
sleep 1 sleep 1
retry retry
end end
assert_instance_of(MatchHistory, matchHistory) assert_instance_of(Sightstone::MatchHistory, matchHistory)
assert_instance_of(Fixnum, matchHistory.summonerId) assert_instance_of(Fixnum, matchHistory.summonerId)
assert_instance_of(Array, matchHistory.games) assert_instance_of(Array, matchHistory.games)
matchHistory.games.each do |game| matchHistory.games.each do |game|
@@ -22,7 +22,7 @@ class GameModuleTest < BaseTest
end end
def _check_game(game) def _check_game(game)
assert_instance_of(HistoryGame, game) assert_instance_of(Sightstone::HistoryGame, game)
assert_instance_of(Fixnum, game.createDate) assert_instance_of(Fixnum, game.createDate)
assert_instance_of(Fixnum, game.championId) assert_instance_of(Fixnum, game.championId)
assert_instance_of(Fixnum, game.gameId) assert_instance_of(Fixnum, game.gameId)
@@ -42,7 +42,7 @@ class GameModuleTest < BaseTest
def _check_statistics(stats) def _check_statistics(stats)
stats.each do |stat| stats.each do |stat|
assert_instance_of(Stat, stat) assert_instance_of(Sightstone::Stat, stat)
assert_instance_of(Fixnum, stat.value) assert_instance_of(Fixnum, stat.value)
assert_instance_of(Fixnum, stat.id) assert_instance_of(Fixnum, stat.id)
assert_instance_of(String, stat.name) assert_instance_of(String, stat.name)
@@ -51,7 +51,7 @@ class GameModuleTest < BaseTest
def _check_fellows(fellows) def _check_fellows(fellows)
fellows.each do |fellow| fellows.each do |fellow|
assert_instance_of(Player, fellow) assert_instance_of(Sightstone::Player, fellow)
assert_instance_of(Fixnum, fellow.championId) assert_instance_of(Fixnum, fellow.championId)
assert_instance_of(Fixnum, fellow.summonerId) assert_instance_of(Fixnum, fellow.summonerId)
assert_instance_of(Fixnum, fellow.teamId) assert_instance_of(Fixnum, fellow.teamId)

View File

@@ -14,7 +14,7 @@ class LeagueModuleTest < BaseTest
retry retry
end end
leagues.each do |league| leagues.each do |league|
assert_instance_of(League, league) assert_instance_of(Sightstone::League, league)
# check the league entries # check the league entries
_check_league(league) _check_league(league)
@@ -32,7 +32,7 @@ class LeagueModuleTest < BaseTest
end end
def _check_league_item(item) def _check_league_item(item)
assert_instance_of LeagueItem, item assert_instance_of Sightstone::LeagueItem, item
assert (item.isFreshBlood == true or item.isFreshBlood == false), "#{item.isFreshBlood} should be a boolean" assert (item.isFreshBlood == true or item.isFreshBlood == false), "#{item.isFreshBlood} should be a boolean"
assert (item.isHotStreak == true or item.isHotStreak == false), "#{item.isHotStreak} should be a boolean" assert (item.isHotStreak == true or item.isHotStreak == false), "#{item.isHotStreak} should be a boolean"
assert (item.isInactive == true or item.isInactive == false), "#{item.isInactive} should be a boolean" assert (item.isInactive == true or item.isInactive == false), "#{item.isInactive} should be a boolean"
@@ -51,7 +51,7 @@ class LeagueModuleTest < BaseTest
end end
def _check_miniseries(ms) def _check_miniseries(ms)
assert_instance_of MiniSeries, ms assert_instance_of Sightstone::MiniSeries, ms
assert_instance_of Fixnum, ms.losses assert_instance_of Fixnum, ms.losses
assert_instance_of Fixnum, ms.wins assert_instance_of Fixnum, ms.wins
assert_instance_of Fixnum, ms.target assert_instance_of Fixnum, ms.target

View File

@@ -11,7 +11,7 @@ class StatsModuleTest < BaseTest
sleep 1 sleep 1
retry retry
end end
assert_instance_of(PlayerStatsSummaryList, summary) assert_instance_of(Sightstone::PlayerStatsSummaryList, summary)
assert_instance_of(Fixnum, summary.summonerId) assert_instance_of(Fixnum, summary.summonerId)
assert_instance_of(Array, summary.playerStatSummaries) assert_instance_of(Array, summary.playerStatSummaries)
summary.playerStatSummaries.each do |summary| summary.playerStatSummaries.each do |summary|
@@ -20,7 +20,7 @@ class StatsModuleTest < BaseTest
end end
def _check_summary(sum) def _check_summary(sum)
assert_instance_of(PlayerStatSummary, sum) assert_instance_of(Sightstone::PlayerStatSummary, sum)
assert_instance_of(Fixnum, sum.wins) assert_instance_of(Fixnum, sum.wins)
assert_instance_of(Fixnum, sum.losses) assert_instance_of(Fixnum, sum.losses)
assert_instance_of(Fixnum, sum.modifyDate) assert_instance_of(Fixnum, sum.modifyDate)

View File

@@ -18,10 +18,10 @@ class TeamModuleTest < BaseTest
end end
def _check_team(team) def _check_team(team)
assert_instance_of(Team, team) assert_instance_of(Sightstone::Team, team)
assert_instance_of(String, team.status) assert_instance_of(String, team.status)
assert_instance_of(String, team.tag) assert_instance_of(String, team.tag)
assert_instance_of(Roster, team.roster) assert_instance_of(Sightstone::Roster, team.roster)
_check_roster(team.roster) _check_roster(team.roster)
assert_instance_of(Fixnum, team.lastGameDate) assert_instance_of(Fixnum, team.lastGameDate)
assert_instance_of(Fixnum, team.modifyDate) assert_instance_of(Fixnum, team.modifyDate)
@@ -42,7 +42,7 @@ class TeamModuleTest < BaseTest
assert_instance_of(Fixnum, roster.ownerId) assert_instance_of(Fixnum, roster.ownerId)
assert_instance_of(Array, roster.memberList) assert_instance_of(Array, roster.memberList)
roster.memberList.each do |member| roster.memberList.each do |member|
assert_instance_of(Member, member) assert_instance_of(Sightstone::Member, member)
assert_instance_of(Fixnum, member.joinDate) assert_instance_of(Fixnum, member.joinDate)
assert_instance_of(Fixnum, member.inviteDate) assert_instance_of(Fixnum, member.inviteDate)
assert_instance_of(Fixnum, member.playerId) assert_instance_of(Fixnum, member.playerId)
@@ -52,7 +52,7 @@ class TeamModuleTest < BaseTest
def _check_history(history) def _check_history(history)
history.each do |game| history.each do |game|
assert_instance_of(TeamHistoryGame, game) assert_instance_of(Sightstone::TeamHistoryGame, game)
assert_instance_of(String, game.gameMode) assert_instance_of(String, game.gameMode)
assert_instance_of Fixnum, game.mapId assert_instance_of Fixnum, game.mapId
assert_instance_of Fixnum, game.assists assert_instance_of Fixnum, game.assists
@@ -68,7 +68,7 @@ class TeamModuleTest < BaseTest
def _check_team_stats(stats) def _check_team_stats(stats)
stats.each do |stat| stats.each do |stat|
assert_instance_of(TeamStat, stat) assert_instance_of(Sightstone::TeamStat, stat)
assert_instance_of(Fixnum, stat.wins) assert_instance_of(Fixnum, stat.wins)
assert_instance_of(Fixnum, stat.losses) assert_instance_of(Fixnum, stat.losses)
assert_instance_of(Fixnum, stat.averageGamesPlayed) assert_instance_of(Fixnum, stat.averageGamesPlayed)