gitfinger 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/Rakefile +6 -0
- data/bin/gitfinger +55 -0
- data/gitfinger.gemspec +24 -0
- metadata +62 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/gitfinger
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
user = ARGV.first
|
5
|
+
if user.nil?
|
6
|
+
$stderr.puts "Usage: #{File.basename(__FILE__)} [a GitHub username]"
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'octokit'
|
11
|
+
require 'yaml'
|
12
|
+
c = Octokit::Client.new
|
13
|
+
begin
|
14
|
+
repos = c.repositories(user, per_page: 300)
|
15
|
+
rescue Octokit::NotFound
|
16
|
+
$stderr.puts "GitHub user #{user} not found"
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def truncate(s, len)
|
21
|
+
return unless s
|
22
|
+
s.length > len ? s[0,len-3] + '...' : s
|
23
|
+
end
|
24
|
+
|
25
|
+
res = repos.map {|r|
|
26
|
+
d = %w( name name w watchers f forks i open_issues updated updated_at pushed pushed_at type fork desc description).each_slice(2).reduce({}) {|m, x|
|
27
|
+
m[x[0]] = r[x[1]]
|
28
|
+
m
|
29
|
+
}
|
30
|
+
%w( updated pushed ).each {|x| d[x] = d[x] && DateTime.parse(d[x]) }
|
31
|
+
d['type'] = d['type'] ? 'fork' : 'source'
|
32
|
+
d
|
33
|
+
}.sort_by {|x| x['updated']}.reverse
|
34
|
+
|
35
|
+
|
36
|
+
def fmt_datetime(t)
|
37
|
+
t.strftime("%b %d %Y")
|
38
|
+
end
|
39
|
+
|
40
|
+
abort "No repositories found for #{user}" unless !res.empty?
|
41
|
+
|
42
|
+
longest_name_len = res.reduce(0) {|max, row| [max, row['name'].length].max }
|
43
|
+
|
44
|
+
placeholders = "%#{longest_name_len}s%6s%5s%4s%13s%13s%9s "
|
45
|
+
desc_length = `tput cols`.to_i - (placeholders.scan(/\d+/).map(&:to_i).reduce(0){|sum,x| sum+x} + 3)
|
46
|
+
placeholders += "%-#{desc_length}s"
|
47
|
+
|
48
|
+
# print headers
|
49
|
+
puts placeholders % res[0].keys
|
50
|
+
|
51
|
+
res.each {|r|
|
52
|
+
%w( updated pushed ).each {|x| r[x] = r[x] && fmt_datetime(r[x]) }
|
53
|
+
r['desc'] = truncate(r['desc'], desc_length)
|
54
|
+
puts placeholders % r.values
|
55
|
+
}
|
data/gitfinger.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "gitfinger"
|
6
|
+
s.version = '0.0.1'
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.required_ruby_version = '>= 1.9.0'
|
9
|
+
|
10
|
+
s.authors = ["Daniel Choi"]
|
11
|
+
s.email = ["dhchoi@gmail.com"]
|
12
|
+
s.homepage = "http://gitihub.com/danchoi/gitfinger"
|
13
|
+
s.summary = %q{Finger GitHub users}
|
14
|
+
s.description = %q{Finger GitHub users}
|
15
|
+
|
16
|
+
s.rubyforge_project = "gitfinger"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_dependency 'octokit', '~> 0.6'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitfinger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniel Choi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-24 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: octokit
|
16
|
+
requirement: &70231540634480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.6'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70231540634480
|
25
|
+
description: Finger GitHub users
|
26
|
+
email:
|
27
|
+
- dhchoi@gmail.com
|
28
|
+
executables:
|
29
|
+
- gitfinger
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- Rakefile
|
36
|
+
- bin/gitfinger
|
37
|
+
- gitfinger.gemspec
|
38
|
+
homepage: http://gitihub.com/danchoi/gitfinger
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.9.0
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project: gitfinger
|
58
|
+
rubygems_version: 1.8.10
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Finger GitHub users
|
62
|
+
test_files: []
|