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

.scaffolding(target_dir) ⇒ Object

Creates the scaffolding for a new rutema_web instance



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

def self.scaffolding target_dir
  if File.exists?(target_dir)
    unless File.directory?(target_dir)
     puts "FATAL: '#{target_dir}' exists but is not a directory"
    exit 1
    end
  else
    FileUtils.mkdir_p(target_dir)
  end
  gemfile=File.join(File.dirname(__FILE__),'../../Gemfile')
  config=File.join(File.dirname(__FILE__),'../../examples/rutema_web.yaml')
  FileUtils.cp(config,target_dir,:verbose=>false)
  FileUtils.cp(gemfile,target_dir,:verbose=>false)
  puts "Done!"
  puts "You should now do\n\tbundle install\n\trutema_web\nto start "
end

.start(cfg_file) ⇒ Object

Starts App



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

def self.start(cfg_file)
  logger=Patir.setup_logger
  if File.exists?(cfg_file)
    Dir.chdir(File.dirname(cfg_file)) do
      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
  else
    logger.fatal("Could not find rutema_web.yaml")
  end
end