Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy conditions #510

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this can be removed because we no longer call include Sprockets::Rails::RouteWrapper ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly

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