Class: Rack::StaticBuilder::RequestPathQueue
- Inherits:
-
Object
- Object
- Rack::StaticBuilder::RequestPathQueue
- Defined in:
- lib/rack/static-builder.rb
Instance Method Summary collapse
- #drain ⇒ Object
- #enqueue(url) ⇒ Object (also: #<<)
-
#initialize ⇒ RequestPathQueue
constructor
A new instance of RequestPathQueue.
Constructor Details
#initialize ⇒ RequestPathQueue
Returns a new instance of RequestPathQueue.
14 15 16 17 18 |
# File 'lib/rack/static-builder.rb', line 14 def initialize @active = nil @queue = ['/'] @seen = {} end |
Instance Method Details
#drain ⇒ Object
34 35 36 37 38 |
# File 'lib/rack/static-builder.rb', line 34 def drain while path = @queue.shift @seen[path] ||= (yield(path); true) end end |
#enqueue(url) ⇒ Object Also known as: <<
20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 |