Module: Automatic::Pipeline
- Defined in:
- lib/automatic/pipeline.rb
Class Method Summary collapse
-
.load_plugin(module_name) ⇒ Object
Resolve a module name such as SubscriptionFeed to
/subscription/feed.rb and register it for autoloading. -
.run(recipe) ⇒ Object
Run a Recipe: each plugin's return value is the next plugin's input.
Class Method Details
.load_plugin(module_name) ⇒ Object
Resolve a module name such as SubscriptionFeed to
The user directory is searched before the installation, so a plugin in ~/.automatic/plugins shadows a shipped plugin of the same name.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/automatic/pipeline.rb', line 29 def load_plugin(module_name) underscored = module_name.underscore search_roots.each do |dir| category = File.basename(dir) next unless /\A#{Regexp.escape(category)}_(.*)\z/ =~ underscored path = File.join(dir, "#{Regexp.last_match(1)}.rb") next unless File.exist?(path) return Automatic::Plugin.autoload(module_name.to_sym, path) end raise NoPluginError, "unknown plugin named #{module_name}" end |
.run(recipe) ⇒ Object
Run a Recipe: each plugin's return value is the next plugin's input.
Nothing here rescues a plugin's exception. A Recipe is a sequence in which each step consumes the previous one's output, so continuing past a failed step would run the rest on a value their author never intended. See doc/REQUIREMENTS.md section 12.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/automatic/pipeline.rb', line 51 def run(recipe) raise NoRecipeError, 'no recipe given' if recipe.nil? pipeline = [] recipe.each_plugin do |plugin| mod = plugin.module load_plugin(mod) klass = Automatic::Plugin.const_get(mod) pipeline = klass.new(plugin.config, pipeline).run end pipeline end |