class Sprockets::Asset

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/sprockets/asset.rbs

class Sprockets::Asset
  def digest: () -> String
  def digest_path: () -> String
  def environment_version: () -> String
  def etag: () -> String
  def initialize: (?Hash attributes) -> void
  def links: () -> Set
  def source: () -> String
end

def base64digest

Public: Returns String base64 digest of source.
def base64digest
  DigestUtils.pack_base64digest(digest)
end

def charset

Returns a String charset name or nil if binary.

Public: Get charset of source.
def charset
  metadata[:charset]
end

def digest

Experimental RBS support (using type sampling data from the type_fusion project).

def digest: () -> String

This signature was generated using 6 samples from 2 applications.

Public: Returns String byte digest of source.
def digest
  metadata[:digest]
end

def digest_path

Experimental RBS support (using type sampling data from the type_fusion project).

def digest_path: () -> String

This signature was generated using 3 samples from 2 applications.

Returns String.

"foo/bar-37b51d194a7513e45b56f6524f2d51f2.js"

Public: Return logical path with digest spliced in.
def digest_path
  if DigestUtils.already_digested?(@name)
    logical_path
  else
    logical_path.sub(/\.(\w+)$/) { |ext| "-#{etag}#{ext}" }
  end
end

def each

Returns nothing.

part - String body chunk
block

compatible body objects.
Public: Add enumerator to allow `Asset` instances to be used as Rack
def each
  yield to_s
end

def environment_version

Experimental RBS support (using type sampling data from the type_fusion project).

def environment_version: () -> String

This signature was generated using 4 samples from 3 applications.

Private: Return the version of the environment where the asset was generated.
def environment_version
  metadata[:environment_version]
end

def eql?(other)

Returns true or false.

Assets are equal if they share the same path and digest.

Public: Compare assets.
def eql?(other)
  self.class == other.class && self.id == other.id
end

def etag

Experimental RBS support (using type sampling data from the type_fusion project).

def etag: () -> String

This signature was generated using 1 sample from 1 application.

Pubic: ETag String of Asset.
def etag
  version = environment_version
  if version && version != ""
    DigestUtils.hexdigest(version + digest)
  else
    DigestUtils.pack_hexdigest(digest)
  end
end

def full_digest_path

Returns String.

Public: Return load path + logical path with digest spliced in.
def full_digest_path
  File.join(@load_path, digest_path)
end

def hash

Returns Integer hash of the id.

in a Set.
Public: Implements Object#hash so Assets can be used as a Hash key or
def hash
  id.hash
end

def hexdigest

Public: Returns String hexdigest of source.
def hexdigest
  DigestUtils.pack_hexdigest(digest)
end

def initialize(attributes = {})

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize: (?(uri | String | load_path | String | filename | String | name | String | logical_path | String | content_type | String | source | NilClass | metadata | digest | String | length | Integer | dependencies | Set | environment_version | String | dependencies_digest | String | id | String | uri | String | load_path | String | filename | String | name | String | logical_path | String | content_type | String | source | String | metadata | dependencies | Set | required | Set | stubbed | Set | links | Set | to_load | Set | to_link | Set | map | version | Integer | file | String | mappings | String | sources |  | names |  | x_sprockets_linecount | Integer | charset | String | digest | String | length | Integer | environment_version | String | dependencies_digest | String | id | String | uri | String | load_path | String | filename | String | name | String | logical_path | String | content_type | String | source | String | metadata | dependencies | Set | sources |  | map | version | Integer | file | String | sections |  | links | Set | included |  | charset | String | digest | String | length | Integer | environment_version | String | dependencies_digest | String | id | String) attributes) -> void

This signature was generated using 23 samples from 4 applications.

Returns Asset.

attributes - Hash of ivars

Environment#find_asset should vend them.
Asset wrappers should not be initialized directly, only

Private: Initialize Asset wrapper from attributes Hash.
def initialize(attributes = {})
  @attributes   = attributes
  @content_type = attributes[:content_type]
  @filename     = attributes[:filename]
  @id           = attributes[:id]
  @load_path    = attributes[:load_path]
  @logical_path = attributes[:logical_path]
  @metadata     = attributes[:metadata]
  @name         = attributes[:name]
  @source       = attributes[:source]
  @uri          = attributes[:uri]
end

def inspect

Returns String.

Public: Pretty inspect
def inspect
  "#<#{self.class}:#{object_id.to_s(16)} #{uri.inspect}>"
end

def integrity

Public: A "named information" URL for subresource integrity.
def integrity
  DigestUtils.integrity_uri(digest)
end

def length

Public: Returns Integer length of source.
def length
  metadata[:length]
end

def links

Experimental RBS support (using type sampling data from the type_fusion project).

def links: () -> Set

This signature was generated using 18 samples from 2 applications.

Returns Set of String asset URIs.

All linked assets should be compiled anytime this asset is.

Public: Get all externally linked asset filenames from asset.
def links
  metadata[:links] || Set.new
end

def source

Experimental RBS support (using type sampling data from the type_fusion project).

def source: () -> String

This signature was generated using 1 sample from 1 application.

Returns String.

Public: Return `String` of concatenated source.
def source
  if @source
    @source
  else
    # File is read everytime to avoid memory bloat of large binary files
    File.binread(filename)
  end
end

def to_hash

Returns a Hash.

Internal: Return all internal instance variables as a hash.
def to_hash
  @attributes
end

def to_s

Returns String.

Public: Alias for #source.
def to_s
  source
end

def write_to(filename)

Returns nothing.

filename - String target

Deprecated: Save asset to disk.
def write_to(filename)
  FileUtils.mkdir_p File.dirname(filename)
  PathUtils.atomic_write(filename) do |f|
    f.write source
  end
  nil
end