Sha256: d919112c6d0d5611b4b0fc5f7b6ab41e445e89e9eecac7c83976c671b68d28b4
Contents?: true
Size: 690 Bytes
Versions: 2
Compression:
Stored size: 690 Bytes
Contents
# frozen_string_literal: true module LogAnalyser class Parser class FileNotFoundError < StandardError def initialize(path) super("File not found for path: [#{path}]") end end def self.call(file_path) new.call(file_path) end def call(file_path) raise FileNotFoundError, file_path unless File.exist?(file_path) data = File.open(file_path).map(&:strip) data.reject!(&:empty?) parse(data) end private def parse(data) entries = Hash.new { |h, k| h[k] = [] } data.each do |entry| key, value = *entry.split(/\s+/) entries[key] << value end entries end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
log-analyser-0.1.3.pre.documentation.20201108193310 | lib/parser.rb |
log-analyser-0.1.3.pre.documentation.20201108192110 | lib/parser.rb |