Class: Uniword::Themes::ThemePackageReader
- Inherits:
-
Object
- Object
- Uniword::Themes::ThemePackageReader
- Defined in:
- lib/uniword/theme/theme_package_reader.rb
Overview
Reads and extracts .thmx theme package files
.thmx files are ZIP archives containing PowerPoint theme definitions with optional variant packages. The actual Word theme is nested at theme/theme/theme1.xml (not theme/theme1.xml as initially expected).
Instance Method Summary collapse
-
#extract(path) ⇒ Hash
Extract theme files from .thmx package.
Instance Method Details
#extract(path) ⇒ Hash
Extract theme files from .thmx package
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 |
# File 'lib/uniword/theme/theme_package_reader.rb', line 26 def extract(path) extractor = Infrastructure::ZipExtractor.new content = extractor.extract(path) # Extract base theme from corrected path base_theme_xml = content["theme/theme/theme1.xml"] unless base_theme_xml raise ArgumentError, "Invalid theme package: missing theme/theme/theme1.xml" end # Extract variants variants = extract_variants(content) # Extract variant manager if present variant_manager_xml = content["themeVariants/themeVariantManager.xml"] # Extract media files media = extract_media_files(content) { base: base_theme_xml, variants: variants, variant_manager: variant_manager_xml, media: media, } end |