module Sprockets::Loader

def load_from_unloaded(unloaded)

successfully pulled from cache.
This method is only called when the given unloaded asset could not be

unloaded - An UnloadedAsset

Internal: Loads an asset and saves it to cache
def load_from_unloaded(unloaded)
  unless file?(unloaded.filename)
    raise FileNotFound, "could not find file: #{unloaded.filename}"
  end
  load_path, logical_path = paths_split(config[:paths], unloaded.filename)
  unless load_path
    raise FileOutsidePaths, "#{unloaded.filename} is no longer under a load path: #{self.paths.join(', ')}"
  end
  logical_path, file_type, engine_extnames, _ = parse_path_extnames(logical_path)
  name = logical_path
  if pipeline = unloaded.params[:pipeline]
    logical_path += ".#{pipeline}"
  end
  if type = unloaded.params[:type]
    logical_path += config[:mime_types][type][:extensions].first
  end
  if type != file_type && !config[:transformers][file_type][type]
    raise ConversionError, "could not convert #{file_type.inspect} to #{type.inspect}"
  end
  processors = processors_for(type, file_type, engine_extnames, pipeline)
  processors_dep_uri = build_processors_uri(type, file_type, engine_extnames, pipeline)
  dependencies = config[:dependencies] + [processors_dep_uri]
  # Read into memory and process if theres a processor pipeline
  if processors.any?
    result = call_processors(processors, {
      environment: self,
      cache: self.cache,
      uri: unloaded.uri,
      filename: unloaded.filename,
      load_path: load_path,
      name: name,
      content_type: type,
      metadata: { dependencies: dependencies }
    })
    validate_processor_result!(result)
    source = result.delete(:data)
    metadata = result
    metadata[:charset] = source.encoding.name.downcase unless metadata.key?(:charset)
    metadata[:digest]  = digest(source)
    metadata[:length]  = source.bytesize
  else
    dependencies << build_file_digest_uri(unloaded.filename)
    metadata = {
      digest: file_digest(unloaded.filename),
      length: self.stat(unloaded.filename).size,
      dependencies: dependencies
    }
  end
  asset = {
    uri: unloaded.uri,
    load_path: load_path,
    filename: unloaded.filename,
    name: name,
    logical_path: logical_path,
    content_type: type,
    source: source,
    metadata: metadata,
    dependencies_digest: DigestUtils.digest(resolve_dependencies(metadata[:dependencies]))
  }
  asset[:id]  = pack_hexdigest(digest(asset))
  asset[:uri] = build_asset_uri(unloaded.filename, unloaded.params.merge(id: asset[:id]))
  # Deprecated: Avoid tracking Asset mtime
  asset[:mtime] = metadata[:dependencies].map { |u|
    if u.start_with?("file-digest:")
      s = self.stat(parse_file_digest_uri(u))
      s ? s.mtime.to_i : nil
    else
      nil
    end
  }.compact.max
  asset[:mtime] ||= self.stat(unloaded.filename).mtime.to_i
  store_asset(asset, unloaded)
  asset
end