Get rid of build_reroute. The last thing using it was the sprockets extension, though it didn't appear to need it since removing the build_reroute call leaves tests passing, and the test site I tried still generated JS from CoffeeScript just fine.

This commit is contained in:
Ben Hollis 2012-02-08 22:13:49 -08:00
parent 57061a17c0
commit 382107d403
2 changed files with 1 additions and 51 deletions

View file

@ -6,45 +6,7 @@ module Middleman::CoreExtensions::Builder
# @private # @private
def registered(app) def registered(app)
app.define_hook :after_build app.define_hook :after_build
app.extend ClassMethods
app.send :include, InstanceMethods
app.delegate :build_reroute, :to => :"self.class"
end end
alias :included :registered alias :included :registered
end end
# Build Class Methods
module ClassMethods
# Get a list of callbacks which can modify a files build path
# Each callback takes a destination path and a request path and
# returns a new destination path, or false if it doesn't want to reroute.
# @return [Array<Proc>]
def build_reroute(&block)
@build_rerouters ||= []
@build_rerouters << block if block_given?
@build_rerouters
end
end
# Build Instance Methods
module InstanceMethods
# Run through callbacks and get the new values
#
# @param [String] destination The current destination path of the built file
# @param [String] request_path The request path of the file
# @return [String] The new destination path
def reroute_builder(destination, request_path)
result = [destination, request_path]
build_reroute.each do |block|
output = block.call(destination, request_path)
if output
result = output
break
end
end
result
end
end
end end

View file

@ -13,18 +13,6 @@ module Middleman::CoreExtensions::Sprockets
app.set :js_compressor, false app.set :js_compressor, false
app.set :css_compressor, false app.set :css_compressor, false
# Cut off every extension after .js (which sprockets eats up)
app.build_reroute do |destination, request_path|
if !request_path.match(/\.js\./i)
false
else
[
destination.gsub(/\.js(\..*)$/, ".js"),
request_path.gsub(/\.js(\..*)$/, ".js")
]
end
end
# Once Middleman is setup # Once Middleman is setup
app.ready do app.ready do
# Create sprockets env for JS # Create sprockets env for JS
@ -172,4 +160,4 @@ module Middleman::CoreExtensions::Sprockets
super(exception) super(exception)
end end
end end
end end