Sha256: cd17f71d609115756c26008f2beeb7556dbd0571fa33e95f52f892adee33e489

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

# encoding: utf-8

# dependencies
require "rack"

# imports
require "rango/project"
require "rango/rack/request"
require "rango/router"

# === Boot sequence:
# 1) logger
# 2) Project
# 3) init & dependencies (we must load the plugins before they will be configured)
# 4) settings

# project
module Rango
  class << self
    # @since 0.0.1
    # @return [String] Returns current environment name. Possibilities are +development+ or +production+.
    attribute :environment, "development"
  end
end

# The only file which Rango really requires is init.rb,
# where is expected that you setup database connection,
# require gems etc. However if you really want to, you
# can bypass loading of init.rb and ORM setup.
# This is useful mostly for one file applications

module Rango
  class BootLoader
    def load_settings
      begin
        Project.logger.info("Reading settings")
        Project.import_first(["settings", "config/settings"], soft: true)
      rescue LoadError
        Rango.logger.fatal("settings.rb wasn't found or it cause another LoadError.")
        exit 1
      end

      # settings_local.rb
      Project.import_first(["settings_local", "config/settings_local"], soft: true, verbose: false)
    end

    def setup_orm
      if orm = Project.settings.orm
        unless Rango.import("orm/adapters/#{orm}/setup", soft: true, verbose: false)
          Project.logger.error("ORM #{orm} isn't supported. You will need to setup your database connection manually.")
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rango-0.1.0 lib/rango/boot.rb
rango-0.0.6 lib/rango/boot.rb
rango-0.1.pre lib/rango/boot.rb