Sha256: aef9e61211addd877be31c9f4ac7f231856ef4303640c71fa39486dd138e9858

Contents?: true

Size: 512 Bytes

Versions: 34

Compression:

Stored size: 512 Bytes

Contents

# must be run without Rack::Lint since that clobbers to_path
class Wrapper < Struct.new(:app)
  def call(env)
    status, headers, body = app.call(env)
    body = Body.new(body) if body.respond_to?(:to_path)
    [ status, headers, body ]
  end

  class Body < Struct.new(:body)
    def to_path
      body.to_path
    end

    def each(&block)
      body.each(&block)
    end

    def close
      ::File.open(ENV['fifo'], 'wb') { |fp| fp.puts "CLOSING" }
    end
  end
end
use Wrapper
run Rack::File.new(Dir.pwd)

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
rainbows-5.2.1 t/file-wrap-to_path.ru
rainbows-5.2.0 t/file-wrap-to_path.ru
rainbows-5.1.1 t/file-wrap-to_path.ru
rainbows-5.1.0 t/file-wrap-to_path.ru
rainbows-5.0.0.5.ge717 t/file-wrap-to_path.ru
rainbows-5.0.0 t/file-wrap-to_path.ru
rainbows-4.7.0 t/file-wrap-to_path.ru
rainbows-4.6.2 t/file-wrap-to_path.ru
rainbows-4.6.1 t/file-wrap-to_path.ru
rainbows-4.6.0.4.g4108 t/file-wrap-to_path.ru
rainbows-4.6.0 t/file-wrap-to_path.ru
rainbows-4.5.0 t/file-wrap-to_path.ru
rainbows-4.4.3 t/file-wrap-to_path.ru
rainbows-4.4.2 t/file-wrap-to_path.ru
rainbows-4.4.1.1.gd5c8c t/file-wrap-to_path.ru
rainbows-4.4.1 t/file-wrap-to_path.ru
rainbows-4.4.0 t/file-wrap-to_path.ru
rainbows-4.3.1 t/file-wrap-to_path.ru
rainbows-4.3.0 t/file-wrap-to_path.ru
rainbows-4.2.0 t/file-wrap-to_path.ru