Method: TDiary::Application#initialize

Defined in:
lib/tdiary/application.rb

#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