Class: Mentawai::Application
- Inherits:
-
Object
- Object
- Mentawai::Application
- Defined in:
- lib/mentawai/application.rb
Instance Attribute Summary collapse
-
#appContext ⇒ Object
readonly
Returns the value of attribute appContext.
-
#appManager ⇒ Object
readonly
Returns the value of attribute appManager.
-
#appManagerClass ⇒ Object
readonly
Returns the value of attribute appManagerClass.
-
#appManagerFile ⇒ Object
readonly
Returns the value of attribute appManagerFile.
-
#appManagerFilename ⇒ Object
readonly
Returns the value of attribute appManagerFilename.
-
#contextPath ⇒ Object
readonly
Returns the value of attribute contextPath.
-
#default_page ⇒ Object
readonly
Returns the value of attribute default_page.
-
#dirs_allowed_for_listing ⇒ Object
readonly
Returns the value of attribute dirs_allowed_for_listing.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#listing_allowed ⇒ Object
readonly
Returns the value of attribute listing_allowed.
Instance Method Summary collapse
- #contextPathDir ⇒ Object
-
#initialize(params) ⇒ Application
constructor
A new instance of Application.
- #reloadAppManager(force = false) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(params) ⇒ Application
Returns a new instance of Application.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mentawai/application.rb', line 8 def initialize(params) @appContext = Hash.new @contextPath = params[:app_context] || '/' @appManagerFilename = params[:app_manager_file] || 'app_manager.rb' @appManagerFilename = ".#{contextPathDir}/WEB-INF/#{@appManagerFilename.sub(/^\//, "")}" raise "Application manager does not exist: " + @appManagerFilename if not File.exists?(@appManagerFilename) @appManagerClass = params[:app_manager_class] || 'AppManager' @appManagerFile = File.new(@appManagerFilename) @appManager = nil @extension = params[:action_extension] || 'mtw' @default_page = params[:default_page] || 'index.erb' @listing_allowed = params[:listing_allowed] || false @dirs_allowed_for_listing = params[:dirs_allowed_for_listing] || [] @appManagerFileLastModified = 0 end |
Instance Attribute Details
#appContext ⇒ Object (readonly)
Returns the value of attribute appContext.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def appContext @appContext end |
#appManager ⇒ Object (readonly)
Returns the value of attribute appManager.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def appManager @appManager end |
#appManagerClass ⇒ Object (readonly)
Returns the value of attribute appManagerClass.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def appManagerClass @appManagerClass end |
#appManagerFile ⇒ Object (readonly)
Returns the value of attribute appManagerFile.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def appManagerFile @appManagerFile end |
#appManagerFilename ⇒ Object (readonly)
Returns the value of attribute appManagerFilename.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def appManagerFilename @appManagerFilename end |
#contextPath ⇒ Object (readonly)
Returns the value of attribute contextPath.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def contextPath @contextPath end |
#default_page ⇒ Object (readonly)
Returns the value of attribute default_page.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def default_page @default_page end |
#dirs_allowed_for_listing ⇒ Object (readonly)
Returns the value of attribute dirs_allowed_for_listing.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def dirs_allowed_for_listing @dirs_allowed_for_listing end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def extension @extension end |
#listing_allowed ⇒ Object (readonly)
Returns the value of attribute listing_allowed.
6 7 8 |
# File 'lib/mentawai/application.rb', line 6 def listing_allowed @listing_allowed end |
Instance Method Details
#contextPathDir ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/mentawai/application.rb', line 36 def contextPathDir if contextPath == '/' "/ROOT" else contextPath end end |
#reloadAppManager(force = false) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mentawai/application.rb', line 48 def reloadAppManager(force = false) if force || @appManagerFile.mtime != @appManagerFileLastModified then if @appManagerFileLastModified == 0 then puts "Loading app manager: " + @appManagerFilename else puts "Reloading app manager: " + @appManagerFilename end load @appManagerFilename @appManager = eval(appManagerClass + ".new(self)") @appManager.init(@appContext) @appManagerFileLastModified = @appManagerFile.mtime end end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/mentawai/application.rb', line 44 def to_s "#{contextPath} (#{appManagerFilename}/#{appManagerClass})" end |