Class: Vizcore::CLISupport::SceneValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/cli/scene_validator.rb

Overview

Validates scene DSL files without starting the realtime server.

Defined Under Namespace

Classes: Issue, Result

Constant Summary collapse

BUILTIN_SHADERS =
Vizcore::LayerCatalog::BUILTIN_SHADERS
MAPPING_SOURCE_KINDS =
%i[
  amplitude peak frequency_band frequency_band_peak fft_spectrum onset kick snare hihat beat beat_confidence beat_pulse beat_count bpm
  beat_phase beat_2 beat_4 beat_8 beat_triplet triplet bar_phase bar_count phrase_count bpm_confidence
  spectral_centroid spectral_rolloff spectral_flatness spectral_flux zero_crossing_rate global lfo adsr envelope
].freeze
LFO_WAVES =
%i[sine triangle saw square].freeze
FREQUENCY_BANDS =
%i[sub low mid high].freeze
SUPPORTED_BLEND_MODES =
Vizcore::LayerCatalog::BLEND_MODES
SUPPORTED_POST_EFFECTS =
Vizcore::LayerCatalog::POST_EFFECTS
SUPPORTED_VJ_EFFECTS =
Vizcore::LayerCatalog::VJ_EFFECTS
SUPPORTED_SHAPE_KINDS =
%i[circle line rect polygon polyline path star].freeze
STRICT_PARAM_ALLOWLIST =
Vizcore::DSL::LayerBuilder::STRICT_PARAM_ALLOWLIST

Instance Method Summary collapse

Constructor Details

#initialize(scene_file:, loader: Vizcore::DSL::Engine.method(:load_file), shader_resolver: Vizcore::DSL::ShaderSourceResolver.new, strict: false) ⇒ SceneValidator

Returns a new instance of SceneValidator.



53
54
55
56
57
58
# File 'lib/vizcore/cli/scene_validator.rb', line 53

def initialize(scene_file:, loader: Vizcore::DSL::Engine.method(:load_file), shader_resolver: Vizcore::DSL::ShaderSourceResolver.new, strict: false)
  @scene_file = scene_file
  @loader = loader
  @shader_resolver = shader_resolver
  @strict = !!strict
end

Instance Method Details

#callObject



60
61
62
63
64
65
66
67
68
# File 'lib/vizcore/cli/scene_validator.rb', line 60

def call
  definition = load_definition
  Result.new(definition: definition, issues: validate_definition(definition))
rescue StandardError => e
  Result.new(
    definition: nil,
    issues: [error("failed to load scene: #{e.message}", code: "E_SCENE_LOAD")]
  )
end