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 38 39 40 41 42 |
# 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' }, :sass_options => { :syntax => :scss, :cache => :false, :style => :compressed }, :session_options => { :enabled => false, :key => 'zorglub.sid', :secret => 'session-secret-secret', :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.
44 45 46 |
# File 'lib/zorglub/app.rb', line 44 def engines_cache @engines_cache end |
Instance Method Details
#at(location) ⇒ Object
59 60 61 |
# File 'lib/zorglub/app.rb', line 59 def at location @map[location] end |
#delete(location) ⇒ Object
54 55 56 57 |
# File 'lib/zorglub/app.rb', line 54 def delete location @map.delete location remap @map end |
#engine_proc_ext(engine, ext) ⇒ Object
91 92 93 94 95 |
# File 'lib/zorglub/app.rb', line 91 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
102 103 104 105 |
# File 'lib/zorglub/app.rb', line 102 def layout_base_path p = @options[:layout_path] ( p.nil? ? File.join(@options[:root], @options[:layout_dir]) : p ) end |
#map(location, object) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/zorglub/app.rb', line 46 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
73 74 75 |
# File 'lib/zorglub/app.rb', line 73 def opt sym @options[sym] end |
#opt!(sym, val) ⇒ Object
77 78 79 |
# File 'lib/zorglub/app.rb', line 77 def opt! sym, val @options[sym] = val end |
#register_engine!(name, ext, proc) ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/zorglub/app.rb', line 81 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
107 108 109 110 |
# File 'lib/zorglub/app.rb', line 107 def static_base_path p = @options[:static_path] ( p.nil? ? File.join(@options[:root], @options[:static_dir]) : p ) end |
#to(object) ⇒ Object
63 64 65 |
# File 'lib/zorglub/app.rb', line 63 def to object @map.invert[object] end |
#to_hash ⇒ Object
67 68 69 |
# File 'lib/zorglub/app.rb', line 67 def to_hash @map.dup end |
#view_base_path ⇒ Object
97 98 99 100 |
# File 'lib/zorglub/app.rb', line 97 def view_base_path p = @options[:view_path] ( p.nil? ? File.join(@options[:root], @options[:view_dir]) : p ) end |