github_contributions_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a1380017f03381e51c2b16db583cab90befe49ec
4
+ data.tar.gz: 4b277d21d9b671ee8b39cb36db876b47c17fb0e2
5
+ SHA512:
6
+ metadata.gz: 7e1f352d1c638fa4fd877de82d89b7a41d4f5b5209066f5443c8603be610482fac02a208902c3fd9e07bd3d146ab7291aa9bc1038b91675e560f0cbd7c515619
7
+ data.tar.gz: 9f86c1dfa3bc87fc07519604cf9d2d4a4e1e3aa20fcc24680455d7f0596ba0ff086ced922648ea7bf1022b78f5441d96bf2a192bb2081f36d8a2cdd2a330895e
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1 @@
1
+ --markup-provider=redcarpet --markup=markdown
@@ -0,0 +1,6 @@
1
+ # Credits, Notes, and Reference
2
+
3
+ + https://githubcontributions.io/
4
+ + https://github.com/tenex/github-contributions
5
+ + https://jsonformatter.curiousconcept.com/
6
+ + http://data-creative.info/process-documentation/2015/07/03/how-to-make-a-ruby-gem.html
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in github_contributions_api.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 MJ Rossetti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,108 @@
1
+ # GitHub Contributions API - Ruby
2
+
3
+ A ruby interface to the [GitHub Contributions Archive](https://githubcontributions.io) API. Get information about GitHub users and events, including all repositories a user has contributed to. No authentication required.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile before running `bundle install`:
8
+
9
+ ```ruby
10
+ gem 'github_contributions_api'
11
+ ```
12
+
13
+ Or install it yourself as:
14
+
15
+ $ gem install github_contributions_api
16
+
17
+ ## Usage
18
+
19
+ ### GitHub User
20
+
21
+ Get GitHub user information, including all repositories contributed to.
22
+
23
+ ```` sh
24
+ user = GithubContributionsApi.user("octocat")
25
+
26
+ #=> {
27
+ # "username":"octocat",
28
+ # "repos":[
29
+ # "OpenELEC/OpenELEC.tv",
30
+ # "octocat/Hello-World",
31
+ # "octocat/Spoon-Knife",
32
+ # "octocat/ThisIsATest",
33
+ # "octocat/git-alliance",
34
+ # "octocat/git-consortium",
35
+ # "octocat/octocat.github.io"
36
+ # ],
37
+ # "eventCount":28
38
+ #}
39
+ ````
40
+
41
+ ### GitHub Events
42
+
43
+ Get events information for a given GitHub user. By default, this returns the first page of available results.
44
+
45
+ ```` sh
46
+ events = GithubContributionsApi.user_events("octocat")
47
+
48
+ #=> {
49
+ # "events":[
50
+ # {
51
+ # "_event_id":"3342744700",
52
+ # "_id":"564c28d972c4347a4234f081",
53
+ # "_repo_lower":"octocat/octocat.github.io",
54
+ # "_user_lower":"octocat",
55
+ # "before":"e2daa5755ee24217f39a10dc6b94988c19e0f109",
56
+ # "commit_count":1,
57
+ # "created_at":"2015-11-14T22:22:37+00:00",
58
+ # "distinct_commit_count":1,
59
+ # "head":"3a9796cf19902af0f7e677391b340f1ae4128433",
60
+ # "ref":"refs/heads/master",
61
+ # "repo":"octocat/octocat.github.io",
62
+ # "type":"PushEvent",
63
+ # "user":"octocat"
64
+ # },
65
+ # ...
66
+ # {
67
+ # "_id":"564de6ba72c4347a42a05b05",
68
+ # "_org_lower":"",
69
+ # "_repo_lower":"octocat/thisisatest",
70
+ # "_user_lower":"octocat",
71
+ # "created_at":"2012-03-12T21:14:01+00:00",
72
+ # "org":"",
73
+ # "repo":"octocat/ThisIsATest",
74
+ # "type":"PublicEvent",
75
+ # "user":"octocat"
76
+ # }
77
+ # ],
78
+ # "start":0,
79
+ # "end":28,
80
+ # "currentPage":1,
81
+ # "size":28
82
+ #}
83
+ ````
84
+
85
+ Optionally traverse pagination for users who have more than one page of events.
86
+
87
+ ```` sh
88
+ events = GithubContributionsApi.user_events("s2t2", :page => 2)
89
+ ````
90
+
91
+ ## Development
92
+
93
+ ```` sh
94
+ git clone git@github.com:data-creative/github-contributions-api-ruby.git
95
+ cd github-contributions-api-ruby.git/
96
+ ````
97
+
98
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
99
+
100
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
101
+
102
+ ## Contributing
103
+
104
+ Bug reports and pull requests are welcome on GitHub at https://github.com/data-creative/github-contributions-api-ruby.
105
+
106
+ ## License
107
+
108
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "github_contributions_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "pry"
14
+ Pry.start
15
+
16
+ # require "irb"
17
+ # IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'github_contributions_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "github_contributions_api"
8
+ spec.version = GithubContributionsApi::VERSION
9
+ spec.authors = ["MJ Rossetti"]
10
+ spec.email = ["datacreativellc@gmail.com"]
11
+
12
+ spec.summary = %q{A ruby interface to the GitHub Contributions Archive API (https://githubcontributions.io). Get information about GitHub users and events, including all repositories a user has contributed to. No authentication required.}
13
+ spec.description = %q{A ruby interface to the GitHub Contributions Archive API (https://githubcontributions.io). Get information about GitHub users and events, including all repositories a user has contributed to. No authentication required.}
14
+ spec.homepage = "https://github.com/data-creative/github-contributions-api-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "pry", "~> 0.10"
26
+ spec.add_development_dependency "yard"
27
+ spec.add_development_dependency "redcarpet"
28
+ spec.add_development_dependency "github-markup"
29
+ spec.add_dependency "httparty", "~> 0.13"
30
+ end
@@ -0,0 +1,34 @@
1
+ require "github_contributions_api/version"
2
+ require 'json'
3
+ require "httparty"
4
+
5
+ # A ruby interface to the GitHub Contributions Archive API (https://githubcontributions.io). To the author's knowlege, this API is undocumented.
6
+ module GithubContributionsApi
7
+ # The prexix for all GitHub Contributions API endpoints.
8
+ URL_BASE = "https://githubcontributions.io/api"
9
+
10
+ # Get information about a given github user.
11
+ # @param [String] github_username The username of the github user.
12
+ # @example GithubContributionsApi.user("octocat")
13
+ # @return [Hash]
14
+ def self.user(github_username)
15
+ request_url = "#{URL_BASE}/user/#{github_username}"
16
+ response = HTTParty.get(request_url)
17
+ JSON.parse(response.body)
18
+ end
19
+
20
+ # Get events for a given github user.
21
+ # @param [String] github_username The username of the github user.
22
+ # @param [Hash] options
23
+ # @option options [Integer] :page (1) The requested page number.
24
+ # @example GithubContributionsApi.user_events("octocat")
25
+ # @example GithubContributionsApi.user_events("octocat", :page => 1)
26
+ # @example GithubContributionsApi.user_events("s2t2", :page => 2)
27
+ # @return [Hash]
28
+ def self.user_events(github_username, options = {})
29
+ page_number = options[:page] || 1
30
+ request_url = "#{URL_BASE}/user/#{github_username}/events/#{page_number}"
31
+ response = HTTParty.get(request_url)
32
+ JSON.parse(response.body)
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ module GithubContributionsApi
2
+ # The current version of this library. Follows semantic versioning (http://semver.org/).
3
+ VERSION = "1.0.0"
4
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_contributions_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - MJ Rossetti
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: redcarpet
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: github-markup
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: httparty
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.13'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.13'
125
+ description: A ruby interface to the GitHub Contributions Archive API (https://githubcontributions.io).
126
+ Get information about GitHub users and events, including all repositories a user
127
+ has contributed to. No authentication required.
128
+ email:
129
+ - datacreativellc@gmail.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".travis.yml"
137
+ - ".yardopts"
138
+ - CREDITS.md
139
+ - Gemfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/console
144
+ - bin/setup
145
+ - github_contributions_api.gemspec
146
+ - lib/github_contributions_api.rb
147
+ - lib/github_contributions_api/version.rb
148
+ homepage: https://github.com/data-creative/github-contributions-api-ruby
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.4.5
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: A ruby interface to the GitHub Contributions Archive API (https://githubcontributions.io).
172
+ Get information about GitHub users and events, including all repositories a user
173
+ has contributed to. No authentication required.
174
+ test_files: []
175
+ has_rdoc: