Sha256: 6dda45666fd74bca539f46665613c756b7e1498e9c6952c3c130f81798bcbc75

Contents?: true

Size: 776 Bytes

Versions: 15

Compression:

Stored size: 776 Bytes

Contents

module Fontist
  module Utils
    module MsiExtractor
      def msi_extract(resource)
        file = @downloaded ? resource : download_file(resource)

        cab_content = read_the_largest_file(file)

        cab_file = Tempfile.new(["data", ".cab"], mode: File::BINARY)
        cab_file.write(cab_content)

        block_given? ? yield(cab_file.path) : cab_file.path
      end

      private

      def read_the_largest_file(file)
        ole = storage.open(file)
        the_largest_file = ole.dir.entries(".").max_by { |x| ole.file.size(x) }
        ole.file.read(the_largest_file)
      end

      def storage
        @storage ||= begin
                       require "ole/storage"
                       Ole::Storage
                     end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fontist-1.8.7 lib/fontist/utils/msi_extractor.rb
fontist-1.8.6 lib/fontist/utils/msi_extractor.rb
fontist-1.8.5 lib/fontist/utils/msi_extractor.rb
fontist-1.8.4 lib/fontist/utils/msi_extractor.rb
fontist-1.8.3 lib/fontist/utils/msi_extractor.rb
fontist-1.8.2 lib/fontist/utils/msi_extractor.rb
fontist-1.8.1 lib/fontist/utils/msi_extractor.rb
fontist-1.7.3 lib/fontist/utils/msi_extractor.rb
fontist-1.7.2 lib/fontist/utils/msi_extractor.rb
fontist-1.7.1 lib/fontist/utils/msi_extractor.rb
fontist-1.7.0 lib/fontist/utils/msi_extractor.rb
fontist-1.6.0 lib/fontist/utils/msi_extractor.rb
fontist-1.5.1 lib/fontist/utils/msi_extractor.rb
fontist-1.5.0 lib/fontist/utils/msi_extractor.rb
fontist-1.4.0 lib/fontist/utils/msi_extractor.rb