Skip to content

Instantly share code, notes, and snippets.

@directionless
Created December 23, 2014 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save directionless/9ba70fed57685bcadbcb to your computer and use it in GitHub Desktop.
Save directionless/9ba70fed57685bcadbcb to your computer and use it in GitHub Desktop.
Octocat pagination
# WTF Octocat. This should be cleaner.
members = client.org_members(ORGNAME)
next_url = client.last_response.rels[:next]
while ! next_url.nil? do
page = next_url.href.gsub(/.*page=(\d+)/,'\1')
puts "Fetching page #{page}"
members.concat client.org_members(ORGNAME, :page => page)
next_url = client.last_response.rels[:next]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment