octokit/octokit.rb — pull request #496 by krzyzak (2014-07-15 14:36:19+00:00)
Title: Enhanced Octokit::TooManyRequests exception

Hi,

When I was trying to catch ```Octokit::TooManyRequests``` exception in my application, I found that there’s no way to return my current rate limit, as well as when limit will be reset.

Before, I had to do something like this:
```ruby
begin
Octokit.repo("rails/rails")
rescue Octokit::TooManyRequests => e
reset = e.instance_variable_get(:@response).response_headers["x-ratelimit-reset"].to_i
sleep Time.at(reset) - Time.now
retry
end
```

This code is bad, and I feel bad that I wrote it ;)

With my patch, I don’t have to break encapsulation and write code like this:

```ruby
begin
Octokit.repo("rails/rails")
rescue Octokit::TooManyRequests => e
sleep e.limit_resets_at - Time.now
retry
end
```