class Hanami::Assets::Bundler::ManifestEntry

Constructs a hash for a single asset's manifest file entry

@since 0.3.0 @api private

Constants

SUBRESOURCE_INTEGRITY_SEPARATOR

@since 0.3.0 @api private

Public Class Methods

new(asset) click to toggle source

Return a new instance

@since 0.3.0 @api private

# File lib/hanami/assets/bundler/manifest_entry.rb, line 19
def initialize(asset)
  @asset = asset
end

Public Instance Methods

entry() click to toggle source

A single entry for this asset, to go into manifest file @since 0.3.0 @api private

# File lib/hanami/assets/bundler/manifest_entry.rb, line 26
def entry
  {name => values}
end

Private Instance Methods

_convert_to_url(path) click to toggle source

@since 0.3.0 @api private

# File lib/hanami/assets/bundler/manifest_entry.rb, line 57
def _convert_to_url(path)
  path.sub(@asset.configuration.public_directory.to_s, URL_REPLACEMENT)
    .gsub(File::SEPARATOR, URL_SEPARATOR)
end
name() click to toggle source

@since 0.3.0 @api private

# File lib/hanami/assets/bundler/manifest_entry.rb, line 34
def name
  _convert_to_url(@asset.expanded_path)
end
subresource_integrity_values() click to toggle source

@since 0.3.0 @api private

# File lib/hanami/assets/bundler/manifest_entry.rb, line 49
def subresource_integrity_values
  @asset.configuration.subresource_integrity_algorithms.map do |algorithm|
    [algorithm, @asset.base64_digest(algorithm)].join(SUBRESOURCE_INTEGRITY_SEPARATOR)
  end
end
values() click to toggle source

@since 0.3.0 @api private

# File lib/hanami/assets/bundler/manifest_entry.rb, line 40
def values
  Hash[
    target: _convert_to_url(@asset.expanded_fingerprinted_target),
    sri: subresource_integrity_values
  ]
end