Sha256: 497107414067f91d68e4cf90b67dfc32ca1ed7ce317633a1c205e709b5783dca
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
module JsAssets class List class << self attr_accessor :exclude, :allow end @exclude = ['application.js'] @allow = ['*.html'] def self.fetch project_assets = {} assets_filters = ::Rails.application.config.assets.precompile ::Rails.application.assets.each_file do |filename| if logical_path = ::Rails.application.assets.send(:logical_path_for_filename, filename, assets_filters) next if matches_filter(@exclude, logical_path, filename) next unless matches_filter(@allow, logical_path, filename) if ::Rails.application.config.assets.digest project_assets[logical_path] = '/assets/' + ::Rails.application.assets[logical_path].digest_path else project_assets[logical_path] = '/assets/' + logical_path end end end return project_assets end protected # from # https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/base.rb:418 def self.matches_filter(filters, logical_path, filename) return true if filters.nil? || filters.empty? filters.any? do |filter| if filter.is_a?(Regexp) filter.match(logical_path) elsif filter.respond_to?(:call) if filter.arity == 1 filter.call(logical_path) else filter.call(logical_path, filename.to_s) end else # puts filter File.fnmatch(filter.to_s, logical_path) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
js_assets-0.0.8 | lib/js_assets/list.rb |