Top Level Namespace

Defined Under Namespace

Modules: Mina

Instance Method Summary collapse

Instance Method Details

#scp_download(from, to, options = {}) ⇒ Object



18
19
20
# File 'lib/mina/scp.rb', line 18

def scp_download(from, to, options = {})
  scp_transfer(:down, from, to, options)
end

#scp_transfer(direction, from, to, options = {}) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mina/scp.rb', line 1

def scp_transfer(direction, from, to, options = {})
  remote_prefix = "#{domain!}:"
  remote_prefix = "#{user}@#{remote_prefix}" if user?
  command = "scp"
  command << " -i #{identity_file}" if identity_file?
  command << " -P #{port}" if port?
  command << " -r" if options[:recursively]
  case direction
  when :up   then to   = remote_prefix + to
  when :down then from = remote_prefix + from
  end
  command << " #{from} #{to}"
  print_command command if options[:verbose]
  result = %x[#{command}]
  puts result unless result == ""
end

#scp_upload(from, to, options = {}) ⇒ Object



22
23
24
# File 'lib/mina/scp.rb', line 22

def scp_upload(from, to, options = {})
  scp_transfer(:up, from, to, options)
end