Class: Rake::Pipeline::Middleware
- Inherits:
-
Object
- Object
- Rake::Pipeline::Middleware
- Defined in:
- lib/rake-pipeline/middleware.rb
Overview
This middleware is used to provide a server that will continuously compile your files on demand.
Instance Attribute Summary collapse
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
-
#call(env) ⇒ Array(Fixnum, Hash, #each)
Automatically compiles your assets if required and serves them up.
-
#initialize(app, project) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, project) ⇒ Middleware
Returns a new instance of Middleware.
21 22 23 24 |
# File 'lib/rake-pipeline/middleware.rb', line 21 def initialize(app, project) @app = app @project = project end |
Instance Attribute Details
#project ⇒ Object
Returns the value of attribute project.
17 18 19 |
# File 'lib/rake-pipeline/middleware.rb', line 17 def project @project end |
Instance Method Details
#call(env) ⇒ Array(Fixnum, Hash, #each)
Automatically compiles your assets if required and serves them up.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rake-pipeline/middleware.rb', line 31 def call(env) project.invoke path = env["PATH_INFO"] if project.maps.has_key?(path) return project.maps[path].call(env) end if filename = file_for(path) if File.directory?(filename) index = File.join(filename, "index.html") filename = File.file?(index) ? index : nil end if filename return response_for(filename) end end @app.call(env) end |