Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Middleware should take a project

Refactor the server/middleware to take a project instance. This change
does not instantiate a new project for every HTTP request. This prevents
needless resetting and rebuilding between requests. Mainly this ensures
that manifest objects maintain state between HTTP requests.
  • Loading branch information...
commit c71efaa27369e663c26fd6ae5044f10757377981 1 parent 75f79b8
twinturbo authored
View
7 lib/rake-pipeline/middleware.rb
@@ -17,11 +17,10 @@ class Middleware
attr_accessor :project
# @param [#call] app a Rack application
- # @param [String|Rake::Pipeline] pipeline either a path to an
- # Assetfile to use to build a pipeline, or an existing pipeline.
- def initialize(app, pipeline)
+ # @param [Rake::Pipeline::Project] an existing project
+ def initialize(app, project)
@app = app
- @project = Rake::Pipeline::Project.new(pipeline)
+ @project = project
end
# Automatically compiles your assets if required and
View
2  lib/rake-pipeline/server.rb
@@ -6,7 +6,7 @@ class Pipeline
class Server < Rack::Server
def app
not_found = proc { [404, { "Content-Type" => "text/plain" }, ["not found"]] }
- config = "Assetfile"
+ project = Rake::Pipline::Project.new "Assetfile"
@wagenet Owner
wagenet added a note

What a "Pipline" is?

@wagenet Owner
wagenet added a note

And why are you assigning an unused variable of project here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Middleware.new(not_found, config)
@wagenet Owner
wagenet added a note

Also, you just removed the config variable so this blows up too.

@wagenet Owner
wagenet added a note

Fixed here: #122

@tchak
tchak added a note

I made a PR earlier with fix for this and to railties too #121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
end
View
4 spec/middleware_spec.rb
@@ -68,8 +68,10 @@
assetfile_path = File.join(tmp, "Assetfile")
File.open(assetfile_path, "w") { |file| file.write(assetfile_source) }
+ project = Rake::Pipeline::Project.new assetfile_path
+
app = lambda { |env| [404, {}, ['not found']] }
- middleware = Rake::Pipeline::Middleware.new(app, assetfile_path)
+ middleware = Rake::Pipeline::Middleware.new(app, project)
end
describe "dynamic requests" do
@wagenet

What a "Pipline" is?

@wagenet

Also, you just removed the config variable so this blows up too.

@wagenet

And why are you assigning an unused variable of project here?

@tchak

I made a PR earlier with fix for this and to railties too #121

Please sign in to comment.
Something went wrong with that request. Please try again.