Sha256: f09c6cbc5da25244eec91485ec700713de657f56bd3907ba454378d0eeeadd2b

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

module Mack
  module Utils

    # Houses a registry of Rack runners that should be called before the Mack::Runner.
    class RunnersRegistry < Mack::Utils::RegistryList
    end

    module Server

      # This method wraps all the necessary components of the Rack system around
      # Mack::Runner. This can be used build your own server around the Mack framework.
      def self.build_app
        # Mack framework:
        app = Mack::Runner.new

        Mack::Utils::RunnersRegistry.registered_items.each do |runner|
          app = runner.new(app)
        end

        # Any urls listed will go straight to the public directly and will not be served up via the app:
        app = Rack::Static.new(app, :urls => ["/css", "/images", "/files", "/images", "/stylesheets", "/javascripts", "/media", "/favicon.ico"], :root => "public")
        app = Mack::Utils::ContentLengthHandler.new(app)
        app = Rack::Lint.new(app) if app_config.mack.use_lint 
        app = Rack::ShowStatus.new(app) 
        app = Rack::ShowExceptions.new(app) if app_config.mack.show_exceptions
        app = Rack::Recursive.new(app)
        
        # This will reload any edited classes if the cache_classes config setting is set to true.
        app = Rack::Reloader.new(app, 1) unless app_config.mack.cache_classes
        app
      end

    end # Server
  end # Utils
end # Mack

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mack-0.7.1.1 lib/mack/utils/server.rb
mack-0.7.1 lib/mack/utils/server.rb