Class: Forward::Static::App

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, app = nil) ⇒ App

Returns a new instance of App.



82
83
84
85
86
# File 'lib/forward/static/app.rb', line 82

def initialize(root, app = nil)
  @root            = File.expand_path(root)
  @app             = app || Rack::File.new(@root)
  @listing_view    = File.read(File.expand_path('../directory.erb', __FILE__))
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



78
79
80
# File 'lib/forward/static/app.rb', line 78

def files
  @files
end

#pathObject

Returns the value of attribute path.



80
81
82
# File 'lib/forward/static/app.rb', line 80

def path
  @path
end

#rootObject

Returns the value of attribute root.



79
80
81
# File 'lib/forward/static/app.rb', line 79

def root
  @root
end

Instance Method Details

#_call(env) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/forward/static/app.rb', line 92

def _call(env)
  @env       = env
  @path_info = Rack::Utils.unescape(env['PATH_INFO'])

  if forbidden?
    render_404
  else
    @path = File.join(@root, @path_info)
    process
  end
end

#call(env) ⇒ Object



88
89
90
# File 'lib/forward/static/app.rb', line 88

def call(env)
  dup._call(env)
end