Class: Hakoy::Proxy
- Inherits:
-
Object
- Object
- Hakoy::Proxy
- Defined in:
- lib/hakoy.rb
Constant Summary collapse
- DEFAULT_OUTPUT_FORMAT =
'csv'- DEFAULT_UID_KEY =
'uid'- REQUIED_KEYS =
%w(customer product timestamp price quantity order_id)
Instance Method Summary collapse
-
#initialize(conf) ⇒ Proxy
constructor
A new instance of Proxy.
- #store(file) ⇒ Object
Constructor Details
#initialize(conf) ⇒ Proxy
Returns a new instance of Proxy.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hakoy.rb', line 23 def initialize(conf) = conf.fetch(:timestamp_key) @db_dir = conf.fetch(:db_dir) @output_format = conf.fetch(:output_format) { DEFAULT_OUTPUT_FORMAT } @uid_key = conf.fetch(:uid_key) { DEFAULT_UID_KEY } @file_iterator = conf.fetch(:file_iterator) { FileIterator } @append_strategy = conf.fetch(:append_strategy) { AppendStrategy.new } @required_keys_mapping = conf.fetch(:required_keys_mapping) assert_required_keys_present!(@required_keys_mapping) = TimestampPath.new @row_normalizer = RowNormalizer.new( required_keys: @required_keys_mapping.values, uid_key: @uid_key ) end |
Instance Method Details
#store(file) ⇒ Object
40 41 42 43 |
# File 'lib/hakoy.rb', line 40 def store(file) @file_iterator.(file) { |row_hash| store_row(row_hash) } finalize_store! end |