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
106
107
108
|
# File 'lib/ffwd/plugin.rb', line 106
def self.category
'plugin'
end
|
.discovered ⇒ Object
79
80
81
|
# File 'lib/ffwd/plugin.rb', line 79
def self.discovered
@@discovered ||= {}
end
|
.included(mod) ⇒ Object
102
103
104
|
# File 'lib/ffwd/plugin.rb', line 102
def self.included mod
mod.extend ClassMethods
end
|
.load_discovered(source) ⇒ Object
.load_plugins(log, kind_name, config, kind, m) ⇒ Object
118
119
120
121
122
123
124
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
153
154
155
156
157
|
# File 'lib/ffwd/plugin.rb', line 118
def self.load_plugins log, kind_name, config, kind, m
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
factory = setup.call Hash[plugin_config]
unless factory.respond_to? m
log.error "#{d}: Plugin '#{name}' does not support '#{m.to_s}'"
next
end
unless factory.respond_to? :config
log.error "#{d}: Plugin '#{name}' does not support 'config'"
next
end
result << Setup.new(factory.method(m), factory.config, name)
end
return result
end
|
.loaded ⇒ Object
83
84
85
|
# File 'lib/ffwd/plugin.rb', line 83
def self.loaded
@@loaded ||= {}
end
|
.option(name, opts = {}) ⇒ Object
159
160
161
162
|
# File 'lib/ffwd/plugin.rb', line 159
def self.option name, opts={}
{:name => name, :default => opts[:default], :help => opts[:help],
:modes => opts[:modes]}
end
|