lib/chronicle/etl/extractors/extractor.rb in chronicle-etl-0.3.1 vs lib/chronicle/etl/extractors/extractor.rb in chronicle-etl-0.4.0
- old
+ new
@@ -3,19 +3,24 @@
module Chronicle
module ETL
# Abstract class representing an Extractor for an ETL job
class Extractor
extend Chronicle::ETL::Registry::SelfRegistering
+ include Chronicle::ETL::Configurable
+ setting :since, type: :date
+ setting :until, type: :date
+ setting :limit
+ setting :load_after_id
+ setting :filename
+
# Construct a new instance of this extractor. Options are passed in from a Runner
- # == Paramters:
+ # == Parameters:
# options::
# Options for configuring this Extractor
def initialize(options = {})
- @options = options.transform_keys!(&:to_sym)
- sanitize_options
- handle_continuation
+ apply_options(options)
end
# Hook called before #extract. Useful for gathering data, initailizing proxies, etc
def prepare; end
@@ -28,20 +33,16 @@
raise NotImplementedError
end
private
- def sanitize_options
- @options[:load_since] = Time.parse(@options[:load_since]) if @options[:load_since] && @options[:load_since].is_a?(String)
- @options[:load_until] = Time.parse(@options[:load_until]) if @options[:load_until] && @options[:load_until].is_a?(String)
- end
+ # TODO: reimplemenet this
+ # def handle_continuation
+ # return unless @config.continuation
- def handle_continuation
- return unless @options[:continuation]
-
- @options[:load_since] = @options[:continuation].highest_timestamp if @options[:continuation].highest_timestamp
- @options[:load_after_id] = @options[:continuation].last_id if @options[:continuation].last_id
- end
+ # @config.since = @config.continuation.highest_timestamp if @config.continuation.highest_timestamp
+ # @config.load_after_id = @config.continuation.last_id if @config.continuation.last_id
+ # end
end
end
end
require_relative 'helpers/filesystem_reader'