-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreputation.rb
58 lines (43 loc) · 983 Bytes
/
reputation.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
libdir = File.dirname(__FILE__)
$LOAD_PATH.unshift(libdir)
require 'services/base'
Dir[libdir+'/services/**/*.rb'].each{|s| require s}
module Reputation
extend self
def self.run(args = ARGV)
unless ARGV.size == 2
puts(usage)
exit
end
service_name = args.first
account = args.last
begin
@service = Service.class_for(service_name).new(account)
rescue NameError
puts "Err: No service named '#{service_name}' found!"
puts usage
exit
end
puts(<<-RESULT.trim)
Account '#{account}' on #{@service}
#{@service.render_items}
RESULT
end
def self.usage()<<-USAGE.trim
Usage:
#{$0} <service> <account-name>
Supported services:
- github
- twitter
- youtube
USAGE
end
end
class String
def camelize
self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end
def trim
self.gsub(/^ +/, '')
end
end