Class: MockSFTP::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/mock_sftp.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ Session

Returns a new instance of Session.



22
# File 'lib/mock_sftp.rb', line 22

def initialize(dir) ; @dir = dir        ; end

Instance Method Details

#dirObject



23
# File 'lib/mock_sftp.rb', line 23

def dir             ; SFTPDir.new(@dir) ; end

#download!(remote_dir, local_dir, options = {}) ⇒ Object



37
38
39
40
41
42
# File 'lib/mock_sftp.rb', line 37

def download!(remote_dir, local_dir, options={})
  raise 'options not supported' unless options == {:recursive => true}

  local_remote_dir = File.join(@dir, remote_dir)
  FileUtils.cp_r(Dir.glob(local_remote_dir + '/*'), local_dir)
end

#rename(src, dest, flags_ignored) ⇒ Object



31
32
33
34
35
# File 'lib/mock_sftp.rb', line 31

def rename(src, dest, flags_ignored)
  local_src = File.join(@dir, src)
  local_dest = File.join(@dir, dest)
  FileUtils.mv(local_src, local_dest)
end

#upload!(local_path, remote_path) ⇒ Object



25
26
27
28
29
# File 'lib/mock_sftp.rb', line 25

def upload!(local_path, remote_path)
  local_remote_path = File.join(@dir, remote_path)
  FileUtils.cp(local_path, local_remote_path)
  nil
end