From: Ben Beltran Date: Sat, 6 Oct 2012 08:02:43 +0000 (-0500) Subject: Change error names to favor convention X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli.rb/commitdiff_plain/76e96cc0010b4db5159d3ebe360ce8e0e8729737?ds=sidebyside;hp=2677b890a58ffaccf47f54615cd3ae6715586ab8 Change error names to favor convention --- diff --git a/lib/lyricli.rb b/lib/lyricli.rb index 1c908b0..041959b 100755 --- a/lib/lyricli.rb +++ b/lib/lyricli.rb @@ -17,9 +17,19 @@ require "lyricli/configuration" require "lyricli/lyricli" require "lyricli/lyrics_engine" require "lyricli/source_manager" +require "lyricli/sources" require "lyricli/sources/arguments" require "lyricli/sources/rdio" require "lyricli/sources/itunes" +require "lyricli/exceptions" +require "lyricli/exceptions/disable_source_error" +require "lyricli/exceptions/enable_source_error" +require "lyricli/exceptions/invalid_lyrics_error" +require "lyricli/exceptions/lyrics_not_found_error" +require "lyricli/exceptions/reset_source_error" +require "lyricli/exceptions/source_configuration_error" +require "lyricli/exceptions/start_source_error" +require "lyricli/exceptions/unknown_source_error" # The Lyricli module allows you to easily search for lyrics by looking for # song and artist data from diverse sources. diff --git a/lib/lyricli/.DS_Store b/lib/lyricli/.DS_Store new file mode 100644 index 0000000..bf6d0c0 Binary files /dev/null and b/lib/lyricli/.DS_Store differ diff --git a/lib/lyricli/exceptions/lyrics_not_found_exception.rb b/lib/lyricli/exceptions/disable_source_error.rb similarity index 54% rename from lib/lyricli/exceptions/lyrics_not_found_exception.rb rename to lib/lyricli/exceptions/disable_source_error.rb index c09321d..1f9b0d3 100644 --- a/lib/lyricli/exceptions/lyrics_not_found_exception.rb +++ b/lib/lyricli/exceptions/disable_source_error.rb @@ -1,6 +1,6 @@ module Lyricli module Exceptions - class LyricsNotFoundException + class DisableSourceError < StandardError end end end diff --git a/lib/lyricli/exceptions/invalid_lyrics_exception.rb b/lib/lyricli/exceptions/enable_source_error.rb similarity index 55% rename from lib/lyricli/exceptions/invalid_lyrics_exception.rb rename to lib/lyricli/exceptions/enable_source_error.rb index 30cab41..b1596c8 100644 --- a/lib/lyricli/exceptions/invalid_lyrics_exception.rb +++ b/lib/lyricli/exceptions/enable_source_error.rb @@ -1,6 +1,6 @@ module Lyricli module Exceptions - class InvalidLyricsException + class EnableSourceError < StandardError end end end diff --git a/lib/lyricli/exceptions/invalid_lyrics_error.rb b/lib/lyricli/exceptions/invalid_lyrics_error.rb new file mode 100644 index 0000000..3f1b7c8 --- /dev/null +++ b/lib/lyricli/exceptions/invalid_lyrics_error.rb @@ -0,0 +1,7 @@ +module Lyricli + module Exceptions + class InvalidLyricsError < StandardError + end + end +end + diff --git a/lib/lyricli/exceptions/lyrics_not_found_error.rb b/lib/lyricli/exceptions/lyrics_not_found_error.rb new file mode 100644 index 0000000..023e3db --- /dev/null +++ b/lib/lyricli/exceptions/lyrics_not_found_error.rb @@ -0,0 +1,7 @@ +module Lyricli + module Exceptions + class LyricsNotFoundError < StandardError + end + end +end + diff --git a/lib/lyricli/exceptions/disable_source_exception.rb b/lib/lyricli/exceptions/reset_source_error.rb similarity index 55% rename from lib/lyricli/exceptions/disable_source_exception.rb rename to lib/lyricli/exceptions/reset_source_error.rb index 449c979..0bfa7f4 100644 --- a/lib/lyricli/exceptions/disable_source_exception.rb +++ b/lib/lyricli/exceptions/reset_source_error.rb @@ -1,6 +1,6 @@ module Lyricli module Exceptions - class DisableSourceException + class ResetSourceError < StandardError end end end diff --git a/lib/lyricli/exceptions/reset_source_exception.rb b/lib/lyricli/exceptions/reset_source_exception.rb deleted file mode 100644 index ba079e4..0000000 --- a/lib/lyricli/exceptions/reset_source_exception.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Lyricli - module Exceptions - class ResetSourceException - end - end -end - diff --git a/lib/lyricli/exceptions/source_configuration_error.rb b/lib/lyricli/exceptions/source_configuration_error.rb new file mode 100644 index 0000000..b297083 --- /dev/null +++ b/lib/lyricli/exceptions/source_configuration_error.rb @@ -0,0 +1,7 @@ +module Lyricli + module Exceptions + class SourceConfigurationError < StandardError + end + end +end + diff --git a/lib/lyricli/exceptions/source_configuration_exception.rb b/lib/lyricli/exceptions/source_configuration_exception.rb deleted file mode 100644 index 9e9ef31..0000000 --- a/lib/lyricli/exceptions/source_configuration_exception.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Lyricli - module Exceptions - class SourceConfigurationException - end - end -end - diff --git a/lib/lyricli/exceptions/enable_source_exception.rb b/lib/lyricli/exceptions/start_source_error.rb similarity index 55% rename from lib/lyricli/exceptions/enable_source_exception.rb rename to lib/lyricli/exceptions/start_source_error.rb index f1395df..9db1549 100644 --- a/lib/lyricli/exceptions/enable_source_exception.rb +++ b/lib/lyricli/exceptions/start_source_error.rb @@ -1,7 +1,6 @@ module Lyricli module Exceptions - class EnableSourceException + class StartSourceError < StandardError end end end - diff --git a/lib/lyricli/exceptions/start_source_exception.rb b/lib/lyricli/exceptions/start_source_exception.rb deleted file mode 100644 index 1abcc5a..0000000 --- a/lib/lyricli/exceptions/start_source_exception.rb +++ /dev/null @@ -1,6 +0,0 @@ -module Lyricli - module Exceptions - class StartSourceException - end - end -end diff --git a/lib/lyricli/exceptions/unknown_source_error.rb b/lib/lyricli/exceptions/unknown_source_error.rb new file mode 100644 index 0000000..8d9ba62 --- /dev/null +++ b/lib/lyricli/exceptions/unknown_source_error.rb @@ -0,0 +1,7 @@ +module Lyricli + module Exceptions + class UnknownSourceError < StandardError + end + end +end + diff --git a/lib/lyricli/exceptions/unknown_source_exception.rb b/lib/lyricli/exceptions/unknown_source_exception.rb deleted file mode 100644 index 3b16bea..0000000 --- a/lib/lyricli/exceptions/unknown_source_exception.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Lyricli - module Exceptions - class UnknownSourceException - end - end -end - diff --git a/lib/lyricli/lyricli.rb b/lib/lyricli/lyricli.rb index 518db2d..d546e54 100644 --- a/lib/lyricli/lyricli.rb +++ b/lib/lyricli/lyricli.rb @@ -9,12 +9,12 @@ module Lyricli @source_manager = SourceManager.new end - # Raises an InvalidLyricsException which means we did not get any valid + # Raises an InvalidLyricsError which means we did not get any valid # artist/song from any of the sources # - # @raise [Lyricli::InvalidLyricsException] because we found nothing + # @raise [Lyricli::Exceptions::InvalidLyricsError] because we found nothing def exit_with_error - raise InvalidLyricsException + raise Exceptions::InvalidLyricsError end # Extracts the current track, validates it and requests the lyrics from our @@ -29,7 +29,7 @@ module Lyricli begin engine.get_lyrics - rescue LyricsNotFoundException + rescue Exceptions::LyricsNotFoundError "Lyrics not found :(" end end diff --git a/lib/lyricli/lyrics_engine.rb b/lib/lyricli/lyrics_engine.rb index beacd46..72ee402 100644 --- a/lib/lyricli/lyrics_engine.rb +++ b/lib/lyricli/lyrics_engine.rb @@ -24,7 +24,7 @@ module Lyricli doc = Nokogiri::HTML(open(response['url'])) node = doc.search(".lyricbox").first rescue - raise Lyricli::LyricsNotFoundException + raise Exceptions::LyricsNotFoundError end node.search(".rtMatcher").each do |n| diff --git a/lib/lyricli/source_manager.rb b/lib/lyricli/source_manager.rb index 020870d..e6004df 100644 --- a/lib/lyricli/source_manager.rb +++ b/lib/lyricli/source_manager.rb @@ -15,7 +15,7 @@ module Lyricli current_source = klass.new @enabled_sources << current_source else - raise StartSourceException + raise Exceptions::StartSourceError end end end @@ -33,10 +33,10 @@ module Lyricli @config["enabled_sources"].uniq! @config.save_config else - raise EnableSourceException + raise Exceptions::EnableSourceError end else - raise UnknownSourceException + raise Exceptions::UnknownSourceError end end @@ -50,10 +50,10 @@ module Lyricli @config["enabled_sources"].delete(klass.name) @config.save_config else - raise DisableSourceException + raise Exceptions::DisableSourceError end else - raise UnknownSourceException + raise Exceptions::UnknownSourceError end end @@ -67,10 +67,10 @@ module Lyricli klass.reset disable(source_name) else - raise ResetSourceException + raise Exceptions::ResetSourceError end else - raise UnknownSourceException + raise Exceptions::UnknownSourceError end end @@ -92,7 +92,7 @@ module Lyricli lock = true if source.class.name == "arguments" end rescue - raise SourceConfigurationException + raise Exceptions::SourceConfigurationError end end track diff --git a/lyricli-0.0.1.gem b/lyricli-0.0.1.gem index bb1d4de..c5bbe76 100644 Binary files a/lyricli-0.0.1.gem and b/lyricli-0.0.1.gem differ