Class: Flatrack
- Inherits:
-
Object
- Object
- Flatrack
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/flatrack.rb,
lib/flatrack/cli.rb,
lib/flatrack/site.rb,
lib/flatrack/view.rb,
lib/flatrack/request.rb,
lib/flatrack/version.rb,
lib/flatrack/response.rb,
lib/flatrack/template.rb,
lib/flatrack/template/rb.rb,
lib/flatrack/template/html.rb,
lib/flatrack/template/erubis.rb,
lib/flatrack/view/tag_helper.rb,
lib/flatrack/asset_extensions.rb,
lib/flatrack/view/link_helper.rb,
lib/flatrack/view/output_buffer.rb,
lib/flatrack/view/render_helper.rb,
lib/flatrack/view/capture_helper.rb,
lib/flatrack/view/request_helper.rb,
lib/flatrack/template/erubis/handler.rb
Overview
Version
Defined Under Namespace
Modules: AssetExtensions, Site Classes: CLI, Request, Response, Template, View
Constant Summary collapse
- TemplateNotFound =
Class.new StandardError
- FileNotFound =
Class.new StandardError
- FORMATS =
{}
- VERSION =
'1.3.1'
Class Attribute Summary collapse
-
.gem_root ⇒ String
readonly
The root of the flatrack gem.
-
.site_root ⇒ String
readonly
The site root.
Instance Attribute Summary collapse
-
#assets ⇒ Sprockets::Environment
readonly
The flatrack sprockets environment.
Class Method Summary collapse
-
.reset! ⇒ Object
Reset the state of flatrack and its configuration.
Instance Method Summary collapse
-
#config {|Flatrack| ... } ⇒ Flatrack
Configure the flatrack instance.
-
#middleware ⇒ Object
The middleware stack for flatrack.
-
#register_format(ext, mime) ⇒ Object
register a format extension by its mime type.
-
#use(middleware, options = nil) ⇒ Object
Insert a rack middleware at the end of the stack.
Class Attribute Details
.gem_root ⇒ String (readonly)
The root of the flatrack gem
34 35 36 |
# File 'lib/flatrack.rb', line 34 def gem_root File. File.join __FILE__, '..' end |
.site_root ⇒ String (readonly)
The site root
41 42 43 |
# File 'lib/flatrack.rb', line 41 def site_root File. Dir.pwd end |
Instance Attribute Details
#assets ⇒ Sprockets::Environment (readonly)
The flatrack sprockets environment
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/flatrack.rb', line 72 def assets @assets ||= begin Sprockets::Environment.new.tap do |environment| environment.append_path 'assets/images' environment.append_path 'assets/javascripts' environment.append_path 'assets/stylesheets' environment.context_class.class_eval { include AssetExtensions } end end end |
Class Method Details
.reset! ⇒ Object
Reset the state of flatrack and its configuration
46 47 48 |
# File 'lib/flatrack.rb', line 46 def reset! @delegate_instance = nil end |
Instance Method Details
#config {|Flatrack| ... } ⇒ Flatrack
Configure the flatrack instance
64 65 66 67 |
# File 'lib/flatrack.rb', line 64 def config(&block) yield self self end |
#middleware ⇒ Object
The middleware stack for flatrack
91 92 93 |
# File 'lib/flatrack.rb', line 91 def middleware @middleware ||= [] end |
#register_format(ext, mime) ⇒ Object
register a format extension by its mime type
86 87 88 |
# File 'lib/flatrack.rb', line 86 def register_format(ext, mime) FORMATS[ext.to_s] = mime end |
#use(middleware, options = nil) ⇒ Object
Insert a rack middleware at the end of the stack
98 99 100 |
# File 'lib/flatrack.rb', line 98 def use(middleware, = nil) self.middleware << [middleware, ].compact end |