Sha256: 3314a0414a976f2bb5cc20b9a1f30aecb210a2d8317fd9bc29f57bc75a42b685

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'faraday_middleware'
Dir[File.expand_path('../../../faraday/*.rb', __FILE__)].each{|file| require file}

module Octokit
  class Client
    # @private
    module Connection
      private

      def connection(raw=false, authenticate=true)
        options = {
          :proxy => proxy,
          :ssl => {:verify => false},
          :url => endpoint,
        }

        options.merge!(:params => { :access_token => oauth_token }) if oauthed? && !authenticated?

        Faraday::Connection.new(options) do |connection|
          connection.adapter(adapter)
          connection.basic_auth authentication[:login], authentication[:password] if authenticate and authenticated?
          connection.use Faraday::Response::RaiseError
          unless raw
            case format.to_s.downcase
            when 'json' then connection.use Faraday::Response::ParseJson
            when 'xml' then connection.use Faraday::Response::ParseXml
            end
            connection.use Faraday::Response::Mashify
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
octokit-0.5.2 lib/octokit/client/connection.rb
octokit-0.5.1 lib/octokit/client/connection.rb
octokit-0.5.0 lib/octokit/client/connection.rb