Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

niftp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

niftp

  • 3.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

NiFTP

Only supports Ruby 2.0.0+ A Ruby gem, makes Ruby's decidedly un-nifty Net::FTP library easier to use. It abstracts away the FTP plumbing, such as establishing and closing connections. Options include retrying your commands on flakey FTP servers, and forced timeouts. FTP Secure (FTPS) is also supported.

Code Climate Build Status

Usage

# Without NiFTP:
begin
  client = Net::FTP.new("localhost")
  client.list
ensure
  client.try(:close)
end

# With NiFTP:
ftp("localhost") { |client| client.list }

# A more concrete example:

# Mixin the +NiFTP+ module, which provides the +ftp+ method.
require 'niftp'
class SomeObject
  include NiFTP

  def ftps_options
    {
      username: "",
      password: "",
      ftps: true,
      ssl_context_params: {
        verify_mode: OpenSSL::SSL::VERIFY_NONE
      }
    }
  end

  def ftp_stuff
    ftp("ftp.appareldownload.com", ftps_options) do |client|
      files = client.list('n*')
      # ...
      file = client.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
      # ...
    end
  end
end

Options

  • username: The user name, if required by the host (default: "").
  • password: The password, if required by the host (default: "").
  • port: The port for the host (default: 21).
  • tries: The number of times to try the given FTP commands upon any exception, before raising the exception (Default: 2, meaning it will retry once upon any exception).
  • sleep: The number of seconds to sleep in between tries (default: 1).
  • on: An array of errors to limit when the code block is retried (default: StandardError). See the retryable gem for usage details
  • matching: An exception message regex to limit when the code block is retried (default: /.*/). See the retryable gem for usage details
  • timeout: The number of seconds to wait before timing out authentication (default: 30). Use 0 to disable the authentication timeout.
  • passive: Set to false to prevent a connection in passive mode (default: true).
  • ftps: Set to true if connecting to a FTP Secure server (default: false).
  • ftps_mode: Set to one of the following: DoubleBagFTPS::EXPLICIT or DoubleBagFTPS::IMPLICIT (default: DoubleBagFTPS::IMPLICIT).
  • ssl_context_params: See the DoubleBagFTPS for options. (default: { }).

Caveats

Setting the :tries option to 0 will raise a runtime error, otherwise the codeblock would never execute.

Testing

Tests are written using minitest-spec and Mocha.

FAQs

Package last updated on 07 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc