Class: Impex::FileLoader::FileSystem

Inherits:
Base
  • Object
show all
Defined in:
lib/impex/file_loaders/file_system.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Impex::FileLoader::Base

Instance Method Details

#loadObject

The method #load is responsible to fetch all files (instances of Impex::File). Each rows are stored as an array of Impex::Row. The routine CSVImport::FileFormatter.build takes an instance of File as parameter and returns an instance of Impex::File which contains a set of Impex::Row accessible via :each method



13
14
15
16
17
18
19
# File 'lib/impex/file_loaders/file_system.rb', line 13

def load
  files = []
  ::Dir.glob("#{::Rails.root}/#{@options[:relative_path]}/csv_import/**/*.csv").each do |f|
    files << Impex::FileFormatter.build(::File.open(f))
  end
  files
end