Class: Remi::Loader::LocalFile

Inherits:
Remi::Loader show all
Defined in:
lib/remi/data_subjects/local_file.rb

Overview

Local file loader Used to output files to a local filesystem

Examples:

class MyJob < Remi::Job
  target :my_target do
    encoder Remi::Encoder::CsvFile.new(
      csv_options: { col_sep: '|' }
    )
    loader Remi::Loader::LocalFile.new(
      path: 'test.csv'
    )
  end
end

my_df = Daru::DataFrame.new({ a: 1.upto(5).to_a, b: 6.upto(10) })
job = MyJob.new
job.my_target.df = my_df
job.my_target.load

Instance Attribute Summary

Attributes inherited from Remi::Loader

#context, #logger

Instance Method Summary collapse

Methods inherited from Remi::Loader

#autoload, #fields

Constructor Details

#initialize(*args, **kargs) ⇒ LocalFile

Returns a new instance of LocalFile.



89
90
91
92
# File 'lib/remi/data_subjects/local_file.rb', line 89

def initialize(*args, **kargs)
  super
  init_local_file_loader(*args, **kargs)
end

Instance Method Details

#load(data) ⇒ true

Moves the file from the temporary workspace to another local path

Parameters:

  • data (Object)

    The path to the file in the temporary work location

Returns:

  • (true)

    On success



97
98
99
100
# File 'lib/remi/data_subjects/local_file.rb', line 97

def load(data)
  logger.info "Writing file #{@local_path}"
  FileUtils.mv(data, @local_path)
end