Sha256: 43c67f0b89e8e6215bdff238b030bf11d92cbcaa73fde828eb64c534ca04d746

Contents?: true

Size: 612 Bytes

Versions: 2

Compression:

Stored size: 612 Bytes

Contents

module Pipio
  class ParserFactory
    PARSER_FOR_EXTENSION = {
      "html" => HtmlLogParser,
      "htm" => HtmlLogParser,
      "txt" => TextLogParser
    }

    def initialize(logfile_path, aliases)
      @logfile_path = logfile_path
      @aliases = aliases
    end

    def parser
      parser_class.new(@logfile_path, @aliases)
    end

    private

    def parser_class
      PARSER_FOR_EXTENSION.fetch(extension, NullParser)
    end

    def extension
      extension_with_leading_period[1..-1]
    end

    def extension_with_leading_period
      File.extname(@logfile_path).downcase
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pipio-0.0.2 lib/pipio/parser_factory.rb
pipio-0.0.1 lib/pipio/parser_factory.rb