Class: Uniword::Themes::ThemeLoader
- Inherits:
-
Object
- Object
- Uniword::Themes::ThemeLoader
- Defined in:
- lib/uniword/theme/theme_loader.rb
Overview
Orchestrates theme loading from .thmx files
Coordinates between ThemePackageReader and ThemeXmlParser to load themes and their variants from .thmx packages.
Instance Method Summary collapse
-
#load(path) ⇒ Theme
Load theme from .thmx file.
-
#load_with_variant(path, variant_id) ⇒ Theme
Load theme with specific variant applied.
Instance Method Details
#load(path) ⇒ Theme
Load theme from .thmx file
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/uniword/theme/theme_loader.rb', line 25 def load(path) # Extract package reader = ThemePackageReader.new extracted = reader.extract(path) # Parse base theme parser = ThemeXmlParser.new theme = parser.parse(extracted[:base]) # Store source file reference theme.source_file = path # Store media files theme.media_files = extracted[:media] || {} # Load variants theme.variants = load_variants(extracted[:variants]) theme end |
#load_with_variant(path, variant_id) ⇒ Theme
Load theme with specific variant applied
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/uniword/theme/theme_loader.rb', line 53 def load_with_variant(path, variant_id) # Normalize variant ID variant_key = normalize_variant_id(variant_id) # Load base theme base_theme = load(path) # Get variant variant = base_theme.variants[variant_key] unless variant raise ArgumentError, "Variant '#{variant_id}' not found. " \ "Available variants: #{base_theme.variants.keys.join(', ')}" end # Apply variant to base theme variant.apply_to(base_theme) end |