Class: FileLoaders::Adapters::Sftp

Inherits:
Base
  • Object
show all
Defined in:
lib/file_loaders/adapters/sftp.rb

Instance Attribute Summary

Attributes inherited from Base

#patterns, #settings

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from FileLoaders::Adapters::Base

Instance Method Details

#eachObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/file_loaders/adapters/sftp.rb', line 6

def each
  tempdir = make_tempdir
  Net::SFTP.start settings.host, settings.user do |sftp|
    entries(sftp).each do |entry|
      filename = download!(sftp, entry, tempdir)
      move_to_processed(sftp, entry) if yield(filename, entry)
    end
  end
ensure
  FileUtils.remove_dir(tempdir, true)
end