Sha256: e974c316cf7a189967435d5be5f28688dea1d25365f7ce3a03083fd8bb75aa13

Contents?: true

Size: 874 Bytes

Versions: 15

Compression:

Stored size: 874 Bytes

Contents

module Fontist
  module Import
    module Extractors
      class OleExtractor < Extractor
        def extract
          dir = Dir.mktmpdir
          extract_ole(@archive, dir)
          dir
        end

        def format
          "msi"
        end

        private

        def extract_ole(archive, dir)
          ole = storage.open(archive)
          file = the_largest_file(ole)

          content = ole.file.read(file)
          path = File.join(dir, "data.cab")
          File.open(path, "wb") { |f| f.write(content) }
        end

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

        def the_largest_file(ole)
          ole.dir.entries(".").max_by do |x|
            ole.file.size(x)
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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