Sha256: 0f6b534c10f01c596dab9683ece34c9204372fa8897a5cc63bdcd339baaad238

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

require 'pathname'

module Chronicle
  module ETL
    class FileExtractor < Chronicle::ETL::Extractor
      include Extractors::Helpers::FilesystemReader

      register_connector do |r|
        r.description = 'file or directory of files'
      end

      # TODO: consolidate this with @config.filename
      setting :dir_glob_pattern

      def extract
        filenames.each do |filename|
          yield Chronicle::ETL::Extraction.new(data: filename)
        end
      end

      def results_count
        filenames.count
      end

      private

      def filenames
        @filenames ||= filenames_in_directory(
          path: @config.filename,
          dir_glob_pattern: @config.dir_glob_pattern,
          load_since: @config.since,
          load_until: @config.until
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chronicle-etl-0.4.0 lib/chronicle/etl/extractors/file_extractor.rb