Sha256: fa22bdf3d05955a2129a4f4c98e500f001830d407c16391c69058506d939c337
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
module Borg module Configuration module Stages def stage(app, name, &block) app = app.to_sym name = name.to_sym application app unless @applications[app] namespace app do desc "Load Application #{app} and Stage #{name}" task name do @applications[app].stages[name].execute end end @applications[app].stages[name] ||= Stage.new(name, @applications[app]) @applications[app].stages[name].execution_blocks << block if block_given? end class Stage attr_accessor :execution_blocks attr_accessor :parent # TODO: We might want to name this differently def name "#{parent.name}:#{@name}" end def initialize(name, parent) @execution_blocks = [] @name = name @parent = parent end def load_into(config) if config.respond_to?(:stage) # Undefine the stage method now that the app:stage config is created config_metaclass = class << config; self; end config_metaclass.send(:undef_method, 'stage') # Create a capistrano variable for stage config.instance_exec(@name, &(lambda { |name| set :stage, name })) end parent.load_into(config) @execution_blocks.each { |blk| config.load(&blk) } end end end end end Capistrano::Configuration.send(:include, Borg::Configuration::Stages)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
borg-rb-0.0.5 | lib/borg/configuration/stages.rb |