lib/chronicle/etl/extractors/file_extractor.rb in chronicle-etl-0.5.5 vs lib/chronicle/etl/extractors/file_extractor.rb in chronicle-etl-0.6.1
- old
+ new
@@ -1,18 +1,20 @@
+# frozen_string_literal: true
+
require 'pathname'
module Chronicle
module ETL
# Return filenames that match a pattern in a directory
class FileExtractor < Chronicle::ETL::Extractor
-
register_connector do |r|
+ r.identifier = :file
r.description = 'file or directory of files'
end
setting :input, default: ['.']
- setting :dir_glob_pattern, default: "**/*"
+ setting :dir_glob_pattern, default: '**/*'
setting :larger_than
setting :smaller_than
def prepare
@pathnames = gather_files
@@ -30,10 +32,10 @@
private
def gather_files
roots = [@config.input].flatten.map { |filename| Pathname.new(filename) }
- raise(ExtractionError, "Input must exist") unless roots.all?(&:exist?)
+ raise(ExtractionError, 'Input must exist') unless roots.all?(&:exist?)
directories, files = roots.partition(&:directory?)
directories.each do |directory|
files += Dir.glob(File.join(directory, @config.dir_glob_pattern)).map { |filename| Pathname.new(filename) }