Skip to content

Commit

Permalink
Merge pull request #510 from skipkayhil/rm-legacy-conditions
Browse files Browse the repository at this point in the history
Remove legacy conditions
  • Loading branch information
rafaelfranca authored Aug 10, 2022
2 parents d933dc1 + 05e40aa commit 60f032e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
3 changes: 1 addition & 2 deletions lib/sprockets/rails/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ def compute_asset_path(path, options = {})
message << "To bypass the asset pipeline and preserve this behavior,\n"
message << "use the `skip_pipeline: true` option.\n"

call_stack = Kernel.respond_to?(:caller_locations) && ::Rails::VERSION::MAJOR >= 5 ? caller_locations : caller
ActiveSupport::Deprecation.warn(message, call_stack)
ActiveSupport::Deprecation.warn(message, caller_locations)
end
super
end
Expand Down
10 changes: 0 additions & 10 deletions lib/sprockets/rails/route_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
module Sprockets
module Rails
module RouteWrapper

def internal_assets_path?
path =~ %r{\A#{self.class.assets_prefix}\z}
end

def internal?
super || internal_assets_path?
end

def self.included(klass)
klass.class_eval do
def internal_with_sprockets?
internal_without_sprockets? || internal_assets_path?
end
alias_method_chain :internal?, :sprockets
end
end
end
end
end
23 changes: 7 additions & 16 deletions lib/sprockets/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ def precompiled_assets(clear_cache = false)
@precompiled_assets ||= assets_manifest.find(config.assets.precompile).map(&:logical_path).to_set
end
end

class Engine < Railtie
# Skip defining append_assets_path on Rails <= 4.2
unless initializers.find { |init| init.name == :append_assets_path }
initializer :append_assets_path, :group => :all do |app|
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
end
end
end
end

module Sprockets
Expand Down Expand Up @@ -96,6 +85,12 @@ def configure(&block)
end
end

::Rails::Engine.initializer :append_assets_path, :group => :all do |app|
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
end

config.assets = OrderedOptions.new
config.assets._blocks = []
config.assets.paths = []
Expand Down Expand Up @@ -237,11 +232,7 @@ def self.build_manifest(app)
ActionDispatch::Routing::RouteWrapper.class_eval do
class_attribute :assets_prefix

if defined?(prepend) && ::Rails.version >= '4'
prepend Sprockets::Rails::RouteWrapper
else
include Sprockets::Rails::RouteWrapper
end
prepend Sprockets::Rails::RouteWrapper

self.assets_prefix = config.assets.prefix
end
Expand Down

0 comments on commit 60f032e

Please sign in to comment.