Sha256: e0e60a894e59c0d134481556f6e9968c47614f89523319c490fa72054836c88a

Contents?: true

Size: 1.73 KB

Versions: 4

Compression:

Stored size: 1.73 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_limit/#rate-limit
      # @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_limit/#rate-limit
      # @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_limit/#rate-limit
      # @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_limit/#rate-limit
      # @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

4 entries across 4 versions & 1 rubygems

Version Path
octokit-3.0.0.pre lib/octokit/client/rate_limit.rb
octokit-2.7.2 lib/octokit/client/rate_limit.rb
octokit-2.7.1 lib/octokit/client/rate_limit.rb
octokit-2.7.0 lib/octokit/client/rate_limit.rb