Module: Plugins
- Defined in:
- lib/wiki_lyrics/cli/plugins.rb,
lib/wiki_lyrics/amarok/plugins.rb
Constant Summary collapse
- @@ALL =
[]
- @@WIKI =
[]
- @@USED =
@@WIKI + (@@ALL - @@WIKI)
Class Method Summary collapse
- .all_names ⇒ Object
- .all_plugins ⇒ Object
- .find_plugins ⇒ Object
- .load_plugins(plugins) ⇒ Object
- .plugin_by_name(name) ⇒ Object
- .used_names ⇒ Object
- .used_names=(names) ⇒ Object
- .used_plugins ⇒ Object
- .wiki_names ⇒ Object
- .wiki_plugins ⇒ Object
Class Method Details
.all_names ⇒ Object
60 61 62 |
# File 'lib/wiki_lyrics/cli/plugins.rb', line 60 def Plugins.all_names() return @@ALL.collect(){ |plugin| plugin.plugin_name() } end |
.all_plugins ⇒ Object
56 57 58 |
# File 'lib/wiki_lyrics/cli/plugins.rb', line 56 def Plugins.all_plugins() return @@ALL end |
.find_plugins ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/wiki_lyrics/cli/plugins.rb', line 28 def Plugins.find_plugins() plugins = {} Dir.new( File.( File.dirname( __FILE__ ) + "/.." ) ).each() do |filename| filename = File.( File.dirname( __FILE__ ) + "/../" + filename ) if File.file?( filename ) && (md = /\/lyrics_([A-Za-z_0-9]*)\.rb$/.match( filename )) plugins[md[1]] = filename end end return plugins end |
.load_plugins(plugins) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/wiki_lyrics/cli/plugins.rb', line 39 def Plugins.load_plugins( plugins ) plugins.each() do |classname, filename| require( filename ? filename : File.( File.dirname( __FILE__ ) + "/../lyrics_#{classname}.rb" ) ) classobj = eval( classname ) if classobj.ancestors().include?( MediaWikiLyrics ) eval( "class CLI#{classname} < #{classname}\ninclude WikiPluginAdapter\nend" ) plugin = eval( "CLI#{classname}.new()" ) @@WIKI << plugin else eval( "class CLI#{classname} < #{classname}\ninclude PluginAdapter\nend" ) plugin = eval( "CLI#{classname}.new()" ) end @@ALL << plugin end end |
.plugin_by_name(name) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/wiki_lyrics/cli/plugins.rb', line 72 def Plugins.plugin_by_name( name ) @@ALL.each() do |plugin| return plugin if plugin.plugin_name() == name end return nil end |
.used_names ⇒ Object
64 65 66 |
# File 'lib/wiki_lyrics/amarok/plugins.rb', line 64 def Plugins.used_names() return @@USED.collect(){ |plugin| plugin.plugin_name() } end |
.used_names=(names) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/wiki_lyrics/amarok/plugins.rb', line 68 def Plugins.used_names=( names ) @@USED = [] names.uniq().each() do |name| @@ALL.each do |plugin| if plugin.plugin_name() == name @@USED << plugin break end end end end |
.used_plugins ⇒ Object
60 61 62 |
# File 'lib/wiki_lyrics/amarok/plugins.rb', line 60 def Plugins.used_plugins() return @@USED end |
.wiki_names ⇒ Object
68 69 70 |
# File 'lib/wiki_lyrics/cli/plugins.rb', line 68 def Plugins.wiki_names() return @@WIKI.collect(){ |plugin| plugin.plugin_name() } end |
.wiki_plugins ⇒ Object
64 65 66 |
# File 'lib/wiki_lyrics/cli/plugins.rb', line 64 def Plugins.wiki_plugins() return @@WIKI end |