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
|