Module: Capistrano::Progress::Configuration::Actions::Progress

Included in:
Configuration
Defined in:
lib/capistrano/progress/configuration/actions/progress.rb

Instance Method Summary collapse

Instance Method Details

#disable_run_progressObject



44
45
46
# File 'lib/capistrano/progress/configuration/actions/progress.rb', line 44

def disable_run_progress
  @run_with_progress = false
end

#enable_run_progressObject



40
41
42
# File 'lib/capistrano/progress/configuration/actions/progress.rb', line 40

def enable_run_progress
  @run_with_progress = true
end

#run(cmd, options = {}, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/capistrano/progress/configuration/actions/progress.rb', line 16

def run(cmd, options = {}, &block)
  if @run_with_progress
    servers = find_servers_for_task(current_task).map { |server|
      ServerWithRoles.new(server, role_names_for_host(server))
    }
    status = ParallelStatus.new(servers)
    logger_level(Capistrano::Logger::IMPORTANT) do
      status.block do
        parallelize do |session|
          servers.each do |server|
            session.run do
              status.step server, "Executing ..."
              run_without_progress cmd, options.merge(:hosts => server), &block
              status.step server, "Done"
            end
          end
        end
      end
    end
  else
    run_without_progress cmd, options, &block
  end
end

#run_without_progress(cmd, options = {}, &block) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/capistrano/progress/configuration/actions/progress.rb', line 7

def run_without_progress(cmd, options = {}, &block)
  if options[:eof].nil? && !cmd.include?(sudo)
    options = options.merge(:eof => !block_given?)
  end
  block ||= self.class.default_io_proc
  tree = Command::Tree.new(self) do |t| t.else(cmd, &block) end
  run_tree(tree, options)
end