0.0
No commit activity in last 3 years
No release in over 3 years
This rubygem does not have a description or summary.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.10
>= 10.0

Runtime

>= 1.6
 Project Readme

Spine::Engines

Gem Version Dependency Status Code Climate security Inline docs

Starting point for your Rack application and its configurations.

Installation

To install it, add the gem to your Gemfile:

gem 'spine-engines'

Then run bundle. If you're not using Bundler, just gem install spine-engines.

Usage

Define your application and configuration:

# lib/my_app/application.rb

module MyApp
  module Application
    extend Spine::Engines::Application
    extend self

    # Add loaders
    loaders << Spine::Engines::Loaders::LoadPaths
    loaders << Spine::Engines::Loaders::EnvironmentConfiguration
    loaders << Spine::Engines::Loaders::Initializers

    # Add extensions
    extension Spine::Routing::Engine

    # Add your own extra configuration
    def active_record
      ::ActiveRecord::Base
    end
  end
end

Define your shared configuration between environments. You can define environment specific configurations in config/environments/evironment_name.rb.

# config/environment.rb

require File.expand_path('../boot', __FILE__)

environment = ENV['RACK_ENV'] || 'development'
Bundler.require(:default, environment)

require File.expand_path('../../lib/my_app/application', __FILE__)

MyApp::Application.configure do |config|
  config.environment = environment
  config.root = File.expand_path('../..', __FILE__)

  config.load_paths! %w(
    lib/my_app/**/*.rb
  )

  # Middlewares
  config.middleware.use Rack::Lock
  config.middleware.use Rack::Runtime
  config.middleware.use Rack::MethodOverride
  config.middleware.use Rack::CommonLogger, config.logger
  config.middleware.use Rack::Head
  config.middleware.use Rack::ConditionalGet
  config.middleware.use Rack::ETag
end

MyApp::Application.initialize!

Add Bundler to boot:

# config/boot.rb

require 'rubygems'

# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
  ENV['BUNDLE_GEMFILE'] = gemfile
  require 'bundler'
  Bundler.setup
rescue Bundler::GemNotFound => e
  STDERR.puts e.message
  STDERR.puts "Try running `bundle install`."
  exit!
end if File.exist?(gemfile)

Configuring Rack to use this application:

# config.ru

require ::File.expand_path('../config/environment',  __FILE__)
run MyApp::Application