Sha256: 45a3eed97f12785c295a8247916ba021b7d4ad92b4b140e4435986c5302a33ef

Contents?: true

Size: 1.33 KB

Versions: 43

Compression:

Stored size: 1.33 KB

Contents

require 'zip'
require_relative 'temp_dir'

module Inferno
  module Terminology
    module Tasks
      class UnzipUMLS
        include TempDir

        attr_reader :version

        def initialize(version:)
          @version = version
        end

        def run
          # https://stackoverflow.com/questions/19754883/how-to-unzip-a-zip-file-containing-folders-and-files-in-rails-while-keeping-the
          Zip::File.open(umls_zip_path) do |zip_file|
            # Handle entries one by one
            zip_file.each do |entry|
              # Extract to file/directory/symlink
              Inferno.logger.info "Extracting #{entry.name}"
              f_path = File.join(umls_dir, entry.name)
              FileUtils.mkdir_p(File.dirname(f_path))
              zip_file.extract(entry, f_path) unless File.exist?(f_path)
            end
          end

          wildcard_path = "#{umls_dir}/20*"
          Zip::File.open(File.expand_path("#{Dir[wildcard_path][0]}/mmsys.zip")) do |zip_file|
            zip_file.each do |entry|
              Inferno.logger.info "Extracting #{entry.name}"
              f_path = File.join((Dir[wildcard_path][0]).to_s, entry.name)
              FileUtils.mkdir_p(File.dirname(f_path))
              zip_file.extract(entry, f_path) unless File.exist?(f_path)
            end
          end
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
onc_certification_g10_test_kit-7.0.3 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-7.0.2 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-7.0.1 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-7.0.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-6.0.3 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-6.0.2 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-6.0.1 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-6.0.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-5.4.2 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-5.4.1 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-5.3.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-5.2.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-5.1.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-5.0.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-4.1.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-4.0.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-3.8.1 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-3.8.0 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-3.7.2 lib/inferno/terminology/tasks/unzip_umls.rb
onc_certification_g10_test_kit-3.7.1 lib/inferno/terminology/tasks/unzip_umls.rb