]>
git.r.bdr.sh - rbdr/lyricli.rb/blob - lib/lyricli/source_manager.rb
0bc81e5f5b313c45c0904dc5cf8c943aa7ab3854
8 @config = Configuration
.instance
9 @config["enabled_sources"].each
do |source
|
10 if klass
= parse_class(camelize(source
))
11 current_source
= klass
.new
12 @enabled_sources << current_source
14 raise StartSourceException
19 def enable(source_name
)
20 if klass
= parse_class(camelize(source_name
))
22 @config["enabled_sources"] << klass
.name
23 @config["enabled_sources"].uniq!
25 raise EnableSourceException
29 def disable(source_name
)
30 if klass
= parse_class(camelize(source_name
))
31 @config["enabled_sources"].delete(klass
.name
)
33 raise DisableSourceException
37 def reset(source_name
)
38 if klass
= parse_class(camelize(source_name
))
42 raise ResetSourceException
48 @enabled_sources.each
do |source
|
50 track
||= source
.current_track
52 fail
"Source #{source.name} has failed to start. Please reset the source by running `#{$0} source reset #{source.name}.`"
59 path_root
= File
.expand_path(File
.dirname(__FILE__
))
60 sources
= Dir
[path_root+
"/sources/*"].map
{ |s
|
61 s
.split("/").last
.gsub(/\
.rb
/, "")
64 # Remove arguments (Hack?) We don't want anybody to touch tihs one.
65 sources
.delete("arguments")