lib/fontist/utils/exe_extractor.rb in fontist-1.5.0 vs lib/fontist/utils/exe_extractor.rb in fontist-1.5.1

- old
+ new

@@ -10,14 +10,14 @@ fonts_paths = extract_cabbed_fonts_to_assets(cabbed_fonts) block_given? ? yield(fonts_paths) : fonts_paths end - def exe_extract(source) + def exe_extract(source, subarchive: nil) cab_file = decompressor.search(download_file(source).path) - fonts_paths = build_cab_file_hash(cab_file.files) - block_given? ? yield(fonts_paths) : fonts_paths + subarchive_path = extract_subarchive(cab_file.files, subarchive) + block_given? ? yield(subarchive_path) : subarchive_path end private def decompressor @@ -45,21 +45,28 @@ fonts.push(font_path) end end end - def build_cab_file_hash(file) + def extract_subarchive(file, subarchive = nil) while file filename = file.filename - if filename.include?("cab") || filename.include?("msi") + + if subarchive_found?(filename, subarchive) file_path = File.join(Dir.mktmpdir, filename) decompressor.extract(file, file_path) return file_path end file = file.next end + end + + def subarchive_found?(filename, subarchive) + return subarchive == filename if subarchive + + filename.include?("cab") || filename.include?("msi") end end end end