class Sprockets::Rails::HelperAssetResolvers::Environment
Experimental RBS support (using type sampling data from the type_fusion project).
# sig/sprockets/rails/helper.rbs class Sprockets::Rails::HelperAssetResolvers::Environment def asset_path: (String path, true digest, ?nil allow_non_precompiled) -> String def digest_path: (String path, ?nil allow_non_precompiled) -> String end
:nodoc:
def asset_path(path, digest, allow_non_precompiled = false)
Experimental RBS support (using type sampling data from the type_fusion project).
def asset_path: (String path, true digest, ?nil allow_non_precompiled) -> String
This signature was generated using 1 sample from 1 application.
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)
Experimental RBS support (using type sampling data from the type_fusion project).
def digest_path: (String path, ?nil allow_non_precompiled) -> String
This signature was generated using 1 sample from 1 application.
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 @check_precompiled_asset = view.check_precompiled_asset 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::AssetNotPrecompiledError.new(path) if @check_precompiled_asset && !precompiled?(path) end