Class: MgeWholesale::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mge_wholesale/base.rb

Direct Known Subclasses

Catalog, Category, Inventory, Order, Tracking, User

Class Method Summary collapse

Class Method Details

.connect(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mge_wholesale/base.rb', line 4

def self.connect(options = {})
  requires!(options, :username, :password)

  Net::FTP.open(MgeWholesale.config.ftp_host, options[:username], options[:password]) do |ftp|
    begin
      ftp.debug_mode = MgeWholesale.config.debug_mode
      ftp.passive = true
      yield ftp
    ensure
      ftp.close
    end
  end
rescue Net::FTPPermError => e
  raise case
  when e.message =~ /no such file or directory/i
    MgeWholesale::FileOrDirectoryNotFound
  else
    MgeWholesale::NotAuthenticated
  end
end