Sha256: 3bdcf3736534c39f6173fad1b450e22ac4f9dd9ae8d7eac0ddc8d8cd3f798eae
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 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) project_assets[logical_path] = ::ApplicationController.helpers.asset_path(logical_path) 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.3 | lib/js_assets/list.rb |