Class: Minipack::Manifest
- Inherits:
-
Object
- Object
- Minipack::Manifest
- Defined in:
- lib/minipack/manifest.rb
Defined Under Namespace
Classes: ChunkGroup, Entry, FileNotFoundError, MissingEntryError
Instance Attribute Summary collapse
-
#cache ⇒ Object
writeonly
Sets the attribute cache.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #assets ⇒ Object
- #cache_enabled? ⇒ Boolean
-
#find(name) ⇒ Minipack::Entry
Find an entry by it’s name.
-
#initialize(path, cache: false) ⇒ Manifest
constructor
A new instance of Manifest.
- #lookup!(name) ⇒ Object
- #lookup_pack_with_chunks!(name, type: nil) ⇒ Object
Constructor Details
#initialize(path, cache: false) ⇒ Manifest
Returns a new instance of Manifest.
45 46 47 48 |
# File 'lib/minipack/manifest.rb', line 45 def initialize(path, cache: false) @path = path.to_s @cache = cache end |
Instance Attribute Details
#cache=(value) ⇒ Object (writeonly)
Sets the attribute cache
43 44 45 |
# File 'lib/minipack/manifest.rb', line 43 def cache=(value) @cache = value end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
42 43 44 |
# File 'lib/minipack/manifest.rb', line 42 def path @path end |
Instance Method Details
#assets ⇒ Object
79 80 81 |
# File 'lib/minipack/manifest.rb', line 79 def assets data.values end |
#cache_enabled? ⇒ Boolean
83 84 85 |
# File 'lib/minipack/manifest.rb', line 83 def cache_enabled? @cache end |
#find(name) ⇒ Minipack::Entry
Find an entry by it’s name
70 71 72 73 74 75 76 77 |
# File 'lib/minipack/manifest.rb', line 70 def find(name) path = data[name.to_s] || return if path.is_a? Hash integrity = path['integrity'] path = path['src'] end Entry.new(path, integrity: integrity) end |
#lookup!(name) ⇒ Object
62 63 64 |
# File 'lib/minipack/manifest.rb', line 62 def lookup!(name) find(name) || handle_missing_entry(name) end |
#lookup_pack_with_chunks!(name, type: nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/minipack/manifest.rb', line 50 def lookup_pack_with_chunks!(name, type: nil) manifest_pack_type = manifest_type(name, type) manifest_pack_name = manifest_name(name, manifest_pack_type) paths = data['entrypoints']&.dig(manifest_pack_name, manifest_pack_type) || handle_missing_entry(name) entries = data['entrypoints']&.dig(manifest_pack_name, manifest_pack_type).map do |source| entry_from_source(source) || handle_missing_entry(name) end ChunkGroup.new(entries) end |