metamatter 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +71 -0
- data/LICENSE +22 -0
- data/README.md +72 -0
- data/Rakefile +9 -0
- data/bin/metamatter +12 -0
- data/fixtures/vcr_cassettes/algorithmia.yml +34 -0
- data/fixtures/vcr_cassettes/authors.yml +162 -0
- data/fixtures/vcr_cassettes/license.yml +84 -0
- data/fixtures/vcr_cassettes/readme.yml +82 -0
- data/lib/metamatter.rb +91 -0
- data/lib/metamatter/authors.rb +28 -0
- data/lib/metamatter/classification.rb +18 -0
- data/lib/metamatter/helpers.rb +10 -0
- data/lib/metamatter/license.rb +32 -0
- data/lib/metamatter/readme.rb +37 -0
- data/lib/metamatter/version.rb +3 -0
- data/metamatter.gemspec +30 -0
- data/spec/metamatter_authors_spec.rb +12 -0
- data/spec/metamatter_classification_spec.rb +12 -0
- data/spec/metamatter_license_spec.rb +18 -0
- data/spec/metamatter_readme_spec.rb +25 -0
- data/spec/metamatter_spec.rb +34 -0
- data/spec/spec_helper.rb +11 -0
- data/specs/metamatter_spec.rb +12 -0
- metadata +205 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 38dd9ad2025840d9adefc4dd1dc5e69100dbc4d0
|
4
|
+
data.tar.gz: 66ebb14fbfb0ad15bbb48c64c7db7fe907b54985
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05fd112735daeba38c72f294573c52f67f5daf89c2b23df1edd3272853d40aeafb4a77c435a5a827d2e7028a4b4078349f623caebe77b17b75ecdf1108907347
|
7
|
+
data.tar.gz: df124e00cc1278752b3f56f71523e3ba1220bb5f575a665214b7fec5c4d0af047ddf685b3e1d50093551a26a55f4221407c39fb6e738c15b95177d6bcf2d1454
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
metamatter (0.0.2)
|
5
|
+
algorithmia (~> 0.2.0)
|
6
|
+
octokit (~> 4.0)
|
7
|
+
thor (~> 0.19)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.3.8)
|
13
|
+
algorithmia (0.2.0)
|
14
|
+
httparty (~> 0.13.1)
|
15
|
+
json (~> 1.8)
|
16
|
+
rake (~> 10.4)
|
17
|
+
coderay (1.1.0)
|
18
|
+
crack (0.4.2)
|
19
|
+
safe_yaml (~> 1.0.0)
|
20
|
+
diff-lcs (1.2.5)
|
21
|
+
faraday (0.9.1)
|
22
|
+
multipart-post (>= 1.2, < 3)
|
23
|
+
httparty (0.13.5)
|
24
|
+
json (~> 1.8)
|
25
|
+
multi_xml (>= 0.5.2)
|
26
|
+
json (1.8.3)
|
27
|
+
method_source (0.8.2)
|
28
|
+
multi_xml (0.5.5)
|
29
|
+
multipart-post (2.0.0)
|
30
|
+
octokit (4.0.1)
|
31
|
+
sawyer (~> 0.6.0, >= 0.5.3)
|
32
|
+
pry (0.10.1)
|
33
|
+
coderay (~> 1.1.0)
|
34
|
+
method_source (~> 0.8.1)
|
35
|
+
slop (~> 3.4)
|
36
|
+
rake (10.4.2)
|
37
|
+
rspec (3.3.0)
|
38
|
+
rspec-core (~> 3.3.0)
|
39
|
+
rspec-expectations (~> 3.3.0)
|
40
|
+
rspec-mocks (~> 3.3.0)
|
41
|
+
rspec-core (3.3.2)
|
42
|
+
rspec-support (~> 3.3.0)
|
43
|
+
rspec-expectations (3.3.1)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.3.0)
|
46
|
+
rspec-mocks (3.3.2)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.3.0)
|
49
|
+
rspec-support (3.3.0)
|
50
|
+
safe_yaml (1.0.4)
|
51
|
+
sawyer (0.6.0)
|
52
|
+
addressable (~> 2.3.5)
|
53
|
+
faraday (~> 0.8, < 0.10)
|
54
|
+
slop (3.6.0)
|
55
|
+
thor (0.19.1)
|
56
|
+
vcr (2.9.3)
|
57
|
+
webmock (1.21.0)
|
58
|
+
addressable (>= 2.3.6)
|
59
|
+
crack (>= 0.3.2)
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
ruby
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
bundler (~> 1.6)
|
66
|
+
metamatter!
|
67
|
+
pry (~> 0.10)
|
68
|
+
rake (~> 10.0)
|
69
|
+
rspec (~> 3.3)
|
70
|
+
vcr (~> 2.9)
|
71
|
+
webmock (~> 1.21)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Arfon Smith
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Metamatter
|
2
|
+
|
3
|
+
[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.18873.svg)](http://dx.doi.org/10.5281/zenodo.19630)
|
4
|
+
[![Build Status](https://travis-ci.org/arfon/metamatter.svg?branch=master)](https://travis-ci.org/arfon/metamatter)
|
5
|
+
|
6
|
+
Minimal metadata extractor for the GitHub API. Ultimately the goal is to get this to produce output similar to that described in [this blog post](http://www.arfon.org/json-ld-for-software-discovery-reuse-and-credit). Currently none of the entities in the output have any semantic context.
|
7
|
+
|
8
|
+
```javascript
|
9
|
+
{
|
10
|
+
"@context": "http://schema.org",
|
11
|
+
"@type": "Code",
|
12
|
+
"name": "Fidgit",
|
13
|
+
"codeRepository": "https://github.com/arfon/fidgit",
|
14
|
+
"citation": "http://dx.doi.org/10.6084/m9.figshare.828487",
|
15
|
+
"description": "An ungodly union of GitHub and Figshare http://fidgit.arfon.org",
|
16
|
+
"dateCreated": "2013-10-19",
|
17
|
+
"license": "http://opensource.org/licenses/MIT",
|
18
|
+
"author": {
|
19
|
+
"@type": "Person",
|
20
|
+
"name": "Arfon Smith",
|
21
|
+
"@id": "http://orcid.org/0000-0002-3957-2474",
|
22
|
+
"email": "arfon@github.com"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
ALGORITHMIA_TOKEN = your_algorithmia_token
|
31
|
+
GITHUB_TOKEN = your_github_token
|
32
|
+
|
33
|
+
repository = Metamatter::Repository.new('arfon/metamatter')
|
34
|
+
repository.extract #=> '{"authors": [{"name": "Arfon Smith", "email":"arfon.smith@gmail.com" ...
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
```bash
|
39
|
+
GITHUB_TOKEN=your_github_token ALGORITHMIA_TOKEN=your_algorithmia_token\
|
40
|
+
metamatter extract arfon/metamatter
|
41
|
+
|
42
|
+
{
|
43
|
+
"repository": {
|
44
|
+
"name": "metamatter",
|
45
|
+
"location": "https://github.com/arfon/metamatter",
|
46
|
+
"description": "Minimal metadata extractor for the GitHub API",
|
47
|
+
"created_at": "2015-07-06 10:42:12 UTC"
|
48
|
+
},
|
49
|
+
"authors": [
|
50
|
+
{
|
51
|
+
"name": "Arfon Smith",
|
52
|
+
"email": "arfon.smith@gmail.com",
|
53
|
+
"login": "arfon",
|
54
|
+
"contributions": 10
|
55
|
+
}
|
56
|
+
],
|
57
|
+
"tags": [
|
58
|
+
"api",
|
59
|
+
"extractor",
|
60
|
+
"minimal",
|
61
|
+
"metadata",
|
62
|
+
"github",
|
63
|
+
"metamatter"
|
64
|
+
],
|
65
|
+
"license": {
|
66
|
+
"name": "MIT License",
|
67
|
+
"url": "https://api.github.com/licenses/mit"
|
68
|
+
},
|
69
|
+
"doi": "http://dx.doi.org/10.5281/zenodo.19630"
|
70
|
+
}
|
71
|
+
|
72
|
+
```
|
data/Rakefile
ADDED
data/bin/metamatter
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative "../lib/metamatter"
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
class MetamatterCli < Thor
|
6
|
+
desc "extract REPO_WITH_OWNER", "Extract the authors from a GitHub repository"
|
7
|
+
def extract(repo_with_owner)
|
8
|
+
puts Metamatter::Repository.new(repo_with_owner).extract
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
MetamatterCli.start
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.algorithmia.com/v1/algo/tags/AutoTagGithub
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '["arfon","metamatter"]'
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- "<ALGORITHMIA_TOKEN>"
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Content-Type:
|
20
|
+
- application/json; charset=utf-8
|
21
|
+
Strict-Transport-Security:
|
22
|
+
- max-age=0; includeSubDomains; preload
|
23
|
+
X-Frame-Options:
|
24
|
+
- DENY
|
25
|
+
Content-Length:
|
26
|
+
- '159'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
body:
|
30
|
+
encoding: UTF-8
|
31
|
+
string: '{"result":{"output":2,"blog":1,"context":1,"usage":1,"entities":1,"post":1,"similar":1,"semantic":1},"metadata":{"content_type":"json","duration":0.000486793}}'
|
32
|
+
http_version:
|
33
|
+
recorded_at: Sat, 25 Jul 2015 21:18:33 GMT
|
34
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,162 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.github.com/repos/arfon/metamatter/contributors
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/vnd.github.drax-preview+json
|
12
|
+
User-Agent:
|
13
|
+
- Octokit Ruby Gem 4.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- token <GITHUB_TOKEN>
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- GitHub.com
|
27
|
+
Date:
|
28
|
+
- Sat, 25 Jul 2015 21:34:59 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Status:
|
34
|
+
- 200 OK
|
35
|
+
X-Ratelimit-Limit:
|
36
|
+
- '5000'
|
37
|
+
X-Ratelimit-Remaining:
|
38
|
+
- '4996'
|
39
|
+
X-Ratelimit-Reset:
|
40
|
+
- '1437862937'
|
41
|
+
Cache-Control:
|
42
|
+
- private, max-age=60, s-maxage=60
|
43
|
+
Last-Modified:
|
44
|
+
- Fri, 10 Jul 2015 15:23:18 GMT
|
45
|
+
Etag:
|
46
|
+
- W/"72d827407d14f75a1efb778b2078342d"
|
47
|
+
X-Oauth-Scopes:
|
48
|
+
- public_repo, user
|
49
|
+
X-Accepted-Oauth-Scopes:
|
50
|
+
- ''
|
51
|
+
Vary:
|
52
|
+
- Accept, Authorization, Cookie, X-GitHub-OTP
|
53
|
+
- Accept-Encoding
|
54
|
+
X-Github-Media-Type:
|
55
|
+
- github.drax-preview; format=json
|
56
|
+
X-Xss-Protection:
|
57
|
+
- 1; mode=block
|
58
|
+
X-Frame-Options:
|
59
|
+
- deny
|
60
|
+
Content-Security-Policy:
|
61
|
+
- default-src 'none'
|
62
|
+
Access-Control-Allow-Credentials:
|
63
|
+
- 'true'
|
64
|
+
Access-Control-Expose-Headers:
|
65
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
66
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
67
|
+
Access-Control-Allow-Origin:
|
68
|
+
- "*"
|
69
|
+
X-Github-Request-Id:
|
70
|
+
- 56AACDA8:1B84:6E2D9FB:55B40102
|
71
|
+
Strict-Transport-Security:
|
72
|
+
- max-age=31536000; includeSubdomains; preload
|
73
|
+
X-Content-Type-Options:
|
74
|
+
- nosniff
|
75
|
+
X-Served-By:
|
76
|
+
- 13d09b732ebe76f892093130dc088652
|
77
|
+
body:
|
78
|
+
encoding: UTF-8
|
79
|
+
string: '[{"login":"arfon","id":4483,"avatar_url":"https://avatars.githubusercontent.com/u/4483?v=3","gravatar_id":"","url":"https://api.github.com/users/arfon","html_url":"https://github.com/arfon","followers_url":"https://api.github.com/users/arfon/followers","following_url":"https://api.github.com/users/arfon/following{/other_user}","gists_url":"https://api.github.com/users/arfon/gists{/gist_id}","starred_url":"https://api.github.com/users/arfon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arfon/subscriptions","organizations_url":"https://api.github.com/users/arfon/orgs","repos_url":"https://api.github.com/users/arfon/repos","events_url":"https://api.github.com/users/arfon/events{/privacy}","received_events_url":"https://api.github.com/users/arfon/received_events","type":"User","site_admin":true,"contributions":19}]'
|
80
|
+
http_version:
|
81
|
+
recorded_at: Sat, 25 Jul 2015 21:34:59 GMT
|
82
|
+
- request:
|
83
|
+
method: get
|
84
|
+
uri: https://api.github.com/users/arfon
|
85
|
+
body:
|
86
|
+
encoding: US-ASCII
|
87
|
+
string: ''
|
88
|
+
headers:
|
89
|
+
Accept:
|
90
|
+
- application/vnd.github.drax-preview+json
|
91
|
+
User-Agent:
|
92
|
+
- Octokit Ruby Gem 4.0.1
|
93
|
+
Content-Type:
|
94
|
+
- application/json
|
95
|
+
Authorization:
|
96
|
+
- token <GITHUB_TOKEN>
|
97
|
+
Accept-Encoding:
|
98
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
99
|
+
response:
|
100
|
+
status:
|
101
|
+
code: 200
|
102
|
+
message: OK
|
103
|
+
headers:
|
104
|
+
Server:
|
105
|
+
- GitHub.com
|
106
|
+
Date:
|
107
|
+
- Sat, 25 Jul 2015 21:34:59 GMT
|
108
|
+
Content-Type:
|
109
|
+
- application/json; charset=utf-8
|
110
|
+
Transfer-Encoding:
|
111
|
+
- chunked
|
112
|
+
Status:
|
113
|
+
- 200 OK
|
114
|
+
X-Ratelimit-Limit:
|
115
|
+
- '5000'
|
116
|
+
X-Ratelimit-Remaining:
|
117
|
+
- '4995'
|
118
|
+
X-Ratelimit-Reset:
|
119
|
+
- '1437862937'
|
120
|
+
Cache-Control:
|
121
|
+
- private, max-age=60, s-maxage=60
|
122
|
+
Last-Modified:
|
123
|
+
- Fri, 17 Jul 2015 20:54:50 GMT
|
124
|
+
Etag:
|
125
|
+
- W/"dbce021f11e33a0f3382736c57062638"
|
126
|
+
X-Oauth-Scopes:
|
127
|
+
- public_repo, user
|
128
|
+
X-Accepted-Oauth-Scopes:
|
129
|
+
- user
|
130
|
+
Vary:
|
131
|
+
- Accept, Authorization, Cookie, X-GitHub-OTP
|
132
|
+
- Accept-Encoding
|
133
|
+
X-Github-Media-Type:
|
134
|
+
- github.drax-preview; format=json
|
135
|
+
X-Xss-Protection:
|
136
|
+
- 1; mode=block
|
137
|
+
X-Frame-Options:
|
138
|
+
- deny
|
139
|
+
Content-Security-Policy:
|
140
|
+
- default-src 'none'
|
141
|
+
Access-Control-Allow-Credentials:
|
142
|
+
- 'true'
|
143
|
+
Access-Control-Expose-Headers:
|
144
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
145
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
146
|
+
Access-Control-Allow-Origin:
|
147
|
+
- "*"
|
148
|
+
X-Github-Request-Id:
|
149
|
+
- 56AACDA8:1B84:6E2DAE9:55B40103
|
150
|
+
Strict-Transport-Security:
|
151
|
+
- max-age=31536000; includeSubdomains; preload
|
152
|
+
X-Content-Type-Options:
|
153
|
+
- nosniff
|
154
|
+
X-Served-By:
|
155
|
+
- a241e1a8264a6ace03db946c85b92db3
|
156
|
+
body:
|
157
|
+
encoding: UTF-8
|
158
|
+
string: '{"login":"arfon","id":4483,"avatar_url":"https://avatars.githubusercontent.com/u/4483?v=3","gravatar_id":"","url":"https://api.github.com/users/arfon","html_url":"https://github.com/arfon","followers_url":"https://api.github.com/users/arfon/followers","following_url":"https://api.github.com/users/arfon/following{/other_user}","gists_url":"https://api.github.com/users/arfon/gists{/gist_id}","starred_url":"https://api.github.com/users/arfon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arfon/subscriptions","organizations_url":"https://api.github.com/users/arfon/orgs","repos_url":"https://api.github.com/users/arfon/repos","events_url":"https://api.github.com/users/arfon/events{/privacy}","received_events_url":"https://api.github.com/users/arfon/received_events","type":"User","site_admin":true,"name":"Arfon
|
159
|
+
Smith","company":"GitHub Inc.","blog":"arfon.org","location":"Chicago","email":"arfon.smith@gmail.com","hireable":false,"bio":null,"public_repos":68,"public_gists":67,"followers":186,"following":9,"created_at":"2008-04-03T11:05:32Z","updated_at":"2015-07-17T20:54:50Z","private_gists":78,"total_private_repos":3,"owned_private_repos":3,"disk_usage":39507,"collaborators":2,"plan":{"name":"medium","space":976562499,"collaborators":0,"private_repos":20}}'
|
160
|
+
http_version:
|
161
|
+
recorded_at: Sat, 25 Jul 2015 21:34:59 GMT
|
162
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,84 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.github.com/repos/arfon/metamatter
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/vnd.github.drax-preview+json
|
12
|
+
User-Agent:
|
13
|
+
- Octokit Ruby Gem 4.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- token <GITHUB_TOKEN>
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- GitHub.com
|
27
|
+
Date:
|
28
|
+
- Sat, 25 Jul 2015 21:22:53 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Status:
|
34
|
+
- 200 OK
|
35
|
+
X-Ratelimit-Limit:
|
36
|
+
- '5000'
|
37
|
+
X-Ratelimit-Remaining:
|
38
|
+
- '4998'
|
39
|
+
X-Ratelimit-Reset:
|
40
|
+
- '1437862937'
|
41
|
+
Cache-Control:
|
42
|
+
- private, max-age=60, s-maxage=60
|
43
|
+
Last-Modified:
|
44
|
+
- Fri, 10 Jul 2015 15:23:18 GMT
|
45
|
+
Etag:
|
46
|
+
- W/"6b64e1b3e721ba5e94eda2853702bf97"
|
47
|
+
X-Oauth-Scopes:
|
48
|
+
- public_repo, user
|
49
|
+
X-Accepted-Oauth-Scopes:
|
50
|
+
- repo
|
51
|
+
Vary:
|
52
|
+
- Accept, Authorization, Cookie, X-GitHub-OTP
|
53
|
+
- Accept-Encoding
|
54
|
+
X-Github-Media-Type:
|
55
|
+
- github.drax-preview; format=json
|
56
|
+
X-Xss-Protection:
|
57
|
+
- 1; mode=block
|
58
|
+
X-Frame-Options:
|
59
|
+
- deny
|
60
|
+
Content-Security-Policy:
|
61
|
+
- default-src 'none'
|
62
|
+
Access-Control-Allow-Credentials:
|
63
|
+
- 'true'
|
64
|
+
Access-Control-Expose-Headers:
|
65
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
66
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
67
|
+
Access-Control-Allow-Origin:
|
68
|
+
- "*"
|
69
|
+
X-Github-Request-Id:
|
70
|
+
- 56AACDA8:6937:7A33BA6:55B3FE2D
|
71
|
+
Strict-Transport-Security:
|
72
|
+
- max-age=31536000; includeSubdomains; preload
|
73
|
+
X-Content-Type-Options:
|
74
|
+
- nosniff
|
75
|
+
X-Served-By:
|
76
|
+
- dc1ce2bfb41810a06c705e83b388572d
|
77
|
+
body:
|
78
|
+
encoding: UTF-8
|
79
|
+
string: '{"id":38612794,"name":"metamatter","full_name":"arfon/metamatter","owner":{"login":"arfon","id":4483,"avatar_url":"https://avatars.githubusercontent.com/u/4483?v=3","gravatar_id":"","url":"https://api.github.com/users/arfon","html_url":"https://github.com/arfon","followers_url":"https://api.github.com/users/arfon/followers","following_url":"https://api.github.com/users/arfon/following{/other_user}","gists_url":"https://api.github.com/users/arfon/gists{/gist_id}","starred_url":"https://api.github.com/users/arfon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arfon/subscriptions","organizations_url":"https://api.github.com/users/arfon/orgs","repos_url":"https://api.github.com/users/arfon/repos","events_url":"https://api.github.com/users/arfon/events{/privacy}","received_events_url":"https://api.github.com/users/arfon/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/arfon/metamatter","description":"Minimal
|
80
|
+
metadata extractor for the GitHub API","fork":false,"url":"https://api.github.com/repos/arfon/metamatter","forks_url":"https://api.github.com/repos/arfon/metamatter/forks","keys_url":"https://api.github.com/repos/arfon/metamatter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arfon/metamatter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arfon/metamatter/teams","hooks_url":"https://api.github.com/repos/arfon/metamatter/hooks","issue_events_url":"https://api.github.com/repos/arfon/metamatter/issues/events{/number}","events_url":"https://api.github.com/repos/arfon/metamatter/events","assignees_url":"https://api.github.com/repos/arfon/metamatter/assignees{/user}","branches_url":"https://api.github.com/repos/arfon/metamatter/branches{/branch}","tags_url":"https://api.github.com/repos/arfon/metamatter/tags","blobs_url":"https://api.github.com/repos/arfon/metamatter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arfon/metamatter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arfon/metamatter/git/refs{/sha}","trees_url":"https://api.github.com/repos/arfon/metamatter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arfon/metamatter/statuses/{sha}","languages_url":"https://api.github.com/repos/arfon/metamatter/languages","stargazers_url":"https://api.github.com/repos/arfon/metamatter/stargazers","contributors_url":"https://api.github.com/repos/arfon/metamatter/contributors","subscribers_url":"https://api.github.com/repos/arfon/metamatter/subscribers","subscription_url":"https://api.github.com/repos/arfon/metamatter/subscription","commits_url":"https://api.github.com/repos/arfon/metamatter/commits{/sha}","git_commits_url":"https://api.github.com/repos/arfon/metamatter/git/commits{/sha}","comments_url":"https://api.github.com/repos/arfon/metamatter/comments{/number}","issue_comment_url":"https://api.github.com/repos/arfon/metamatter/issues/comments{/number}","contents_url":"https://api.github.com/repos/arfon/metamatter/contents/{+path}","compare_url":"https://api.github.com/repos/arfon/metamatter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arfon/metamatter/merges","archive_url":"https://api.github.com/repos/arfon/metamatter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arfon/metamatter/downloads","issues_url":"https://api.github.com/repos/arfon/metamatter/issues{/number}","pulls_url":"https://api.github.com/repos/arfon/metamatter/pulls{/number}","milestones_url":"https://api.github.com/repos/arfon/metamatter/milestones{/number}","notifications_url":"https://api.github.com/repos/arfon/metamatter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arfon/metamatter/labels{/name}","releases_url":"https://api.github.com/repos/arfon/metamatter/releases{/id}","created_at":"2015-07-06T10:42:12Z","updated_at":"2015-07-10T15:23:18Z","pushed_at":"2015-07-25T21:04:33Z","git_url":"git://github.com/arfon/metamatter.git","ssh_url":"git@github.com:arfon/metamatter.git","clone_url":"https://github.com/arfon/metamatter.git","svn_url":"https://github.com/arfon/metamatter","homepage":null,"size":164,"stargazers_count":3,"watchers_count":3,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":3,"default_branch":"master","master_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"license":{"key":"mit","name":"MIT
|
81
|
+
License","url":"https://api.github.com/licenses/mit","featured":true},"network_count":0,"subscribers_count":1}'
|
82
|
+
http_version:
|
83
|
+
recorded_at: Sat, 25 Jul 2015 21:22:53 GMT
|
84
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.github.com/repos/arfon/metamatter/readme
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/vnd.github.drax-preview+json
|
12
|
+
User-Agent:
|
13
|
+
- Octokit Ruby Gem 4.0.1
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- token <GITHUB_TOKEN>
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- GitHub.com
|
27
|
+
Date:
|
28
|
+
- Sat, 25 Jul 2015 21:28:14 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Status:
|
34
|
+
- 200 OK
|
35
|
+
X-Ratelimit-Limit:
|
36
|
+
- '5000'
|
37
|
+
X-Ratelimit-Remaining:
|
38
|
+
- '4997'
|
39
|
+
X-Ratelimit-Reset:
|
40
|
+
- '1437862937'
|
41
|
+
Cache-Control:
|
42
|
+
- private, max-age=60, s-maxage=60
|
43
|
+
Last-Modified:
|
44
|
+
- Sat, 25 Jul 2015 20:16:22 GMT
|
45
|
+
Etag:
|
46
|
+
- W/"783ea7988d820497bcbfb678c8d0467a"
|
47
|
+
X-Oauth-Scopes:
|
48
|
+
- public_repo, user
|
49
|
+
X-Accepted-Oauth-Scopes:
|
50
|
+
- ''
|
51
|
+
Vary:
|
52
|
+
- Accept, Authorization, Cookie, X-GitHub-OTP
|
53
|
+
- Accept-Encoding
|
54
|
+
X-Github-Media-Type:
|
55
|
+
- github.drax-preview; format=json
|
56
|
+
X-Xss-Protection:
|
57
|
+
- 1; mode=block
|
58
|
+
X-Frame-Options:
|
59
|
+
- deny
|
60
|
+
Content-Security-Policy:
|
61
|
+
- default-src 'none'
|
62
|
+
Access-Control-Allow-Credentials:
|
63
|
+
- 'true'
|
64
|
+
Access-Control-Expose-Headers:
|
65
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
66
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
67
|
+
Access-Control-Allow-Origin:
|
68
|
+
- "*"
|
69
|
+
X-Github-Request-Id:
|
70
|
+
- 56AACDA8:4122:7A91DFA:55B3FF6E
|
71
|
+
Strict-Transport-Security:
|
72
|
+
- max-age=31536000; includeSubdomains; preload
|
73
|
+
X-Content-Type-Options:
|
74
|
+
- nosniff
|
75
|
+
X-Served-By:
|
76
|
+
- a6882e5cd2513376cb9481dbcd83f3a2
|
77
|
+
body:
|
78
|
+
encoding: UTF-8
|
79
|
+
string: '{"name":"README.md","path":"README.md","sha":"f009862b43ddae3464dfc432eb852e8efb004015","size":1948,"url":"https://api.github.com/repos/arfon/metamatter/contents/README.md?ref=master","html_url":"https://github.com/arfon/metamatter/blob/master/README.md","git_url":"https://api.github.com/repos/arfon/metamatter/git/blobs/f009862b43ddae3464dfc432eb852e8efb004015","download_url":"https://raw.githubusercontent.com/arfon/metamatter/master/README.md","type":"file","content":"IyBNZXRhbWF0dGVyCgpbIVtET0ldKGh0dHBzOi8vemVub2RvLm9yZy9iYWRn\nZS9kb2kvMTAuNTI4MS96ZW5vZG8uMTg4NzMuc3ZnKV0oaHR0cDovL2R4LmRv\naS5vcmcvMTAuNTI4MS96ZW5vZG8uMTk2MzApCgpNaW5pbWFsIG1ldGFkYXRh\nIGV4dHJhY3RvciBmb3IgdGhlIEdpdEh1YiBBUEkuIFVsdGltYXRlbHkgdGhl\nIGdvYWwgaXMgdG8gZ2V0IHRoaXMgdG8gcHJvZHVjZSBvdXRwdXQgc2ltaWxh\nciB0byB0aGF0IGRlc2NyaWJlZCBpbiBbdGhpcyBibG9nIHBvc3RdKGh0dHA6\nLy93d3cuYXJmb24ub3JnL2pzb24tbGQtZm9yLXNvZnR3YXJlLWRpc2NvdmVy\neS1yZXVzZS1hbmQtY3JlZGl0KS4gQ3VycmVudGx5IG5vbmUgb2YgdGhlIGVu\ndGl0aWVzIGluIHRoZSBvdXRwdXQgaGF2ZSBhbnkgc2VtYW50aWMgY29udGV4\ndC4KCmBgYGphdmFzY3JpcHQKewogICJAY29udGV4dCI6ICJodHRwOi8vc2No\nZW1hLm9yZyIsCiAgIkB0eXBlIjogIkNvZGUiLAogICJuYW1lIjogIkZpZGdp\ndCIsCiAgImNvZGVSZXBvc2l0b3J5IjogImh0dHBzOi8vZ2l0aHViLmNvbS9h\ncmZvbi9maWRnaXQiLAogICJjaXRhdGlvbiI6ICJodHRwOi8vZHguZG9pLm9y\nZy8xMC42MDg0L205LmZpZ3NoYXJlLjgyODQ4NyIsCiAgImRlc2NyaXB0aW9u\nIjogIkFuIHVuZ29kbHkgdW5pb24gb2YgR2l0SHViIGFuZCBGaWdzaGFyZSBo\ndHRwOi8vZmlkZ2l0LmFyZm9uLm9yZyIsCiAgImRhdGVDcmVhdGVkIjogIjIw\nMTMtMTAtMTkiLAogICJsaWNlbnNlIjogImh0dHA6Ly9vcGVuc291cmNlLm9y\nZy9saWNlbnNlcy9NSVQiLAogICJhdXRob3IiOiB7CiAgICAiQHR5cGUiOiAi\nUGVyc29uIiwKICAgICJuYW1lIjogIkFyZm9uIFNtaXRoIiwKICAgICJAaWQi\nOiAiaHR0cDovL29yY2lkLm9yZy8wMDAwLTAwMDItMzk1Ny0yNDc0IiwKICAg\nICJlbWFpbCI6ICJhcmZvbkBnaXRodWIuY29tIgogIH0KfQpgYGAKCiMjIFVz\nYWdlCgpgYGBydWJ5CkFMR09SSVRITUlBX1RPS0VOID0geW91cl9hbGdvcml0\naG1pYV90b2tlbgpHSVRIVUJfVE9LRU4gPSB5b3VyX2dpdGh1Yl90b2tlbgoK\ncmVwb3NpdG9yeSA9IE1ldGFtYXR0ZXI6OlJlcG9zaXRvcnkubmV3KCdhcmZv\nbi9tZXRhbWF0dGVyJykKcmVwb3NpdG9yeS5leHRyYWN0ICAgICM9PiAneyJh\ndXRob3JzIjogW3sibmFtZSI6ICJBcmZvbiBTbWl0aCIsICJlbWFpbCI6ImFy\nZm9uLnNtaXRoQGdtYWlsLmNvbSIgLi4uCgpgYGAKCmBgYGJhc2gKR0lUSFVC\nX1RPS0VOPXlvdXJfZ2l0aHViX3Rva2VuIEFMR09SSVRITUlBX1RPS0VOPXlv\ndXJfYWxnb3JpdGhtaWFfdG9rZW5cCm1ldGFtYXR0ZXIgZXh0cmFjdCBhcmZv\nbi9tZXRhbWF0dGVyCgp7CiAgInJlcG9zaXRvcnkiOiB7CiAgICAibmFtZSI6\nICJtZXRhbWF0dGVyIiwKICAgICJsb2NhdGlvbiI6ICJodHRwczovL2dpdGh1\nYi5jb20vYXJmb24vbWV0YW1hdHRlciIsCiAgICAiZGVzY3JpcHRpb24iOiAi\nTWluaW1hbCBtZXRhZGF0YSBleHRyYWN0b3IgZm9yIHRoZSBHaXRIdWIgQVBJ\nIiwKICAgICJjcmVhdGVkX2F0IjogIjIwMTUtMDctMDYgMTA6NDI6MTIgVVRD\nIgogIH0sCiAgImF1dGhvcnMiOiBbCiAgICB7CiAgICAgICJuYW1lIjogIkFy\nZm9uIFNtaXRoIiwKICAgICAgImVtYWlsIjogImFyZm9uLnNtaXRoQGdtYWls\nLmNvbSIsCiAgICAgICJsb2dpbiI6ICJhcmZvbiIsCiAgICAgICJjb250cmli\ndXRpb25zIjogMTAKICAgIH0KICBdLAogICJ0YWdzIjogWwogICAgImFwaSIs\nCiAgICAiZXh0cmFjdG9yIiwKICAgICJtaW5pbWFsIiwKICAgICJtZXRhZGF0\nYSIsCiAgICAiZ2l0aHViIiwKICAgICJtZXRhbWF0dGVyIgogIF0sCiAgImxp\nY2Vuc2UiOiB7CiAgICAibmFtZSI6ICJNSVQgTGljZW5zZSIsCiAgICAidXJs\nIjogImh0dHBzOi8vYXBpLmdpdGh1Yi5jb20vbGljZW5zZXMvbWl0IgogIH0s\nCiAgImRvaSI6ICJodHRwOi8vZHguZG9pLm9yZy8xMC41MjgxL3plbm9kby4x\nOTYzMCIKfQoKYGBgCg==\n","encoding":"base64","_links":{"self":"https://api.github.com/repos/arfon/metamatter/contents/README.md?ref=master","git":"https://api.github.com/repos/arfon/metamatter/git/blobs/f009862b43ddae3464dfc432eb852e8efb004015","html":"https://github.com/arfon/metamatter/blob/master/README.md"}}'
|
80
|
+
http_version:
|
81
|
+
recorded_at: Sat, 25 Jul 2015 21:28:14 GMT
|
82
|
+
recorded_with: VCR 2.9.3
|
data/lib/metamatter.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
|
3
|
+
require_relative 'metamatter/classification'
|
4
|
+
require_relative 'metamatter/authors'
|
5
|
+
require_relative 'metamatter/helpers'
|
6
|
+
require_relative 'metamatter/license'
|
7
|
+
require_relative 'metamatter/readme'
|
8
|
+
|
9
|
+
module Metamatter
|
10
|
+
class Repository
|
11
|
+
include Helpers
|
12
|
+
|
13
|
+
attr_accessor :owner
|
14
|
+
attr_accessor :name
|
15
|
+
|
16
|
+
# Public: Initialize a new Repository from a GitHub repo with owner
|
17
|
+
#
|
18
|
+
# repo_with_owner - e.g. arfon/metamatter
|
19
|
+
#
|
20
|
+
# Returns a Repository.
|
21
|
+
def initialize(repo_with_owner)
|
22
|
+
@owner, @name = repo_with_owner.split('/')
|
23
|
+
end
|
24
|
+
|
25
|
+
# Public: Convenience method for returning the owner with name
|
26
|
+
#
|
27
|
+
# Returns a string e.g. 'arfon/metamatter'
|
28
|
+
def name_with_owner
|
29
|
+
[owner, name].join('/')
|
30
|
+
end
|
31
|
+
|
32
|
+
# Public: Returns the full metadata for the repository
|
33
|
+
#
|
34
|
+
# Returns metatdata hash.
|
35
|
+
def extract
|
36
|
+
return JSON.pretty_generate({ :repository => self.to_hash,
|
37
|
+
:authors => authors,
|
38
|
+
:tags => tags,
|
39
|
+
:license => license,
|
40
|
+
:doi => doi })
|
41
|
+
end
|
42
|
+
|
43
|
+
# Public: Returns the full list of contributors to the repository sorted
|
44
|
+
# by their contribution count
|
45
|
+
#
|
46
|
+
# Returns authors hash.
|
47
|
+
def authors
|
48
|
+
Metamatter::Authors.new(self).list
|
49
|
+
end
|
50
|
+
|
51
|
+
# Public: Returns the tags from the Algorithmia classification
|
52
|
+
#
|
53
|
+
# Returns list of tags or nil.
|
54
|
+
def tags
|
55
|
+
Metamatter::Classification.new(self).tags
|
56
|
+
end
|
57
|
+
|
58
|
+
# Public: Returns the license detected for the repository
|
59
|
+
#
|
60
|
+
# Returns license hash or nil
|
61
|
+
def license
|
62
|
+
Metamatter::License.new(self).license
|
63
|
+
end
|
64
|
+
|
65
|
+
# Public: Returns any known DOIs for the repository
|
66
|
+
#
|
67
|
+
# Returns a DOI string or nil
|
68
|
+
def doi
|
69
|
+
Metamatter::Readme.new(self).doi
|
70
|
+
end
|
71
|
+
|
72
|
+
# Private: The GitHub Repository response
|
73
|
+
#
|
74
|
+
# Returns a cached Octokit response hash
|
75
|
+
def github_response
|
76
|
+
@github_response ||= client.repository(name_with_owner)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Private: Returns a summary hash for the repository
|
80
|
+
#
|
81
|
+
# Returns a hash
|
82
|
+
def to_hash
|
83
|
+
{
|
84
|
+
:name => github_response.name,
|
85
|
+
:location => github_response.html_url,
|
86
|
+
:description => github_response.description,
|
87
|
+
:created_at => github_response.created_at
|
88
|
+
}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'helpers'
|
2
|
+
|
3
|
+
module Metamatter
|
4
|
+
class Authors
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
attr_accessor :repository
|
8
|
+
|
9
|
+
def initialize(repository)
|
10
|
+
@repository = repository
|
11
|
+
end
|
12
|
+
|
13
|
+
def list
|
14
|
+
authors = []
|
15
|
+
contribs = github_response
|
16
|
+
contribs.each do |c|
|
17
|
+
user = client.user(c.login)
|
18
|
+
authors << {:name => user.name, :email => user.email, :login => user.login, :contributions => c.contributions}
|
19
|
+
end
|
20
|
+
|
21
|
+
return authors.sort_by { |a| a[:contributions] }.reverse
|
22
|
+
end
|
23
|
+
|
24
|
+
def github_response
|
25
|
+
@contributors_response ||= client.contributors(repository.name_with_owner)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'algorithmia'
|
2
|
+
|
3
|
+
module Metamatter
|
4
|
+
class Classification
|
5
|
+
attr_accessor :repository
|
6
|
+
|
7
|
+
def initialize(repository)
|
8
|
+
@repository = repository
|
9
|
+
end
|
10
|
+
|
11
|
+
def tags
|
12
|
+
Algorithmia.api_key = ENV['ALGORITHMIA_TOKEN']
|
13
|
+
# Expects params as [owner, repo] - see https://algorithmia.com/algorithms/tags/AutoTagGithub
|
14
|
+
query = Algorithmia.call("tags/AutoTagGithub", [repository.owner, repository.name])
|
15
|
+
return query.result.keys
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Helpers
|
2
|
+
# Authenticated Octokit
|
3
|
+
# TODO remove license preview media type when this ships
|
4
|
+
MEDIA_TYPE = "application/vnd.github.drax-preview+json"
|
5
|
+
|
6
|
+
def client
|
7
|
+
@client ||= Octokit::Client.new(:access_token => ENV['GITHUB_TOKEN'],
|
8
|
+
:default_media_type => MEDIA_TYPE)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'helpers'
|
2
|
+
|
3
|
+
module Metamatter
|
4
|
+
class License
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
attr_accessor :repository
|
8
|
+
|
9
|
+
def initialize(repository)
|
10
|
+
@repository = repository
|
11
|
+
end
|
12
|
+
|
13
|
+
def has_license?
|
14
|
+
!github_response.license.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def license
|
18
|
+
if has_license?
|
19
|
+
{
|
20
|
+
:name => github_response.license.name,
|
21
|
+
:url => github_response.license.url
|
22
|
+
}
|
23
|
+
else
|
24
|
+
return nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def github_response
|
29
|
+
@github_response ||= client.repository(repository.name_with_owner)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'helpers'
|
2
|
+
|
3
|
+
module Metamatter
|
4
|
+
class Readme
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
attr_accessor :repository
|
8
|
+
|
9
|
+
def initialize(repository)
|
10
|
+
@repository = repository
|
11
|
+
end
|
12
|
+
|
13
|
+
def contents
|
14
|
+
contents = github_response
|
15
|
+
return Base64.decode64(contents.content)
|
16
|
+
end
|
17
|
+
|
18
|
+
def has_zenodo_badge?
|
19
|
+
contents.include?('zenodo.org/badge')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Find the Zenodo DOI if it's there
|
23
|
+
# Returns a DOI URL http://dx.doi.org/10.5281/zenodo.9789 or nil
|
24
|
+
def doi
|
25
|
+
if has_zenodo_badge?
|
26
|
+
match = contents.match(/(dx.doi.org\/)\d{2}.\d{4}\/zenodo.\d*/)[0]
|
27
|
+
return "http://#{match}"
|
28
|
+
else
|
29
|
+
return nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def github_response
|
34
|
+
@github_response ||= client.readme(repository.name_with_owner)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/metamatter.gemspec
ADDED
@@ -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 'metamatter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "metamatter"
|
8
|
+
spec.version = Metamatter::VERSION
|
9
|
+
spec.authors = ["Arfon Smith"]
|
10
|
+
spec.email = ["arfon.smith@gmail.com"]
|
11
|
+
spec.summary = "A Ruby Gem for extracting minmal metadata from a GitHub repository"
|
12
|
+
spec.homepage = "https://github.com/arfon/metamatter"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "algorithmia", "~> 0.2.0"
|
21
|
+
spec.add_dependency "octokit", "~> 4.0"
|
22
|
+
spec.add_dependency "thor", "~> 0.19"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
28
|
+
spec.add_development_dependency "vcr", "~> 2.9"
|
29
|
+
spec.add_development_dependency "webmock", "~> 1.21"
|
30
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Metamatter::Authors do
|
4
|
+
subject(:repository) { Metamatter::Repository.new('arfon/metamatter') }
|
5
|
+
subject(:authors) { Metamatter::Authors.new(repository) }
|
6
|
+
|
7
|
+
it "can list authors" do
|
8
|
+
VCR.use_cassette('authors') do
|
9
|
+
expect(authors.list.first[:login]).to eql('arfon')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Metamatter::Classification do
|
4
|
+
subject(:repository) { Metamatter::Repository.new('arfon/metamatter') }
|
5
|
+
subject(:classification) { Metamatter::Classification.new(repository) }
|
6
|
+
|
7
|
+
it "can retrieve the Algorithmia tags" do
|
8
|
+
VCR.use_cassette('algorithmia') do
|
9
|
+
expect(classification.tags).to eql(["output", "blog", "context", "usage", "entities", "post", "similar", "semantic"])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Metamatter::License do
|
4
|
+
subject(:repository) { Metamatter::Repository.new('arfon/metamatter') }
|
5
|
+
subject(:license) { Metamatter::License.new(repository) }
|
6
|
+
|
7
|
+
it "can detect the license" do
|
8
|
+
VCR.use_cassette('license') do
|
9
|
+
expect(license.has_license?).to be true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can returns the license hash" do
|
14
|
+
VCR.use_cassette('license') do
|
15
|
+
expect(license.license[:name]).to eql('MIT License')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Metamatter::Readme do
|
4
|
+
subject(:repository) { Metamatter::Repository.new('arfon/metamatter') }
|
5
|
+
subject(:readme) { Metamatter::Readme.new(repository) }
|
6
|
+
|
7
|
+
it "can return the README contents" do
|
8
|
+
VCR.use_cassette('readme') do
|
9
|
+
expect(readme.contents.size).to eql(1948)
|
10
|
+
expect(readme.contents).to match(/Minimal metadata extractor/)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "knows if there is a Zenodo badge present" do
|
15
|
+
VCR.use_cassette('readme') do
|
16
|
+
expect(readme.has_zenodo_badge?).to be true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "knows what the DOI is" do
|
21
|
+
VCR.use_cassette('readme') do
|
22
|
+
expect(readme.doi).to eql("http://dx.doi.org/10.5281/zenodo.19630")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Metamatter do
|
4
|
+
|
5
|
+
subject { Metamatter::Repository.new('arfon/metamatter') }
|
6
|
+
|
7
|
+
it "knows how to return #name_with_owner" do
|
8
|
+
expect(subject.name_with_owner).to eql('arfon/metamatter')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can return #authors" do
|
12
|
+
VCR.use_cassette('authors') do
|
13
|
+
expect(subject.authors.first[:login]).to eql('arfon')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can return a #tags" do
|
18
|
+
VCR.use_cassette('algorithmia') do
|
19
|
+
expect(subject.tags).to eql(["output", "blog", "context", "usage", "entities", "post", "similar", "semantic"])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can return #license" do
|
24
|
+
VCR.use_cassette('license') do
|
25
|
+
expect(subject.license[:name]).to eql('MIT License')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can return #doi" do
|
30
|
+
VCR.use_cassette('readme') do
|
31
|
+
expect(subject.doi).to eql("http://dx.doi.org/10.5281/zenodo.19630")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "vcr"
|
3
|
+
|
4
|
+
VCR.configure do |config|
|
5
|
+
config.cassette_library_dir = "fixtures/vcr_cassettes"
|
6
|
+
config.hook_into :webmock
|
7
|
+
config.filter_sensitive_data("<ALGORITHMIA_TOKEN>") { ENV['ALGORITHMIA_TOKEN'] }
|
8
|
+
config.filter_sensitive_data("<GITHUB_TOKEN>") { ENV['GITHUB_TOKEN'] }
|
9
|
+
end
|
10
|
+
|
11
|
+
require_relative "../lib/metamatter"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
describe Metamatter do
|
4
|
+
|
5
|
+
subject { Metamatter::Repository.new('arfon/metamatter') }
|
6
|
+
|
7
|
+
it "knows what it's name and owner is" do
|
8
|
+
expect(subject.name_with_owner).to eql('arfon/metamatter')
|
9
|
+
expect(subject.owner).to eql('arfon')
|
10
|
+
expect(subject.name).to eql('metamatter')
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metamatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arfon Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: algorithmia
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octokit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.19'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.19'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.10'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.10'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: vcr
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.9'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.9'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.21'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.21'
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
- arfon.smith@gmail.com
|
142
|
+
executables:
|
143
|
+
- metamatter
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".gitignore"
|
148
|
+
- ".travis.yml"
|
149
|
+
- Gemfile
|
150
|
+
- Gemfile.lock
|
151
|
+
- LICENSE
|
152
|
+
- README.md
|
153
|
+
- Rakefile
|
154
|
+
- bin/metamatter
|
155
|
+
- fixtures/vcr_cassettes/algorithmia.yml
|
156
|
+
- fixtures/vcr_cassettes/authors.yml
|
157
|
+
- fixtures/vcr_cassettes/license.yml
|
158
|
+
- fixtures/vcr_cassettes/readme.yml
|
159
|
+
- lib/metamatter.rb
|
160
|
+
- lib/metamatter/authors.rb
|
161
|
+
- lib/metamatter/classification.rb
|
162
|
+
- lib/metamatter/helpers.rb
|
163
|
+
- lib/metamatter/license.rb
|
164
|
+
- lib/metamatter/readme.rb
|
165
|
+
- lib/metamatter/version.rb
|
166
|
+
- metamatter.gemspec
|
167
|
+
- spec/metamatter_authors_spec.rb
|
168
|
+
- spec/metamatter_classification_spec.rb
|
169
|
+
- spec/metamatter_license_spec.rb
|
170
|
+
- spec/metamatter_readme_spec.rb
|
171
|
+
- spec/metamatter_spec.rb
|
172
|
+
- spec/spec_helper.rb
|
173
|
+
- specs/metamatter_spec.rb
|
174
|
+
homepage: https://github.com/arfon/metamatter
|
175
|
+
licenses:
|
176
|
+
- MIT
|
177
|
+
metadata: {}
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.2.2
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: A Ruby Gem for extracting minmal metadata from a GitHub repository
|
198
|
+
test_files:
|
199
|
+
- spec/metamatter_authors_spec.rb
|
200
|
+
- spec/metamatter_classification_spec.rb
|
201
|
+
- spec/metamatter_license_spec.rb
|
202
|
+
- spec/metamatter_readme_spec.rb
|
203
|
+
- spec/metamatter_spec.rb
|
204
|
+
- spec/spec_helper.rb
|
205
|
+
has_rdoc:
|