Class: Hanami::Assets::Config::Manifest Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/assets/config/manifest.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Manifest file

Since:

  • 0.1.0

Constant Summary collapse

TARGET =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

'target'.freeze
SUBRESOURCE_INTEGRITY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

'sri'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(assets, manifest_path) ⇒ Hanami::Assets::Config::Manifest

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a new instance

Parameters:

  • assets (Hash)

    the content of the manifest

  • manifest_path (Pathname)

    the path to the manifest

See Also:

Since:

  • 0.1.0



96
97
98
99
# File 'lib/hanami/assets/config/manifest.rb', line 96

def initialize(assets, manifest_path)
  @assets        = assets
  @manifest_path = manifest_path
end

Instance Method Details

#resolve(asset) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Resolve the given asset into a fingerprinted path

For a given path /assets/application.js it will return /assets/application-28a6b886de2372ee3922fcaf3f78f2d8.js

Parameters:

  • asset (#to_s)

    the relative asset path

Returns:

  • (String)

    the fingerprinted path

Raises:

Since:

  • 0.1.0



112
113
114
115
116
# File 'lib/hanami/assets/config/manifest.rb', line 112

def resolve(asset)
  @assets.fetch(asset.to_s) do
    raise Hanami::Assets::MissingManifestAssetError.new(asset, @manifest_path)
  end
end

#subresource_integrity_values(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



126
127
128
# File 'lib/hanami/assets/config/manifest.rb', line 126

def subresource_integrity_values(path)
  resolve(path).fetch(SUBRESOURCE_INTEGRITY)
end

#target(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



120
121
122
# File 'lib/hanami/assets/config/manifest.rb', line 120

def target(path)
  resolve(path).fetch(TARGET)
end