Class: Staticme::App

Inherits:
Object
  • Object
show all
Defined in:
lib/staticme/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ App

Returns a new instance of App.



10
11
12
# File 'lib/staticme/app.rb', line 10

def initialize(params)
  self.params = params
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



8
9
10
# File 'lib/staticme/app.rb', line 8

def params
  @params
end

Instance Method Details

#bindObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/staticme/app.rb', line 14

def bind
  params = self.params

  Rack::StaticmeBuilder.new do

    index      = params[:index]
    path       = params[:path]

    map '/staticme/autoreload.js' do
      run Staticme::Scripts::Autoreload
    end

    map /^\/.+/ do
      run Rack::Directory.new( path )
    end

    if !index.nil? && File.exists?( File.join( path, index ) )
      map /^\/$/ do
        run Rack::IndexFile.new( File.join( path, index ) )
      end
    end

  end
end