Class: Monorail::Request::DirectoryAlias

Inherits:
Object
  • Object
show all
Defined in:
lib/monorail/monorail_webd.rb

Overview

class DirectoryAlias

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, actual, processor, auth_required) ⇒ DirectoryAlias

initialize



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/monorail/monorail_webd.rb', line 348

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

#actualObject (readonly)

Returns the value of attribute actual.



343
344
345
# File 'lib/monorail/monorail_webd.rb', line 343

def actual
  @actual
end

#prefixObject (readonly)

Returns the value of attribute prefix.



343
344
345
# File 'lib/monorail/monorail_webd.rb', line 343

def prefix
  @prefix
end

#processorObject (readonly)

Returns the value of attribute processor.



343
344
345
# File 'lib/monorail/monorail_webd.rb', line 343

def processor
  @processor
end

Instance Method Details

#auth_required?Boolean

auth_required?

Returns:

  • (Boolean)


369
370
371
# File 'lib/monorail/monorail_webd.rb', line 369

def auth_required?
  @auth_required
end

#default_resourceObject

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.



388
389
390
391
392
393
394
395
# File 'lib/monorail/monorail_webd.rb', line 388

def default_resource
  case @processor
  when :directory
    "index.html"
  else
    ""
  end
end

#get_path_tail(path_info) ⇒ Object

get_path_tail



412
413
414
415
416
# File 'lib/monorail/monorail_webd.rb', line 412

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



378
379
380
# File 'lib/monorail/monorail_webd.rb', line 378

def match_request path_info
  path_info =~ @prefix_pattern
end

#translate_pathname(path_info) ⇒ Object

translate_pathname



401
402
403
404
405
406
407
# File 'lib/monorail/monorail_webd.rb', line 401

def translate_pathname path_info
  if path_info =~ @prefix_pattern
    filename = $' || ""
    filename.length > 0 or filename = default_resource
    @actual + filename
  end
end