Module: Automatic::Pipeline

Defined in:
lib/automatic/pipeline.rb

Class Method Summary collapse

Class Method Details

.load_plugin(module_name) ⇒ Object

Raises:



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/automatic/pipeline.rb', line 18

def self.load_plugin(module_name)
  Dir[Automatic.user_plugins_dir + "/*",
      Automatic.plugins_dir + "/*"].each{ |dir|
    subdir = File.basename dir
    if /#{subdir}_(.*)$/ =~ module_name.underscore
      path = dir + "/#{$1}.rb"        
      return Automatic::Plugin.autoload module_name.to_sym, path.to_s if File.exists? path
    end
  }
  raise NoPluginError, "unknown plugin named #{module_name}"
end

.run(recipe) ⇒ Object

Raises:



30
31
32
33
34
35
36
37
38
39
# File 'lib/automatic/pipeline.rb', line 30

def self.run(recipe)
  raise NoRecipeError if recipe.nil?
  pipeline = []
  recipe.each_plugin { |plugin|
    mod = plugin.module
    load_plugin(mod)
    klass = Automatic::Plugin.const_get(mod)
    pipeline = klass.new(plugin.config, pipeline).run
  }
end