Module: Godwit::Bootloader

Defined in:
lib/godwit/bootloader.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.bootedObject

Returns the value of attribute booted.



6
7
8
# File 'lib/godwit/bootloader.rb', line 6

def booted
  @booted
end

Class Method Details

.boot(argv = ARGV) ⇒ Object

:nodoc:



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/godwit/bootloader.rb', line 8

def boot(argv=ARGV) #:nodoc:
  return if booted?
  load_config(argv)
  display_init unless Godwit::Config[:silence]
  load_rails
  set_load_path
  set_logger
  init_db
  init_am
  load_plugins
  @booted = true
end

.booted?Boolean

:nodoc:

Returns:

  • (Boolean)


27
28
29
# File 'lib/godwit/bootloader.rb', line 27

def booted? #:nodoc:
  @booted ||= false
end

.display_initObject

:nodoc:



21
22
23
24
25
# File 'lib/godwit/bootloader.rb', line 21

def display_init #:nodoc:
  system('clear')
  Godwit::Buffer.puts "Godwit " + Godwit::VERSION::STRING
  Godwit::Buffer.puts "\nInitializaing..."
end

.init_amObject

:nodoc:



66
67
68
# File 'lib/godwit/bootloader.rb', line 66

def init_am #:nodoc:
  ActiveMigration::KeyMapper.storage_path = Godwit::Config[:key_mapper_path]
end

.init_dbObject

:nodoc:



60
61
62
63
64
# File 'lib/godwit/bootloader.rb', line 60

def init_db #:nodoc:
  db_conf = YAML::load(File.open(File.join(Godwit::Config[:godwit_root], 'config', 'database.yml')))
  LegacyRecord::Base.establish_connection(db_conf['legacy'])
  ActiveRecord::Base.establish_connection(db_conf['active']) if Godwit::Config[:rails_root].nil?
end

.load_config(argv = ARGV) ⇒ Object

:nodoc:



37
38
39
40
41
# File 'lib/godwit/bootloader.rb', line 37

def load_config(argv=ARGV) #:nodoc:
  Godwit::Config.setup
  require File.join(Godwit::Config[:godwit_root], 'config', 'environment.rb')
  Godwit::Config.parse_args(argv)
end

.load_pluginsObject

:nodoc:



70
71
72
73
74
# File 'lib/godwit/bootloader.rb', line 70

def load_plugins #:nodoc:
  Dir[File.join(Godwit::Config[:godwit_root], 'vendor', 'plugins', '*', 'init.rb')].each do |init|
    require init
  end
end

.load_railsObject

:nodoc:



31
32
33
34
35
# File 'lib/godwit/bootloader.rb', line 31

def load_rails #:nodoc:
  unless Godwit::Config[:rails_root].nil?
    require "#{Godwit::Config[:rails_root]}/config/environment"
  end
end

.set_load_pathObject

:nodoc:



43
44
45
46
47
48
49
50
51
# File 'lib/godwit/bootloader.rb', line 43

def set_load_path #:nodoc:
  $:.concat [File.join(Godwit::Config[:godwit_root], 'app', 'models'),
             File.join(Godwit::Config[:godwit_root], 'app', 'migrations'),
             File.join(Godwit::Config[:godwit_root], 'lib')]
  Dir[File.join(Godwit::Config[:godwit_root], 'vendor', 'plugins', '*', 'lib')].each do |dir|
    $:.push dir
  end
  ActiveSupport::Dependencies.load_paths.concat $:           
end

.set_loggerObject

:nodoc:



53
54
55
56
57
58
# File 'lib/godwit/bootloader.rb', line 53

def set_logger #:nodoc:
  ActiveRecord::Base.logger = Godwit::Config[:active_record_log]
  ActiveRecord::Base.logger.level = Godwit::Config[:active_record_log_level]
  ActiveMigration::Base.logger = Godwit::Config[:active_migration_log]
  ActiveMigration::Base.logger.level = Godwit::Config[:active_migration_log_level]
end