Sha256: 60619fccf4b6efea8c5f973e20c16100967c66424723f55aa4f6c57c3767c5cd
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Chake class Backend < Struct.new(:node) def rsync_dest node.path + '/' end def run(cmd) puts "#{node.hostname}: $ #{cmd}" output = IO.popen(command_runner + [cmd]) output.each_line do |line| puts [node.hostname, line.strip].join(': ') end output.close if $? status = $?.exitstatus if status != 0 puts [node.hostname, 'FAILED with exit status %d' % status].join(': ') end end end def run_as_root(cmd) if node.username == 'root' run(cmd) else run('sudo sh -c "' + cmd + '"') end end def to_s self.class.backend_name end def self.backend_name name.split("::").last.downcase end def self.inherited(subclass) @backends ||= [] @backends << subclass end def self.get(name) backend = @backends.find { |b| b.backend_name == name } backend || raise(ArgumentError.new("Invalid backend name: #{name}")) end end end require 'chake/backend/ssh' require 'chake/backend/local'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chake-0.1.4 | lib/chake/backend.rb |