Sha256: f316b18e747355be066039df6597cd8adea712d4b783299198f3b591b3bd8701

Contents?: true

Size: 893 Bytes

Versions: 15

Compression:

Stored size: 893 Bytes

Contents

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

        def try
          File.open(@archive, "rb") do |file|
            reader.open(file)
          end

          true
        rescue StandardError => e
          return false if e.message.start_with?("Invalid file format")

          raise
        end

        def format
          "seven_zip"
        end

        private

        def extract_7z(archive, dir)
          File.open(archive, "rb") do |file|
            reader.extract_all(file, dir)
          end
        end

        def reader
          @reader ||= begin
                        require "seven_zip_ruby"
                        SevenZipRuby::Reader
                      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/seven_zip_extractor.rb
fontist-1.8.6 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.8.5 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.8.4 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.8.3 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.8.2 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.8.1 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.7.3 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.7.2 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.7.1 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.7.0 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.6.0 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.5.1 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.5.0 lib/fontist/import/extractors/seven_zip_extractor.rb
fontist-1.4.0 lib/fontist/import/extractors/seven_zip_extractor.rb