Sha256: 9498c95442f5bcc5a21ffaaad238a3a32e918567e398d67771a4feec447d619c
Contents?: true
Size: 1.44 KB
Versions: 20
Compression:
Stored size: 1.44 KB
Contents
class Capistrano::Configuration ## # Print an informative message with asterisks. def inform(message) puts "#{'*' * (message.length + 4)}" puts "* #{message} *" puts "#{'*' * (message.length + 4)}" end ## # Read a file and evaluate it as an ERB template. # Path is relative to this file's directory. def render_erb_template(filename) template = File.read(filename) result = ERB.new(template).result(binding) end ## # Run a command and return the result as a string. # # TODO May not work properly on multiple servers. def run_and_return(cmd) output = [] run cmd do |ch, st, data| output << data end return output.to_s end def try(command, options) success = true invoke_command(command, options) do |ch, stream, out| warn "#{ch[:server]}: #{out}" if stream == :err yield ch, stream, out if block_given? end rescue Capistrano::CommandError => e success = false end def check(cmd, options) puts cmd puts options success = false if options[:check_exit_code] command = "#{cmd}; if [ $? = 0 ]; then echo pass; else echo fail; fi" else command = "if [#{cmd}]; then echo pass; else echo fail; fi" end invoke_command(command, options) do |ch, stream, out| warn "#{ch[:server]}: #{out}" if stream == :err success = out.strip == 'pass' ? true : false break if stream == :err end success end end
Version data entries
20 entries across 20 versions & 1 rubygems