huboard / ghee

This is an unofficial ruby client for the Github API. The end goal is a complete, simple, and intuitive ruby API for all things Github.
http://documentup.com/huboard/ghee
MIT License
160 stars 51 forks source link

Pagination #3

Closed rauhryan closed 12 years ago

rauhryan commented 12 years ago

Here is an early example of pagination support

im thinking that we hang #paginate off of the resource_proxy

examples:

gh.user.repos.paginate :page => 1, :per_page => 100 #=> [] of repos

that way we can hang paging information off of the proxy as well

gh.user.repos.paginate(:page => 1).current_page #=> 1
gh.user.repos.paginate(:page => 1).next_page #=> 2
gh.user.repos.paginate(:page => 1).last_page #=> 5
gh.user.repos.paginate(:page => 1).total #=> 122

Next phase we have an #all method that will loop through all the pages and give you return all the pages in one array

gh.user.repos.all.size() #=> 122

Opening up this pull request for some feedback while I work on it. Definitely not ready to pull in yet

rauhryan commented 12 years ago

Added support for filter params

gh.user.repos(:type => "public") #=> http://api.github.com/user/repos?type=public

Can also be chained with pagination

gh.user.repos(:type => "public").paginate(:page => 2) 
    #=>  http://api.github.com/user/repos?type=public&page=2
jonmagic commented 12 years ago

I'm at our company summit right now, sorry its taking me so long to respond. Probably won't be able to really sit down and look at stuff until the weekend. Talk to ya soon!

rauhryan commented 12 years ago

So... What do you think?

I'm actually pretty happy with this method. The only thing left is to make a pass through the library and finish up the missing pieces of the api and we could 1.0 this thing.

jonmagic commented 12 years ago

You are killing it Ryan, great work. I haven't had much time lately to work on it and you've been totally rockin, so feel free to stick your name all over the README if you want more credit (I think your name is just at the bottom right now)...

Thanks for giving me the opportunity to review your code and stuff, I haven't really done that before so this is helping me learn as well. I think your ruby chops are a lot better than mine in most cases so maybe I'm not the best person to review stuff but it is definitely helping me learn along the way.

If you ever have the desire to take the project over don't hesitate to ask, you've got way more work than I do into it at this point. But if you'd prefer to keep my repo as the main one thats cool too, I'm really enjoying helping.

jonmagic commented 12 years ago

I made a few comments on the diff, the only one that I'd like to talk about more before merging is not supporting ruby 1.8... Monday or Tuesday I'll take a closer look at that part and see what our options are before merging this PR.

rauhryan commented 12 years ago

BTW! isnt github freaking incredible.... I love the pull request feature and how I'm able to document thought process and progress while we work on this feature.

jonmagic commented 12 years ago

So all looks good except for making it 1.8 compatible and updating a few docs (including the readme). Once those are complete lets merge. I don't think we're quite at 1.0 yet because we're not API complete yet are we? I think we still have the following to implement:

I guess we could go to 1.0 before implementing everything, but my inclination would be not to. Thoughts?

rauhryan commented 12 years ago

I agree, we should be as api complete as possible before 1.0

Since you work at github now, could you try and find out if we can send the V2 API token from here https://github.com/account/admin as the password in basic authentication

That would be baller for writing command line apps using the v3 api, I am really concerned about storing my password in plain text on my machine

jonmagic commented 12 years ago

So after asking around it sounds like the API token available on that page will be going away. But hope is not lost, check this out: https://github.com/blog/977-access-your-event-timelines-and-oauth-tokens-through-the-api

We should work that into the gem so an CLI apps written that use ghee will automatically prompt for user/pass first. We'll be limited to repo specific tasks though if I understand that post right.

rauhryan commented 12 years ago

Yes this is perfect

I can use highline to get user/pass and stuff it into the git config :)

I'd like to have a cli for release

ghee issues -o "Hellz yeah open an issue"

I want to be able to grep through issues

ghee issues | grep "Bug: "
jonmagic commented 12 years ago

I love it, but I'd be tempted to pull this type of stuff out into a separate gem that just uses Ghee. I love keep libraries small and focused.

On that note, with your example we'll have to have the CLI look at where its executed for a .git folder, then we can read the .git/config and get the repo name from it so you don't have to specify the repo on the command line.

This is gonna be awesome :) How do you feel about putting it into a separate gem?

jonmagic commented 12 years ago

Also https://github.com/defunkt/github-gem does some of this stuff already. Worth taking a look at.

rauhryan commented 12 years ago

I'm going to push this into master. I'm going to force push on top of the little changes I made to the readme

This might give you fits when you pull that latest code

I'm going to bump the version to something like "0.7.0" because I would say its about 70% api complete. There's some outliers and I don't really need right now and I'm hoping someone else might contibute considering the groundwork is laid its mostly filling the gaps now

Also would you consider switching the main fork over to rauhryan/ghee?

Can I also get some help publishing the new gem?

Thanks!

Ryan

jonmagic commented 12 years ago

Do you have time to screenshare tomorrow or this weekend? We could get everything transferred over quickly if we just screenshare for a few minutes I'm thinking. I'll email you directly with my gchat/aim credentials.

On Wednesday, February 8, 2012 at 6:17 PM, Ryan Rauh wrote:

I'm going to push this into master. I'm going to force push on top of the little changes I made to the readme

This might give you fits when you pull that latest code

I'm going to bump the version to something like "0.7.0" because I would say its about 70% api complete. There's some outliers and I don't really need right now and I'm hoping someone else might contibute considering the groundwork is laid its mostly filling the gaps now

Also would you consider switching the main fork over to rauhryan/ghee?

Can I also get some help publishing the new gem?

Thanks!

Ryan


Reply to this email directly or view it on GitHub: https://github.com/jonmagic/ghee/pull/3#issuecomment-3878587

rauhryan commented 12 years ago

I should be able to screenshare sometime. My email is [my last name] dot [my first name] at [gmail] dot com so add me to gchat if you like