Class: MockSFTP::Session
- Inherits:
-
Object
- Object
- MockSFTP::Session
- Defined in:
- lib/mock_sftp.rb
Instance Method Summary collapse
- #dir ⇒ Object
- #download!(remote_dir, local_dir, options = {}) ⇒ Object
-
#initialize(dir) ⇒ Session
constructor
A new instance of Session.
- #rename(src, dest, flags_ignored) ⇒ Object
- #upload!(local_path, remote_path) ⇒ Object
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
#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, ={}) raise 'options not supported' unless == {: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 |