Class: SFTPWriter::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/sftp_writer/local.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, logger:) ⇒ Local

Returns a new instance of Local.



5
6
7
8
# File 'lib/sftp_writer/local.rb', line 5

def initialize(config, logger:)
  @config = config
  @logger = logger
end

Instance Method Details

#closeObject



10
11
12
# File 'lib/sftp_writer/local.rb', line 10

def close
  true
end

#write(contents, filename) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/sftp_writer/local.rb', line 18

def write(contents, filename)
  path = File.join(write_path(filename), filename)
  FileUtils.mkdir_p(File.dirname(path))
  File.open(path, 'wb') do |f|
    f.write(contents)
  end
end

#write_path(_filename) ⇒ Object



14
15
16
# File 'lib/sftp_writer/local.rb', line 14

def write_path(_filename)
  Rails.root.join('tmp', @config.relative_path.to_s)
end