Module: Plugins
- Defined in:
- lib/lyrics/cli/plugins.rb
Constant Summary collapse
- @@ALL =
[]
- @@WIKI =
[]
Class Method Summary collapse
- .all_names ⇒ Object
- .all_plugins ⇒ Object
- .find_plugins ⇒ Object
- .load_plugins(plugins) ⇒ Object
- .plugin_by_name(name) ⇒ Object
- .wiki_names ⇒ Object
- .wiki_plugins ⇒ Object
Class Method Details
.all_names ⇒ Object
60 61 62 |
# File 'lib/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/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/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/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" ) # FIXME: refactor plugin = eval( "CLI#{classname}.new()" ) @@WIKI << plugin else eval( "class CLI#{classname} < #{classname}\ninclude PluginAdapter\nend" ) # FIXME: refactor plugin = eval( "CLI#{classname}.new()" ) end @@ALL << plugin end end |
.plugin_by_name(name) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/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 |
.wiki_names ⇒ Object
68 69 70 |
# File 'lib/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/lyrics/cli/plugins.rb', line 64 def Plugins.wiki_plugins() return @@WIKI end |