Class: SpsFtpdDriver
- Inherits:
-
Object
- Object
- SpsFtpdDriver
- Defined in:
- lib/sps-ftpd-driver.rb
Instance Method Summary collapse
- #authenticate(user, password) ⇒ Object
- #file_system(user) ⇒ Object
-
#initialize(dir, sps: {}, between_times: '') ⇒ SpsFtpdDriver
constructor
A new instance of SpsFtpdDriver.
Constructor Details
#initialize(dir, sps: {}, between_times: '') ⇒ SpsFtpdDriver
Returns a new instance of SpsFtpdDriver.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sps-ftpd-driver.rb', line 12 def initialize(dir, sps: {}, between_times: '') @dir = dir opt = {host: 'sps', port: '59000', topic: 'test'}.merge(sps) @sps_topic = opt[:topic] @sps_host = opt[:host] @sps_port = opt[:port] @times = between_times end |
Instance Method Details
#authenticate(user, password) ⇒ Object
24 25 26 |
# File 'lib/sps-ftpd-driver.rb', line 24 def authenticate(user, password) true end |
#file_system(user) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sps-ftpd-driver.rb', line 28 def file_system(user) fs = Ftpd::DiskFileSystem.new(@dir) fs.instance_eval(" @sps_topic = '#{@sps_topic}' @sps_host = '#{@sps_host}' @sps_port = '#{@sps_port}' @times = '#{@times}' ") def fs.write(ftp_path, contents) if @times.empty? or ChronicBetween.new(@times).within?(Time.now) then = "%s: uploaded file %s" % [@sps_topic, ftp_path] SPSPub.notice , address: @sps_host, port: @sps_port end super(ftp_path, contents) end fs end |