Class: Vedeu::Runtime::Bootstrap
- Inherits:
-
Object
- Object
- Vedeu::Runtime::Bootstrap
- 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
- #argv ⇒ Array<String> readonly protected
Class Method Summary collapse
Instance Method Summary collapse
- #base_path ⇒ String private
- #client_application! ⇒ void private
- #client_configuration! ⇒ void private
- #client_initialize! ⇒ void private
- #client_initialize_error ⇒ String private
- #configure_log! ⇒ void private
-
#initialize(argv) ⇒ Vedeu::Runtime::Bootstrap
constructor
Returns a new instance of Vedeu::Runtime::Bootstrap.
-
#load(path) ⇒ String
private
Load each of the loadable files.
-
#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.
-
#start ⇒ void
Loads all of the client application files so that Vedeu has access to them, then launches the client application.
Constructor Details
#initialize(argv) ⇒ Vedeu::Runtime::Bootstrap
Returns a new instance of Vedeu::Runtime::Bootstrap.
25 26 27 |
# File 'lib/vedeu/runtime/bootstrap.rb', line 25 def initialize(argv) @argv = argv end |
Instance Attribute Details
#argv ⇒ Array<String> (readonly, protected)
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.
17 18 19 |
# File 'lib/vedeu/runtime/bootstrap.rb', line 17 def self.start(argv = ARGV) new(argv).start end |
Instance Method Details
#base_path ⇒ String (private)
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)
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_error ⇒ String (private)
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.
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.
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 |
#start ⇒ void
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 |