Module: NiFTP

Defined in:
lib/niftp.rb,
lib/niftp/version.rb

Overview

Abstracts away File Transfer Protocol plumbing, such as establishing and closing connections.

Constant Summary collapse

VERSION =
"3.0.0"

Instance Method Summary collapse

Instance Method Details

#ftp(host, options = {}, &block) ⇒ Object

Connects to the host FTP server, executes the given block then closes the connection.

See the README for available options and examples.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/niftp.rb', line 14

def ftp(host, options = {}, &block)
  options = default_options.merge(options)
  raise "The :tries option must be > 0." if options[:tries] < 1
  Retryable.retryable(retryable_options(options)) do
    ftp = instantiate_ftp_per_options(options)
    begin
      (ftp, host, options)
      yield ftp if ftp && block_given?
    ensure
      ftp.close if ftp
    end
  end
end