Module: Capistrano::DSL

Defined in:
lib/capistrano/locally.rb

Instance Method Summary collapse

Instance Method Details

#on(hosts, options = {}, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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) && fetch(:run_locally_with_clean_env, true)
      Bundler.with_clean_env do
        klass.new(localhost, &block).run
      end
    else
      klass.new(localhost, &block).run
    end
  end

  original_on(remotehosts, options, &block)
end

#original_onObject



12
# File 'lib/capistrano/locally.rb', line 12

alias original_on on