]> git.r.bdr.sh - rbdr/lyricli.rb/blame_incremental - lib/lyricli.rb
Add dangling files
[rbdr/lyricli.rb] / lib / lyricli.rb
... / ...
CommitLineData
1require 'uri'
2require 'cgi'
3require 'net/http'
4require 'multi_json'
5require 'nokogiri'
6require 'open-uri'
7require 'launchy'
8
9# This shit causes a lot of warnings. Quick Hack.
10original_verbosity = $VERBOSE
11$VERBOSE = nil
12require 'rdio'
13$VERBOSE = original_verbosity
14
15# Local Dependencies
16require "lyricli/util"
17require "lyricli/configuration"
18require "lyricli/lyricli"
19require "lyricli/lyrics_engine"
20require "lyricli/source_manager"
21require "lyricli/sources"
22require "lyricli/sources/arguments"
23require "lyricli/sources/rdio"
24require "lyricli/sources/itunes"
25require "lyricli/exceptions"
26require "lyricli/exceptions/disable_source_error"
27require "lyricli/exceptions/enable_source_error"
28require "lyricli/exceptions/invalid_lyrics_error"
29require "lyricli/exceptions/lyrics_not_found_error"
30require "lyricli/exceptions/reset_source_error"
31require "lyricli/exceptions/source_configuration_error"
32require "lyricli/exceptions/start_source_error"
33require "lyricli/exceptions/unknown_source_error"
34
35# The Lyricli module allows you to easily search for lyrics by looking for
36# song and artist data from diverse sources.
37module Lyricli
38 # Creates a new Lyricli instance and returns lyrics by going through the
39 # sources.
40 # @return [String] the fetched lyrics
41 def self.lyrics
42 @lyricli = Lyricli.new
43 @lyricli.get_lyrics(@show_title)
44 end
45
46 # Returns the version of the library
47 # @return [String] the version
48 def self.version
49 Gem.loaded_specs["lyricli"].version
50 end
51
52 # Returns a list of the available sources to enable or disable
53 # @return [String] the list of available sources. Enabled sources have
54 # a star appended.
55 def self.sources
56 source_manager = SourceManager.new
57 source_manager.available_sources(true).join(", ")
58 end
59
60 # Enables a source via the Source Manager
61 def self.enable(source_name)
62 source_manager = SourceManager.new
63 begin
64 source_manager.enable(source_name)
65 rescue Exceptions::UnknownSourceError
66 "There is no such Source"
67 end
68 end
69
70 # Disables a source via the Source Manager
71 def self.disable(source_name)
72 source_manager = SourceManager.new
73 begin
74 source_manager.disable(source_name)
75 rescue Exceptions::UnknownSourceError
76 "There is no such Source"
77 end
78 end
79
80 # Resets all configuration for a source via the Source Manager
81 def self.reset(source_name)
82 source_manager = SourceManager.new
83 begin
84 source_manager.reset(source_name)
85 rescue Exceptions::UnknownSourceError
86 "There is no such Source"
87 end
88 end
89
90 # Returns the root of the Gem.
91 #
92 # @return [String] the root path for this gem
93 def self.root
94 File.expand_path('../..',__FILE__)
95 end
96
97 # Sets the show_title instance variable so it requests the title
98 def self.show_title
99 @show_title = true
100 end
101end