Module: RutemaWeb

Defined in:
lib/rutema_web/main.rb,
lib/rutema_web/sinatra.rb

Overview

This is the web frontend for Rutema databases.

Defined Under Namespace

Modules: UI, Version

Class Method Summary collapse

Class Method Details

.parse_command_line(args) ⇒ Object

Parses the command line arguments



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rutema_web/main.rb', line 30

def self.parse_command_line args
  args.options do |opt|
    opt.on("Usage:")  
    opt.on("rutema_web [options] config_file")
    opt.on("Options:")
    opt.on("--debug", "-d","Turns on debug messages") { $DEBUG=true }
    opt.on("-v", "--version","Displays the version") { $stdout.puts("v#{Version::STRING}");exit 0 }
    opt.on("--help", "-h", "-?", "This text") { $stdout.puts opt; exit 0 }
    opt.parse!
    #and now the rest
    if args.empty?
      $stdout.puts opt 
      exit 0
    else
      return args.shift
    end
  end
end

.startObject

Starts App



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rutema_web/main.rb', line 16

def self.start
  logger=Patir.setup_logger
  cfg_file=parse_command_line(ARGV)
  cfg_file=File.expand_path(cfg_file)
  configuration=YAML.load_file(cfg_file)
  if (configuration[:db])
    Rutema::ActiveRecord.connect(configuration[:db],logger)
    RutemaWeb::UI::SinatraApp.define_settings(configuration[:settings])
    RutemaWeb::UI::SinatraApp.run!
  else
    logger.fatal("No database configuration information found in #{cfg_file}")
  end
end