Class: Monorail::Request::DirectoryAlias
- Inherits:
-
Object
- Object
- Monorail::Request::DirectoryAlias
- Defined in:
- lib/monorail/monorail_webd.rb
Overview
class DirectoryAlias
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
Instance Method Summary collapse
-
#auth_required? ⇒ Boolean
auth_required?.
-
#default_resource ⇒ Object
default_resource Generate a default resource, such as for requests that don’t specify one.
-
#get_path_tail(path_info) ⇒ Object
get_path_tail.
-
#initialize(prefix, actual, processor, auth_required) ⇒ DirectoryAlias
constructor
initialize.
-
#match_request(path_info) ⇒ Object
match_request Does our prefix match that of the incoming path_info? Return T/F.
-
#translate_pathname(path_info) ⇒ Object
translate_pathname.
Constructor Details
#initialize(prefix, actual, processor, auth_required) ⇒ DirectoryAlias
initialize
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/monorail/monorail_webd.rb', line 360 def initialize prefix, actual, processor, auth_required unless prefix =~ /^\// prefix = "/" + prefix end unless prefix =~ /\/$/ prefix = prefix + "/" end unless actual =~ /\/$/ actual = actual + "/" end @prefix = prefix @prefix_pattern = Regexp.new( "^#{prefix}" ) @actual = actual @processor = processor @auth_required = auth_required end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
355 356 357 |
# File 'lib/monorail/monorail_webd.rb', line 355 def actual @actual end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
355 356 357 |
# File 'lib/monorail/monorail_webd.rb', line 355 def prefix @prefix end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
355 356 357 |
# File 'lib/monorail/monorail_webd.rb', line 355 def processor @processor end |
Instance Method Details
#auth_required? ⇒ Boolean
auth_required?
381 382 383 |
# File 'lib/monorail/monorail_webd.rb', line 381 def auth_required? @auth_required end |
#default_resource ⇒ Object
default_resource Generate a default resource, such as for requests that don’t specify one. For now we only handle directory requests, and we hardcode index.html. Eventually this needs to become more flexible.
400 401 402 403 404 405 406 407 |
# File 'lib/monorail/monorail_webd.rb', line 400 def default_resource case @processor when :directory "index.html" else "" end end |
#get_path_tail(path_info) ⇒ Object
get_path_tail
424 425 426 427 428 |
# File 'lib/monorail/monorail_webd.rb', line 424 def get_path_tail path_info if path_info =~ @prefix_pattern $' end end |
#match_request(path_info) ⇒ Object
match_request Does our prefix match that of the incoming path_info? Return T/F
390 391 392 |
# File 'lib/monorail/monorail_webd.rb', line 390 def match_request path_info path_info =~ @prefix_pattern end |
#translate_pathname(path_info) ⇒ Object
translate_pathname
413 414 415 416 417 418 419 |
# File 'lib/monorail/monorail_webd.rb', line 413 def translate_pathname path_info if path_info =~ @prefix_pattern filename = $' || "" filename.length > 0 or filename = default_resource @actual + filename end end |