Sha256: 9d62a9c9ccce6b4f34e3fc35cce5e4fc0951cf6b063815088bf4a0de21d8d687
Contents?: true
Size: 1.44 KB
Versions: 8
Compression:
Stored size: 1.44 KB
Contents
require 'securerandom' set :applications, [] module Capistrano module Cluster class Application def initialize(&configurator) @configurator = configurator end def configure! @configurator.call end end module DSL def application(&block) fetch(:applications) << Application.new(&block) end def configure_application(application) original_env = Capistrano::Configuration.env Capistrano::Configuration.env = original_env.copy application.configure! original_env end def login_as(user, on: nil, &block) if on old_user,on.user = on.user, "#{user}" end yield ensure on.user = "#{old_user}" if on end def with_application(application, &block) original_env = configure_application(application) yield ensure Capistrano::Configuration.env = original_env end def applications(*names, &block) names.compact! fetch(:applications).map do |application| with_application application do if names.include? "#{fetch(:application)}" or names.empty? yield if block_given? application end end end.compact end end end end include Capistrano::Cluster::DSL Capistrano::Configuration.class_eval do def self.env=(value) @env = value end end
Version data entries
8 entries across 8 versions & 1 rubygems