contribution-checker 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/contribution-checker.gemspec +1 -2
- data/lib/contribution-checker.rb +1 -0
- data/lib/contribution-checker/checker.rb +22 -6
- data/lib/contribution-checker/error.rb +10 -0
- data/lib/contribution-checker/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 861b8fcdc7200e4a0c0f2ac9a177a7cb5299e41d
|
4
|
+
data.tar.gz: 95cf9de9a6eb0f53e0060fa4740917d193349c96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92c9763dac3837ac574e7df2c3f9c3075d04f2934c437401f84dfe53c63c8ef597241d1ca47f0a5735e370df9a1bd5659ff82986fcdb892e9ef59b32b37814b0
|
7
|
+
data.tar.gz: 3115ca43d29d6a7b5ceb05db9c738a510a5529608df448d10858c9ad0c5c5df32135ef59a1c19be735950931d6f43cf7a385fb035c9bc6fb36415bf12eada2a6
|
data/README.md
CHANGED
@@ -5,14 +5,15 @@ People :heart: GitHub Contributions. However, it's not always simple to tell why
|
|
5
5
|
## Usage
|
6
6
|
|
7
7
|
```ruby
|
8
|
+
require "contribution-checker"
|
9
|
+
|
8
10
|
checker = ContributionChecker::Checker.new \
|
9
11
|
:access_token => "<Your 40 char GitHub API token>",
|
10
12
|
:commit_url => "https://github.com/user/repo/commit/sha"
|
11
|
-
)
|
12
13
|
|
13
14
|
checker.check
|
14
15
|
=> {
|
15
|
-
:
|
16
|
+
:contribution => true,
|
16
17
|
:and_criteria => {
|
17
18
|
:commit_in_valid_branch => true,
|
18
19
|
:commit_in_last_year => true,
|
@@ -9,8 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["James Dennes"]
|
10
10
|
spec.email = ["jdennes@gmail.com"]
|
11
11
|
spec.summary = %q{Check whether a commit is counted as a contribution.}
|
12
|
-
spec.description = %q{Check whether a GitHub commit is counted as a
|
13
|
-
contribution for a specific GitHub user.}
|
12
|
+
spec.description = %q{Check whether a GitHub commit is counted as a contribution for a specific GitHub user.}
|
14
13
|
spec.homepage = ""
|
15
14
|
spec.license = "MIT"
|
16
15
|
|
data/lib/contribution-checker.rb
CHANGED
@@ -31,7 +31,7 @@ module ContributionChecker
|
|
31
31
|
#
|
32
32
|
# @return [Hash] The return value takes the following form:
|
33
33
|
# {
|
34
|
-
# :
|
34
|
+
# :contribution => true,
|
35
35
|
# :and_criteria => {
|
36
36
|
# :commit_in_valid_branch => true,
|
37
37
|
# :commit_in_last_year => true,
|
@@ -46,12 +46,14 @@ module ContributionChecker
|
|
46
46
|
# }
|
47
47
|
# }
|
48
48
|
def check
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
@nwo, @sha = parse_commit_url @commit_url
|
50
|
+
begin
|
51
|
+
@commit = @client.commit @nwo, @sha
|
52
|
+
rescue Octokit::NotFound
|
53
|
+
raise ContributionChecker::InvalidCommitUrlError
|
54
|
+
end
|
53
55
|
@repo = @client.repository @nwo
|
54
|
-
@
|
56
|
+
@user = @client.user
|
55
57
|
|
56
58
|
@commit_in_valid_branch = commit_in_valid_branch?
|
57
59
|
@commit_in_last_year = commit_in_last_year?
|
@@ -79,6 +81,20 @@ module ContributionChecker
|
|
79
81
|
}
|
80
82
|
end
|
81
83
|
|
84
|
+
# Parses the commit URL provided.
|
85
|
+
#
|
86
|
+
# @return [Array] URL parts: nwo, sha
|
87
|
+
def parse_commit_url(url)
|
88
|
+
begin
|
89
|
+
parts = URI.parse(@commit_url).path.split("/")
|
90
|
+
nwo = "#{parts[1]}/#{parts[2]}"
|
91
|
+
sha = parts[4]
|
92
|
+
return nwo, sha
|
93
|
+
rescue
|
94
|
+
raise ContributionChecker::InvalidCommitUrlError
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
82
98
|
# Checks whether the commit is in a valid branch. A valid branch is defined
|
83
99
|
# as either the default branch of the repository, or the gh-pages branch.
|
84
100
|
#
|
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.
|
4
|
+
version: 0.0.2
|
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-
|
11
|
+
date: 2014-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -52,9 +52,8 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
56
|
-
|
57
|
-
contribution for a specific GitHub user.
|
55
|
+
description: Check whether a GitHub commit is counted as a contribution for a specific
|
56
|
+
GitHub user.
|
58
57
|
email:
|
59
58
|
- jdennes@gmail.com
|
60
59
|
executables: []
|
@@ -69,6 +68,7 @@ files:
|
|
69
68
|
- contribution-checker.gemspec
|
70
69
|
- lib/contribution-checker.rb
|
71
70
|
- lib/contribution-checker/checker.rb
|
71
|
+
- lib/contribution-checker/error.rb
|
72
72
|
- lib/contribution-checker/version.rb
|
73
73
|
homepage: ''
|
74
74
|
licenses:
|