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

Class Method Details

.all_namesObject



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_pluginsObject



56
57
58
# File 'lib/wiki_lyrics/cli/plugins.rb', line 56

def Plugins.all_plugins()
	return @@ALL
end

.find_pluginsObject



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.expand_path( File.dirname( __FILE__ ) + "/.." ) ).each() do |filename|
		filename = File.expand_path( 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.expand_path( 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_namesObject



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_pluginsObject



60
61
62
# File 'lib/wiki_lyrics/amarok/plugins.rb', line 60

def Plugins.used_plugins()
	return @@USED
end

.wiki_namesObject



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_pluginsObject



64
65
66
# File 'lib/wiki_lyrics/cli/plugins.rb', line 64

def Plugins.wiki_plugins()
	return @@WIKI
end