Class: Inferno::Terminology::Tasks::UnzipUMLS
- Inherits:
-
Object
- Object
- Inferno::Terminology::Tasks::UnzipUMLS
- Includes:
- TempDir
- Defined in:
- lib/inferno/terminology/tasks/unzip_umls.rb
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(version:) ⇒ UnzipUMLS
constructor
A new instance of UnzipUMLS.
- #run ⇒ Object
Methods included from TempDir
#pipe_files, #umls_dir, #umls_subset_dir, #umls_zip_path, #versioned_temp_dir
Constructor Details
#initialize(version:) ⇒ UnzipUMLS
Returns a new instance of UnzipUMLS.
12 13 14 |
# File 'lib/inferno/terminology/tasks/unzip_umls.rb', line 12 def initialize(version:) @version = version end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/inferno/terminology/tasks/unzip_umls.rb', line 10 def version @version end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/inferno/terminology/tasks/unzip_umls.rb', line 16 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.("#{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 |