Class: Zorglub::App
- Inherits:
-
Rack::URLMap
- Object
- Rack::URLMap
- Zorglub::App
- Defined in:
- lib/zorglub/app.rb
Instance Attribute Summary collapse
-
#engines_cache ⇒ Object
readonly
Returns the value of attribute engines_cache.
Instance Method Summary collapse
- #at(location) ⇒ Object
- #delete(location) ⇒ Object
- #engine_proc_ext(engine, ext) ⇒ Object
-
#initialize(map = {}, &block) ⇒ App
constructor
A new instance of App.
- #layout_base_path ⇒ Object
- #map(location, object) ⇒ Object
-
#opt(sym) ⇒ Object
OPTIONS @options.
- #opt!(sym, val) ⇒ Object
- #register_engine!(name, ext, proc) ⇒ Object
- #static_base_path ⇒ Object
- #to(object) ⇒ Object
- #to_hash ⇒ Object
- #view_base_path ⇒ Object
Constructor Details
#initialize(map = {}, &block) ⇒ App
Returns a new instance of App.
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 35 36 37 |
# File 'lib/zorglub/app.rb', line 9 def initialize map={}, &block super @map = map @engines_cache = { } @options = { :debug => false, :root => '.', :layout => 'default', :view_dir => 'view', :layout_dir => 'layout', :static_dir => 'static', :engine => nil, :engines_cache_enabled => true, :engines => { }, :haml_options => { :format => :html5, :ugly => false, :encoding => 'utf-8' }, :session_options => { :session_on => false, :session_key => 'zorglub.sid', :session_secret => 'session-secret-secret', :session_sid_len => 64, } } instance_eval &block if block_given? remap @map end |
Instance Attribute Details
#engines_cache ⇒ Object (readonly)
Returns the value of attribute engines_cache.
39 40 41 |
# File 'lib/zorglub/app.rb', line 39 def engines_cache @engines_cache end |
Instance Method Details
#at(location) ⇒ Object
54 55 56 |
# File 'lib/zorglub/app.rb', line 54 def at location @map[location] end |
#delete(location) ⇒ Object
49 50 51 52 |
# File 'lib/zorglub/app.rb', line 49 def delete location @map.delete location remap @map end |
#engine_proc_ext(engine, ext) ⇒ Object
86 87 88 89 90 |
# File 'lib/zorglub/app.rb', line 86 def engine_proc_ext engine, ext p,x = @options[:engines][engine] return [nil, ''] if p.nil? [ p, ((ext.nil? or ext.empty?) ? x : ext ) ] end |
#layout_base_path ⇒ Object
97 98 99 100 |
# File 'lib/zorglub/app.rb', line 97 def layout_base_path p = @options[:layout_path] ( p.nil? ? File.join(@options[:root], @options[:layout_dir]) : p ) end |
#map(location, object) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/zorglub/app.rb', line 41 def map location, object return unless location and object raise Exception.new "#{@map[location]} already mapped to #{location}" if @map.has_key? location object.app = self @map.merge! location.to_s=>object remap @map end |
#opt(sym) ⇒ Object
OPTIONS @options
68 69 70 |
# File 'lib/zorglub/app.rb', line 68 def opt sym @options[sym] end |
#opt!(sym, val) ⇒ Object
72 73 74 |
# File 'lib/zorglub/app.rb', line 72 def opt! sym, val @options[sym] = val end |
#register_engine!(name, ext, proc) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/zorglub/app.rb', line 76 def register_engine! name, ext, proc return unless name if ext.nil? or ext.empty? x = nil else x = (ext[0]=='.' ? (ext.length==1 ? nil : ext) : '.'+ext) end @options[:engines][name]=[ proc, x ] end |
#static_base_path ⇒ Object
102 103 104 105 |
# File 'lib/zorglub/app.rb', line 102 def static_base_path p = @options[:static_path] ( p.nil? ? File.join(@options[:root], @options[:static_dir]) : p ) end |
#to(object) ⇒ Object
58 59 60 |
# File 'lib/zorglub/app.rb', line 58 def to object @map.invert[object] end |
#to_hash ⇒ Object
62 63 64 |
# File 'lib/zorglub/app.rb', line 62 def to_hash @map.dup end |
#view_base_path ⇒ Object
92 93 94 95 |
# File 'lib/zorglub/app.rb', line 92 def view_base_path p = @options[:view_path] ( p.nil? ? File.join(@options[:root], @options[:view_dir]) : p ) end |