Class: BunBunBundle::Manifest
- Inherits:
-
Object
- Object
- BunBunBundle::Manifest
- Defined in:
- lib/bun_bun_bundle/manifest.rb
Defined Under Namespace
Classes: Entry, InvalidEntryError, MigrationError, MissingAssetError
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Class Method Summary collapse
-
.load(path: nil, root: Dir.pwd, retries: 10, delay: 0.25) ⇒ Object
Loads the manifest from a JSON file.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #css_entry_points ⇒ Object
-
#initialize(entries = {}) ⇒ Manifest
constructor
A new instance of Manifest.
- #key?(key) ⇒ Boolean
Constructor Details
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
26 27 28 |
# File 'lib/bun_bun_bundle/manifest.rb', line 26 def entries @entries end |
Class Method Details
.load(path: nil, root: Dir.pwd, retries: 10, delay: 0.25) ⇒ Object
Loads the manifest from a JSON file.
Retries a configurable number of times to allow for the manifest to be built during boot (e.g. in development).
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bun_bun_bundle/manifest.rb', line 38 def self.load(path: nil, root: Dir.pwd, retries: 10, delay: 0.25) path ||= BunBunBundle.config.manifest_path full_path = File.(path, root) retries.times do if File.exist?(full_path) data = JSON.parse(File.read(full_path)) return new(data) end sleep(delay) end raise "Manifest not found at #{full_path}. Run: bun_bun_bundle build" end |
Instance Method Details
#[](key) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/bun_bun_bundle/manifest.rb', line 53 def [](key) entries.fetch(key) do suggestion = find_similar(key) = "Asset not found: #{key}" += ". Did you mean: #{suggestion}?" if suggestion raise MissingAssetError, end end |
#css_entry_points ⇒ Object
66 67 68 |
# File 'lib/bun_bun_bundle/manifest.rb', line 66 def css_entry_points entries.keys.select { |k| k.end_with?('.css') } end |
#key?(key) ⇒ Boolean
62 63 64 |
# File 'lib/bun_bun_bundle/manifest.rb', line 62 def key?(key) entries.key?(key) end |