Module: AnimateIt

Defined in:
lib/animate_it.rb,
lib/animate_it/beats.rb,
lib/animate_it/scene.rb,
lib/animate_it/style.rb,
lib/animate_it/units.rb,
lib/animate_it/easing.rb,
lib/animate_it/engine.rb,
lib/animate_it/errors.rb,
lib/animate_it/output.rb,
lib/animate_it/timing.rb,
lib/animate_it/version.rb,
lib/animate_it/registry.rb,
lib/animate_it/timeline.rb,
lib/animate_it/animation.rb,
lib/animate_it/composition.rb,
lib/animate_it/props_schema.rb,
lib/animate_it/render_store.rb,
lib/animate_it/view_helpers.rb,
lib/animate_it/configuration.rb,
lib/animate_it/frame_context.rb,
lib/animate_it/asset_renderer.rb,
lib/animate_it/frame_duration.rb,
lib/animate_it/video_renderer.rb,
app/jobs/animate_it/render_job.rb,
lib/animate_it/animation_helpers.rb,
app/jobs/animate_it/application_job.rb,
app/controllers/animate_it/audio_controller.rb,
app/controllers/animate_it/props_controller.rb,
app/controllers/animate_it/frames_controller.rb,
app/controllers/animate_it/studio_controller.rb,
app/controllers/animate_it/renders_controller.rb,
app/controllers/animate_it/application_controller.rb,
lib/generators/animate_it/install/install_generator.rb

Overview

playwright is a development-only gem (deploy image runs bundle install --without development test). Defer loading until a render is actually requested so production boot / asset precompile can load this file without the gem present.

Defined Under Namespace

Modules: AnimationHelpers, AssetRenderer, Easing, Generators, Style, Timing, Units, ViewHelpers Classes: AnimatableBuilder, AnimatableElement, AnimationProperty, AnimationSet, ApplicationController, ApplicationJob, AudioController, Beat, Beats, Composition, CompositionNotFoundError, Configuration, Engine, Error, FrameContext, FrameDuration, FramesController, Output, OutputsBuilder, PropsController, PropsSchema, Registry, RenderJob, RenderStore, RendersController, Scene, StudioController, Timeline, VideoRenderer

Constant Summary collapse

VERSION =
"0.1.0".freeze

Class Method Summary collapse

Class Method Details

.compositionsObject



43
44
45
# File 'lib/animate_it.rb', line 43

def compositions
  registry.all
end

.configObject



31
32
33
# File 'lib/animate_it.rb', line 31

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



35
36
37
# File 'lib/animate_it.rb', line 35

def configure
  yield(config)
end

.load_compositions!Object

Boot-time + dev-reload entry point. Wired by the engine's to_prepare initializer, which fires once at boot and on every autoloader reload after a watched file changes.

The host's app/videos is in config.autoload_paths (set by the engine), so Zeitwerk owns the constants. On reload Zeitwerk has already remove_const'd every composition by the time we run, so eager_load_dir re-defines them fresh and the inherited hook fires — guaranteeing a clean Timeline / @beats / @outputs per reload (no stale segments accumulating across edits).



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/animate_it.rb', line 61

def load_compositions!
  return unless defined?(Rails) && Rails.respond_to?(:root) && Rails.root

  videos_dir = Rails.root.join("app/videos")
  return unless videos_dir.directory?

  if defined?(Rails.autoloaders) && Rails.autoloaders.main.respond_to?(:eager_load_dir)
    Rails.autoloaders.main.eager_load_dir(videos_dir.to_s)
  else
    # Fallback for environments without Zeitwerk eager_load_dir
    # (older Rails / non-Zeitwerk autoloaders). `load` re-runs the
    # file each time which is fine here because compositions are
    # idempotent re-openable classes.
    videos_dir.glob("**/*.rb").sort.each { |path| load(path.to_s) }
  end

  # After every composition class is loaded, give each one a chance
  # to auto-mount its single nested Scene class (the single-scene
  # shorthand). Idempotent: skips comps that already declared a
  # `scene`/`series`/`audio`.
  compositions.each(&:auto_mount_single_scene!)
end

.registryObject



39
40
41
# File 'lib/animate_it.rb', line 39

def registry
  @registry ||= Registry.new
end

.reload_compositions!Object

Dev-reload alias — clears the registry so a renamed or deleted composition id doesn't linger, then re-loads everything.



86
87
88
89
# File 'lib/animate_it.rb', line 86

def reload_compositions!
  registry.reset!
  load_compositions!
end

.reset!Object



47
48
49
# File 'lib/animate_it.rb', line 47

def reset!
  @registry = Registry.new
end