class Chake::Backend

Public Class Methods

backend_name() click to toggle source
# File lib/chake/backend.rb, line 59
def self.backend_name
  name.split("::").last.downcase
end
get(name) click to toggle source
# File lib/chake/backend.rb, line 68
def self.get(name)
  backend = @backends.find { |b| b.backend_name == name }
  backend || raise(ArgumentError.new("Invalid backend name: #{name}"))
end
inherited(subclass) click to toggle source
# File lib/chake/backend.rb, line 63
def self.inherited(subclass)
  @backends ||= []
  @backends << subclass
end

Public Instance Methods

rsync() click to toggle source
# File lib/chake/backend.rb, line 16
def rsync
  ['rsync']
end
rsync_dest() click to toggle source
# File lib/chake/backend.rb, line 20
def rsync_dest
  node.path + '/'
end
run(cmd) click to toggle source
# File lib/chake/backend.rb, line 24
def run(cmd)
  printf "%#{Node.max_node_name_length}s: $ %s\n", node.hostname, cmd
  output = IO.popen(command_runner + [cmd])
  output.each_line do |line|
    printf "%#{Node.max_node_name_length}s: %s\n", node.hostname, line.strip
  end
  output.close
  if $?
    status = $?.exitstatus
    if status != 0
      raise CommandFailed.new([node.hostname, 'FAILED with exit status %d' % status].join(': '))
    end
  end
end
run_as_root(cmd) click to toggle source
# File lib/chake/backend.rb, line 43
def run_as_root(cmd)
  if node.remote_username == 'root'
    run(cmd)
  else
    run('sudo ' + cmd)
  end
end
run_shell() click to toggle source
# File lib/chake/backend.rb, line 39
def run_shell
  system(*shell_command)
end
scp() click to toggle source
# File lib/chake/backend.rb, line 8
def scp
  ['scp']
end
scp_dest() click to toggle source
# File lib/chake/backend.rb, line 12
def scp_dest
  ''
end
skip?() click to toggle source
# File lib/chake/backend.rb, line 55
def skip?
  false
end
to_s() click to toggle source
# File lib/chake/backend.rb, line 51
def to_s
  self.class.backend_name
end