Sha256: 9edc0e47bd849d67ada284881f0eaa1d03665ce144646f06d9c06ace77fe5dfa

Contents?: true

Size: 885 Bytes

Versions: 3

Compression:

Stored size: 885 Bytes

Contents

if ENV['DEADWEIGHT'] == 'true'
  require 'deadweight'
  require 'deadweight/hijack'
  require 'deadweight/rack/capturing_middleware'

  class Deadweight
    module Hijack
      module Rails
        class Railtie < ::Rails::Railtie
          initializer "deadweight.hijack" do |app|
            root = ::Rails.root

            original_stdout, original_stderr = Deadweight::Hijack.redirect_output(root + 'log/test_')

            dw = Deadweight.new

            dw.root        = root + 'public'
            dw.stylesheets = Dir.chdir(dw.root) { Dir.glob("stylesheets/*.css") }
            dw.log_file    = original_stderr

            dw.reset!

            at_exit do
              dw.report
              dw.dump(original_stdout)
            end

            app.middleware.insert(0, Deadweight::Rack::CapturingMiddleware, dw)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deadweight-0.2.2 lib/deadweight/hijack/rails.rb
deadweight-0.2.1 lib/deadweight/hijack/rails.rb
deadweight-0.2.0 lib/deadweight/hijack/rails.rb