Sha256: a8d68dc0c44a8cf66618d4a6b1575211f7bdae52b885e0d80e54138621a7fe6a

Contents?: true

Size: 1.28 KB

Versions: 25

Compression:

Stored size: 1.28 KB

Contents

require 'colored'

logger.level = Capistrano::Logger::IMPORTANT

STDOUT.sync

$silent_stack      = []
$silent_stack_tm   = []
$silent_stack_cur  = nil
$silent_stack_skip = nil

def format_silent(name, options = {})
  s = name.size
  i = (70 - s).abs
  #name = name.bold
  if options[:bold]
    name = name.gsub(/ [_a-z:]+/) do |a|
      a.bold
    end
  end
  print(name + (" " * i))
end

on :before do
  $silent_stack_tm.push Time.now.to_f

  name = current_task.fully_qualified_name
  if $silent_stack_cur && $silent_stack_cur == $silent_stack.last
    puts ""
  end
  $silent_stack.push name
  $silent_stack_cur = name

  roles = current_task.instance_eval{ @options[:roles] }

  name = "#{name} [#{[roles].flatten.map(&:to_s).join(',')}]" if roles
  format_silent(("  " * ($silent_stack.size - 1)) + "* #{name}", :bold => true)
end

on :after do
  name = current_task.fully_qualified_name
  old = $silent_stack.pop
  tm  = $silent_stack_tm.pop
  tm = Time.now.to_f - tm

  spaces = $silent_stack.size
  rs = "DONE".green
  rs += (" %0.2fs" % tm).to_s

  if $silent_stack_skip == true
    rs = "SKIP".yellow
    $silent_stack_skip = nil
  end

  if old == $silent_stack_cur
    puts rs
  else
    format_silent(("  " * (spaces)) + "...", :bold => true)
    puts rs
  end

  $silent_stack_cur = nil
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
capistrano_evrone_recipes-0.1.21 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_rails_recipes-0.1.23 lib/capistrano_rails_recipes/recipes/silent.rb
capistrano_rails_recipes-0.1.22 lib/capistrano_rails_recipes/recipes/silent.rb
capistrano_rails_recipes-0.1.21 lib/capistrano_rails_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.20 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.19 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.18 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.17 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.16 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.15 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.14 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.13 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.12 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.11 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.10 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.9 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.8 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.7 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.6 lib/capistrano_evrone_recipes/recipes/silent.rb
capistrano_evrone_recipes-0.1.5 lib/capistrano_evrone_recipes/recipes/silent.rb