Sha256: 05a5eea0584ce757d69697269d74a82e96f43c78263a19987241b79a29b2e307

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'active_support/core_ext/object'
require 'active_support/core_ext/hash'

require 'configuration'
require 'xftp/version'
require 'xftp/errors'
require 'xftp/client'

require_relative 'initializers/i18n'

# Interface unification for FTP/SFTP protocols
module XFTP
  # Config accessor
  def self.config
    @configuration ||= Configuration.new
  end

  # Calls the given block using temporary configuration
  # :reek:TooManyStatements
  def self.using(logger: config.logger, ftp: config.ftp, ssh: config.ssh)
    snapshot = config.clone
    config.logger = logger
    config.ftp = ftp
    config.ssh = ssh
    yield
    @configuration = snapshot
  end

  # For a block { |config| ... }
  # @yield the (see #config)
  def self.configure
    yield config
  end

  # Initiates a new session
  #
  # @param [String] :url the remote host url
  # @param [Hash] settings the connection settings
  # @option settings [Hash<Symbol, String>] :credentials the authentication credentials
  #
  # @raise [URI::InvalidURIError] if url given is not a correct URI
  # @raise [XFTP::MissingArgument] if some of the required settings are missing
  # @raise [XFTP::NotSupportedProtocol] if protocol detected by schema is not supported
  #
  # @see Net::SSH
  # @see Net::FTP
  def self.start(url, settings = {}, &callback)
    Client.start(url, settings, &callback)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xftp-0.4.2 lib/xftp.rb