vain 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/vain +7 -0
- data/lib/vain/cli.rb +57 -0
- data/lib/vain/version.rb +5 -0
- data/lib/vain.rb +4 -0
- metadata +113 -0
data/bin/vain
ADDED
data/lib/vain/cli.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
module Vain
|
2
|
+
|
3
|
+
class CLI
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'columnizer'
|
7
|
+
require 'hubruby'
|
8
|
+
|
9
|
+
# Some colors used in the output
|
10
|
+
NameColor = "\e[33m"
|
11
|
+
CommandColor = "\e[36m"
|
12
|
+
DefaultColor = "\e[0m"
|
13
|
+
ErrorColor = "\e[31m"
|
14
|
+
|
15
|
+
# Get the commands from the command line
|
16
|
+
# (Somewhat primitive, will be expanded) TODO
|
17
|
+
def start
|
18
|
+
ARGV.length == 1 ? status(ARGV[0]) : help
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def status(user_handle)
|
24
|
+
user = GitHub.user(user_handle)
|
25
|
+
return failtown("Unknown user: #{user_handle}") if user.login.nil?
|
26
|
+
puts "#{CommandColor}#{user.login}#{DefaultColor} - #{user.followers_count} followers"
|
27
|
+
# get the repositories sorted by watcher count
|
28
|
+
repositories = user.repositories.sort_by { |r| 1.0 / r.watchers }
|
29
|
+
data = repositories.map do |repo|
|
30
|
+
[
|
31
|
+
NameColor + repo.name + DefaultColor,
|
32
|
+
' ',
|
33
|
+
"#{repo.watchers} watchers",
|
34
|
+
"#{repo.forks} forks",
|
35
|
+
ErrorColor + (repo.fork ? '(FORK)' : '')
|
36
|
+
]
|
37
|
+
end
|
38
|
+
puts Columnizer.columnize(data, :padding => 3)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Display help section
|
42
|
+
def help(*args)
|
43
|
+
puts "#{NameColor}vain#{DefaultColor} by John Crepezzi <john.crepezzi@gmail.com>"
|
44
|
+
puts 'http://github.com/seejohnrun/vain'
|
45
|
+
puts
|
46
|
+
puts "#{CommandColor}vain handle#{DefaultColor} View account info"
|
47
|
+
end
|
48
|
+
|
49
|
+
# Show error message with help below it
|
50
|
+
def failtown(message = nil)
|
51
|
+
puts "#{ErrorColor}Uh-oh! #{message}#{DefaultColor}\n" if message
|
52
|
+
help
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/lib/vain/version.rb
ADDED
data/lib/vain.rb
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vain
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- John Crepezzi
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-04 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hubruby
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: columnizer
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - "="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 25
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
- 0
|
61
|
+
- 3
|
62
|
+
version: 0.0.3
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
65
|
+
description: View information about a GitHub account
|
66
|
+
email: john@crepezzi.com
|
67
|
+
executables:
|
68
|
+
- vain
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files: []
|
72
|
+
|
73
|
+
files:
|
74
|
+
- lib/vain/cli.rb
|
75
|
+
- lib/vain/version.rb
|
76
|
+
- lib/vain.rb
|
77
|
+
- bin/vain
|
78
|
+
has_rdoc: true
|
79
|
+
homepage: http://github.com/seejohnrun/vain/
|
80
|
+
licenses: []
|
81
|
+
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
105
|
+
requirements: []
|
106
|
+
|
107
|
+
rubyforge_project: vain
|
108
|
+
rubygems_version: 1.3.7
|
109
|
+
signing_key:
|
110
|
+
specification_version: 3
|
111
|
+
summary: GitHub account info
|
112
|
+
test_files: []
|
113
|
+
|