Class: GulpRails::Middleware
- Inherits:
-
Object
- Object
- GulpRails::Middleware
- Defined in:
- lib/gulp_rails/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
4 5 6 |
# File 'lib/gulp_rails/middleware.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gulp_rails/middleware.rb', line 8 def call(env) result = @app.call(env) if GulpRails.[:enabled] && (GulpRails.[:development_only] && Rails.env.development?) if result[1]['Content-Type'] =~ /\Atext\/html/ log "-----> Compiling assets with gulp" gulp_output = `cd #{GulpRails.[:directory]} && #{GulpRails.[:command]}` log gulp_output.strip.split("\n").map { |l| " #{l}"}.join("\n") log "-----> Finished compiling with gulp" end end result end |