Sha256: 09e831da57e78084c4fb3b7a657442979e4b379625a26175b6771e51ca7a3641

Contents?: true

Size: 841 Bytes

Versions: 15

Compression:

Stored size: 841 Bytes

Contents

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

        def format
          File.extname(@archive) == ".exe" ? "exe" : "cab"
        end

        private

        def extract_exe(archive, dir)
          opened = decompressor.search(archive)
          file = opened.files

          while file
            path = File.join(dir, file.filename)
            decompressor.extract(file, path)
            file = file.next
          end
        end

        def decompressor
          @decompressor ||= begin
                              require "libmspack"
                              LibMsPack::CabDecompressor.new
                            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/cab_extractor.rb
fontist-1.8.6 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.8.5 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.8.4 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.8.3 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.8.2 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.8.1 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.7.3 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.7.2 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.7.1 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.7.0 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.6.0 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.5.1 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.5.0 lib/fontist/import/extractors/cab_extractor.rb
fontist-1.4.0 lib/fontist/import/extractors/cab_extractor.rb