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, pipeline) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, pipeline) ⇒ Middleware
Returns a new instance of Middleware.
22 23 24 25 |
# File 'lib/rake-pipeline/middleware.rb', line 22 def initialize(app, pipeline) @app = app @project = Rake::Pipeline::Project.new(pipeline) 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rake-pipeline/middleware.rb', line 32 def call(env) project.invoke_clean 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 |