Class: Davidsons::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/davidsons/base.rb
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
|
# File 'lib/davidsons/base.rb', line 4
def self.connect(options = {})
requires!(options, :username, :password)
Net::FTP.open(Davidsons.config.ftp_host, options[:username], options[:password]) do |ftp|
ftp.passive = true
ftp.debug_mode = Davidsons.config.debug_mode?
yield ftp
end
rescue Net::FTPPermError => e
if e.to_s.start_with?('530')
raise Davidsons::NotAuthenticated
else
raise e
end
end
|