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"
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"

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



106
107
108
109
# File 'lib/hanami/assets/config/manifest.rb', line 106

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



122
123
124
125
126
# File 'lib/hanami/assets/config/manifest.rb', line 122

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



136
137
138
# File 'lib/hanami/assets/config/manifest.rb', line 136

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



130
131
132
# File 'lib/hanami/assets/config/manifest.rb', line 130

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