Sha256: ebb7fd966851cb077081c8670497af2b544f1357763ea713e921eef181d7aa88

Contents?: true

Size: 1.7 KB

Versions: 18

Compression:

Stored size: 1.7 KB

Contents

module Octokit
  class Client

    # Methods for API rate limiting info
    #
    # @see http://developer.github.com/v3/#rate-limiting
    module RateLimit

      # Get rate limit info from last response if available
      # or make a new request to fetch rate limit
      #
      # @see http://developer.github.com/v3/#rate-limiting
      # @return [Octokit::RateLimit] Rate limit info
      def rate_limit(options = {})
        return rate_limit! if last_response.nil?

        Octokit::RateLimit.from_response(last_response)
      end
      alias ratelimit rate_limit

      # Get number of rate limted requests remaining
      #
      # @see http://developer.github.com/v3/#rate-limiting
      # @return [Fixnum] Number of requests remaining in this period
      def rate_limit_remaining(options = {})
        puts "Deprecated: Please use .rate_limit.remaining"
        rate_limit.remaining
      end
      alias ratelimit_remaining rate_limit_remaining

      # Refresh rate limit info by making a new request
      #
      # @see http://developer.github.com/v3/#rate-limiting
      # @return [Octokit::RateLimit] Rate limit info
      def rate_limit!(options = {})
        get "rate_limit"
        Octokit::RateLimit.from_response(last_response)
      end
      alias ratelimit! rate_limit!

      # Refresh rate limit info and get number of rate limted requests remaining
      #
      # @see http://developer.github.com/v3/#rate-limiting
      # @return [Fixnum] Number of requests remaining in this period
      def rate_limit_remaining!(options = {})
        puts "Deprecated: Please use .rate_limit!.remaining"
        rate_limit!.remaining
      end
      alias ratelimit_remaining! rate_limit_remaining!

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
octokit-2.6.3 lib/octokit/client/rate_limit.rb
octokit-2.6.2 lib/octokit/client/rate_limit.rb
octokit-2.6.1 lib/octokit/client/rate_limit.rb
octokit-2.6.0 lib/octokit/client/rate_limit.rb
octokit-2.5.1 lib/octokit/client/rate_limit.rb
octokit-2.5.0 lib/octokit/client/rate_limit.rb
octokit-2.4.0 lib/octokit/client/rate_limit.rb
octokit-2.3.1 lib/octokit/client/rate_limit.rb
octokit-2.3.0 lib/octokit/client/rate_limit.rb
octokit-2.2.0 lib/octokit/client/rate_limit.rb
octokit-2.1.2 lib/octokit/client/rate_limit.rb
octokit-2.1.1 lib/octokit/client/rate_limit.rb
octokit-2.1.0 lib/octokit/client/rate_limit.rb
octokit-2.0.0 lib/octokit/client/rate_limit.rb
octokit-2.0.0.rc4 lib/octokit/client/rate_limit.rb
octokit-2.0.0.rc3 lib/octokit/client/rate_limit.rb
octokit-2.0.0.rc2 lib/octokit/client/rate_limit.rb
octokit-2.0.0.rc1 lib/octokit/client/rate_limit.rb