Sha256: c0d44459e8fd5ad008d55abf0526c7163f92fa0a973709756a7b1a74b8b206f7

Contents?: true

Size: 716 Bytes

Versions: 4

Compression:

Stored size: 716 Bytes

Contents

require 'httparty'

module CabbageDoc
  class Client
    include HTTParty

    class CustomParser < HTTParty::Parser
      def json
        JSON.parse(body, :quirks_mode => true, :allow_nan => true)
      end
    end
    parser CustomParser

    class << self
      def new(auth)
        Class.new(self) do |klass|
          klass.headers "User-Agent" => auth.user_agent
          klass.base_uri auth.uri

          if auth.type == :basic
            klass.basic_auth auth.username, auth.password
          elsif auth.token
            klass.headers "Authorization" => "#{auth.type.to_s.capitalize} #{auth.token}"
          end

          debug_output $stdout if auth.verbose
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cabbage_doc-0.1.4 lib/cabbage_doc/client.rb
cabbage_doc-0.1.3 lib/cabbage_doc/client.rb
cabbage_doc-0.1.2 lib/cabbage_doc/client.rb
cabbage_doc-0.1.1 lib/cabbage_doc/client.rb