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 [StatsModule] Stats module to call the stats api
# @attr [TeamModule] Team module to call the team api
module Sightstone
class Sightstone
attr_accessor :region
@@ -53,3 +55,6 @@ class SightstoneConnectionException < SightstoneApiException; end
# Raised when the RateLimit has been exceeded (api returns http error code 429)
class RateLimitExceededException < SightstoneApiException; end
end

View File

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

View File

@@ -1,3 +1,4 @@
module Sightstone
# Class to represent a league
# @attr [String] name name of the league
# @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']
end
end
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -33,7 +33,7 @@ class ChampionModuleTest < BaseTest
end
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.defenseRank)
assert_instance_of(String, champ.name)

View File

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

View File

@@ -14,7 +14,7 @@ class LeagueModuleTest < BaseTest
retry
end
leagues.each do |league|
assert_instance_of(League, league)
assert_instance_of(Sightstone::League, league)
# check the league entries
_check_league(league)
@@ -32,7 +32,7 @@ class LeagueModuleTest < BaseTest
end
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.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"
@@ -51,7 +51,7 @@ class LeagueModuleTest < BaseTest
end
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.wins
assert_instance_of Fixnum, ms.target

View File

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

View File

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