Class: Jagger::Builder
- Inherits:
-
Object
- Object
- Jagger::Builder
- Defined in:
- lib/jagger/builder.rb
Overview
Public: Builder creates rack compatible application which gathers and serves static sinatra app and sprockets pipeline together.
Example
app = Jagger::Builder.new do
set :asset_paths, %w(src/main/ src/test/ src/look/ lib/)
set :views, 'templates'
set :public_folder, 'static'
end
run app
Configuration above is the default one, so in most of cases only the following declaration will be enough:
run Jagger::Builder.new
Instance Method Summary collapse
-
#app ⇒ Object
Internal: Sinatra application used to serve static files and index page.
-
#assets ⇒ Object
Internal: Assets pipeline environment.
-
#call(env) ⇒ Object
Public: Serves the application and assets pipeline together as one rack application.
-
#initialize(&block) ⇒ Builder
constructor
Public: Constructor.
Constructor Details
#initialize(&block) ⇒ Builder
Public: Constructor. Initializes application and the assets pipeline. Passed block accepts custom configuration.
23 24 25 26 |
# File 'lib/jagger/builder.rb', line 23 def initialize(&block) app.instance_eval(&block) if block_given? assets.append_paths(app.asset_paths) end |
Instance Method Details
#app ⇒ Object
Internal: Sinatra application used to serve static files and index page.
30 31 32 |
# File 'lib/jagger/builder.rb', line 30 def app @app ||= App end |
#assets ⇒ Object
Internal: Assets pipeline environment.
35 36 37 |
# File 'lib/jagger/builder.rb', line 35 def assets @assets ||= Assets.new end |
#call(env) ⇒ Object
Public: Serves the application and assets pipeline together as one rack application.
env - The Hash with request environment.
44 45 46 47 48 49 50 51 |
# File 'lib/jagger/builder.rb', line 44 def call(env) map = { '/assets' => assets, '/' => app.new, } router = Rack::URLMap.new(map) router.call(env) end |