Class: Merb::BootLoader::Dependencies
- Inherits:
-
Merb::BootLoader
- Object
- Merb::BootLoader
- Merb::BootLoader::Dependencies
- Defined in:
- lib/merb-core/bootloader.rb
Class Method Summary collapse
-
.enable_json_gem ⇒ Object
Loads json or json_pure and requires it.
-
.load_dependencies ⇒ Object
private
Load each dependency that has been declared so far.
-
.run ⇒ Object
Load the init_file specified in Merb::Config or if not specified, the init.rb file from the Merb configuration directory, and any environment files, which register the list of necessary dependencies and any after_app_loads hooks.
-
.set_encoding ⇒ Object
private
Default encoding to UTF8 if it has not already been set to something else.
-
.update_logger ⇒ Object
private
Resets the logger and sets the log_stream to Merb::Config if one is specified, falling back to STDOUT.
Methods inherited from Merb::BootLoader
after, after_app_loads, before, before_app_loads, default_framework, finished?, inherited, move_klass
Class Method Details
.enable_json_gem ⇒ Object
Loads json or json_pure and requires it.
Returns
nil
379 380 381 382 383 384 385 |
# File 'lib/merb-core/bootloader.rb', line 379 def self.enable_json_gem gem "json" require "json/ext" rescue LoadError gem "json_pure" require "json/pure" end |
.load_dependencies ⇒ Object
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 dependency that has been declared so far.
Returns
nil
370 371 372 373 |
# File 'lib/merb-core/bootloader.rb', line 370 def self.load_dependencies dependencies.each { |dependency| Kernel.load_dependency(dependency) } nil end |
.run ⇒ Object
Load the init_file specified in Merb::Config or if not specified, the init.rb file from the Merb configuration directory, and any environment files, which register the list of necessary dependencies and any after_app_loads hooks.
Dependencies can hook into the bootloader process itself by using before or after insertion methods. Since these are loaded from this bootloader (Dependencies), they can only adapt the bootloaders that haven’t been loaded up until this point.
Returns
nil
349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/merb-core/bootloader.rb', line 349 def self.run set_encoding # this is crucial: load init file with all the preferences # then environment init file, then start enabling specific # components, load dependencies and update logger. unless Merb::disabled?(:initfile) load_initfile load_env_config end enable_json_gem unless Merb::disabled?(:json) load_dependencies update_logger nil end |
.set_encoding ⇒ Object
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.
Default encoding to UTF8 if it has not already been set to something else.
Returns
nil
416 417 418 419 |
# File 'lib/merb-core/bootloader.rb', line 416 def self.set_encoding $KCODE = 'UTF8' if $KCODE == 'NONE' || $KCODE.blank? nil end |
.update_logger ⇒ Object
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.
Resets the logger and sets the log_stream to Merb::Config if one is specified, falling back to STDOUT.
Returns
nil
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/merb-core/bootloader.rb', line 394 def self.update_logger Merb.reset_logger! # If log file is given, use it and not log stream we have. if Merb::Config[:log_file] raise "log file should be a string, got: #{Merb::Config[:log_file].inspect}" unless Merb::Config[:log_file].is_a?(String) STDOUT.puts "Logging to file at #{Merb::Config[:log_file]}" unless Merb.testing? Merb::Config[:log_stream] = File.open(Merb::Config[:log_file], "w+") # but if it's not given, fallback to log stream or stdout else Merb::Config[:log_stream] ||= STDOUT end nil end |