Skip to content

Instantly share code, notes, and snippets.

@SteveBenner
Created March 15, 2015 09:46
Show Gist options
  • Save SteveBenner/11808b089d97ccfd2c93 to your computer and use it in GitHub Desktop.
Save SteveBenner/11808b089d97ccfd2c93 to your computer and use it in GitHub Desktop.

Revisions

  1. SteveBenner created this gist Mar 15, 2015.
    19 changes: 19 additions & 0 deletions gh-starred.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    # The 'github_api' gem is implicility assumed to have been loaded at this point...

    # Configuration data is passed to Github::Client#new as a Hash whose keys are Symbols
    CONFIG_DATA = {
    user: 'github-username',
    login: '[email protected]',
    oauth_token: 'personal-access-token' # one of many valid authentication methods (see the gem docs for more)
    }

    # Data is returned from the API as a Github::ResponseWrapper object
    starred = Github.new(CONFIG_DATA).activity.starring.starred

    File.open('path-to-output-dir/starred.md', 'w') do |f|
    # By default, entries are dispensed 30-per-call. Thanks to helpers provided in Github::Paginate, the entire
    # result set can be collated into a single Array; just call 'auto_paginate' with 'true' as parameter.
    starred.auto_paginate(true).each do |r|
    f.puts "- [#{r['full_name']}](#{r['html_url']})" # Markdown links are easy to generate
    end
    end