class Sprockets::Rails::HelperAssetResolvers::Environment
:nodoc:
def asset_path(path, digest, allow_non_precompiled = false)
def asset_path(path, digest, allow_non_precompiled = false) # Digests enabled? Do the work to calculate the full asset path. if digest digest_path path, allow_non_precompiled # Otherwise, ask the Sprockets environment whether the asset exists # and check whether it's also precompiled for production deploys. elsif asset = find_asset(path) raise_unless_precompiled_asset asset.logical_path unless allow_non_precompiled path end end
def digest_path(path, allow_non_precompiled = false)
def digest_path(path, allow_non_precompiled = false) if asset = find_asset(path) raise_unless_precompiled_asset asset.logical_path unless allow_non_precompiled asset.digest_path end end
def find_asset(path, options = {})
def find_asset(path, options = {}) @env[path, options] end
def find_debug_asset(path)
def find_debug_asset(path) if asset = find_asset(path, pipeline: :debug) raise_unless_precompiled_asset asset.logical_path.sub('.debug', '') asset end end
def initialize(view)
def initialize(view) raise ArgumentError, 'config.assets.resolve_with includes :environment, but app.assets is nil' unless view.assets_environment @env = view.assets_environment @precompiled_asset_checker = view.precompiled_asset_checker end
def integrity(path)
def integrity(path) find_asset(path).try :integrity end
def precompiled?(path)
def precompiled?(path) @precompiled_asset_checker.call path end
def raise_unless_precompiled_asset(path)
def raise_unless_precompiled_asset(path) raise Helper::AssetNotPrecompiled.new(path) unless precompiled?(path) end