Module: Superset::FileUtilities
- Included in:
- Dashboard::Export, Database::Export, Services::DashboardLoader, Services::ImportDashboardAcrossEnvironments
- Defined in:
- lib/superset/file_utilities.rb
Instance Method Summary collapse
-
#unzip_file(zip_file, destination) ⇒ Object
rubyzip is loaded lazily so the gem can be required without it; only consumers that actually import/export need rubyzip installed.
Instance Method Details
#unzip_file(zip_file, destination) ⇒ Object
rubyzip is loaded lazily so the gem can be required without it; only consumers that actually import/export need rubyzip installed.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/superset/file_utilities.rb', line 5 def unzip_file(zip_file, destination) require 'zip' entries = [] Zip::File.open(zip_file) do |zip| zip.each do |entry| next if entry.name.empty? entry_path = File.join(destination, entry.name) entries << entry_path FileUtils.mkdir_p(File.dirname(entry_path)) zip.extract(entry, entry.name, destination_directory: destination) { true } rescue => e raise "Error extracting file #{entry.name}: #{e.}" end end entries end |