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.
18 19 20 21 22 23 24 25 26 |
# File 'lib/vizcore/project_manifest.rb', line 18 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.
15 16 17 |
# File 'lib/vizcore/project_manifest.rb', line 15 def path @path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
15 16 17 |
# File 'lib/vizcore/project_manifest.rb', line 15 def root @root end |
Class Method Details
.load(path) ⇒ Vizcore::ProjectManifest
11 12 13 |
# File 'lib/vizcore/project_manifest.rb', line 11 def self.load(path) new(path) end |
Instance Method Details
#config_defaults(profile: nil) ⇒ Hash
Returns config defaults accepted by Vizcore::Config.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vizcore/project_manifest.rb', line 29 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"), plugin_assets: plugin_assets(profile: profile) }.compact end |
#plugin_assets(profile: nil) ⇒ Array<Pathname>
Returns frontend plugin assets served and loaded by RackApp.
49 50 51 52 53 |
# File 'lib/vizcore/project_manifest.rb', line 49 def plugin_assets(profile: nil) entries = plugin_entries(profile: profile) assets = base_values("plugin_assets", "frontend_plugins") + profile_values(profile, "plugin_assets", "frontend_plugins") (entries.filter_map { |entry| plugin_asset_path(entry) } + assets.filter_map { |entry| (entry) }).uniq end |
#plugins(profile: nil) ⇒ Array<String>
Returns require paths loaded before scene evaluation.
44 45 46 |
# File 'lib/vizcore/project_manifest.rb', line 44 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.
56 57 58 |
# File 'lib/vizcore/project_manifest.rb', line 56 def profile_names Hash(@data["profiles"] || {}).keys end |