Class: Manifester::Manifest
- Inherits:
-
Object
- Object
- Manifester::Manifest
- Defined in:
- lib/manifester/manifest.rb
Defined Under Namespace
Classes: MissingEntryError
Instance Method Summary collapse
-
#initialize(manifester) ⇒ Manifest
constructor
A new instance of Manifest.
-
#lookup(name, pack_type = {}) ⇒ Object
Computes the relative path for a given Manifester asset using manifest.json.
-
#lookup!(name, pack_type = {}) ⇒ Object
Like lookup, except that if no asset is found, raises a Manifester::Manifest::MissingEntryError.
- #lookup_manifest_with_chunks(name, pack_type = {}) ⇒ Object
- #lookup_manifest_with_chunks!(name, pack_type = {}) ⇒ Object
- #refresh ⇒ Object
Constructor Details
#initialize(manifester) ⇒ Manifest
Returns a new instance of Manifest.
7 8 9 |
# File 'lib/manifester/manifest.rb', line 7 def initialize(manifester) @manifester = manifester end |
Instance Method Details
#lookup(name, pack_type = {}) ⇒ Object
Computes the relative path for a given Manifester asset using manifest.json. If no asset is found, returns nil.
Example:
Manifester.manifest.lookup('calendar.js') # => "/packs/calendar-1016838bab065ae1e122.js"
33 34 35 |
# File 'lib/manifester/manifest.rb', line 33 def lookup(name, pack_type = {}) find(full_pack_name(name, pack_type[:type])) end |
#lookup!(name, pack_type = {}) ⇒ Object
Like lookup, except that if no asset is found, raises a Manifester::Manifest::MissingEntryError.
38 39 40 |
# File 'lib/manifester/manifest.rb', line 38 def lookup!(name, pack_type = {}) lookup(name, pack_type) || handle_missing_entry(name, pack_type) end |
#lookup_manifest_with_chunks(name, pack_type = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/manifester/manifest.rb', line 15 def lookup_manifest_with_chunks(name, pack_type = {}) manifest_pack_type = manifest_type(pack_type[:type]) manifest_pack_name = manifest_name(name, manifest_pack_type) find("entrypoints")[manifest_pack_name]["assets"][manifest_pack_type] rescue NoMethodError nil end |
#lookup_manifest_with_chunks!(name, pack_type = {}) ⇒ Object
23 24 25 |
# File 'lib/manifester/manifest.rb', line 23 def lookup_manifest_with_chunks!(name, pack_type = {}) lookup_manifest_with_chunks(name, pack_type) || handle_missing_entry(name, pack_type) end |
#refresh ⇒ Object
11 12 13 |
# File 'lib/manifester/manifest.rb', line 11 def refresh @data = load end |