Class: TDiary::Application
- Inherits:
-
Object
- Object
- TDiary::Application
- Defined in:
- lib/tdiary/application.rb
Instance Method Summary collapse
- #assets_paths ⇒ Object
- #call(env) ⇒ Object
-
#initialize(base_dir = nil) ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize(base_dir = nil) ⇒ Application
Returns a new instance of Application.
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 43 44 45 46 47 48 |
# File 'lib/tdiary/application.rb', line 18 def initialize( base_dir = nil ) index_path = self.index_path update_path = self.update_path assets_path = self.assets_path assets_paths = self.assets_paths base_dir ||= self.base_dir @app = ::Rack::Builder.app do map base_dir do map '/' do use TDiary::Rack::HtmlAnchor use TDiary::Rack::Static, ["public"] use TDiary::Rack::ValidRequestPath map index_path do run TDiary::Dispatcher.index end end map update_path do use TDiary::Rack::Auth run TDiary::Dispatcher.update end map assets_path do run TDiary::Rack::Static.new(nil, assets_paths) end end end run_plugin_startup_procs end |
Instance Method Details
#assets_paths ⇒ Object
60 61 62 63 64 |
# File 'lib/tdiary/application.rb', line 60 def assets_paths TDiary::Extensions::constants.map {|extension| TDiary::Extensions::const_get( extension ).assets_path }.flatten.uniq end |
#call(env) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/tdiary/application.rb', line 50 def call( env ) begin @app.call( env ) rescue Exception => e body = ["#{e.class}: #{e}\n"] body << e.backtrace.join("\n") [500, {'Content-Type' => 'text/plain'}, body] end end |