Class/Module Index [+]

Quicksearch

Merb::BootLoader::Dependencies

Public Class Methods

enable_json_gem() click to toggle source

Requires json or json_pure.

Returns

nil

:api: private

# File lib/merb-core/bootloader.rb, line 414
def self.enable_json_gem
  require "json"
  rescue LoadError
      Merb.logger.error! "You have enabled JSON but don't have json "                             "installed or don't have dependency in the Gemfile. "                             "Add \"gem 'json', '>= 1.1.7'\" or "                             "\"gem 'json_pure', '>= 1.1.7'\" to your Gemfile."
end
load_dependencies() click to toggle source

Try to load the gem environment file (set via Merb::Config) defaults to ./gems/environment

Load each the dependencies defined in the Merb::Config using the bundler gem's Bundler::require_env

Falls back to rubygems if no bundler environment exists

Returns

nil

:api: private

# File lib/merb-core/bootloader.rb, line 398
def self.load_dependencies
  begin
    Bundler.require(:default, Merb.environment.to_sym)
  rescue Bundler::GemfileNotFound
    Merb.logger.error! "No Gemfile found! If you're generating new app with merb-gen "                           "this is fine, otherwise run: bundle init to create Gemfile"
  end
  nil
end
run() click to toggle source

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 and any after_app_loads hooks.

Dependencies are loaded via Bunlder and managed in the Gemfile manifest. By default manifest for Bundler is in the root directory of the app and is called Gemfile. All dependencies MUST be definied there because all dependency hangling was removed from Merb.

Deprecated (1.0.x)

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

:api: plugin

# File lib/merb-core/bootloader.rb, line 373
def self.run
  set_encoding
  load_dependencies
  unless Merb::disabled?(:initfile)
    load_initfile
    load_env_config
  end
  expand_ruby_path
  enable_json_gem unless Merb::disabled?(:json)
  update_logger
  nil
end
set_encoding() click to toggle source

Default encoding to UTF8 if it has not already been set to something else.

Returns

nil

:api: private

# File lib/merb-core/bootloader.rb, line 458
def self.set_encoding
  unless RUBY_VERSION >= '1.9'
    $KCODE = 'UTF8' if $KCODE == 'NONE' || $KCODE.blank?
  end
  
  nil
end
update_logger() click to toggle source

Resets the logger and sets the log_stream to Merb::Config if one is specified, falling back to STDOUT.

Returns

nil

:api: private

# File lib/merb-core/bootloader.rb, line 430
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]
    log_file = Merb::Config[:log_file]
    raise "log file should be a string, got: #{log_file.inspect}" unless log_file.is_a?(String)
    STDOUT.puts "Logging to file at #{log_file}" unless Merb.testing?
    
    # try to create log directory (if it doesnt exist)
    log_directory = File.dirname(log_file)
    FileUtils.mkdir_p(log_directory) unless File.exists?(log_directory)

    Merb::Config[:log_stream] = File.open(log_file, "a")
  # but if it's not given, fallback to log stream or stdout
  else
    Merb::Config[:log_stream] ||= STDOUT
  end

  nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.