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-1.5.0 lib/norikra/client/cli/parser.rb
norikra-client-1.4.0 lib/norikra/client/cli/parser.rb
norikra-client-1.3.1 lib/norikra/client/cli/parser.rb
norikra-client-1.3.0-java lib/norikra/client/cli/parser.rb
norikra-client-1.3.0 lib/norikra/client/cli/parser.rb
norikra-client-jruby-1.1.0-java lib/norikra/client/cli/parser.rb
norikra-client-1.1.0 lib/norikra/client/cli/parser.rb
norikra-client-jruby-1.0.0-java lib/norikra/client/cli/parser.rb
norikra-client-1.0.0 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.1.5-java lib/norikra/client/cli/parser.rb
norikra-client-0.1.5 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.1.4-java lib/norikra/client/cli/parser.rb
norikra-client-0.1.4 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.1.1-java lib/norikra/client/cli/parser.rb
norikra-client-0.1.1 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.1.0-java lib/norikra/client/cli/parser.rb
norikra-client-0.1.0 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.9-java lib/norikra/client/cli/parser.rb
norikra-client-0.0.9 lib/norikra/client/cli/parser.rb
norikra-client-jruby-0.0.8-java lib/norikra/client/cli/parser.rb