Sha256: 5bd8a8229604d5f0783e00dfe82484baf6cb38e42502e46e5856d853884f744c
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
# frozen_string_literal: true module Hanami module Assets class Bundler # Constructs a hash for a single asset's manifest file entry # # @since 0.3.0 # @api private class ManifestEntry # @since 0.3.0 # @api private SUBRESOURCE_INTEGRITY_SEPARATOR = "-" # Return a new instance # # @since 0.3.0 # @api private def initialize(asset) @asset = asset end # A single entry for this asset, to go into manifest file # @since 0.3.0 # @api private def entry {name => values} end private # @since 0.3.0 # @api private def name _convert_to_url(@asset.expanded_path) end # @since 0.3.0 # @api private def values Hash[ target: _convert_to_url(@asset.expanded_fingerprinted_target), sri: subresource_integrity_values ] end # @since 0.3.0 # @api private def subresource_integrity_values @asset.configuration.subresource_integrity_algorithms.map do |algorithm| [algorithm, @asset.base64_digest(algorithm)].join(SUBRESOURCE_INTEGRITY_SEPARATOR) end end # @since 0.3.0 # @api private def _convert_to_url(path) path.sub(@asset.configuration.public_directory.to_s, URL_REPLACEMENT) .gsub(File::SEPARATOR, URL_SEPARATOR) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hanami-assets-1.3.5 | lib/hanami/assets/bundler/manifest_entry.rb |