Class: Vedeu::Runtime::Bootstrap Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Parameters:

  • argv (Array<String>)


27
28
29
# File 'lib/vedeu/runtime/bootstrap.rb', line 27

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#argvArray<String> (readonly, protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<String>)


48
49
50
# File 'lib/vedeu/runtime/bootstrap.rb', line 48

def argv
  @argv
end

Class Method Details

.start(argv = ARGV) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

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


19
20
21
# File 'lib/vedeu/runtime/bootstrap.rb', line 19

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

Instance Method Details

#base_pathString (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


53
54
55
# File 'lib/vedeu/runtime/bootstrap.rb', line 53

def base_path
  Vedeu.config.base_path
end

#client_application!void (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



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

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)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

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

This method returns an undefined value.



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

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 is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



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

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)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


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

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 is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



115
116
117
118
119
# File 'lib/vedeu/runtime/bootstrap.rb', line 115

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

#load(path) ⇒ String (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Load each of the loadable files.

Parameters:

  • path (String)

Returns:

  • (String)


96
97
98
99
100
# File 'lib/vedeu/runtime/bootstrap.rb', line 96

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

  path
end

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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>)


108
109
110
111
112
# File 'lib/vedeu/runtime/bootstrap.rb', line 108

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

#startvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.



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

def start
  configure_log!
  client_configuration!
  client_application!
  client_initialize!

  Vedeu::Launcher.execute!(argv)
end