Sha256: 9ed2836269a3a6658488766ffe121ff855d47dd8ffa25af2437fb8dfaa2392d2

Contents?: true

Size: 1.05 KB

Versions: 17

Compression:

Stored size: 1.05 KB

Contents

module GeoConcerns
  module Processors
    module Zip
      extend ActiveSupport::Concern

      included do
        # Unzips a file, invokes a block, and then deletes the unzipped file(s).
        # Use to wrap processor methods for geo file formats that
        # are zipped before uploading.
        # @param in_path [String] file input path
        # @param output_file [String] processor output file path
        def self.unzip(in_path, output_file, _options = {})
          basename = File.basename(output_file, File.extname(output_file))
          zip_out_path = "#{File.dirname(output_file)}/#{basename}_out"
          execute "unzip -qq -j -d \"#{zip_out_path}\" \"#{in_path}\""
          yield zip_out_path
          FileUtils.rm_rf(zip_out_path)
        end

        # Zips a file or directory.
        # @param in_path [String] file input path
        # @param output_file [String] output zip file
        def self.zip(in_path, output_file, _options = {})
          execute "zip -j -qq -r \"#{output_file}\" \"#{in_path}\""
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
geo_concerns-0.3.4 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.3.3 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.3.2 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.3.1 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.3.0 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.2.0 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.1.1 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.1.0 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.10 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.9 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.8 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.7 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.6 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.5 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.4 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.3 app/processors/geo_concerns/processors/zip.rb
geo_concerns-0.0.2 app/processors/geo_concerns/processors/zip.rb