module Capistrano::DSL

Public Instance Methods

on(hosts, options={}, &block) click to toggle source
# File lib/capistrano/locally.rb, line 14
def on(hosts, options={}, &block)
  return unless hosts
  localhosts, remotehosts = Array(hosts).partition { |h| h.hostname.to_s == 'localhost' }
  localhost = Configuration.env.filter(localhosts).first

  unless localhost.nil?
    klass = if dry_run?
              SSHKit::Backend::Printer
            else
              SSHKit::Backend::Local
            end

    if (defined? Bundler) && with_unbundled_env?
      if Bundler.respond_to?(:with_unbundled_env)
        Bundler.method(:with_unbundled_env)
      else
        Bundler.method(:with_clean_env)
      end.call do
        klass.new(localhost, &block).run
      end
    else
      klass.new(localhost, &block).run
    end
  end

  original_on(remotehosts, options, &block)
end
Also aliased as: original_on
original_on(hosts, options={}, &block)
Alias for: on
with_unbundled_env?() click to toggle source
# File lib/capistrano/locally.rb, line 42
def with_unbundled_env?
  [deprecated_with_unbundled_env?, fetch(:run_locally_with_unbundled_env, true)].find do |val|
    !val.nil?
  end
end

Private Instance Methods

deprecated_with_unbundled_env?() click to toggle source
# File lib/capistrano/locally.rb, line 54
    def deprecated_with_unbundled_env?
      fetch(:run_locally_with_clean_env).tap do |val|
        $stderr.puts(<<~MESSAGE) unless val.nil?
          [Deprecation Notice] `set :run_locally_with_clean_env` has been deprecated \
          in favor of `set :run_locally_with_unbundled_env`.
        MESSAGE
      end
    end
dry_run?() click to toggle source
# File lib/capistrano/locally.rb, line 50
def dry_run?
  fetch(:sshkit_backend) == SSHKit::Backend::Printer
end