screenkit 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ScreenKit
4
- class Callout
5
- class TextStyle
6
- attr_reader :color, :size, :font_path, :align
7
-
8
- def initialize(source:, **kwargs)
9
- @source = source
10
-
11
- kwargs.each do |key, value|
12
- value = case key.to_sym
13
- when :font_path
14
- @source.search(value)
15
- else
16
- value
17
- end
18
-
19
- instance_variable_set(:"@#{key}", value)
20
- end
21
- end
22
-
23
- # Convert hex color (with optional alpha) to RGB + opacity
24
- # #RRGGBB or #RRGGBBAA
25
- def rgb_color
26
- color.match(/#([0-9a-fA-F]{6})/) {|m| m[1] }
27
- end
28
-
29
- def opacity
30
- if color.length == 9
31
- color.match(/#[0-9a-fA-F]{6}([0-9a-fA-F]{2})/) do |m|
32
- m[1].to_i(16) / 255.0
33
- end
34
- else
35
- 1.0
36
- end
37
- end
38
-
39
- def as_json(*)
40
- {color:, size:, font_path:, rgb_color:, opacity:, align:}
41
- end
42
- end
43
- end
44
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ScreenKit
4
- module Config
5
- class Base
6
- extend SchemaValidator
7
-
8
- attr_reader :raw_options
9
-
10
- def self.load_file(path)
11
- unless File.file?(path)
12
- raise FileNotFoundError, "Config file not found: #{path}"
13
- end
14
-
15
- template = File.read(path)
16
- contents = ERB.new(template).result
17
-
18
- config = YAML.load(contents, symbolize_names: true)
19
- load(config)
20
- end
21
-
22
- def self.load(config)
23
- validate!(config)
24
-
25
- new(**config)
26
- end
27
-
28
- def initialize(**kwargs)
29
- @raw_options = kwargs
30
-
31
- kwargs.each do |key, value|
32
- value = process(key, value)
33
- instance_variable_set(:"@#{key}", value)
34
- end
35
- end
36
-
37
- def process(_key, value)
38
- value
39
- end
40
-
41
- def to_h
42
- instance_variables.each_with_object({}) do |var, hash|
43
- key = var.to_s.delete_prefix("@").to_sym
44
- value = instance_variable_get(var)
45
-
46
- hash[key] =
47
- if value.respond_to?(:as_json)
48
- value.as_json
49
- elsif value.is_a?(Array)
50
- value.map {|v| v.respond_to?(:as_json) ? v.as_json : v }
51
- else
52
- value
53
- end
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ScreenKit
4
- module Config
5
- class Episode < Base
6
- # The scenes configuration for the episode.
7
- attr_reader :scenes
8
-
9
- # The title of the episode.
10
- attr_reader :title
11
-
12
- # The episode's TTS engine configuration.
13
- attr_reader :tts
14
-
15
- # The episode's backtrack music configuration.
16
- attr_reader :backtrack
17
-
18
- # The watermark configuration.
19
- attr_reader :watermark
20
-
21
- # The demotape configuration.
22
- attr_reader :demotape
23
-
24
- # The callout styles configuration.
25
- attr_reader :callout_styles
26
-
27
- def self.schema_path
28
- @schema_path ||=
29
- ScreenKit.root_dir.join("schemas/episode.json")
30
- end
31
-
32
- def initialize(**)
33
- @scenes = {}
34
-
35
- super
36
- end
37
-
38
- def process(key, value)
39
- case key.to_sym
40
- when /_(dir|path)$/
41
- Pathname(value)
42
- else
43
- value
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ScreenKit
4
- module Config
5
- class Project < Base
6
- # The directory where episode source files are stored.
7
- attr_reader :episode_dir
8
-
9
- # The directory where resources files are stored.
10
- attr_reader :resources_dir
11
-
12
- # The output directory for exported files.
13
- attr_reader :output_dir
14
-
15
- # Callout styles
16
- attr_reader :callout_styles
17
-
18
- # Scene configurations
19
- attr_reader :scenes
20
-
21
- # TTS configuration
22
- attr_reader :tts
23
-
24
- # The backtrack music configuration.
25
- attr_reader :backtrack
26
-
27
- # The watermark configuration.
28
- attr_reader :watermark
29
-
30
- # The demotape configuration.
31
- attr_reader :demotape
32
-
33
- def self.schema_path
34
- @schema_path ||=
35
- ScreenKit.root_dir.join("schemas/project.json")
36
- end
37
-
38
- private def process(key, value)
39
- case key.to_sym
40
- when :resources_dir
41
- Array(value)
42
- when /_(dir|path)$/
43
- Pathname(value)
44
- else
45
- value
46
- end
47
- end
48
-
49
- def to_h
50
- raw_options
51
- end
52
- end
53
- end
54
- end
@@ -1,26 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "$id": "https://screenkit.dev/schemas/episode.json",
4
- "title": "ScreenKit Episode Configuration (config.yml)",
5
- "type": "object",
6
- "required": ["title"],
7
- "properties": {
8
- "backtrack": { "$ref": "refs/sound.json" },
9
- "scenes": { "$ref": "refs/scenes.json" },
10
- "tts": { "$ref": "refs/tts.json" },
11
- "watermark": { "$ref": "refs/watermark.json" },
12
- "title": {
13
- "type": "string",
14
- "description": "The episode title",
15
- "minLength": 1,
16
- "pattern": "\\S"
17
- },
18
- "demotape": { "$ref": "refs/demotape.json" },
19
- "callout_styles": {
20
- "type": "object",
21
- "additionalProperties": {
22
- "$ref": "refs/callout_style.json"
23
- }
24
- }
25
- }
26
- }