X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli.rb/blobdiff_plain/823e558b5cd2ec219d0fc7226c54f2ee7ad807d2..f1f1106951c4acf88e28555415d39e249a3d13f6:/doc/Lyricli/Lyricli.html?ds=inline diff --git a/doc/Lyricli/Lyricli.html b/doc/Lyricli/Lyricli.html index 6d8ed13..e3accb5 100644 --- a/doc/Lyricli/Lyricli.html +++ b/doc/Lyricli/Lyricli.html @@ -6,7 +6,7 @@ Class: Lyricli::Lyricli - — Documentation by YARD 0.8.1 + — Documentation by YARD 0.8.2.1 @@ -94,12 +94,25 @@
Defined in:
-
lib/lyricli.rb
+
lib/lyricli/lyricli.rb
+

Overview

+
+

+This class has the basic logic for extracting the lyrics and controlling +the application +

+ + +
+
+
+ +
@@ -131,7 +144,10 @@ -
+

+Exits with error when there is an empty field from the current track. +

+
@@ -153,7 +169,11 @@ -
+

+Raises an InvalidLyricsError which means we did not get any valid +artist/song from any of the sources. +

+
@@ -161,7 +181,7 @@
  • - - (Object) get_lyrics + - (String) get_lyrics @@ -175,7 +195,11 @@ -
    +

    +Extracts the current track, validates it and requests the lyrics from our +LyricsEngine. +

    +
  • @@ -200,7 +224,7 @@

    -A new instance of Lyricli. +Constructor, initializes `@source_manager`.

    @@ -224,7 +248,11 @@ A new instance of Lyricli. -
    +

    +Set the `@current_track` instance variable by asking the SourceManager for +its current track. +

    +
    @@ -247,7 +275,7 @@ A new instance of Lyricli.

    -A new instance of Lyricli +Constructor, initializes `@source_manager`

    @@ -262,12 +290,12 @@ A new instance of Lyricli
     
     
    -36
    -37
    -38
    +8 +9 +10 -
    # File 'lib/lyricli.rb', line 36
    +      
    # File 'lib/lyricli/lyricli.rb', line 8
     
     def initialize
       @source_manager = SourceManager.new
    @@ -293,21 +321,35 @@ A new instance of Lyricli
       
     
       
    -
    +
    +
    +

    +Exits with error when there is an empty field from the current track. +

    + + +
    +
    +
    + + +
     
     
    -61
    -62
    -63
    -64
    +49 +50 +51 +52 +53
    -
    # File 'lib/lyricli.rb', line 61
    +      
    # File 'lib/lyricli/lyricli.rb', line 49
     
     def check_params
    +  self.exit_with_error unless @current_track
       self.exit_with_error if @current_track[:artist].nil? or @current_track[:artist].empty?
       self.exit_with_error if @current_track[:song].nil? or @current_track[:song].empty?
     end
    @@ -325,21 +367,53 @@ A new instance of Lyricli - +
    +
    +

    +Raises an InvalidLyricsError which means we did not get any valid +artist/song from any of the sources +

    + + +
    +
    +
    + +

    Raises:

    + + +
    @@ -349,44 +423,86 @@ A new instance of Lyricli

    - - (Object) get_lyrics + - (String) get_lyrics -

     
     
    -40
    -41
    -42
    +16 +17 +18
    -
    # File 'lib/lyricli.rb', line 40
    +      
    # File 'lib/lyricli/lyricli.rb', line 16
     
     def exit_with_error
    -  abort "Usage: #{$0} artist song"
    +  raise Exceptions::InvalidLyricsError
     end
    +
    +
    +

    +Extracts the current track, validates it and requests the lyrics from our +LyricsEngine +

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +

      +the found lyrics, or a string indicating none were found +

      +
      + +
    • + +
    + +
    @@ -403,18 +519,31 @@ A new instance of Lyricli -
     
     
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40
    -
    # File 'lib/lyricli.rb', line 44
    +      
    # File 'lib/lyricli/lyricli.rb', line 24
     
     def get_lyrics
    -  set_current_track
    -  check_params
    +
    +  begin
    +    set_current_track
    +    check_params
    +  rescue Exceptions::InvalidLyricsError
    +    return "No Artist/Song could be found :("
    +  end
     
       engine = LyricsEngine.new(@current_track[:artist], @current_track[:song])
     
       begin
    -    engine.get_lyrics
    -  rescue LyricsNotFoundException
    -    "Lyrics not found :("
    +    return engine.get_lyrics
    +  rescue Exceptions::LyricsNotFoundError
    +    return "Lyrics not found :("
       end
     end
    +
    +
    +

    +Set the `@current_track` instance variable by asking the SourceManager for +its current track +

    + + +
    +
    +
    + + +
     
     
    -57
    -58
    -59
    +44 +45 +46
    -
    # File 'lib/lyricli.rb', line 57
    +      
    # File 'lib/lyricli/lyricli.rb', line 44
     
     def set_current_track
       @current_track = @source_manager.current_track
    @@ -429,9 +558,9 @@ A new instance of Lyricli