Class: Chronicle::ETL::JSONExtractor

Inherits:
Extractor
  • Object
show all
Includes:
Extractors::Helpers::InputReader
Defined in:
lib/chronicle/etl/extractors/json_extractor.rb

Instance Attribute Summary

Attributes included from Registry::SelfRegistering

#connector_registration

Instance Method Summary collapse

Methods included from Extractors::Helpers::InputReader

#filenames, #pathnames, #read_from_files?, #read_from_stdin?, #read_input, #read_input_as_lines

Methods inherited from Extractor

#initialize

Methods included from Registry::SelfRegistering

#register_connector

Methods included from Configurable

included

Constructor Details

This class inherits a constructor from Chronicle::ETL::Extractor

Instance Method Details

#extractObject



24
25
26
27
28
# File 'lib/chronicle/etl/extractors/json_extractor.rb', line 24

def extract
  @jsons.each do |json|
    yield Chronicle::ETL::Extraction.new(data: json)
  end
end

#prepareObject



16
17
18
19
20
21
22
# File 'lib/chronicle/etl/extractors/json_extractor.rb', line 16

def prepare
  @jsons = []
  load_input do |input|
    data = parse_data(input)
    @jsons += [data].flatten
  end
end

#results_countObject



30
31
32
# File 'lib/chronicle/etl/extractors/json_extractor.rb', line 30

def results_count
  @jsons.count
end