Sha256: 310c8de702a33e9905822699f387a740a0a52570980ce7266d8ca0a7cd9e1bd3

Contents?: true

Size: 861 Bytes

Versions: 2

Compression:

Stored size: 861 Bytes

Contents

module Middleman::CoreExtensions::RackMap
  class << self
    def registered(app)
      app.extend ClassMethods
    end
    alias :included :registered
  end
  
  module ClassMethods
    def map(path, &block)
      @maps ||= []
      @maps << [path, block]
    end
  
    def maps
      @maps || []
    end
  
    # Creates a Rack::Builder instance with all the middleware set up and
    # an instance of this class as end point.
    def build(*args, &bk)
      builder = ::Rack::Builder.new
      builder.use ::Sinatra::ShowExceptions       if show_exceptions?
      builder.use ::Rack::CommonLogger   if logging?
      builder.use ::Rack::Head
      middleware.each { |c,a,b| builder.use(c, *a, &b) }
      maps.each { |p,b| builder.map(p, &b) }
      builder.map "/" do
        run Middleman::Server.new!(*args, &bk)
      end
      builder
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-2.0.0.rc3 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.0.rc2 lib/middleman/core_extensions/rack_map.rb