Sha256: 163663687dd8a9c06b90694c0e6943430bd782593418468ce5784b8d856f6d17

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

require 'rack'
require 'multi_json'
require 'httpclient'
require 'logger'
require 'active_support'
require 'active_support/core_ext'
require 'attr_required'
require 'attr_optional'

module Rack
  module OAuth2
    VERSION = ::File.read(
      ::File.join(::File.dirname(__FILE__), '../../VERSION')
    )

    def self.logger
      @@logger
    end
    def self.logger=(logger)
      @@logger = logger
    end
    self.logger = ::Logger.new(STDOUT)
    self.logger.progname = 'Rack::OAuth2'

    def self.debugging?
      @@debugging
    end
    def self.debugging=(boolean)
      @@debugging = boolean
    end
    def self.debug!
      self.debugging = true
    end
    def self.debug(&block)
      original = self.debugging?
      self.debugging = true
      yield
    ensure
      self.debugging = original
    end
    self.debugging = false

    def self.http_client(agent_name = "Rack::OAuth2 (#{VERSION})", &local_http_config)
      _http_client_ = HTTPClient.new(
        :agent_name => agent_name
      )
      http_config.try(:call, _http_client_)
      local_http_config.try(:call, _http_client_) unless local_http_config.nil?
      _http_client_.request_filter << Debugger::RequestFilter.new if debugging?
      _http_client_
    end

    def self.http_config(&block)
      @@http_config ||= block
    end

    def self.reset_http_config!
      @@http_config = nil
    end

  end
end

require 'rack/oauth2/util'
require 'rack/oauth2/server'
require 'rack/oauth2/client'
require 'rack/oauth2/access_token'
require 'rack/oauth2/debugger'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-oauth2-1.1.0 lib/rack/oauth2.rb
rack-oauth2-1.0.10 lib/rack/oauth2.rb
rack-oauth2-1.0.9 lib/rack/oauth2.rb