Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/banyan/gh_contrib
https://github.com/banyan/gh_contrib
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/banyan/gh_contrib
- Owner: banyan
- License: mit
- Created: 2014-10-27T18:14:13.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-15T06:48:57.000Z (almost 9 years ago)
- Last Synced: 2024-12-21T00:23:16.388Z (about 2 months ago)
- Language: Ruby
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# gh_contrib
GitHub has a nice feature of [contributions](https://help.github.com/articles/viewing-contributions-on-your-profile-page/).
But unfortunately they don't offer an official API.
Now somehow we can get only from here (`https://github.com/users//contributions`). It returns HTML :cry:.
This is just parsing HTML to JSON or returns as Ruby's object.## Usage
### CLI
```zsh
$ gem install gh_contrib$ gh_contrib username
$ echo 'GITHUB_USERNAME=username
$ GITHUB_PASSWORD=password' > .env# or you can define on shell
# export GITHUB_USERNAME=username
# export GITHUB_PASSWORD=password$ gh_contrib username
$ gh_contrib username -d month
```### API
```ruby
require 'gh_contrib'agent = GhContrib::Agent.new
puts agent.contributions 'username'agent.login 'username', 'password'
puts agent.contributions 'username'
puts agent.contributions_by_month 'username'
```## Tips
* Sum all the contributions with [jq](http://stedolan.github.io/jq/).
```zsh
$ gh_contrib banyan | jq 'reduce .[].count as $item (0; . + $item)'
4698
```## Limitations
* You can't enable two factor authentication for this user if you want to get the data as logged in :cry:.
## Caveat
* Since it's not an official API, it might be broken anytime :dizzy_face:.