Sha256: fe9aa04e90d18ef676db6e87ac408b8c7684b7f37b4871f4284c24cf505b2b4f
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require 'open4' class SourceTreeSyncer attr_accessor :exclude attr_reader :sys_command, :output, :errors SYS_COMMAND = 'rsync' OPTS = "-azr --timeout=5 --rsh='ssh -o NumberOfPasswordPrompts=0 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'" EXCLUDE_OPT = "--exclude" def initialize source_tree_path @source_tree_path = source_tree_path @exclude = [] end def sync @tempdir = Dir.mktmpdir("gorgon") Dir.chdir(@tempdir) exclude_opt = build_exclude_opt @sys_command = "#{SYS_COMMAND} #{OPTS} #{exclude_opt} #{@source_tree_path}/ ." pid, stdin, stdout, stderr = Open4::popen4 @sys_command stdin.close @output, @errors = [stdout, stderr].map { |p| begin p.read ensure p.close end } ignore, status = Process.waitpid2 pid @exitstatus = status.exitstatus end def success? @exitstatus == 0 end def remove_temp_dir FileUtils::remove_entry_secure(@tempdir) end private def build_exclude_opt return "" if @exclude.nil? or @exclude.empty? @exclude.unshift("") @exclude.join(" #{EXCLUDE_OPT} ") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gorgon-0.1.1 | lib/gorgon/source_tree_syncer.rb |
gorgon-0.1.0 | lib/gorgon/source_tree_syncer.rb |