Sha256: ea6eafe1f732486d5cc95cfa5cec275f0e24aab525af39a647a99805af25d99f
Contents?: true
Size: 947 Bytes
Versions: 2
Compression:
Stored size: 947 Bytes
Contents
module Chronicle module ETL class JsonExtractor < Chronicle::ETL::Extractor include Extractors::Helpers::FilesystemReader register_connector do |r| r.description = 'input as JSON' end DEFAULT_OPTIONS = { filename: $stdin, # We're expecting line-separated json objects jsonl: true }.freeze def initialize(options = {}) super(DEFAULT_OPTIONS.merge(options)) end def extract load_input do |input| parsed_data = parse_data(input) yield Chronicle::ETL::Extraction.new(data: parsed_data) if parsed_data end end def results_count end private def parse_data data JSON.parse(data) rescue JSON::ParserError => e end def load_input read_from_filesystem(filename: @options[:filename]) do |data| yield data end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chronicle-etl-0.3.1 | lib/chronicle/etl/extractors/json_extractor.rb |
chronicle-etl-0.3.0 | lib/chronicle/etl/extractors/json_extractor.rb |