Skip to content

Conversation

kapadia
Copy link
Contributor

@kapadia kapadia commented Jun 23, 2015

Addressing pagination of gists when listing #201. Apologies if my use of optparse isn't the best.

/cc @ConradIrwin

@ConradIrwin
Copy link
Collaborator

@kapadia Thanks for this!

I'd prefer this not to be an option, instead we should just automatically paginate and show all results in the list.

That should be pretty easy to implement, but it'll be fun to test it in the case where you do: gist -l | head -n 10, as it'd be nice to exit gracefully in that case (instead of throwing an exception).

@kapadia
Copy link
Contributor Author

kapadia commented Jun 23, 2015

@ConradIrwin I changed it up a bit so that pagination automatically happens. It would be nice to send out concurrent requests, but I don't know the Ruby way to do that. You'll find a new method, list_all_gists, which you may choose to replace to list_gists if you like.

Just to note, I've been wanting a facility to quickly skim through all my gists (public and private), without the need to hit up gist.github.com in the browser. I have many large GeoJSON gists, which severely slows down the page renders while navigating the site. This PR is a nice convenience.

lib/gist.rb Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kapadia I think you should use the rel="next" link header rather than constructing the URLs yourself: https://developer.github.com/v3/#pagination

@ConradIrwin
Copy link
Collaborator

Looks great otherwise, thanks!

lib/gist.rb Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kapadia Can revert this change now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, reverted.

@kapadia
Copy link
Contributor Author

kapadia commented Jun 24, 2015

@ConradIrwin How's this looking? One reason I was keen to construct the urls was in hopes of sending concurrent requests to all pages (though I don't know the Ruby way to do this). Anyway, we're now using the link header to cycle through all pages, and it works.

@ConradIrwin ConradIrwin merged commit 72d1b13 into defunkt:master Jun 24, 2015
@ConradIrwin
Copy link
Collaborator

This looks great! Thanks for being responsive to feedback :).

I've merged and released it as gist v4.4.0.

@kapadia
Copy link
Contributor Author

kapadia commented Jun 25, 2015

Np. Thanks for the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants