hayesdavis / grackle

Lightweight Ruby library for the Twitter API that goes with the flow.
228 stars 36 forks source link

Add rate_limit metadata to client on each request #21

Closed yaauie closed 12 years ago

yaauie commented 12 years ago

after each request, client.rate_limit contains a hash representing the available rate limit information, pulled from the headers.

yaauie commented 12 years ago

bump :)

hayesdavis commented 12 years ago

Hey guys, It's been a while since I've worked on grackle as you can no doubt tell. I'm doing some work on it this week though and I plan to do something like this pull request. I'm not sure if it'll be a straight merge or not. I'll let you know.

hayesdavis commented 12 years ago

Hey guys, we went a slightly different direction with this but I think we achieved the same goal. Now, after a request, you can do the following:

client.response.headers["X-Ratelimit-Remaining"]

This will give you the header value you're looking for. I've tried to avoid hard-coding in any specific things into Grackle since my goal is for it to be very flexible as Twitter makes changes. That's why I chose to give back a more generic response object instead of hard-coding a rate_limit method.

This will be in version 0.2.0 which will be out on rubygems shortly.