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

Version Path
norikra-client-0.0.8 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.7-java lib/norikra/client/cli/parser.rb
norikra-client-0.0.7 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.6-java lib/norikra/client/cli/parser.rb
norikra-client-0.0.6 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.5-java lib/norikra/client/cli/parser.rb
norikra-client-0.0.5 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.4-java lib/norikra/client/cli/parser.rb
norikra-client-0.0.4 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.4.jruby1-java lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.3-java lib/norikra/client/cli/parser.rb
norikra-client-0.0.3 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.2-java lib/norikra/client/cli/parser.rb
norikra-client-0.0.2 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.1-java lib/norikra/client/cli/parser.rb
norikra-client-0.0.1 lib/norikra/client/cli/parser.rb