Sha256: 878d14bd345e3fb109f66daad20c02ff6fd8c2e0b7ba233c57f84c58f365d0fc

Contents?: true

Size: 1.6 KB

Versions: 18

Compression:

Stored size: 1.6 KB

Contents

module IMW
  module Archives
    module Zip

      include IMW::Archives::Base

      def archive_settings
        @archive_settings ||= {
          :program             => :zip,
          :create              => "-qqr",
          :append              => "-qqg",
          :list                => "-l",
          :extract             => "-qqo",
          :unarchiving_program => :unzip
        }
      end

      protected
      
      # The `unzip' program outputs data in a very annoying format:
      #
      #     Archive:  data.zip
      #       Length     Date   Time    Name
      #      --------    ----   ----    ----
      #         18510  07-28-08 15:58   data/4d7Qrgz7.csv
      #          3418  07-28-08 15:41   data/7S.csv
      #         23353  07-28-08 15:41   data/g.csv
      #           711  07-28-08 15:58   data/g.xml
      #          1095  07-28-08 15:41   data/L.xml
      #          2399  07-28-08 15:58   data/mTAu9H3.xml
      #           152  07-28-08 15:58   data/vaHBS2t5R.dat
      #      --------                   -------
      #         49638                   7 files            
      #
      # which is parsed by this method.
      def archive_contents_string_to_array string
        rows = string.split("\n")
        # ignore the first 3 lines of the output and also discared the
        # last 2 (5 = 2 + 3)
        file_rows = rows[3,(rows.length - 5)]
        file_rows.map do |row|
          if row
            columns = row.lstrip.rstrip.split(' ')
            # grab the filename in the fourth column
            columns[3..-1].join(' ')
          end
        end.compact
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
imw-0.2.18 lib/imw/archives/zip.rb
imw-0.2.17 lib/imw/archives/zip.rb
imw-0.2.16 lib/imw/archives/zip.rb
imw-0.2.15 lib/imw/archives/zip.rb
imw-0.2.14 lib/imw/archives/zip.rb
imw-0.2.13 lib/imw/archives/zip.rb
imw-0.2.12 lib/imw/archives/zip.rb
imw-0.2.11 lib/imw/archives/zip.rb
imw-0.2.10 lib/imw/archives/zip.rb
imw-0.2.9 lib/imw/archives/zip.rb
imw-0.2.8 lib/imw/archives/zip.rb
imw-0.2.7 lib/imw/archives/zip.rb
imw-0.2.6 lib/imw/archives/zip.rb
imw-0.2.5 lib/imw/archives/zip.rb
imw-0.2.4 lib/imw/archives/zip.rb
imw-0.2.3 lib/imw/archives/zip.rb
imw-0.2.2 lib/imw/archives/zip.rb
imw-0.2.1 lib/imw/archives/zip.rb