Class: Ramaze::Files

Inherits:
Object show all
Defined in:
lib/ramaze/files.rb

Overview

Serving multiple public directories made easy.

Instance Method Summary collapse

Constructor Details

#initialize(*roots) ⇒ Files

Returns a new instance of Files.



4
5
6
7
# File 'lib/ramaze/files.rb', line 4

def initialize(*roots)
  @roots = roots.flatten.map{|root| File.expand_path(root.to_s) }
  sync
end

Instance Method Details

#<<(path) ⇒ Object



13
14
15
16
17
# File 'lib/ramaze/files.rb', line 13

def <<(path)
  @roots << File.expand_path(path.to_s)
  @roots.uniq!
  sync
end

#call(env) ⇒ Object



9
10
11
# File 'lib/ramaze/files.rb', line 9

def call(env)
  @cascade.call(env)
end

#syncObject



19
20
21
22
# File 'lib/ramaze/files.rb', line 19

def sync
  file_apps = @roots.map{|root| Rack::File.new(root) }
  @cascade = Rack::Cascade.new(file_apps)
end