Sha256: 89fa87e85742faf617aede62d368f9f853e1546a7e134ddbbb3cbc9806531609
Contents?: true
Size: 678 Bytes
Versions: 36
Compression:
Stored size: 678 Bytes
Contents
module Norikra::Client::CLIUtil def parser(format, *args) format ||= 'json' case format when /^json$/i require 'json' Parser::JSON.new(*args) when /^ltsv$/i require 'ltsv' Parser::LTSV.new(*args) else raise ArgumentError, "unknown format name: #{format}" end end module Parser class JSON def initialize(*args) require 'json' end def parse(line) ::JSON.parse(line.chop) end end class LTSV def initialize(*args) require 'ltsv' end def parse(line) ::LTSV.parse_line(line.chop, {:symbolize_keys => false}) end end end end
Version data entries
36 entries across 36 versions & 2 rubygems