Sha256: 2489d4d0fb0ae8e58547dc4e91447e10a35b8fa84521ea1ab8b5ac2aa54bd758

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'rest-core'

# http://developer.github.com/v3/
RestCore::Github = RestCore::Builder.client do
  s = self.class # this is only for ruby 1.8!
  use s::Timeout       , 10

  use s::DefaultSite   , 'https://api.github.com/'
  use s::DefaultHeaders, {'Accept' => 'application/json'}
  use s::Oauth2Query   , nil

  use s::CommonLogger  , nil
  use s::Cache         , nil, 600 do
    use s::ErrorHandler, lambda{ |env|
      if env[s::ASYNC]
        if env[s::RESPONSE_BODY].kind_of?(::Exception)
          env
        else
          env.merge(s::RESPONSE_BODY =>
                      RuntimeError.new(env[s::RESPONSE_BODY]['message']))
        end
      else
        raise env[s::RESPONSE_BODY]['message']
      end}
    use s::ErrorDetectorHttp
    use s::JsonDecode  , true
  end
end

module RestCore::Github::Client
  include RestCore

  def me query={}, opts={}
    get('user', query, opts)
  end
end

RestCore::Github.send(:include, RestCore::Github::Client)
require 'rest-core/client/github/rails_util' if
  Object.const_defined?(:Rails)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rest-more-1.0.1 lib/rest-core/client/github.rb
rest-more-1.0.0 lib/rest-core/client/github.rb