Module: Telm::Assets

Defined in:
lib/telm/assets.rb

Overview

Reads the compiled Dimsum distribution's manifest (written by dimsum-dist/build.mjs) and resolves logical names ("telm.css") to the content-hashed filenames committed under app/assets/telm/.

Class Method Summary collapse

Class Method Details

.filename_for(logical) ⇒ Object



19
20
21
# File 'lib/telm/assets.rb', line 19

def filename_for(logical)
  manifest.fetch(logical)
end

.include?(filename) ⇒ Boolean

The allowlist check the assets controller serves against — an exact match on manifest values, so traversal input can never name a file.

Returns:

  • (Boolean)


25
26
27
# File 'lib/telm/assets.rb', line 25

def include?(filename)
  manifest.value?(filename)
end

.manifestObject



15
16
17
# File 'lib/telm/assets.rb', line 15

def manifest
  @manifest ||= JSON.parse(root.join("manifest.json").read).freeze
end

.rootObject



11
12
13
# File 'lib/telm/assets.rb', line 11

def root
  Engine.root.join("app/assets/telm")
end