Class: Vedeu::Runtime::Bootstrap

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/runtime/bootstrap.rb

Overview

Provides the mechanism to start up a generated application.

This class loads all necessary client application files and initializes Vedeu with this data, then starts the client application.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Vedeu::Runtime::Bootstrap

Returns a new instance of Vedeu::Runtime::Bootstrap.

Parameters:

  • argv (Array<String>)


25
26
27
# File 'lib/vedeu/runtime/bootstrap.rb', line 25

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#argvArray<String> (readonly, protected)

Returns:

  • (Array<String>)


46
47
48
# File 'lib/vedeu/runtime/bootstrap.rb', line 46

def argv
  @argv
end

Class Method Details

.start(argv = ARGV) ⇒ void

This method returns an undefined value.

Parameters:

  • argv (Array<String>) (defaults to: ARGV)


17
18
19
# File 'lib/vedeu/runtime/bootstrap.rb', line 17

def self.start(argv = ARGV)
  new(argv).start
end

Instance Method Details

#base_pathString (private)

Returns:

  • (String)


51
52
53
# File 'lib/vedeu/runtime/bootstrap.rb', line 51

def base_path
  Vedeu.config.base_path
end

#client_application!void (private)

This method returns an undefined value.



68
69
70
71
72
73
74
75
76
77
# File 'lib/vedeu/runtime/bootstrap.rb', line 68

def client_application!
  [
    'app/views/templates/**/*',
    'app/views/interfaces/**/*',
    'app/controllers/**/*',
    'app/helpers/**/*',
    'app/views/**/*',
    'app/models/keymaps/**/*',
  ].each { |path| load(File.join(base_path, path)) }
end

#client_configuration!void (private)

Note:

config/configuration.rb is already loaded so don’t load it twice.

This method returns an undefined value.



59
60
61
62
63
64
65
# File 'lib/vedeu/runtime/bootstrap.rb', line 59

def client_configuration!
  Dir[File.join(base_path, 'config/**/*')].each do |path|
    next if path =~ %r{config/configuration\.rb}

    load(path)
  end
end

#client_initialize!void (private)

This method returns an undefined value.



80
81
82
83
84
85
86
87
88
# File 'lib/vedeu/runtime/bootstrap.rb', line 80

def client_initialize!
  if Vedeu.config.root
    Vedeu.trigger(:_goto_, *Vedeu.config.root)

  else
    Vedeu.log_stderr(message: client_initialize_error)

  end
end

#client_initialize_errorString (private)

Returns:

  • (String)


120
121
122
123
124
125
126
127
# File 'lib/vedeu/runtime/bootstrap.rb', line 120

def client_initialize_error
  "Please update the 'root' setting in " \
  "'config/configuration.rb' to start Vedeu using this " \
  "controller and action: (args are optional)\n\n" \
  "Vedeu.configure do\n" \
  "  root :some_controller, :show, *args\n" \
  "end\n\n"
end

#configure_log!void (private)

This method returns an undefined value.



113
114
115
116
117
# File 'lib/vedeu/runtime/bootstrap.rb', line 113

def configure_log!
  Vedeu.configure do
    log('/tmp/vedeu_bootstrap.log')
  end unless Vedeu.config.log?
end

#load(path) ⇒ String (private)

Load each of the loadable files.

Parameters:

  • path (String)

Returns:

  • (String)


94
95
96
97
98
# File 'lib/vedeu/runtime/bootstrap.rb', line 94

def load(path)
  loadables(path).each { |file| Kernel.load(file) }

  path
end

#loadables(path) ⇒ Array<String> (private)

Collect each of the files from the client application directories by path excluding ‘.’ and ‘..’ and only loading files with the ‘.rb’ extension.

Parameters:

  • path (String)

Returns:

  • (Array<String>)


106
107
108
109
110
# File 'lib/vedeu/runtime/bootstrap.rb', line 106

def loadables(path)
  Dir.glob(path).select do |file|
    File.file?(file) && File.extname(file) == '.rb'
  end
end

#startvoid

This method returns an undefined value.

Loads all of the client application files so that Vedeu has access to them, then launches the client application.



33
34
35
36
37
38
39
40
# File 'lib/vedeu/runtime/bootstrap.rb', line 33

def start
  configure_log!
  client_configuration!
  client_application!
  client_initialize!

  Vedeu::Launcher.execute!(argv)
end