Module: FFWD::Plugin
- Included in:
- JSON, Log
- Defined in:
- lib/ffwd/plugin.rb,
lib/ffwd/plugin/log.rb
Defined Under Namespace
Modules: ClassMethods, JSON, Log
Classes: Loaded, Setup
Class Method Summary
collapse
Class Method Details
.category ⇒ Object
113
114
115
|
# File 'lib/ffwd/plugin.rb', line 113
def self.category
'plugin'
end
|
.discovered ⇒ Object
85
86
87
|
# File 'lib/ffwd/plugin.rb', line 85
def self.discovered
@@discovered ||= {}
end
|
.included(mod) ⇒ Object
109
110
111
|
# File 'lib/ffwd/plugin.rb', line 109
def self.included mod
mod.extend ClassMethods
end
|
.load_discovered(source) ⇒ Object
117
118
119
120
121
122
123
|
# File 'lib/ffwd/plugin.rb', line 117
def self.load_discovered source
FFWD::Plugin.discovered.each do |name, config|
FFWD::Plugin.loaded[name] = Loaded.new source, name, config
end
FFWD::Plugin.discovered.clear
end
|
.load_plugins(log, kind_name, config, kind) ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/ffwd/plugin.rb', line 125
def self.load_plugins log, kind_name, config, kind
result = []
return result if config.nil?
config.each_with_index do |plugin_config, index|
d = "#{kind_name} plugin ##{index}"
unless name = plugin_config[:type]
log.error "#{d}: Missing :type attribute for '#{kind_name}'"
next
end
unless plugin = FFWD::Plugin.loaded[name]
log.error "#{d}: Not an available plugin '#{name}'"
next
end
unless setup = plugin.get(kind)
log.error "#{d}: Not an #{kind_name} plugin '#{name}'"
next
end
result << Setup.new(name, plugin_config, setup)
end
return result
end
|
.loaded ⇒ Object
89
90
91
|
# File 'lib/ffwd/plugin.rb', line 89
def self.loaded
@@loaded ||= {}
end
|
.option(name, opts = {}) ⇒ Object
154
155
156
157
|
# File 'lib/ffwd/plugin.rb', line 154
def self.option name, opts={}
{:name => name, :default => opts[:default], :help => opts[:help],
:modes => opts[:modes]}
end
|