Class: SSHKit::Backend::Local
- Defined in:
- lib/sshkit/backends/local.rb
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
- #download!(remote, local = nil, _options = {}) ⇒ Object
-
#initialize(_ = nil, &block) ⇒ Local
constructor
A new instance of Local.
- #upload!(local, remote, options = {}) ⇒ Object
Methods inherited from Abstract
#as, #background, #capture, config, configure, #execute, #make, #rake, #redact, #run, #test, #with, #within
Constructor Details
Instance Method Details
#download!(remote, local = nil, _options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sshkit/backends/local.rb', line 28 def download!(remote, local=nil, = {}) remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil? if local.nil? FileUtils.cp(remote, File.basename(remote)) else File.open(remote, "rb") do |f| IO.copy_stream(f, local) end end end |
#upload!(local, remote, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sshkit/backends/local.rb', line 13 def upload!(local, remote, = {}) remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil? if local.is_a?(String) if [:recursive] FileUtils.cp_r(local, remote) else FileUtils.cp(local, remote) end else File.open(remote, "wb") do |f| IO.copy_stream(local, f) end end end |