Class: Rack::Gwt::Static

Inherits:
Static
  • Object
show all
Defined in:
lib/rack/gwt/static.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, *gwt_modules) ⇒ Static

Returns a new instance of Static.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rack/gwt/static.rb', line 28

def initialize( app, *gwt_modules )
  if gwt_modules.last.is_a?( Hash )
    gwt_modules.reverse!
    opts = gwt_modules.shift.dup
    gwt_modules.reverse!
  else
    opts = {}
  end
  pathes = gwt_modules.collect { |g| "/#{g}" }
  options = { :root => 'public',
    :index => 'index.html',
    :header_rules => [
                      [ /\.css/, 
                        { 'Content-Type' => 'application/css' } ],
                      [ /\.js/, 
                        { 'Content-Type' => 'application/js' } ],
                      [ /\.cache\./, 
                        { 'Expires' => (Time.now + 365).rfc2822 } ],
                      [ /\.nocache\./, 
                        { 'Expires' => Time.new( 1970 ).rfc2822,
                          'Cache-Control' => 'public, max-age=0, must-revalidate' } ]
                     ]
  }
  options.merge!( opts )
  options[ :urls ] = pathes + [ "/#{opts[ :index] }" ]
  super( app, options )
end