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
- .filename_for(logical) ⇒ Object
-
.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.
- .manifest ⇒ Object
- .root ⇒ Object
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.
25 26 27 |
# File 'lib/telm/assets.rb', line 25 def include?(filename) manifest.value?(filename) end |
.manifest ⇒ Object
15 16 17 |
# File 'lib/telm/assets.rb', line 15 def manifest @manifest ||= JSON.parse(root.join("manifest.json").read).freeze end |