Class: SimpleHotFolder::HotFolder

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_hot_folder/hot_folder.rb

Defined Under Namespace

Classes: Entry

Constant Summary collapse

IGNORE_FOLDERS =
[
  '.',
  '..',
]

Instance Method Summary collapse

Constructor Details

#initialize(input_path, error_path, output_path) ⇒ HotFolder

Returns a new instance of HotFolder.



9
10
11
12
13
14
# File 'lib/simple_hot_folder/hot_folder.rb', line 9

def initialize(input_path, error_path, output_path)
  @input_path = input_path
  @error_path = error_path
  @output_path = output_path
  @validate_file = default_validate_file_function
end

Instance Method Details

#process_input!Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/simple_hot_folder/hot_folder.rb', line 16

def process_input!
  entries = read_input(@input_path)
  entries.each do |entry|
    begin
      yield entry
      FileUtils.mv(entry.path, @output_path) if File.exist?(entry.path)
    rescue Exception => e
      move_file_to_error!(entry, e)
    end
  end
end