reponaut 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/count.feature +18 -0
- data/features/help.feature +16 -1
- data/features/step_definitions/github_steps.rb +4 -0
- data/lib/reponaut/application.rb +8 -1
- data/lib/reponaut/ext/bool.rb +17 -0
- data/lib/reponaut/github.rb +25 -6
- data/lib/reponaut/version.rb +1 -1
- data/spec/fixtures/cassettes/emptyuser.yml +72 -0
- data/spec/fixtures/cassettes/nosuchuser.yml +63 -0
- data/spec/reponaut/bool_spec.rb +30 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65cb2bccfbcc83c315f1ef89bc32d5909e7ba9d8
|
4
|
+
data.tar.gz: 172ab6a1b8eaa8c982b907820519520db2567806
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e981f194e8be53cfffc91781c500e18bbe76d54e455c386b08267230cd8515cc1b834a0d76150b440c976fdc3f2ff6266dcb621b385ff37a828ce929ae0e533
|
7
|
+
data.tar.gz: f04127d458bdbaaeb25815c6a6e62a77bc3e3e1b63a9daace4a7141d6855a8042c25c83736eff4fd8391d533171306eda5f1cb7c9d529aa465101c7eaf2b028d
|
data/features/count.feature
CHANGED
@@ -118,3 +118,21 @@ Feature: Count repositories by language
|
|
118
118
|
Shell 1
|
119
119
|
Swift 12
|
120
120
|
"""
|
121
|
+
|
122
|
+
Scenario: List repository counts for a non-existent user
|
123
|
+
Given the GitHub service returns 404 for the user "nosuchuser"
|
124
|
+
When I run `reponaut nosuchuser`
|
125
|
+
Then the exit status should not be 0
|
126
|
+
And the stderr should contain:
|
127
|
+
"""
|
128
|
+
No such user: nosuchuser
|
129
|
+
"""
|
130
|
+
|
131
|
+
Scenario: List repository counts for a user with no repositories
|
132
|
+
Given the GitHub service returns repository data for the user "emptyuser"
|
133
|
+
When I run `reponaut emptyuser`
|
134
|
+
Then the exit status should not be 0
|
135
|
+
And the stderr should contain:
|
136
|
+
"""
|
137
|
+
emptyuser has no repositories
|
138
|
+
"""
|
data/features/help.feature
CHANGED
@@ -40,8 +40,23 @@ Feature: Get help
|
|
40
40
|
|
41
41
|
Scenario: Specify an invalid option
|
42
42
|
When I run `reponaut -b`
|
43
|
-
Then
|
43
|
+
Then the exit status should not be 0
|
44
|
+
And the stderr should contain:
|
44
45
|
"""
|
45
46
|
unknown option `-b'
|
46
47
|
Run `reponaut --help` for help information
|
47
48
|
"""
|
49
|
+
|
50
|
+
Scenario: Specify no options
|
51
|
+
When I run `reponaut`
|
52
|
+
Then the exit status should not be 0
|
53
|
+
And the stderr should contain:
|
54
|
+
"""
|
55
|
+
Usage: reponaut [OPTIONS] USERNAME
|
56
|
+
|
57
|
+
Options:
|
58
|
+
-s, --sort Sort by repo count
|
59
|
+
-f, --ignore-forks Ignore forked repos
|
60
|
+
-h, --help
|
61
|
+
--version
|
62
|
+
"""
|
@@ -1,3 +1,7 @@
|
|
1
1
|
Given /^the GitHub service returns repository data for the user "([^"]*)"$/ do |username|
|
2
2
|
set_environment_variable 'REPONAUT_ENV', 'cucumber'
|
3
3
|
end
|
4
|
+
|
5
|
+
Given /^the GitHub service returns 404 for the user "([^"]*)"$/ do |username|
|
6
|
+
set_environment_variable 'REPONAUT_ENV', 'cucumber'
|
7
|
+
end
|
data/lib/reponaut/application.rb
CHANGED
@@ -28,13 +28,17 @@ module Reponaut
|
|
28
28
|
|
29
29
|
username = opts.arguments.first
|
30
30
|
unless username
|
31
|
-
puts opts
|
31
|
+
$stderr.puts opts
|
32
32
|
exit 1
|
33
33
|
end
|
34
34
|
|
35
35
|
gh = Reponaut::GitHub::Client.new(username)
|
36
36
|
repos = gh.repos.reject { |r| r.language.nil? }
|
37
37
|
repos = repos.find_all { |r| r.source? } if opts.ignore_forks?
|
38
|
+
if repos.count < 1
|
39
|
+
$stderr.puts "#{username} has no repositories"
|
40
|
+
exit 3
|
41
|
+
end
|
38
42
|
stats = Reponaut::StatisticsCalculator.new(repos)
|
39
43
|
counts = stats.language_counts.pairs
|
40
44
|
counts = if opts.sort?
|
@@ -54,6 +58,9 @@ module Reponaut
|
|
54
58
|
counts.each do |e|
|
55
59
|
printf "%-*s %*d\n", longest_label, e[0], longest_count, e[1]
|
56
60
|
end
|
61
|
+
rescue Reponaut::GitHub::NoSuchUserError => e
|
62
|
+
$stderr.puts "No such user: #{e}"
|
63
|
+
exit 4
|
57
64
|
rescue Slop::UnknownOption => e
|
58
65
|
$stderr.puts e
|
59
66
|
$stderr.puts 'Run `reponaut --help` for help information'
|
data/lib/reponaut/github.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'json'
|
3
3
|
require 'yaml' if ENV['REPONAUT_ENV'] == 'cucumber'
|
4
|
+
require 'reponaut/ext/bool'
|
4
5
|
|
5
6
|
module Reponaut
|
6
7
|
module GitHub
|
8
|
+
class NoSuchUserError < StandardError; end
|
9
|
+
|
7
10
|
class Client
|
8
11
|
include HTTParty
|
9
12
|
|
@@ -19,16 +22,23 @@ module Reponaut
|
|
19
22
|
JSON.parse(repo_data).map { |e| Repository.new(e) }
|
20
23
|
end
|
21
24
|
|
25
|
+
def to_s
|
26
|
+
username
|
27
|
+
end
|
28
|
+
|
22
29
|
private
|
23
30
|
def repo_data
|
24
31
|
return mock_repo_data if ENV['REPONAUT_ENV'] == 'cucumber'
|
25
|
-
self.class.get("/users/#{username}/repos")
|
32
|
+
resp = self.class.get("/users/#{username}/repos")
|
33
|
+
raise NoSuchUserError, username if resp.code == 404
|
34
|
+
resp.body
|
26
35
|
end
|
27
36
|
|
28
37
|
def mock_repo_data
|
29
38
|
path = File.join(File.dirname(__FILE__), '..', '..', 'spec', 'fixtures', 'cassettes', "#{username}.yml")
|
30
39
|
raw_data = IO.read(path)
|
31
40
|
data = YAML.load(raw_data)
|
41
|
+
raise NoSuchUserError, username if data['http_interactions'][0]['response']['status']['code'] == 404
|
32
42
|
data['http_interactions'][0]['response']['body']['string']
|
33
43
|
end
|
34
44
|
end
|
@@ -38,19 +48,28 @@ module Reponaut
|
|
38
48
|
@data = data
|
39
49
|
end
|
40
50
|
|
41
|
-
def fork?
|
42
|
-
self.fork
|
43
|
-
end
|
44
|
-
|
45
51
|
def source?
|
46
52
|
!fork?
|
47
53
|
end
|
48
54
|
|
55
|
+
def to_s
|
56
|
+
full_name
|
57
|
+
end
|
58
|
+
|
49
59
|
def method_missing(symbol, *args)
|
50
60
|
if @data.include?(symbol.to_s)
|
51
61
|
@data[symbol.to_s]
|
52
62
|
else
|
53
|
-
|
63
|
+
if symbol.to_s.end_with?('?')
|
64
|
+
bool_sym = symbol.to_s.slice(0, symbol.to_s.length-1)
|
65
|
+
if @data.include?(bool_sym) && @data[bool_sym].bool?
|
66
|
+
@data[bool_sym]
|
67
|
+
else
|
68
|
+
super
|
69
|
+
end
|
70
|
+
else
|
71
|
+
super
|
72
|
+
end
|
54
73
|
end
|
55
74
|
end
|
56
75
|
end
|
data/lib/reponaut/version.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.github.com/users/lordofcoffee/repos
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- GitHub.com
|
23
|
+
Date:
|
24
|
+
- Fri, 07 Aug 2015 03:35:37 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '2'
|
29
|
+
Status:
|
30
|
+
- 200 OK
|
31
|
+
X-Ratelimit-Limit:
|
32
|
+
- '60'
|
33
|
+
X-Ratelimit-Remaining:
|
34
|
+
- '53'
|
35
|
+
X-Ratelimit-Reset:
|
36
|
+
- '1438921215'
|
37
|
+
Cache-Control:
|
38
|
+
- public, max-age=60, s-maxage=60
|
39
|
+
Etag:
|
40
|
+
- '"98f0c1b396a4e5d54f4d5fe561d54b44"'
|
41
|
+
Vary:
|
42
|
+
- Accept
|
43
|
+
- Accept-Encoding
|
44
|
+
X-Github-Media-Type:
|
45
|
+
- github.v3
|
46
|
+
X-Xss-Protection:
|
47
|
+
- 1; mode=block
|
48
|
+
X-Frame-Options:
|
49
|
+
- deny
|
50
|
+
Content-Security-Policy:
|
51
|
+
- default-src 'none'
|
52
|
+
Access-Control-Allow-Credentials:
|
53
|
+
- 'true'
|
54
|
+
Access-Control-Expose-Headers:
|
55
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
56
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
57
|
+
Access-Control-Allow-Origin:
|
58
|
+
- "*"
|
59
|
+
X-Github-Request-Id:
|
60
|
+
- B8170007:6D95:1297BE9E:55C42788
|
61
|
+
Strict-Transport-Security:
|
62
|
+
- max-age=31536000; includeSubdomains; preload
|
63
|
+
X-Content-Type-Options:
|
64
|
+
- nosniff
|
65
|
+
X-Served-By:
|
66
|
+
- 2d7a5e35115884240089368322196939
|
67
|
+
body:
|
68
|
+
encoding: UTF-8
|
69
|
+
string: "[]"
|
70
|
+
http_version:
|
71
|
+
recorded_at: Fri, 07 Aug 2015 03:35:37 GMT
|
72
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,63 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.github.com/users/shitter/repos
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 404
|
19
|
+
message: Not Found
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- GitHub.com
|
23
|
+
Date:
|
24
|
+
- Fri, 07 Aug 2015 03:28:16 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Status:
|
30
|
+
- 404 Not Found
|
31
|
+
X-Ratelimit-Limit:
|
32
|
+
- '60'
|
33
|
+
X-Ratelimit-Remaining:
|
34
|
+
- '55'
|
35
|
+
X-Ratelimit-Reset:
|
36
|
+
- '1438921215'
|
37
|
+
X-Github-Media-Type:
|
38
|
+
- github.v3
|
39
|
+
X-Xss-Protection:
|
40
|
+
- 1; mode=block
|
41
|
+
X-Frame-Options:
|
42
|
+
- deny
|
43
|
+
Content-Security-Policy:
|
44
|
+
- default-src 'none'
|
45
|
+
Access-Control-Allow-Credentials:
|
46
|
+
- 'true'
|
47
|
+
Access-Control-Expose-Headers:
|
48
|
+
- ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
|
49
|
+
X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
50
|
+
Access-Control-Allow-Origin:
|
51
|
+
- "*"
|
52
|
+
X-Github-Request-Id:
|
53
|
+
- B8170007:6D8F:44D0D48:55C425D0
|
54
|
+
Strict-Transport-Security:
|
55
|
+
- max-age=31536000; includeSubdomains; preload
|
56
|
+
X-Content-Type-Options:
|
57
|
+
- nosniff
|
58
|
+
body:
|
59
|
+
encoding: ASCII-8BIT
|
60
|
+
string: '{"message":"Not Found","documentation_url":"https://developer.github.com/v3"}'
|
61
|
+
http_version:
|
62
|
+
recorded_at: Fri, 07 Aug 2015 03:28:16 GMT
|
63
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'reponaut/ext/bool'
|
3
|
+
|
4
|
+
module Reponaut
|
5
|
+
module Ext
|
6
|
+
describe Object do
|
7
|
+
describe "#bool?" do
|
8
|
+
it "is not a boolean value" do
|
9
|
+
expect(Array.new.bool?).to be false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe TrueClass do
|
15
|
+
describe "#bool?" do
|
16
|
+
it "is a boolean value" do
|
17
|
+
expect(true.bool?).to be true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe FalseClass do
|
23
|
+
describe "#bool?" do
|
24
|
+
it "is a boolean value" do
|
25
|
+
expect(false.bool?).to be true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reponaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dippery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -142,13 +142,17 @@ files:
|
|
142
142
|
- features/support/vcr.rb
|
143
143
|
- lib/reponaut.rb
|
144
144
|
- lib/reponaut/application.rb
|
145
|
+
- lib/reponaut/ext/bool.rb
|
145
146
|
- lib/reponaut/ext/hash.rb
|
146
147
|
- lib/reponaut/github.rb
|
147
148
|
- lib/reponaut/statistics.rb
|
148
149
|
- lib/reponaut/version.rb
|
149
150
|
- reponaut.gemspec
|
151
|
+
- spec/fixtures/cassettes/emptyuser.yml
|
150
152
|
- spec/fixtures/cassettes/mdippery.yml
|
153
|
+
- spec/fixtures/cassettes/nosuchuser.yml
|
151
154
|
- spec/fixtures/cassettes/testuser1.yml
|
155
|
+
- spec/reponaut/bool_spec.rb
|
152
156
|
- spec/reponaut/github_spec.rb
|
153
157
|
- spec/reponaut/hash_spec.rb
|
154
158
|
- spec/reponaut/statistics_spec.rb
|
@@ -183,8 +187,11 @@ test_files:
|
|
183
187
|
- features/step_definitions/github_steps.rb
|
184
188
|
- features/support/aruba.rb
|
185
189
|
- features/support/vcr.rb
|
190
|
+
- spec/fixtures/cassettes/emptyuser.yml
|
186
191
|
- spec/fixtures/cassettes/mdippery.yml
|
192
|
+
- spec/fixtures/cassettes/nosuchuser.yml
|
187
193
|
- spec/fixtures/cassettes/testuser1.yml
|
194
|
+
- spec/reponaut/bool_spec.rb
|
188
195
|
- spec/reponaut/github_spec.rb
|
189
196
|
- spec/reponaut/hash_spec.rb
|
190
197
|
- spec/reponaut/statistics_spec.rb
|