lib/classy_assets.rb in classy_assets-0.11.1 vs lib/classy_assets.rb in classy_assets-0.11.2

- old
+ new

@@ -1,9 +1,10 @@ # encoding: utf-8 # stdlib require 'base64' +require 'oj' require 'escape_utils' require 'sinatra/base' require 'sprockets' # classy assets components @@ -29,12 +30,18 @@ ClassyAssets::Config.instance end # utility methods + def self.asset_manifest + Oj.load(File.open(config.asset_manifest_path, 'r')) + end + def self.asset_url_for(asset) - asset = sprockets[asset].send(determine_path_type) + if config.asset_digest + asset = (manifest_exists?) ? asset_manifest['assets'][asset] : sprockets[asset].digest_path + end debug = (config.asset_debug) ? '?body=1' : '' "#{config.asset_host}/#{config.asset_prefix}/#{asset}#{debug}" end def self.asset_data_uri_for(asset) @@ -54,7 +61,11 @@ private def self.determine_path_type (config.asset_digest) ? :digest_path : :logical_path + end + + def self.manifest_exists? + ::File.exists? config.asset_manifest_path end end