lib/capsaicin/files/remote.rb in joekhoobyar-capsaicin-0.1.5 vs lib/capsaicin/files/remote.rb in joekhoobyar-capsaicin-0.1.6

- old
+ new

@@ -54,16 +54,22 @@ end rescue Interrupt logger.trace "interrupted (Ctrl-C)" if logger end - def upload(*args) + def upload(from, to, options={}, &block) case _via when :system, :local_run - cp(*args) + cp from, to else - @config.upload(*args) + to2, to = to, "/tmp/#{File.basename to}-#{Time.now.utc.to_i}" if _via.to_s[0,4] == 'sudo' + @config.upload(from, to, options, &block) + if to2 + run "chmod 0644 #{to}" + cp to, to2 + run "rm -f #{to}" + end end end def download(*args) case _via @@ -72,16 +78,22 @@ else @config.download(*args) end end - def put(from, to) + def put(data, path, options={}) case _via when :system, :local_run FileUtils::Verbose.copy_stream StringIO.new(from), to else - @config.put(*args) + path2, path = path, "/tmp/#{File.basename path}-#{Time.now.utc.to_i}" if _via.to_s[0,4] == 'sudo' + @config.put(data, path, options) + if path2 + run "chmod 0644 #{path}" + cp path, path2 + run "rm -f #{path}" + end end end def cd(dir, options={}) if block_given? @@ -109,10 +121,25 @@ def tar_cj(dest, src, options={}, &filter) filter and abort "tar_cj: remote mode does not support a filtering proc" _r 'tar -cjf', Array(src).unshift(dest) end + def tar_x(dest, options={}, &filter) + filter and abort "tar_x: remote mode does not support a filtering proc" + _r 'tar -xf', [dest] + end + + def tar_xz(dest, options={}, &filter) + filter and abort "tar_xz: remote mode does not support a filtering proc" + _r 'tar -xzf', [dest] + end + + def tar_xj(dest, src, options={}, &filter) + filter and abort "tar_xj: remote mode does not support a filtering proc" + _r 'tar -xjf', Array(src).unshift(dest) + end + def tar_t(src, options={}, &filter) filter and abort "tar_t: remote mode does not support a filtering proc" _t 'tar -tf', [src] end @@ -170,7 +197,5 @@ end end end end - -Capistrano.plugin :remote_files, Capsaicin::Files::Remote