]> git.r.bdr.sh - rbdr/lyricli.rb/blame - lib/lyricli.rb
removing unused variable options, fixes warning in last ruby 1.9.3 branch
[rbdr/lyricli.rb] / lib / lyricli.rb
CommitLineData
b8498f5c 1require 'uri'
178ffe13 2require 'cgi'
b8498f5c
BB
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
d3e32008
BB
15# Local Dependencies
16require "lyricli/util"
17require "lyricli/configuration"
823e558b 18require "lyricli/lyricli"
d3e32008
BB
19require "lyricli/lyrics_engine"
20require "lyricli/source_manager"
76e96cc0 21require "lyricli/sources"
d3e32008
BB
22require "lyricli/sources/arguments"
23require "lyricli/sources/rdio"
24require "lyricli/sources/itunes"
76e96cc0
BB
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"
d3e32008 34
823e558b
BB
35# The Lyricli module allows you to easily search for lyrics by looking for
36# song and artist data from diverse sources.
d3e32008 37module Lyricli
823e558b
BB
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
d3e32008
BB
42 @lyricli = Lyricli.new
43 @lyricli.get_lyrics
44 end
b9f550e9 45
4f3dbb13
BB
46 # Returns the version of the library
47 # @return [String] the version
b9f550e9
BB
48 def self.version
49 Gem.loaded_specs["lyricli"].version
50 end
51
4f3dbb13 52 # Returns a list of the available sources to enable or disable
34d0bf15
BB
53 # @return [String] the list of available sources. Enabled sources have
54 # a star appended.
b9f550e9
BB
55 def self.sources
56 source_manager = SourceManager.new
4f3dbb13 57 source_manager.available_sources(true).join(", ")
b9f550e9
BB
58 end
59
34d0bf15 60 # Enables a source via the Source Manager
4f3dbb13
BB
61 def self.enable(source_name)
62 source_manager = SourceManager.new
278e6d0a
BB
63 begin
64 source_manager.enable(source_name)
65 rescue Exceptions::UnknownSourceError
66 "There is no such Source"
67 end
b9f550e9
BB
68 end
69
34d0bf15 70 # Disables a source via the Source Manager
4f3dbb13
BB
71 def self.disable(source_name)
72 source_manager = SourceManager.new
278e6d0a
BB
73 begin
74 source_manager.disable(source_name)
75 rescue Exceptions::UnknownSourceError
76 "There is no such Source"
77 end
b9f550e9
BB
78 end
79
34d0bf15 80 # Resets all configuration for a source via the Source Manager
4f3dbb13
BB
81 def self.reset(source_name)
82 source_manager = SourceManager.new
278e6d0a
BB
83 begin
84 source_manager.reset(source_name)
85 rescue Exceptions::UnknownSourceError
86 "There is no such Source"
87 end
b9f550e9 88 end
ac4c2838
BB
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
b8498f5c 96end