Class: Tumugi::Plugin::LocalFileTarget

Inherits:
FileSystemTarget show all
Defined in:
lib/tumugi/plugin/target/local_file.rb

Instance Attribute Summary

Attributes inherited from FileSystemTarget

#path

Instance Method Summary collapse

Methods inherited from FileSystemTarget

#exist?, #initialize, #remove, #to_s

Methods inherited from Target

#exist?, #initialize, #log, #logger

Constructor Details

This class inherits a constructor from Tumugi::Plugin::FileSystemTarget

Instance Method Details

#fsObject



10
11
12
# File 'lib/tumugi/plugin/target/local_file.rb', line 10

def fs
  @fs ||= LocalFileSystem.new
end

#open(mode = "r", &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/tumugi/plugin/target/local_file.rb', line 14

def open(mode="r", &block)
  if mode.include? 'r'
    File.open(path, mode, &block)
  elsif mode.include? 'w'
    AtomicLocalFile.new(path).open(&block)
  else
    raise 'Invalid mode: #{mode}'
  end
end