Module: MailCatcher::Web

Extended by:
Web
Included in:
Web
Defined in:
lib/mail_catcher/web.rb,
lib/mail_catcher/web/assets.rb,
lib/mail_catcher/web/application.rb

Defined Under Namespace

Classes: Application

Constant Summary collapse

Assets =
Sprockets::Environment.new(File.expand_path("#{__FILE__}/../../../..")).tap do |sprockets|
  Dir["#{sprockets.root}/{,vendor}/assets/*"].each do |path|
    sprockets.append_path(path)
  end
end

Instance Method Summary collapse

Instance Method Details

#appObject


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mail_catcher/web.rb', line 7

def app
  @@app ||= Rack::Builder.new do
    map(MailCatcher.options[:http_path]) do
      if MailCatcher.development?
        require "mail_catcher/web/assets"
        map("/assets") { run Assets }
      end

      run Application
    end

    # This should only affect when http_path is anything but "/" above
    run lambda { |env| [302, {"Location" => MailCatcher.options[:http_path]}, []] }
  end
end

#call(env) ⇒ Object


23
24
25
# File 'lib/mail_catcher/web.rb', line 23

def call(env)
  app.call(env)
end