Class: Svn::Log::Application

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

Overview

The main program

Defined Under Namespace

Classes: HelpCommand, IndexCommand, InfoCommand, SearchCommand

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ Application

Returns a new instance of Application.



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

def initialize(argv = ARGV)
  @argv = argv
end

Class Method Details

.commandsObject

Returns a list of the available commands



40
41
42
43
44
45
46
47
48
# File 'lib/svnlog.rb', line 40

def self.commands
  commands = {}
  Application.constants.each do |c|
    if c =~ /(.+)Command/
      commands[$1.downcase] = eval(c)
    end
  end
  commands
end

Instance Method Details

#create_command(argv) ⇒ Object

Creates the command



29
30
31
32
33
34
35
36
37
# File 'lib/svnlog.rb', line 29

def create_command(argv)
  command = nil
  name = argv[0]
  if name
    command = Application.commands[name.downcase]
  end
  command ||= HelpCommand
  command.new(argv)
end

#runObject

Run the program



20
21
22
23
24
25
26
# File 'lib/svnlog.rb', line 20

def run
  begin
    create_command(@argv).run
  rescue
    puts $!
  end
end