Class: Remi::DataTarget::SftpFile

Inherits:
Remi::DataSubject show all
Includes:
Remi::DataSubject::DataTarget
Defined in:
lib/remi/data_subject/sftp_file.rb

Instance Attribute Summary collapse

Attributes inherited from Remi::DataSubject

#fields

Instance Method Summary collapse

Methods included from Remi::DataSubject::DataTarget

#load

Methods inherited from Remi::DataSubject

#df, #df=, #field_symbolizer

Constructor Details

#initialize(*args, **kargs, &block) ⇒ SftpFile

Returns a new instance of SftpFile.



6
7
8
9
# File 'lib/remi/data_subject/sftp_file.rb', line 6

def initialize(*args, **kargs, &block)
  super
  init_sftp_file(*args, **kargs, &block)
end

Instance Attribute Details

#local_pathObject (readonly)

Returns the value of attribute local_path.



11
12
13
# File 'lib/remi/data_subject/sftp_file.rb', line 11

def local_path
  @local_path
end

#remote_pathObject (readonly)

Returns the value of attribute remote_path.



12
13
14
# File 'lib/remi/data_subject/sftp_file.rb', line 12

def remote_path
  @remote_path
end

Instance Method Details

#load!Object

Public: Performs the load operation, regardless of whether it has already executed.

Returns true if the load operation was successful



18
19
20
21
22
23
24
25
# File 'lib/remi/data_subject/sftp_file.rb', line 18

def load!
  @logger.info "Uploading #{@local_path} to #{@credentials[:username]}@#{@credentials[:host]}: #{@remote_path}"
  connection do |sftp|
    retry_upload { sftp.upload! @local_path, @remote_path }
  end

  true
end