Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Bootloading

ngollan edited this page · 2 revisions

The Merb boot process starts when you run the Merb binary, which calls Merb.start; that performs the following tasks:

  • Loads merb.yml from the root directory or config directory and puts them in the Merb::Config hash
  • Parses config arguments from the command-line and adds them to the Merb::Config hash
  • Runs the BootLoaders (see below)
  • Starts the Merb Rack adapter

The BootLoader is a configurable process, which, by default, runs the following processes:

  1. Environment: Sets the Merb environment based on any -e flag passed the merb binary
  2. BuildFramework: Set the framework paths, which can either be set in the Merb::Config[:framework] variable or defaults to the paths described below.
  3. Dependencies: Load dependencies.rb, which should include any plugins that will be loaded, as well as an after_app_loaded hook.
  4. Logger: Set up the logger in the Merb.dir_for(:log) directory. In test mode, it will be called test_logger. In other modes, it will be set to merb.#{pid}.log. The log level will default to info but can be specified via the Merb::Config[:log_level] option.
  5. LoadRouter: The router is loaded from Merb.dir_for(:config)/router.rb.
  6. LoadClasses: Files in all of the load paths are required, and classes added during the load of each files are tracked so they can be removed later during the reloading process.
  7. Templates: All templates under the _template_root of any loaded controllers, as well as all templates under Merb.dir_for(:view) are registered as inlined templates.
  8. MimeTypes: Register all MimeTypes (see below for defaults).
  9. AfterAppLoads: Call any after_app_loads hooks that were registered in dependencies.rb
  10. MixinSessionContainer: Register the session types and set the app to use one if Merb::Config[:session_type] is set.
  11. ChooseAdapter: Set Merb.adapter to be the adapter chosen via Merb::Config:adapter.
  12. RackUpApplication: Set up a default rack application. Alternatively, allow for additional configuration in Merb.dir_for(:config)/rack.rb, which will be evaluated in the context of a Rack::Builder.new block. The application is available in Merb::Config[:app].
  13. ReloadClasses: If Merb::Config[:reload_classes] is set, begin the process of reloading classes every time a class is modified.

Default Framework Paths:

  • application: Merb.root/app/controller/application.rb
  • config: Merb.root/config
  • lib: Merb.root/lib
  • log: Merb.root/log
  • view: Merb.root/app/views
  • model: Merb.root/app/models
  • controller: Merb.root/app/controllers
  • helper: Merb.root/app/helpers
  • mailer: Merb.root/app/mailers
  • part: Merb.root/app/parts

Mime Types:

  • :all: no transform, /
  • :yaml: to_yaml, application/x-yaml or text/yaml
  • :text: to_text, text/plain
  • :html: to_html, text/html or application/xhtml+xml or application/html
  • :xml: to_xml, application/xml or text/xml or application/x-xml, adds "Encoding: UTF-8" response header
  • :js: to_json, text/javascript ot application/javascript or application/x-javascript
  • :json: to_json, application/json or text/x-json
Something went wrong with that request. Please try again.