Sha256: 4fdba52ea1b255e60aeab2ca2a91054e6361fc6dcf248fc2f575de1f3d3ac121
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 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.env == 'development' project_assets[logical_path] = ::ApplicationController.helpers.asset_path(logical_path) elsif ::Rails.env == 'production' project_assets[logical_path] = '/assets/' + ::Rails.application.assets[logical_path].digest_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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
js_assets-0.0.6 | lib/js_assets/list.rb |
js_assets-0.0.5 | lib/js_assets/list.rb |