Sha256: 4bc3a31b46f98cdac5cb8006fbdbc9e24a1ea95971923bae0d4747b39dfc46f2

Contents?: true

Size: 617 Bytes

Versions: 14

Compression:

Stored size: 617 Bytes

Contents

# frozen_string_literal: true

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
log-analyser-0.1.3.pre.documentation.20201108184713 lib/parser.rb
log-analyser-0.1.3.pre.documentation.20201108181359 lib/parser.rb
log-analyser-0.1.2b lib/parser.rb
log-analyser-0.1.2b.pre.bumpversion.20201107195800 lib/parser.rb
log-analyser-0.1.2 lib/parser.rb
log-analyser-0.1.2.pre.v012b.20201107192223 lib/parser.rb
log-analyser-0.1.1.pre.v012b.20201107192007 lib/parser.rb
log-analyser-0.1.1.pre.v012b.20201107191751 lib/parser.rb
log-analyser-0.1.2.pre.v012.20201107185736 lib/parser.rb
log-analyser-0.1.1 lib/parser.rb
log-analyser-0.1.1.pre.deployment.20201107180229 lib/parser.rb
log-analyser-0.1.1.pre.expandreadme.20201107175459 lib/parser.rb
log-analyser-0.1.1.pre.addgemtagrelease.20201106201808 lib/parser.rb
log-analyser-0.1.1.pre.test.20201106194135 lib/parser.rb