Class: Reponaut::Application::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/reponaut/command.rb

Direct Known Subclasses

Count, List

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prog) ⇒ Command

Returns a new instance of Command.



17
# File 'lib/reponaut/command.rb', line 17

def initialize(prog); end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



15
16
17
# File 'lib/reponaut/command.rb', line 15

def client
  @client
end

#reposObject (readonly)

Returns the value of attribute repos.



15
16
17
# File 'lib/reponaut/command.rb', line 15

def repos
  @repos
end

#usernameObject (readonly)

Returns the value of attribute username.



15
16
17
# File 'lib/reponaut/command.rb', line 15

def username
  @username
end

Class Method Details

.inherited(base) ⇒ Object



9
10
11
12
# File 'lib/reponaut/command.rb', line 9

def inherited(base)
  subclasses << base
  super
end

.subclassesObject



5
6
7
# File 'lib/reponaut/command.rb', line 5

def subclasses
  @subclasses ||= []
end

Instance Method Details

#process(options, args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/reponaut/command.rb', line 19

def process(options, args)
  raise ArgumentError.new('You must specify a username') if args.empty?
  @username = args.first
  @client = Reponaut::GitHub::Client.new(username)
  @repos = client.repos.reject { |r| r.language.nil? }
  @repos = @repos.find_all { |r| r.source? } if options['ignore_forks']
rescue Reponaut::GitHub::NoSuchUserError
  quit 4, "No such user: #{username}"
rescue Reponaut::GitHub::RateLimitExceededError
  quit 5, 'GitHub rate limit exceeded. Try your request again later.'
end

#quit(code, msg) ⇒ Object



31
32
33
34
# File 'lib/reponaut/command.rb', line 31

def quit(code, msg)
  $stderr.puts msg
  exit code
end