Class: AnimateIt::AssetManifest
- Inherits:
-
Object
- Object
- AnimateIt::AssetManifest
- Defined in:
- lib/animate_it/asset_manifest.rb
Overview
Validates source inputs that a host application needs to reproduce its compositions. Media remains owned by the host; the gem only defines the manifest contract and checksum/provenance preflight.
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root: Rails.root, path: nil) ⇒ AssetManifest
constructor
A new instance of AssetManifest.
- #validate ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(root: Rails.root, path: nil) ⇒ AssetManifest
Returns a new instance of AssetManifest.
18 19 20 21 |
# File 'lib/animate_it/asset_manifest.rb', line 18 def initialize(root: Rails.root, path: nil) @root = Pathname(root). @path = Pathname(path || @root.join("config/animate_it_assets.yml")) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
16 17 18 |
# File 'lib/animate_it/asset_manifest.rb', line 16 def path @path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
16 17 18 |
# File 'lib/animate_it/asset_manifest.rb', line 16 def root @root end |
Instance Method Details
#validate ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/animate_it/asset_manifest.rb', line 23 def validate manifest = load_manifest assets = manifest.fetch("assets") errors = [] errors << "manifest version must be 1" unless manifest["version"] == 1 errors.concat(validate_assets(assets)) Result.new(assets.size, errors) rescue Errno::ENOENT Result.new(0, ["asset manifest not found: #{path}"]) rescue KeyError, Psych::Exception => e Result.new(0, ["invalid asset manifest #{path}: #{e.}"]) end |
#validate! ⇒ Object
36 37 38 39 40 41 |
# File 'lib/animate_it/asset_manifest.rb', line 36 def validate! result = validate return result if result.success? raise Error, "AnimateIt asset preflight failed:\n- #{result.errors.join("\n- ")}" end |