Class: Vizcore::ProjectManifest
- Inherits:
-
Object
- Object
- Vizcore::ProjectManifest
- Defined in:
- lib/vizcore/project_manifest.rb
Overview
Reads a project-level manifest such as vizcore.yml.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
-
#config_defaults(profile: nil) ⇒ Hash
Config defaults accepted by Vizcore::Config.
-
#initialize(path) ⇒ ProjectManifest
constructor
A new instance of ProjectManifest.
-
#plugin_assets(profile: nil) ⇒ Array<Pathname>
Frontend plugin assets served and loaded by RackApp.
-
#plugins(profile: nil) ⇒ Array<String>
Require paths loaded before scene evaluation.
-
#profile_names ⇒ Array<String>
Configured profile names.
Constructor Details
#initialize(path) ⇒ ProjectManifest
Returns a new instance of ProjectManifest.
19 20 21 22 23 24 25 26 27 |
# File 'lib/vizcore/project_manifest.rb', line 19 def initialize(path) @path = Pathname.new(path). raise ArgumentError, "Project manifest not found: #{@path}" unless @path.file? @root = @path.dirname @data = normalize_hash(YAML.safe_load_file(@path, aliases: false) || {}) rescue Psych::Exception => e raise ArgumentError, "Invalid project manifest #{@path}: #{e.}" end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
16 17 18 |
# File 'lib/vizcore/project_manifest.rb', line 16 def path @path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
16 17 18 |
# File 'lib/vizcore/project_manifest.rb', line 16 def root @root end |
Class Method Details
.load(path) ⇒ Vizcore::ProjectManifest
12 13 14 |
# File 'lib/vizcore/project_manifest.rb', line 12 def self.load(path) new(path) end |
Instance Method Details
#config_defaults(profile: nil) ⇒ Hash
Returns config defaults accepted by Vizcore::Config.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vizcore/project_manifest.rb', line 30 def config_defaults(profile: nil) data = data_for(profile) { scene_file: (value_at(data, "scene") || value_at(data, "scene_file")), audio_source: value_at(data, "audio_source") || value_at(data, "audio", "source"), audio_file: (value_at(data, "audio_file") || value_at(data, "audio", "file")), audio_device: value_at(data, "audio_device") || value_at(data, "audio", "device"), feature_file: (value_at(data, "feature_file") || value_at(data, "features")), control_preset: (value_at(data, "control_preset") || value_at(data, "controlPreset")), osc_port: value_at(data, "osc_port") || value_at(data, "sync", "osc_port") || value_at(data, "sync", "osc", "port"), scene_switch_effect: value_at(data, "scene_switch_effect"), scene_switch_effect_duration: value_at(data, "scene_switch_effect_duration"), plugin_assets: plugin_assets(profile: profile) }.compact end |
#plugin_assets(profile: nil) ⇒ Array<Pathname>
Returns frontend plugin assets served and loaded by RackApp.
52 53 54 55 56 57 |
# File 'lib/vizcore/project_manifest.rb', line 52 def plugin_assets(profile: nil) entries = plugin_entries(profile: profile) assets = base_values("plugin_assets", "frontend_plugins") + profile_values(profile, "plugin_assets", "frontend_plugins") manifest_assets = assets.filter_map { |entry| validate_plugin_asset_path((entry)) } (entries.filter_map { |entry| plugin_asset_path(entry) } + manifest_assets).uniq end |
#plugins(profile: nil) ⇒ Array<String>
Returns require paths loaded before scene evaluation.
47 48 49 |
# File 'lib/vizcore/project_manifest.rb', line 47 def plugins(profile: nil) plugin_entries(profile: profile).filter_map { |entry| plugin_require_path(entry) }.uniq end |
#profile_names ⇒ Array<String>
Returns configured profile names.
60 61 62 |
# File 'lib/vizcore/project_manifest.rb', line 60 def profile_names Hash(@data["profiles"] || {}).keys end |