Sha256: 7508a61d9e8650b889285cd3896998e79511b17e1b392aba5f9f337a00a83683

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 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
      end

      class Stage
        attr_accessor :execution_blocks
        attr_accessor :parent
        def name
          "#{parent.name}:#{@name}"
        end

        def initialize name, parent
          @execution_blocks = []
          @name = name
          @parent = parent
        end

        def load_into config
          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

3 entries across 3 versions & 1 rubygems

Version Path
borg-rb-0.0.3 lib/borg/configuration/stages.rb
borg-rb-0.0.2 lib/borg/configuration/stages.rb
borg-rb-0.0.1 lib/borg/configuration/stages.rb