Class: SimpleCataloger::WebServer

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/dircat/server/web_server.rb

Class Method Summary collapse

Class Method Details

.run!(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dircat/server/web_server.rb', line 6

def self.run!(*args)
  options = args.last.is_a?(::Hash) ? args.last : { }
  catalog = options[:catalog]

  catalog.roots.each do |root|
    use Rack::MyStatic,
        :urls => ["/#{File.basename(root)}"],
        :root => File.dirname(root)
    puts "mount #{File.basename(root)} -> #{File.dirname(root)}"
  end

  define_method :catalog do
    catalog
  end
  super(*args)
end