From 8b36c940761a28c5e14a33abc224e21cd4a58cfd Mon Sep 17 00:00:00 2001 From: danijoo Date: Tue, 7 Jan 2014 09:34:24 +0100 Subject: [PATCH] namespaced all classes to Sightstone::Classname --- lib/sightstone.rb | 5 +++++ lib/sightstone/champion.rb | 2 ++ lib/sightstone/league.rb | 2 ++ lib/sightstone/masterybook.rb | 2 ++ lib/sightstone/match_history.rb | 3 ++- lib/sightstone/modules/champion_module.rb | 3 ++- lib/sightstone/modules/datadragon_module.rb | 3 ++- lib/sightstone/modules/game_module.rb | 3 ++- lib/sightstone/modules/league_module.rb | 2 ++ lib/sightstone/modules/sightstone_base_module.rb | 14 ++++++++------ lib/sightstone/modules/stats_module.rb | 4 +++- lib/sightstone/modules/summoner_module.rb | 2 ++ lib/sightstone/modules/team_module.rb | 2 ++ lib/sightstone/player_stats_summary.rb | 3 ++- lib/sightstone/ranked_stats.rb | 2 ++ lib/sightstone/runebook.rb | 2 ++ lib/sightstone/summoner.rb | 2 ++ lib/sightstone/team.rb | 2 ++ sightstone.gemspec | 4 ++-- test/test_champions_module.rb | 2 +- test/test_game_module.rb | 8 ++++---- test/test_league_module.rb | 6 +++--- test/test_stats.rb | 4 ++-- test/test_team_module.rb | 10 +++++----- 24 files changed, 63 insertions(+), 29 deletions(-) diff --git a/lib/sightstone.rb b/lib/sightstone.rb index 34aae0a..9a7f443 100644 --- a/lib/sightstone.rb +++ b/lib/sightstone.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/champion.rb b/lib/sightstone/champion.rb index b83d2ce..4ddc163 100644 --- a/lib/sightstone/champion.rb +++ b/lib/sightstone/champion.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/league.rb b/lib/sightstone/league.rb index 68b6687..2e83340 100644 --- a/lib/sightstone/league.rb +++ b/lib/sightstone/league.rb @@ -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 diff --git a/lib/sightstone/masterybook.rb b/lib/sightstone/masterybook.rb index e322584..b56918b 100644 --- a/lib/sightstone/masterybook.rb +++ b/lib/sightstone/masterybook.rb @@ -1,3 +1,4 @@ +module Sightstone # Class to represent the masterybook of a summoner # @attr [Numeric] summonerId id of the summoner # @attr [Array] pages of the masterybook @@ -45,4 +46,5 @@ class Talent @name = data['name'] @rank = data['rank'] end +end end \ No newline at end of file diff --git a/lib/sightstone/match_history.rb b/lib/sightstone/match_history.rb index 0e20098..c24a6de 100644 --- a/lib/sightstone/match_history.rb +++ b/lib/sightstone/match_history.rb @@ -1,4 +1,4 @@ - +module Sightstone # match history of a summoner # @attr [Fixnum] summonerId ID of the summoner # @attr [Array] games unsorted list of recently played games @@ -90,3 +90,4 @@ class Stat end end end +end diff --git a/lib/sightstone/modules/champion_module.rb b/lib/sightstone/modules/champion_module.rb index 15a037c..d8a1d9c 100644 --- a/lib/sightstone/modules/champion_module.rb +++ b/lib/sightstone/modules/champion_module.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/modules/datadragon_module.rb b/lib/sightstone/modules/datadragon_module.rb index f4a8c77..9cf2662 100644 --- a/lib/sightstone/modules/datadragon_module.rb +++ b/lib/sightstone/modules/datadragon_module.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/modules/game_module.rb b/lib/sightstone/modules/game_module.rb index a42e309..658ed9d 100644 --- a/lib/sightstone/modules/game_module.rb +++ b/lib/sightstone/modules/game_module.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/modules/league_module.rb b/lib/sightstone/modules/league_module.rb index 1a3fdbb..25d66c9 100644 --- a/lib/sightstone/modules/league_module.rb +++ b/lib/sightstone/modules/league_module.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/modules/sightstone_base_module.rb b/lib/sightstone/modules/sightstone_base_module.rb index 256b8fb..75d962d 100644 --- a/lib/sightstone/modules/sightstone_base_module.rb +++ b/lib/sightstone/modules/sightstone_base_module.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/modules/stats_module.rb b/lib/sightstone/modules/stats_module.rb index f603b13..0816630 100644 --- a/lib/sightstone/modules/stats_module.rb +++ b/lib/sightstone/modules/stats_module.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/modules/summoner_module.rb b/lib/sightstone/modules/summoner_module.rb index 8165b1f..fe79528 100644 --- a/lib/sightstone/modules/summoner_module.rb +++ b/lib/sightstone/modules/summoner_module.rb @@ -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 diff --git a/lib/sightstone/modules/team_module.rb b/lib/sightstone/modules/team_module.rb index 22689bd..303707c 100644 --- a/lib/sightstone/modules/team_module.rb +++ b/lib/sightstone/modules/team_module.rb @@ -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 diff --git a/lib/sightstone/player_stats_summary.rb b/lib/sightstone/player_stats_summary.rb index 4ceba47..6441285 100644 --- a/lib/sightstone/player_stats_summary.rb +++ b/lib/sightstone/player_stats_summary.rb @@ -1,4 +1,4 @@ - +module Sightstone # summary of player statistic # @attr [Fixnum] summonerId ID of the summoner # @attr [Array] pages of the runebook @@ -47,4 +48,5 @@ class Rune @name = data['name'] @tier = data['tier'] end +end end \ No newline at end of file diff --git a/lib/sightstone/summoner.rb b/lib/sightstone/summoner.rb index cdb89e7..abce2ee 100644 --- a/lib/sightstone/summoner.rb +++ b/lib/sightstone/summoner.rb @@ -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 \ No newline at end of file diff --git a/lib/sightstone/team.rb b/lib/sightstone/team.rb index ae5508d..4a6ea16 100644 --- a/lib/sightstone/team.rb +++ b/lib/sightstone/team.rb @@ -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 \ No newline at end of file diff --git a/sightstone.gemspec b/sightstone.gemspec index 9f63545..f6755df 100644 --- a/sightstone.gemspec +++ b/sightstone.gemspec @@ -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"] diff --git a/test/test_champions_module.rb b/test/test_champions_module.rb index e0001b9..7fe41b2 100644 --- a/test/test_champions_module.rb +++ b/test/test_champions_module.rb @@ -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) diff --git a/test/test_game_module.rb b/test/test_game_module.rb index e845a73..13ff07c 100644 --- a/test/test_game_module.rb +++ b/test/test_game_module.rb @@ -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) diff --git a/test/test_league_module.rb b/test/test_league_module.rb index 268803e..c750d20 100644 --- a/test/test_league_module.rb +++ b/test/test_league_module.rb @@ -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 diff --git a/test/test_stats.rb b/test/test_stats.rb index b84e93e..cec7bd4 100644 --- a/test/test_stats.rb +++ b/test/test_stats.rb @@ -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) diff --git a/test/test_team_module.rb b/test/test_team_module.rb index 822b95e..a5de6ff 100644 --- a/test/test_team_module.rb +++ b/test/test_team_module.rb @@ -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)