Module: Fabriq::PluginPort
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logging
config, debug, error, info, send_output
Instance Attribute Details
#plugins ⇒ Object
Returns the value of attribute plugins.
6
7
8
|
# File 'lib/fabriq/plugin_port.rb', line 6
def plugins
@plugins
end
|
Instance Method Details
#initialize_plugins ⇒ Object
46
47
48
49
50
|
# File 'lib/fabriq/plugin_port.rb', line 46
def initialize_plugins
@plugins.each do |plugin|
invoke_plugin_callback(plugin, :initialized)
end
end
|
#plugin_load_paths ⇒ Object
8
9
10
11
12
|
# File 'lib/fabriq/plugin_port.rb', line 8
def plugin_load_paths
[File.expand_path("~") + "/.fabriq", Dir.pwd].collect do |base_path|
Dir.glob("#{base_path}/plugins/*")
end.flatten
end
|
#register_plugin(klass, &config_block) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/fabriq/plugin_port.rb', line 33
def register_plugin(klass, &config_block)
@plugins ||= []
plugin = klass.init
if block_given? && plugin.respond_to?(:configurator)
config_block.call(plugin.configurator)
end
invoke_plugin_callback(plugin, :registered)
@plugins << plugin
end
|
#require_plugin_from_path(plugin_base_dir) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/fabriq/plugin_port.rb', line 23
def require_plugin_from_path(plugin_base_dir)
plugin_name = plugin_base_dir.split("/").last
base_file_path = File.join(plugin_base_dir, "lib", "#{plugin_name}.rb")
if File.exist?(base_file_path)
require base_file_path
else
error("Plugin: #{plugin_name} - Base file not found (#{base_file_path}")
end
end
|
#require_plugins ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/fabriq/plugin_port.rb', line 14
def require_plugins
debug "Plugin Load paths: #{plugin_load_paths}"
plugin_load_paths.each do |plugin_base_dir|
next unless File.exist?(plugin_base_dir)
require_plugin_from_path plugin_base_dir
end
end
|