lib/sinatra/assetpack/options.rb in sinatra-assetpack-0.2.6 vs lib/sinatra/assetpack/options.rb in sinatra-assetpack-0.2.7
- old
+ new
@@ -264,29 +264,25 @@
# Returns an array of URI paths of those matching given globs.
#
# glob('spec')
# glob(['spec1', 'spec2' ...])
- # glob('spec', preserve: true)
#
- # If `preserve` is set to true, it will preserve any specs that are not
- # wildcards that don't match anything.
- #
- def glob(match, options={})
- match = [*match] # Force array-ness
+ def glob(match)
+ paths = Array.new(match) # Force array-ness
- paths = match.map { |spec|
- if options[:preserve] && !spec.include?('*')
- spec
+ paths.map! do |spec|
+ if spec.include?('*')
+ files.select do |file, _|
+ # Dir#glob like source matching
+ File.fnmatch?(spec, file, File::FNM_PATHNAME | File::FNM_DOTMATCH)
+ end.sort
else
- files.keys.select { |f| File.fnmatch?(spec, f) }.sort
+ [spec, files[spec]]
end
- }.flatten
+ end
- paths = paths.uniq
- tuples = paths.map { |key| [key, files[key]] }
-
- Hash[*tuples.flatten]
+ Hash[*paths.flatten]
end
# Fetches the contents of a dynamic asset. If `cache_dynamic_assets` is set,
# check file mtime and potentially return contents from cache instead of re-compiling.
# Yields to a block to compile & render the asset.