class Object
Public Instance Methods
current_git_branch()
click to toggle source
Get the name of the current local branch
# File lib/easy/deployment/capistrano.rb, line 12 def current_git_branch current_branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\/heads\//, '') puts red("Warning: Redundant use of 'tag'. Your current branch is deployed by default") if ENV['tag'] == current_branch branch_to_deploy = ENV['tag'] || current_branch puts "Deploying branch #{red branch_to_deploy}" branch_to_deploy end
l(s)
click to toggle source
# File lib/easy/deployment/performance.rb, line 21 def l(s) logger.info s end
print_report(start_times, end_times, order)
click to toggle source
# File lib/easy/deployment/performance.rb, line 20 def print_report(start_times, end_times, order) def l(s) logger.info s end l " Performance Report" l "==========================================================" indent = 0 (order + [nil]).each_cons(2) do |payload1, payload2| action, task = payload1 if action == :start l "#{".." * indent}#{task.fully_qualified_name}" unless task == payload2.last indent += 1 else indent -= 1 l "#{".." * indent}#{task.fully_qualified_name} #{(end_times[task] - start_times[task]).to_i}s" end end l "==========================================================" end
red(str)
click to toggle source
color the string
# File lib/easy/deployment/capistrano.rb, line 7 def red(str) "\e[31m#{str}\e[0m" end
remote_file_exists?(full_path)
click to toggle source
# File lib/easy/deployment/apache.rb, line 5 def remote_file_exists?(full_path) 'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip end
run_local(cmd, verbose = false)
click to toggle source
# File lib/easy/deployment/capistrano.rb, line 121 def run_local(cmd, verbose = false) result = `#{cmd}` puts(result) if verbose return [result, $?.exitstatus] end
stream_output_from_command(cmd, continuous = false)
click to toggle source
Helper function to stream output colorized by host
# File lib/easy/deployment/capistrano.rb, line 128 def stream_output_from_command(cmd, continuous = false) trap("INT") { puts 'Output cancelled'; exit 0; } Capistrano::CLI.ui.say("<%= color('Streaming output Ctrl+c to cancel', :blue) %>") if continuous run(cmd) do |channel, stream, data| puts # for an extra line break before the host name Capistrano::CLI.ui.say("<%= color('#{channel[:host]}', :cyan) %>: #{data}") # puts "#{channel[:host]}: #{data}" break if stream == :err end end