Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprocket
## Master

- Remove remaining support for Ruby < 2.4.[#672](https://github.com/rails/sprockets/pull/672)
- Find all asset by a regexp filemask or a filepath.[#698](https://github.com/rails/sprockets/pull/698)

## 4.0.2

Expand Down
19 changes: 19 additions & 0 deletions lib/sprockets/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@ def find_asset!(*args)
end
end

# Find all asset by a regexp filemask or a filepath.
def find_all_assets(*args, &block)
paths = config[:paths]

args.each do |arg|
if arg.is_a?(Regexp)
paths.each do |path|
files = Dir["#{path}/*"].select {|file| arg =~ file }

files.each do |file|
find_all_linked_assets(file, &block)
end
end
else
find_all_linked_assets(arg, &block)
end
end
end

# Pretty inspect
def inspect
"#<#{self.class}:0x#{object_id.to_s(16)} " +
Expand Down
2 changes: 1 addition & 1 deletion lib/sprockets/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def find(*args)
environment = self.environment.cached
promises = args.flatten.map do |path|
Concurrent::Promise.execute(executor: executor) do
environment.find_all_linked_assets(path) do |asset|
environment.find_all_assets(path) do |asset|
yield asset
end
end
Expand Down