contribution-checker 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 861b8fcdc7200e4a0c0f2ac9a177a7cb5299e41d
4
- data.tar.gz: 95cf9de9a6eb0f53e0060fa4740917d193349c96
3
+ metadata.gz: 241c4ee2503dc6c454248088914459b8e6c0d306
4
+ data.tar.gz: e7a88db8ca3da98b428460e47b129b5d22148ecb
5
5
  SHA512:
6
- metadata.gz: 92c9763dac3837ac574e7df2c3f9c3075d04f2934c437401f84dfe53c63c8ef597241d1ca47f0a5735e370df9a1bd5659ff82986fcdb892e9ef59b32b37814b0
7
- data.tar.gz: 3115ca43d29d6a7b5ceb05db9c738a510a5529608df448d10858c9ad0c5c5df32135ef59a1c19be735950931d6f43cf7a385fb035c9bc6fb36415bf12eada2a6
6
+ metadata.gz: 1d7c6fa55868b8f9fc153534d801156ac4b57554ff819f2c84a61479d3c78ee9d974b2b41a8853165972b2f6d904d80598fefbc21ad361bf7fed03ebfddbd05b
7
+ data.tar.gz: f45f611e4d0823cbd1a5fe06541c7c34c5c0aa402af4e6ec20612a92d01f06523ad395bfe7b77cd1da2d23a0e3efcf85466495a863f27f771c7f0d3c85fbc682
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ require "rspec/core/rake_task"
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :test => :spec
7
+ task :default => :spec
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'contribution-checker/version'
4
+ require "contribution-checker/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "contribution-checker"
@@ -22,4 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.6"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "webmock"
27
+
25
28
  end
@@ -51,6 +51,8 @@ module ContributionChecker
51
51
  @commit = @client.commit @nwo, @sha
52
52
  rescue Octokit::NotFound
53
53
  raise ContributionChecker::InvalidCommitUrlError
54
+ rescue Octokit::Unauthorized
55
+ raise ContributionChecker::InvalidAccessTokenError
54
56
  end
55
57
  @repo = @client.repository @nwo
56
58
  @user = @client.user
@@ -81,6 +83,8 @@ module ContributionChecker
81
83
  }
82
84
  end
83
85
 
86
+ private
87
+
84
88
  # Parses the commit URL provided.
85
89
  #
86
90
  # @return [Array] URL parts: nwo, sha
@@ -111,8 +115,8 @@ module ContributionChecker
111
115
 
112
116
  # The compare status should be "identical" or "behind" if the commit is in
113
117
  # the default branch
114
- unless default_compare &&
115
- %w(identical behind).include?(default_compare[:status])
118
+ if default_compare.nil? ||
119
+ !(%w(identical behind).include?(default_compare[:status]))
116
120
 
117
121
  # If the commit is not in the default branch, check the gh-pages branch
118
122
  begin
@@ -167,7 +171,7 @@ module ContributionChecker
167
171
  #
168
172
  # @return [Boolean]
169
173
  def user_is_repo_org_member?
170
- false if @repo[:owner] != "Organization"
174
+ return false if @repo[:owner] != "Organization"
171
175
  @client.organization_member? @repo[:owner][:login], @user[:login]
172
176
  end
173
177
 
@@ -185,8 +189,31 @@ module ContributionChecker
185
189
  # @return [Boolean]
186
190
  def user_has_fork_of_repo?
187
191
  # The API doesn't provide a simple means of checking whether a user has
188
- # forked a repository. Here we need to get the user's forks and check the
189
- # `parent` field of each fork to see whether it matches @repo.
192
+ # forked a repository.
193
+
194
+ # First, if there are no forks for the repository, return false.
195
+ return false if @repo[:forks_count] == 0
196
+
197
+ # Then check whether it's worth getting the list of forks
198
+ if @repo[:forks_count] <= 100
199
+ repo_forks = @client.forks @repo[:full_name], :per_page => 100
200
+ repo_forks.each do |f|
201
+ return true if f[:owner][:login] == @user[:login]
202
+ end
203
+ end
204
+
205
+ # Then try to directly find a repository with the same name as the
206
+ # repository in which the commit exists.
207
+ potential_fork_nwo = "#{@user[:login]}/#{@repo[:name]}"
208
+ begin
209
+ potential_fork = @client.repository potential_fork_nwo
210
+ return true if potential_fork[:parent][:full_name] == @repo[:full_name]
211
+ rescue Octokit::NotFound
212
+ # Keep going...
213
+ end
214
+
215
+ # Otherwise, get the user's forks and check the `parent` field of each
216
+ # fork to see whether it matches @repo.
190
217
  @client.auto_paginate = true
191
218
  @user_repos = @client.repos
192
219
  @user_forks = @user_repos.select { |r| r[:fork] }
@@ -7,4 +7,11 @@ module ContributionChecker
7
7
  end
8
8
  end
9
9
 
10
+ # Error class to help us rescue from invalid access token input.
11
+ class InvalidAccessTokenError < StandardError
12
+ def initialize
13
+ super "Invalid access token provided"
14
+ end
15
+ end
16
+
10
17
  end
@@ -1,3 +1,3 @@
1
1
  module ContributionChecker
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,91 @@
1
+ require "helper"
2
+
3
+ describe ContributionChecker::Checker do
4
+
5
+ describe "#check" do
6
+
7
+ context "when an invalid URL is provided as a commit URL" do
8
+ let(:checker) { checker = ContributionChecker::Checker.new \
9
+ :access_token => "your token",
10
+ :commit_url => "not a url"
11
+ }
12
+
13
+ it "raises an error" do
14
+ expect { checker.check }.to raise_error ContributionChecker::InvalidCommitUrlError
15
+ end
16
+ end
17
+
18
+ context "when a valid URL is provided which isn't a commit URL" do
19
+ let(:checker) { checker = ContributionChecker::Checker.new \
20
+ :access_token => "your token",
21
+ :commit_url => "https://example.com/"
22
+ }
23
+
24
+ before do
25
+ stub_request(:get, "https://api.github.com/repos/commits/").to_return(
26
+ :status => 404, :body => "")
27
+ end
28
+
29
+ it "raises an error" do
30
+ expect { checker.check }.to raise_error ContributionChecker::InvalidCommitUrlError
31
+ end
32
+ end
33
+
34
+ context "when an invalid access token is provided" do
35
+ let(:checker) { checker = ContributionChecker::Checker.new \
36
+ :access_token => "invalid access token",
37
+ :commit_url => "https://github.com/git/git-scm.com/commit/f6b5cb6"
38
+ }
39
+
40
+ before do
41
+ stub_request(:get, "https://api.github.com/repos/git/git-scm.com/commits/f6b5cb6").to_return(
42
+ :status => 401, :body => "")
43
+ end
44
+
45
+ it "raises an error" do
46
+ expect { checker.check }.to raise_error ContributionChecker::InvalidAccessTokenError
47
+ end
48
+ end
49
+
50
+ context "when a commit is successfully checked" do
51
+ let(:checker) { checker = ContributionChecker::Checker.new \
52
+ :access_token => "token",
53
+ :commit_url => "https://github.com/jdennes/contribution-checker/commit/731e83d4abf1bd67ac6ab68d18387693482e47cf"
54
+ }
55
+
56
+ before do
57
+ stub_get("/repos/jdennes/contribution-checker/commits/731e83d4abf1bd67ac6ab68d18387693482e47cf").
58
+ to_return(json_response("commit.json"))
59
+ stub_get("/repos/jdennes/contribution-checker").
60
+ to_return(json_response("repo.json"))
61
+ stub_get("/user").
62
+ to_return(json_response("user.json"))
63
+ stub_get("/repos/jdennes/contribution-checker/compare/master...731e83d4abf1bd67ac6ab68d18387693482e47cf").
64
+ to_return(json_response("default_compare.json"))
65
+ stub_get("/user/emails").
66
+ to_return(json_response("emails.json"))
67
+ stub_get("/user/starred/jdennes/contribution-checker").
68
+ to_return(:return => 404)
69
+ end
70
+
71
+ it "returns the check result" do
72
+ result = checker.check
73
+ expect(result).to be_a(Hash)
74
+
75
+ expect(result[:contribution]).to eq(true)
76
+
77
+ expect(result[:and_criteria][:commit_in_valid_branch]).to eq(true)
78
+ expect(result[:and_criteria][:commit_in_last_year]).to eq(true)
79
+ expect(result[:and_criteria][:repo_not_a_fork]).to eq(true)
80
+ expect(result[:and_criteria][:commit_email_linked_to_user]).to eq(true)
81
+
82
+ expect(result[:or_criteria][:user_has_starred_repo]).to eq(false)
83
+ expect(result[:or_criteria][:user_can_push_to_repo]).to eq(true)
84
+ expect(result[:or_criteria][:user_is_repo_org_member]).to eq(false)
85
+ expect(result[:or_criteria][:user_has_fork_of_repo]).to eq(false)
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ end
@@ -0,0 +1,89 @@
1
+ {
2
+ "sha": "731e83d4abf1bd67ac6ab68d18387693482e47cf",
3
+ "commit": {
4
+ "author": {
5
+ "name": "James Dennes",
6
+ "email": "example@example.com",
7
+ "date": "2014-06-08T10:25:34Z"
8
+ },
9
+ "committer": {
10
+ "name": "James Dennes",
11
+ "email": "example@example.com",
12
+ "date": "2014-06-08T10:25:34Z"
13
+ },
14
+ "message": "Version 0.0.2",
15
+ "tree": {
16
+ "sha": "30d937ac96b77183e8df7f319acc1e4387516981",
17
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/git/trees/30d937ac96b77183e8df7f319acc1e4387516981"
18
+ },
19
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/git/commits/731e83d4abf1bd67ac6ab68d18387693482e47cf",
20
+ "comment_count": 0
21
+ },
22
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/commits/731e83d4abf1bd67ac6ab68d18387693482e47cf",
23
+ "html_url": "https://github.com/jdennes/contribution-checker/commit/731e83d4abf1bd67ac6ab68d18387693482e47cf",
24
+ "comments_url": "https://api.github.com/repos/jdennes/contribution-checker/commits/731e83d4abf1bd67ac6ab68d18387693482e47cf/comments",
25
+ "author": {
26
+ "login": "jdennes",
27
+ "id": 65057,
28
+ "avatar_url": "https://avatars.githubusercontent.com/u/65057?",
29
+ "gravatar_id": "55fd031da91ef9af6e6ed88b101416a1",
30
+ "url": "https://api.github.com/users/jdennes",
31
+ "html_url": "https://github.com/jdennes",
32
+ "followers_url": "https://api.github.com/users/jdennes/followers",
33
+ "following_url": "https://api.github.com/users/jdennes/following{/other_user}",
34
+ "gists_url": "https://api.github.com/users/jdennes/gists{/gist_id}",
35
+ "starred_url": "https://api.github.com/users/jdennes/starred{/owner}{/repo}",
36
+ "subscriptions_url": "https://api.github.com/users/jdennes/subscriptions",
37
+ "organizations_url": "https://api.github.com/users/jdennes/orgs",
38
+ "repos_url": "https://api.github.com/users/jdennes/repos",
39
+ "events_url": "https://api.github.com/users/jdennes/events{/privacy}",
40
+ "received_events_url": "https://api.github.com/users/jdennes/received_events",
41
+ "type": "User",
42
+ "site_admin": true
43
+ },
44
+ "committer": {
45
+ "login": "jdennes",
46
+ "id": 65057,
47
+ "avatar_url": "https://avatars.githubusercontent.com/u/65057?",
48
+ "gravatar_id": "55fd031da91ef9af6e6ed88b101416a1",
49
+ "url": "https://api.github.com/users/jdennes",
50
+ "html_url": "https://github.com/jdennes",
51
+ "followers_url": "https://api.github.com/users/jdennes/followers",
52
+ "following_url": "https://api.github.com/users/jdennes/following{/other_user}",
53
+ "gists_url": "https://api.github.com/users/jdennes/gists{/gist_id}",
54
+ "starred_url": "https://api.github.com/users/jdennes/starred{/owner}{/repo}",
55
+ "subscriptions_url": "https://api.github.com/users/jdennes/subscriptions",
56
+ "organizations_url": "https://api.github.com/users/jdennes/orgs",
57
+ "repos_url": "https://api.github.com/users/jdennes/repos",
58
+ "events_url": "https://api.github.com/users/jdennes/events{/privacy}",
59
+ "received_events_url": "https://api.github.com/users/jdennes/received_events",
60
+ "type": "User",
61
+ "site_admin": true
62
+ },
63
+ "parents": [
64
+ {
65
+ "sha": "5514532ab61216d1d7d242fd624a2f215d225a31",
66
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/commits/5514532ab61216d1d7d242fd624a2f215d225a31",
67
+ "html_url": "https://github.com/jdennes/contribution-checker/commit/5514532ab61216d1d7d242fd624a2f215d225a31"
68
+ }
69
+ ],
70
+ "stats": {
71
+ "total": 2,
72
+ "additions": 1,
73
+ "deletions": 1
74
+ },
75
+ "files": [
76
+ {
77
+ "sha": "d8853e79dea5d3235cb470f4ea1de0ec2d17bcb5",
78
+ "filename": "lib/contribution-checker/version.rb",
79
+ "status": "modified",
80
+ "additions": 1,
81
+ "deletions": 1,
82
+ "changes": 2,
83
+ "blob_url": "https://github.com/jdennes/contribution-checker/blob/731e83d4abf1bd67ac6ab68d18387693482e47cf/lib/contribution-checker/version.rb",
84
+ "raw_url": "https://github.com/jdennes/contribution-checker/raw/731e83d4abf1bd67ac6ab68d18387693482e47cf/lib/contribution-checker/version.rb",
85
+ "contents_url": "https://api.github.com/repos/jdennes/contribution-checker/contents/lib/contribution-checker/version.rb?ref=731e83d4abf1bd67ac6ab68d18387693482e47cf",
86
+ "patch": "@@ -1,3 +1,3 @@\n module ContributionChecker\n- VERSION = \"0.0.1\"\n+ VERSION = \"0.0.2\"\n end"
87
+ }
88
+ ]
89
+ }
@@ -0,0 +1,157 @@
1
+ {
2
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/compare/master...731e83d4abf1bd67ac6ab68d18387693482e47cf",
3
+ "html_url": "https://github.com/jdennes/contribution-checker/compare/master...731e83d4abf1bd67ac6ab68d18387693482e47cf",
4
+ "permalink_url": "https://github.com/jdennes/contribution-checker/compare/jdennes:8007252...jdennes:731e83d",
5
+ "diff_url": "https://github.com/jdennes/contribution-checker/compare/master...731e83d4abf1bd67ac6ab68d18387693482e47cf.diff",
6
+ "patch_url": "https://github.com/jdennes/contribution-checker/compare/master...731e83d4abf1bd67ac6ab68d18387693482e47cf.patch",
7
+ "base_commit": {
8
+ "sha": "80072520cb4a9dc70dabbc61492d94c962abdc0b",
9
+ "commit": {
10
+ "author": {
11
+ "name": "James Dennes",
12
+ "email": "example@example.com",
13
+ "date": "2014-06-08T22:47:15Z"
14
+ },
15
+ "committer": {
16
+ "name": "James Dennes",
17
+ "email": "example@example.com",
18
+ "date": "2014-06-08T22:47:15Z"
19
+ },
20
+ "message": "Add ContributionChecker::InvalidAccessTokenError",
21
+ "tree": {
22
+ "sha": "bad7a5547a5b973d74492aba53adb1da02aecb9c",
23
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/git/trees/bad7a5547a5b973d74492aba53adb1da02aecb9c"
24
+ },
25
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/git/commits/80072520cb4a9dc70dabbc61492d94c962abdc0b",
26
+ "comment_count": 0
27
+ },
28
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/commits/80072520cb4a9dc70dabbc61492d94c962abdc0b",
29
+ "html_url": "https://github.com/jdennes/contribution-checker/commit/80072520cb4a9dc70dabbc61492d94c962abdc0b",
30
+ "comments_url": "https://api.github.com/repos/jdennes/contribution-checker/commits/80072520cb4a9dc70dabbc61492d94c962abdc0b/comments",
31
+ "author": {
32
+ "login": "jdennes",
33
+ "id": 65057,
34
+ "avatar_url": "https://avatars.githubusercontent.com/u/65057?",
35
+ "gravatar_id": "55fd031da91ef9af6e6ed88b101416a1",
36
+ "url": "https://api.github.com/users/jdennes",
37
+ "html_url": "https://github.com/jdennes",
38
+ "followers_url": "https://api.github.com/users/jdennes/followers",
39
+ "following_url": "https://api.github.com/users/jdennes/following{/other_user}",
40
+ "gists_url": "https://api.github.com/users/jdennes/gists{/gist_id}",
41
+ "starred_url": "https://api.github.com/users/jdennes/starred{/owner}{/repo}",
42
+ "subscriptions_url": "https://api.github.com/users/jdennes/subscriptions",
43
+ "organizations_url": "https://api.github.com/users/jdennes/orgs",
44
+ "repos_url": "https://api.github.com/users/jdennes/repos",
45
+ "events_url": "https://api.github.com/users/jdennes/events{/privacy}",
46
+ "received_events_url": "https://api.github.com/users/jdennes/received_events",
47
+ "type": "User",
48
+ "site_admin": true
49
+ },
50
+ "committer": {
51
+ "login": "jdennes",
52
+ "id": 65057,
53
+ "avatar_url": "https://avatars.githubusercontent.com/u/65057?",
54
+ "gravatar_id": "55fd031da91ef9af6e6ed88b101416a1",
55
+ "url": "https://api.github.com/users/jdennes",
56
+ "html_url": "https://github.com/jdennes",
57
+ "followers_url": "https://api.github.com/users/jdennes/followers",
58
+ "following_url": "https://api.github.com/users/jdennes/following{/other_user}",
59
+ "gists_url": "https://api.github.com/users/jdennes/gists{/gist_id}",
60
+ "starred_url": "https://api.github.com/users/jdennes/starred{/owner}{/repo}",
61
+ "subscriptions_url": "https://api.github.com/users/jdennes/subscriptions",
62
+ "organizations_url": "https://api.github.com/users/jdennes/orgs",
63
+ "repos_url": "https://api.github.com/users/jdennes/repos",
64
+ "events_url": "https://api.github.com/users/jdennes/events{/privacy}",
65
+ "received_events_url": "https://api.github.com/users/jdennes/received_events",
66
+ "type": "User",
67
+ "site_admin": true
68
+ },
69
+ "parents": [
70
+ {
71
+ "sha": "1a048d7745c5ea48eff015063f49369d6c7c3913",
72
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/commits/1a048d7745c5ea48eff015063f49369d6c7c3913",
73
+ "html_url": "https://github.com/jdennes/contribution-checker/commit/1a048d7745c5ea48eff015063f49369d6c7c3913"
74
+ }
75
+ ]
76
+ },
77
+ "merge_base_commit": {
78
+ "sha": "731e83d4abf1bd67ac6ab68d18387693482e47cf",
79
+ "commit": {
80
+ "author": {
81
+ "name": "James Dennes",
82
+ "email": "example@example.com",
83
+ "date": "2014-06-08T10:25:34Z"
84
+ },
85
+ "committer": {
86
+ "name": "James Dennes",
87
+ "email": "example@example.com",
88
+ "date": "2014-06-08T10:25:34Z"
89
+ },
90
+ "message": "Version 0.0.2",
91
+ "tree": {
92
+ "sha": "30d937ac96b77183e8df7f319acc1e4387516981",
93
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/git/trees/30d937ac96b77183e8df7f319acc1e4387516981"
94
+ },
95
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/git/commits/731e83d4abf1bd67ac6ab68d18387693482e47cf",
96
+ "comment_count": 0
97
+ },
98
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/commits/731e83d4abf1bd67ac6ab68d18387693482e47cf",
99
+ "html_url": "https://github.com/jdennes/contribution-checker/commit/731e83d4abf1bd67ac6ab68d18387693482e47cf",
100
+ "comments_url": "https://api.github.com/repos/jdennes/contribution-checker/commits/731e83d4abf1bd67ac6ab68d18387693482e47cf/comments",
101
+ "author": {
102
+ "login": "jdennes",
103
+ "id": 65057,
104
+ "avatar_url": "https://avatars.githubusercontent.com/u/65057?",
105
+ "gravatar_id": "55fd031da91ef9af6e6ed88b101416a1",
106
+ "url": "https://api.github.com/users/jdennes",
107
+ "html_url": "https://github.com/jdennes",
108
+ "followers_url": "https://api.github.com/users/jdennes/followers",
109
+ "following_url": "https://api.github.com/users/jdennes/following{/other_user}",
110
+ "gists_url": "https://api.github.com/users/jdennes/gists{/gist_id}",
111
+ "starred_url": "https://api.github.com/users/jdennes/starred{/owner}{/repo}",
112
+ "subscriptions_url": "https://api.github.com/users/jdennes/subscriptions",
113
+ "organizations_url": "https://api.github.com/users/jdennes/orgs",
114
+ "repos_url": "https://api.github.com/users/jdennes/repos",
115
+ "events_url": "https://api.github.com/users/jdennes/events{/privacy}",
116
+ "received_events_url": "https://api.github.com/users/jdennes/received_events",
117
+ "type": "User",
118
+ "site_admin": true
119
+ },
120
+ "committer": {
121
+ "login": "jdennes",
122
+ "id": 65057,
123
+ "avatar_url": "https://avatars.githubusercontent.com/u/65057?",
124
+ "gravatar_id": "55fd031da91ef9af6e6ed88b101416a1",
125
+ "url": "https://api.github.com/users/jdennes",
126
+ "html_url": "https://github.com/jdennes",
127
+ "followers_url": "https://api.github.com/users/jdennes/followers",
128
+ "following_url": "https://api.github.com/users/jdennes/following{/other_user}",
129
+ "gists_url": "https://api.github.com/users/jdennes/gists{/gist_id}",
130
+ "starred_url": "https://api.github.com/users/jdennes/starred{/owner}{/repo}",
131
+ "subscriptions_url": "https://api.github.com/users/jdennes/subscriptions",
132
+ "organizations_url": "https://api.github.com/users/jdennes/orgs",
133
+ "repos_url": "https://api.github.com/users/jdennes/repos",
134
+ "events_url": "https://api.github.com/users/jdennes/events{/privacy}",
135
+ "received_events_url": "https://api.github.com/users/jdennes/received_events",
136
+ "type": "User",
137
+ "site_admin": true
138
+ },
139
+ "parents": [
140
+ {
141
+ "sha": "5514532ab61216d1d7d242fd624a2f215d225a31",
142
+ "url": "https://api.github.com/repos/jdennes/contribution-checker/commits/5514532ab61216d1d7d242fd624a2f215d225a31",
143
+ "html_url": "https://github.com/jdennes/contribution-checker/commit/5514532ab61216d1d7d242fd624a2f215d225a31"
144
+ }
145
+ ]
146
+ },
147
+ "status": "behind",
148
+ "ahead_by": 0,
149
+ "behind_by": 10,
150
+ "total_commits": 0,
151
+ "commits": [
152
+
153
+ ],
154
+ "files": [
155
+
156
+ ]
157
+ }
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "email": "example@example.com",
4
+ "primary": false,
5
+ "verified": true
6
+ },
7
+ {
8
+ "email": "another@example.com",
9
+ "primary": true,
10
+ "verified": true
11
+ }
12
+ ]
@@ -0,0 +1,93 @@
1
+ {
2
+ "id": 20517235,
3
+ "name": "contribution-checker",
4
+ "full_name": "jdennes/contribution-checker",
5
+ "owner": {
6
+ "login": "jdennes",
7
+ "id": 65057,
8
+ "avatar_url": "https://avatars.githubusercontent.com/u/65057?",
9
+ "gravatar_id": "55fd031da91ef9af6e6ed88b101416a1",
10
+ "url": "https://api.github.com/users/jdennes",
11
+ "html_url": "https://github.com/jdennes",
12
+ "followers_url": "https://api.github.com/users/jdennes/followers",
13
+ "following_url": "https://api.github.com/users/jdennes/following{/other_user}",
14
+ "gists_url": "https://api.github.com/users/jdennes/gists{/gist_id}",
15
+ "starred_url": "https://api.github.com/users/jdennes/starred{/owner}{/repo}",
16
+ "subscriptions_url": "https://api.github.com/users/jdennes/subscriptions",
17
+ "organizations_url": "https://api.github.com/users/jdennes/orgs",
18
+ "repos_url": "https://api.github.com/users/jdennes/repos",
19
+ "events_url": "https://api.github.com/users/jdennes/events{/privacy}",
20
+ "received_events_url": "https://api.github.com/users/jdennes/received_events",
21
+ "type": "User",
22
+ "site_admin": false
23
+ },
24
+ "private": false,
25
+ "html_url": "https://github.com/jdennes/contribution-checker",
26
+ "description": "Check whether one of your GitHub commits qualifies as a contribution.",
27
+ "fork": false,
28
+ "url": "https://api.github.com/repos/jdennes/contribution-checker",
29
+ "forks_url": "https://api.github.com/repos/jdennes/contribution-checker/forks",
30
+ "keys_url": "https://api.github.com/repos/jdennes/contribution-checker/keys{/key_id}",
31
+ "collaborators_url": "https://api.github.com/repos/jdennes/contribution-checker/collaborators{/collaborator}",
32
+ "teams_url": "https://api.github.com/repos/jdennes/contribution-checker/teams",
33
+ "hooks_url": "https://api.github.com/repos/jdennes/contribution-checker/hooks",
34
+ "issue_events_url": "https://api.github.com/repos/jdennes/contribution-checker/issues/events{/number}",
35
+ "events_url": "https://api.github.com/repos/jdennes/contribution-checker/events",
36
+ "assignees_url": "https://api.github.com/repos/jdennes/contribution-checker/assignees{/user}",
37
+ "branches_url": "https://api.github.com/repos/jdennes/contribution-checker/branches{/branch}",
38
+ "tags_url": "https://api.github.com/repos/jdennes/contribution-checker/tags",
39
+ "blobs_url": "https://api.github.com/repos/jdennes/contribution-checker/git/blobs{/sha}",
40
+ "git_tags_url": "https://api.github.com/repos/jdennes/contribution-checker/git/tags{/sha}",
41
+ "git_refs_url": "https://api.github.com/repos/jdennes/contribution-checker/git/refs{/sha}",
42
+ "trees_url": "https://api.github.com/repos/jdennes/contribution-checker/git/trees{/sha}",
43
+ "statuses_url": "https://api.github.com/repos/jdennes/contribution-checker/statuses/{sha}",
44
+ "languages_url": "https://api.github.com/repos/jdennes/contribution-checker/languages",
45
+ "stargazers_url": "https://api.github.com/repos/jdennes/contribution-checker/stargazers",
46
+ "contributors_url": "https://api.github.com/repos/jdennes/contribution-checker/contributors",
47
+ "subscribers_url": "https://api.github.com/repos/jdennes/contribution-checker/subscribers",
48
+ "subscription_url": "https://api.github.com/repos/jdennes/contribution-checker/subscription",
49
+ "commits_url": "https://api.github.com/repos/jdennes/contribution-checker/commits{/sha}",
50
+ "git_commits_url": "https://api.github.com/repos/jdennes/contribution-checker/git/commits{/sha}",
51
+ "comments_url": "https://api.github.com/repos/jdennes/contribution-checker/comments{/number}",
52
+ "issue_comment_url": "https://api.github.com/repos/jdennes/contribution-checker/issues/comments/{number}",
53
+ "contents_url": "https://api.github.com/repos/jdennes/contribution-checker/contents/{+path}",
54
+ "compare_url": "https://api.github.com/repos/jdennes/contribution-checker/compare/{base}...{head}",
55
+ "merges_url": "https://api.github.com/repos/jdennes/contribution-checker/merges",
56
+ "archive_url": "https://api.github.com/repos/jdennes/contribution-checker/{archive_format}{/ref}",
57
+ "downloads_url": "https://api.github.com/repos/jdennes/contribution-checker/downloads",
58
+ "issues_url": "https://api.github.com/repos/jdennes/contribution-checker/issues{/number}",
59
+ "pulls_url": "https://api.github.com/repos/jdennes/contribution-checker/pulls{/number}",
60
+ "milestones_url": "https://api.github.com/repos/jdennes/contribution-checker/milestones{/number}",
61
+ "notifications_url": "https://api.github.com/repos/jdennes/contribution-checker/notifications{?since,all,participating}",
62
+ "labels_url": "https://api.github.com/repos/jdennes/contribution-checker/labels{/name}",
63
+ "releases_url": "https://api.github.com/repos/jdennes/contribution-checker/releases{/id}",
64
+ "created_at": "2014-06-05T08:16:43Z",
65
+ "updated_at": "2014-06-08T22:47:25Z",
66
+ "pushed_at": "2014-06-08T22:47:22Z",
67
+ "git_url": "git://github.com/jdennes/contribution-checker.git",
68
+ "ssh_url": "git@github.com:jdennes/contribution-checker.git",
69
+ "clone_url": "https://github.com/jdennes/contribution-checker.git",
70
+ "svn_url": "https://github.com/jdennes/contribution-checker",
71
+ "homepage": "",
72
+ "size": 0,
73
+ "stargazers_count": 0,
74
+ "watchers_count": 0,
75
+ "language": "Ruby",
76
+ "has_issues": true,
77
+ "has_downloads": true,
78
+ "has_wiki": false,
79
+ "forks_count": 0,
80
+ "mirror_url": null,
81
+ "open_issues_count": 0,
82
+ "forks": 0,
83
+ "open_issues": 0,
84
+ "watchers": 0,
85
+ "default_branch": "master",
86
+ "permissions": {
87
+ "admin": true,
88
+ "push": true,
89
+ "pull": true
90
+ },
91
+ "network_count": 0,
92
+ "subscribers_count": 2
93
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "login": "jdennes",
3
+ "id": 65057,
4
+ "avatar_url": "https://avatars.githubusercontent.com/u/12345?",
5
+ "gravatar_id": "whatever",
6
+ "url": "https://api.github.com/users/jdennes",
7
+ "html_url": "https://github.com/jdennes",
8
+ "followers_url": "https://api.github.com/users/jdennes/followers",
9
+ "following_url": "https://api.github.com/users/jdennes/following{/other_user}",
10
+ "gists_url": "https://api.github.com/users/jdennes/gists{/gist_id}",
11
+ "starred_url": "https://api.github.com/users/jdennes/starred{/owner}{/repo}",
12
+ "subscriptions_url": "https://api.github.com/users/jdennes/subscriptions",
13
+ "organizations_url": "https://api.github.com/users/jdennes/orgs",
14
+ "repos_url": "https://api.github.com/users/jdennes/repos",
15
+ "events_url": "https://api.github.com/users/jdennes/events{/privacy}",
16
+ "received_events_url": "https://api.github.com/users/jdennes/received_events",
17
+ "type": "User",
18
+ "site_admin": false,
19
+ "name": "James Dennes",
20
+ "company": "GitHub",
21
+ "blog": "http://jdenn.es",
22
+ "location": "Berlin, Germany",
23
+ "email": "",
24
+ "hireable": false,
25
+ "bio": "",
26
+ "public_repos": 5,
27
+ "public_gists": 5,
28
+ "followers": 5,
29
+ "following": 5,
30
+ "created_at": "2009-03-19T22:11:12Z",
31
+ "updated_at": "2014-06-08T23:11:57Z",
32
+ "private_gists": 5,
33
+ "total_private_repos": 5,
34
+ "owned_private_repos": 5,
35
+ "disk_usage": 100,
36
+ "collaborators": 0
37
+ }
data/spec/helper.rb ADDED
@@ -0,0 +1,30 @@
1
+ require "rspec"
2
+ require "webmock/rspec"
3
+ require "contribution-checker"
4
+
5
+ WebMock.disable_net_connect!
6
+
7
+ def github_url(url)
8
+ url =~ /^http/ ? url : "https://api.github.com#{url}"
9
+ end
10
+
11
+ def stub_get(url)
12
+ stub_request(:get, github_url(url))
13
+ end
14
+
15
+ def fixture_path
16
+ File.expand_path("../fixtures", __FILE__)
17
+ end
18
+
19
+ def fixture(file)
20
+ File.new(fixture_path + '/' + file)
21
+ end
22
+
23
+ def json_response(file)
24
+ {
25
+ :body => fixture(file),
26
+ :headers => {
27
+ :content_type => 'application/json; charset=utf-8'
28
+ }
29
+ }
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contribution-checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Dennes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-08 00:00:00.000000000 Z
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
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'
55
83
  description: Check whether a GitHub commit is counted as a contribution for a specific
56
84
  GitHub user.
57
85
  email:
@@ -70,6 +98,13 @@ files:
70
98
  - lib/contribution-checker/checker.rb
71
99
  - lib/contribution-checker/error.rb
72
100
  - lib/contribution-checker/version.rb
101
+ - spec/contribution-checker/checker_spec.rb
102
+ - spec/fixtures/commit.json
103
+ - spec/fixtures/default_compare.json
104
+ - spec/fixtures/emails.json
105
+ - spec/fixtures/repo.json
106
+ - spec/fixtures/user.json
107
+ - spec/helper.rb
73
108
  homepage: ''
74
109
  licenses:
75
110
  - MIT
@@ -94,4 +129,11 @@ rubygems_version: 2.0.3
94
129
  signing_key:
95
130
  specification_version: 4
96
131
  summary: Check whether a commit is counted as a contribution.
97
- test_files: []
132
+ test_files:
133
+ - spec/contribution-checker/checker_spec.rb
134
+ - spec/fixtures/commit.json
135
+ - spec/fixtures/default_compare.json
136
+ - spec/fixtures/emails.json
137
+ - spec/fixtures/repo.json
138
+ - spec/fixtures/user.json
139
+ - spec/helper.rb