Class: Measures::BaseLoaderDefinition
- Inherits:
-
Object
- Object
- Measures::BaseLoaderDefinition
- Defined in:
- lib/measures/loading/base_loader_definition.rb
Overview
Base Class for the different types of loader formats Bonnie Bundler supports.
Direct Known Subclasses
Class Method Summary collapse
- .extract(zip_file, entry, out_dir) ⇒ Object
-
.extract_xml_files(zip_file, files, output_directory = nil) ⇒ Object
Wrapper function that performs checks before extracting all xml files in the given zip Returns a hash with the type of xml files present and their paths.
Class Method Details
.extract(zip_file, entry, out_dir) ⇒ Object
5 6 7 8 9 |
# File 'lib/measures/loading/base_loader_definition.rb', line 5 def self.extract(zip_file, entry, out_dir) out_file = File.join(out_dir,Pathname.new(entry.name).basename.to_s) zip_file.extract(entry, out_file) out_file end |
.extract_xml_files(zip_file, files, output_directory = nil) ⇒ Object
Wrapper function that performs checks before extracting all xml files in the given zip Returns a hash with the type of xml files present and their paths. Ex: => ‘/var/149825825jf/Test111_eMeasure.xml’
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/measures/loading/base_loader_definition.rb', line 14 def self.extract_xml_files(zip_file, files, output_directory=nil) file_paths_hash = {} if files.count > 0 # If no directory is given, create a new temporary directory. if output_directory.nil? # Create a temporary directory to extract all xml files contained in the zip. Dir.mktmpdir do |dir| file_paths_hash = extract_to_temporary_location(zip_file, files, dir) end # Use the provided directory to extract the files to. else file_paths_hash = extract_to_temporary_location(zip_file, files, output_directory) end end file_paths_hash end |