Class: Remi::DataTarget::SftpFile

Inherits:
Object
  • Object
show all
Includes:
Remi::DataTarget
Defined in:
lib/remi/data_target/sftp_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Remi::DataSubject

#df, #df=, #field_symbolizer, #fields

Constructor Details

#initialize(credentials:, local_path:, remote_path: File.basename(local_path), logger: Remi::Settings.logger) ⇒ SftpFile

Returns a new instance of SftpFile.



6
7
8
9
10
11
# File 'lib/remi/data_target/sftp_file.rb', line 6

def initialize(credentials:, local_path:, remote_path: File.basename(local_path), logger: Remi::Settings.logger)
  @credentials = credentials
  @local_path = local_path
  @remote_path = remote_path
  @logger = logger
end

Instance Attribute Details

#local_pathObject (readonly)

Returns the value of attribute local_path.



13
14
15
# File 'lib/remi/data_target/sftp_file.rb', line 13

def local_path
  @local_path
end

#remote_pathObject (readonly)

Returns the value of attribute remote_path.



14
15
16
# File 'lib/remi/data_target/sftp_file.rb', line 14

def remote_path
  @remote_path
end

Instance Method Details

#loadObject



16
17
18
19
20
21
22
23
24
# File 'lib/remi/data_target/sftp_file.rb', line 16

def load
  return true if @loaded

  connection do |sftp|
    retry_upload { sftp.upload! @local_path, @remote_path }
  end

  @loaded = true
end