Sha256: 1decfe1f5d55b27ac0305c62422b1d993a66a473df922fd2b07e942767ad8bbd
Contents?: true
Size: 1.5 KB
Versions: 19
Compression:
Stored size: 1.5 KB
Contents
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 = '-'.freeze # 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
19 entries across 19 versions & 1 rubygems