Sha256: 3981eb4562029b84f8f298fc44953ee588449849c81858880f6484bb08629fdc

Contents?: true

Size: 453 Bytes

Versions: 6

Compression:

Stored size: 453 Bytes

Contents

require 'rack'

module Rail
  class Browser
    extend Forwardable

    def_delegator :@host, :root
    def_delegator :@directory, :call

    def initialize(host)
      @host = host
      @directory ||= Rack::Directory.new(File.join(root, 'public'))
    end

    def process(request)
      call(request.env)
    end

    def accept?(request)
      path = request.path
      !path.empty? && File.exist?(File.join(root, 'public', path))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rail-0.0.7 lib/rail/browser.rb
rail-0.0.6 lib/rail/browser.rb
rail-0.0.5 lib/rail/browser.rb
rail-0.0.4 lib/rail/browser.rb
rail-0.0.3 lib/rail/browser.rb
rail-0.0.2 lib/rail/browser.rb