class Rack::StaticBuilder::RequestPathQueue

Public Class Methods

new() click to toggle source
# File lib/rack/static-builder.rb, line 14
def initialize
  @active = nil
  @queue = ['/']
  @seen = {}
end

Public Instance Methods

'<<'(url)
Alias for: enqueue
drain() { |path| ... } click to toggle source
# File lib/rack/static-builder.rb, line 34
def drain
  while path = @queue.shift
    @seen[path] ||= (yield(path); true)
  end
end
enqueue(url) click to toggle source
# File lib/rack/static-builder.rb, line 20
def enqueue(url)
  path = URI.parse(url).path

  # discard URNs like data: and magnet:
  return false unless path

  if path[0] != '/'
    path = URI.parse( (@active || '/').sub(/\/[^\/]*$/, '') + '/' + path ).path
  end

  @queue << path
end
Also aliased as: '<<'