Class: UICov::Main

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

Constant Summary collapse

COMMANDS =
{
  gentpl: 'Generate coverage template file',
  gather: 'Gather coverage information from log file',
  report: 'Generate coverage report',
  merge: 'Merge coverage files',
}

Class Method Summary collapse

Class Method Details

.do_command(args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/uicov/main.rb', line 25

def self.do_command(args)
  if args.empty?
    usage "Command is not specified"
  else
    cmd_name = args[0]
    usage "Wrong command '#{cmd_name}'" unless COMMANDS.keys.include? cmd_name.to_sym
    class_type = UICov.const_get cmd_name.capitalize
    class_type.new.do_job args[1..-1]
  end
end

.usage(err_msg) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/uicov/main.rb', line 36

def self.usage(err_msg)
  msg = %Q^
    \rERROR: #{err_msg}\n
    \rUsage:
    \r\t#{$0} command [command_arguments]\n
    \rCommands are:
    #{COMMANDS.inject([]){|a, e| a << "\r\t#{e[0]}\t- #{e[1]}"; a}.join("\n")}
    
    \rTo see command usage run:
    \r\t#{$0} command\n
    \rFor instance:
    \r\t#{$0} gather\n
  ^
  Log.fatal msg
end