Class: BulkImports::Common::Extractors::JsonExtractor
- Inherits:
-
Object
- Object
- BulkImports::Common::Extractors::JsonExtractor
- Defined in:
- lib/bulk_imports/common/extractors/json_extractor.rb
Instance Method Summary collapse
- #extract(context) ⇒ Object
-
#initialize(relation:) ⇒ JsonExtractor
constructor
A new instance of JsonExtractor.
- #remove_tmpdir ⇒ Object
Constructor Details
#initialize(relation:) ⇒ JsonExtractor
Returns a new instance of JsonExtractor.
7 8 9 10 |
# File 'lib/bulk_imports/common/extractors/json_extractor.rb', line 7 def initialize(relation:) @relation = relation @tmpdir = Dir.mktmpdir end |
Instance Method Details
#extract(context) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/bulk_imports/common/extractors/json_extractor.rb', line 12 def extract(context) download_service(context).execute decompression_service.execute attributes = ndjson_reader.consume_attributes(relation) BulkImports::Pipeline::ExtractedData.new(data: attributes) end |
#remove_tmpdir ⇒ Object
21 22 23 |
# File 'lib/bulk_imports/common/extractors/json_extractor.rb', line 21 def remove_tmpdir FileUtils.remove_entry(tmpdir) if Dir.exist?(tmpdir) end |