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.
module Lyricli
module Exceptions
- class LyricsNotFoundException
+ class DisableSourceError < StandardError
end
end
end
module Lyricli
module Exceptions
- class InvalidLyricsException
+ class EnableSourceError < StandardError
end
end
end
--- /dev/null
+module Lyricli
+ module Exceptions
+ class InvalidLyricsError < StandardError
+ end
+ end
+end
+
--- /dev/null
+module Lyricli
+ module Exceptions
+ class LyricsNotFoundError < StandardError
+ end
+ end
+end
+
module Lyricli
module Exceptions
- class DisableSourceException
+ class ResetSourceError < StandardError
end
end
end
+++ /dev/null
-module Lyricli
- module Exceptions
- class ResetSourceException
- end
- end
-end
-
--- /dev/null
+module Lyricli
+ module Exceptions
+ class SourceConfigurationError < StandardError
+ end
+ end
+end
+
+++ /dev/null
-module Lyricli
- module Exceptions
- class SourceConfigurationException
- end
- end
-end
-
module Lyricli
module Exceptions
- class EnableSourceException
+ class StartSourceError < StandardError
end
end
end
-
+++ /dev/null
-module Lyricli
- module Exceptions
- class StartSourceException
- end
- end
-end
--- /dev/null
+module Lyricli
+ module Exceptions
+ class UnknownSourceError < StandardError
+ end
+ end
+end
+
+++ /dev/null
-module Lyricli
- module Exceptions
- class UnknownSourceException
- end
- end
-end
-
@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
begin
engine.get_lyrics
- rescue LyricsNotFoundException
+ rescue Exceptions::LyricsNotFoundError
"Lyrics not found :("
end
end
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|
current_source = klass.new
@enabled_sources << current_source
else
- raise StartSourceException
+ raise Exceptions::StartSourceError
end
end
end
@config["enabled_sources"].uniq!
@config.save_config
else
- raise EnableSourceException
+ raise Exceptions::EnableSourceError
end
else
- raise UnknownSourceException
+ raise Exceptions::UnknownSourceError
end
end
@config["enabled_sources"].delete(klass.name)
@config.save_config
else
- raise DisableSourceException
+ raise Exceptions::DisableSourceError
end
else
- raise UnknownSourceException
+ raise Exceptions::UnknownSourceError
end
end
klass.reset
disable(source_name)
else
- raise ResetSourceException
+ raise Exceptions::ResetSourceError
end
else
- raise UnknownSourceException
+ raise Exceptions::UnknownSourceError
end
end
lock = true if source.class.name == "arguments"
end
rescue
- raise SourceConfigurationException
+ raise Exceptions::SourceConfigurationError
end
end
track