9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/ace/demo/atoms/yaml_record_planner.rb', line 9
def plan(
tape_path:,
output:,
format:,
playback_speed:,
retime_output:,
yaml_spec:,
yaml_parser:,
supported_formats:,
default_output_path_builder:,
backend: nil,
default_backend: "asciinema"
)
spec = yaml_spec || yaml_parser.parse_file(tape_path)
settings = spec["settings"] || {}
selected_backend = RecordOptionValidator.normalize_backend(backend || settings["backend"] || default_backend)
selected_format = RecordOptionValidator.normalize_format(
format || settings["format"] || "gif",
supported_formats: supported_formats,
allow_nil: false
)
RecordOptionValidator.validate_yaml_backend_format!(backend: selected_backend, format: selected_format)
selected_speed = playback_speed.nil? ? settings["playback_speed"] : playback_speed
selected_speed = Atoms::PlaybackSpeedParser.parse(selected_speed)
selected_output = output.nil? ? settings["output"] : output
selected_retime_output = retime_output || selected_output
default_output_path = File.expand_path(default_output_path_builder.call(selected_format), Dir.pwd)
raw_output_path, retime_output_path = resolve_output_paths(
default_output_path: default_output_path,
output: selected_output,
speed: selected_speed,
retime_output: selected_retime_output
)
{
spec: spec,
backend: selected_backend,
format: selected_format,
speed: selected_speed,
selected_output: selected_output,
raw_output_path: raw_output_path,
retime_output_path: retime_output_path
}
end
|