Class: DAV4Rack::File
- Inherits:
-
Rack::File
- Object
- Rack::File
- DAV4Rack::File
- Defined in:
- lib/dav4rack/file.rb
Overview
DAV4Rack::File simply allows us to use Rack::File but with the specific location we deem appropriate
Instance Attribute Summary collapse
-
#path ⇒ Object
(also: #to_path)
Returns the value of attribute path.
Instance Method Summary collapse
- #_call(env) ⇒ Object
-
#initialize(path) ⇒ File
constructor
A new instance of File.
- #not_found ⇒ Object
Constructor Details
#initialize(path) ⇒ File
Returns a new instance of File.
13 14 15 |
# File 'lib/dav4rack/file.rb', line 13 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object Also known as: to_path
Returns the value of attribute path.
9 10 11 |
# File 'lib/dav4rack/file.rb', line 9 def path @path end |
Instance Method Details
#_call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dav4rack/file.rb', line 17 def _call(env) begin if F.file?(@path) && F.readable?(@path) serving(env) else raise Errno::EPERM end rescue SystemCallError not_found end end |
#not_found ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/dav4rack/file.rb', line 29 def not_found body = "File not found: #{Rack::Utils.unescape(env["PATH_INFO"])}\n" [404, {"Content-Type" => "text/plain", "Content-Length" => body.size.to_s, "X-Cascade" => "pass"}, [body]] end |