zip 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,154 @@
1
+ = Version 2.0.2
2
+
3
+ Change project name to just "zip". samlown.
4
+ Added support for StringIO. edsono (August 2008)
5
+
6
+ = Version 2.0.1
7
+
8
+ Support for Ruby 1.9.1, postmodern
9
+
10
+
11
+ = Version 0.9.1
12
+
13
+ Added symlink support and support for unix file permissions. Reduced
14
+ memory usage during decompression.
15
+
16
+ New methods ZipFile::[follow_symlinks, restore_times, restore_permissions, restore_ownership].
17
+ New methods ZipEntry::unix_perms, ZipInputStream::eof?.
18
+ Added documentation and test for new ZipFile::extract.
19
+ Added some of the API suggestions from sf.net #1281314.
20
+ Applied patch for sf.net bug #1446926.
21
+ Applied patch for sf.net bug #1459902.
22
+ Rework ZipEntry and delegate classes.
23
+
24
+ = Version 0.5.12
25
+
26
+ Fixed problem with writing binary content to a ZipFile in MS Windows.
27
+
28
+ = Version 0.5.11
29
+
30
+ Fixed name clash file method copy_stream from fileutils.rb. Fixed
31
+ problem with references to constant CHUNK_SIZE.
32
+ ZipInputStream/AbstractInputStream read is now buffered like ruby IO's
33
+ read method, which means that read and gets etc can be mixed. The
34
+ unbuffered read method has been renamed to sysread.
35
+
36
+ = Version 0.5.10
37
+
38
+ Fixed method name resolution problem with FileUtils::copy_stream and
39
+ IOExtras::copy_stream.
40
+
41
+ = Version 0.5.9
42
+
43
+ Fixed serious memory consumption issue
44
+
45
+ = Version 0.5.8
46
+
47
+ Fixed install script.
48
+
49
+ = Version 0.5.7
50
+
51
+ install.rb no longer assumes it is being run from the toplevel source
52
+ dir. Directory structure changed to reflect common ruby library
53
+ project structure. Migrated from RubyUnit to Test::Unit format. Now
54
+ uses Rake to build source packages and gems and run unit tests.
55
+
56
+ = Version 0.5.6
57
+
58
+ Fix for FreeBSD 4.9 which returns Errno::EFBIG instead of
59
+ Errno::EINVAL for some invalid seeks. Fixed 'version needed to
60
+ extract'-field incorrect in local headers.
61
+
62
+ = Version 0.5.5
63
+
64
+ Fix for a problem with writing zip files that concerns only ruby 1.8.1.
65
+
66
+ = Version 0.5.4
67
+
68
+ Significantly reduced memory footprint when modifying zip files.
69
+
70
+ = Version 0.5.3
71
+
72
+ Added optimization to avoid decompressing and recompressing individual
73
+ entries when modifying a zip archive.
74
+
75
+ = Version 0.5.2
76
+
77
+ Fixed ZipFile corruption bug in ZipFile class. Added basic unix
78
+ extra-field support.
79
+
80
+ = Version 0.5.1
81
+
82
+ Fixed ZipFile.get_output_stream bug.
83
+
84
+ = Version 0.5.0
85
+
86
+ List of changes:
87
+ * Ruby 1.8.0 and ruby-zlib 0.6.0 compatibility
88
+ * Changed method names from camelCase to rubys underscore style.
89
+ * Installs to zip/ subdir instead of directly to site_ruby
90
+ * Added ZipFile.directory and ZipFile.file - each method return an
91
+ object that can be used like Dir and File only for the contents of the
92
+ zip file.
93
+ * Added sample application zipfind which works like Find.find, only
94
+ Zip::ZipFind.find traverses into zip archives too.
95
+
96
+ Bug fixes:
97
+ * AbstractInputStream.each_line with non-default separator
98
+
99
+
100
+ = Version 0.5.0a
101
+
102
+ Source reorganized. Added ziprequire, which can be used to load ruby
103
+ modules from a zip file, in a fashion similar to jar files in
104
+ Java. Added gtkRubyzip, another sample application. Implemented
105
+ ZipInputStream.lineno and ZipInputStream.rewind
106
+
107
+ Bug fixes:
108
+
109
+ * Read and write date and time information correctly for zip entries.
110
+ * Fixed read() using separate buffer, causing mix of gets/readline/read to
111
+ cause problems.
112
+
113
+ = Version 0.4.2
114
+
115
+ Performance optimizations. Test suite runs in half the time.
116
+
117
+ = Version 0.4.1
118
+
119
+ Windows compatibility fixes.
120
+
121
+ = Version 0.4.0
122
+
123
+ Zip::ZipFile is now mutable and provides a more convenient way of
124
+ modifying zip archives than Zip::ZipOutputStream. Operations for
125
+ adding, extracting, renaming, replacing and removing entries to zip
126
+ archives are now available.
127
+
128
+ Runs without warnings with -w switch.
129
+
130
+ Install script install.rb added.
131
+
132
+
133
+ = Version 0.3.1
134
+
135
+ Rudimentary support for writing zip archives.
136
+
137
+
138
+ = Version 0.2.2
139
+
140
+ Fixed and extended unit test suite. Updated to work with ruby/zlib
141
+ 0.5. It doesn't work with earlier versions of ruby/zlib.
142
+
143
+
144
+ = Version 0.2.0
145
+
146
+ Class ZipFile added. Where ZipInputStream is used to read the
147
+ individual entries in a zip file, ZipFile reads the central directory
148
+ in the zip archive, so you can get to any entry in the zip archive
149
+ without having to skipping through all the preceeding entries.
150
+
151
+
152
+ = Version 0.1.0
153
+
154
+ First working version of ZipInputStream.
data/README ADDED
@@ -0,0 +1,72 @@
1
+ = rubyzip
2
+
3
+ rubyzip is a ruby library for reading and writing zip files.
4
+
5
+ = Install
6
+
7
+ If you have rubygems you can install rubyzip directly from the gem
8
+ repository
9
+
10
+ gem install rubyzip
11
+
12
+ Otherwise obtain the source (see below) and run
13
+
14
+ ruby install.rb
15
+
16
+ To run the unit tests you need to have test::unit installed
17
+
18
+ rake test
19
+
20
+
21
+ = Documentation
22
+
23
+ There is more than one way to access or create a zip archive with
24
+ rubyzip. The basic API is modeled after the classes in
25
+ java.util.zip from the Java SDK. This means there are classes such
26
+ as Zip::ZipInputStream, Zip::ZipOutputStream and
27
+ Zip::ZipFile. Zip::ZipInputStream provides a basic interface for
28
+ iterating through the entries in a zip archive and reading from the
29
+ entries in the same way as from a regular File or IO
30
+ object. ZipOutputStream is the corresponding basic output
31
+ facility. Zip::ZipFile provides a mean for accessing the archives
32
+ central directory and provides means for accessing any entry without
33
+ having to iterate through the archive. Unlike Java's
34
+ java.util.zip.ZipFile rubyzip's Zip::ZipFile is mutable, which means
35
+ it can be used to change zip files as well.
36
+
37
+ Another way to access a zip archive with rubyzip is to use rubyzip's
38
+ Zip::ZipFileSystem API. Using this API files can be read from and
39
+ written to the archive in much the same manner as ruby's builtin
40
+ classes allows files to be read from and written to the file system.
41
+
42
+ rubyzip also features the
43
+ zip/ziprequire.rb[link:files/lib/zip/ziprequire_rb.html] module which
44
+ allows ruby to load ruby modules from zip archives.
45
+
46
+ For details about the specific behaviour of classes and methods refer
47
+ to the test suite. Finally you can generate the rdoc documentation or
48
+ visit http://rubyzip.sourceforge.net.
49
+
50
+ = License
51
+
52
+ rubyzip is distributed under the same license as ruby. See
53
+ http://www.ruby-lang.org/en/LICENSE.txt
54
+
55
+
56
+ = Website and Project Home
57
+
58
+ http://rubyzip.sourceforge.net
59
+
60
+ http://sourceforge.net/projects/rubyzip
61
+
62
+ == Download (tarballs and gems)
63
+
64
+ http://sourceforge.net/project/showfiles.php?group_id=43107&package_id=35377
65
+
66
+ = Authors
67
+
68
+ Thomas Sondergaard (thomas at sondergaard.cc)
69
+
70
+ Technorama Ltd. (oss-ruby-zip at technorama.net)
71
+
72
+ extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)
@@ -0,0 +1,62 @@
1
+ # Rakefile for RubyGems -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+
6
+ require './lib/zip/version.rb'
7
+
8
+ begin
9
+ require 'jeweler'
10
+ Jeweler::Tasks.new do |gem|
11
+ gem.name = 'zip'
12
+ gem.version = Zip::VERSION
13
+ gem.summary = 'zip is a Ruby library for reading and writing Zip files'
14
+ gem.description = 'zip is a Ruby library for reading and writing Zip files. Unlike the official rubyzip, zip is compatible with Ruby 1.9.1.'
15
+ gem.email = ['me@samlown.com', 'postmodern.mod3@gmail.com']
16
+ gem.homepage = 'http://github.com/postmodern/rubyzip2'
17
+ gem.authors = ['Postmodern', 'Thomas Sondergaard', 'Sam Lown']
18
+ gem.files = FileList[
19
+ 'README.txt',
20
+ 'NEWS.txt',
21
+ 'TODO.txt',
22
+ 'ChangeLog.txt',
23
+ 'Rakefile',
24
+ 'lib/zip.rb',
25
+ 'lib/zip/ioextras.rb',
26
+ 'lib/zip/stdrubyext.rb',
27
+ 'lib/zip/tempfile_bugfixed.rb',
28
+ 'lib/zip/zip.rb',
29
+ 'lib/zip/zipfilesystem.rb',
30
+ 'lib/zip/ziprequire.rb',
31
+ 'lib/zip/version.rb',
32
+ 'samples/example.rb',
33
+ 'samples/example_filesystem.rb',
34
+ 'samples/gtk_zip.rb',
35
+ 'samples/qt_zip.rb',
36
+ 'samples/write_simple.rb',
37
+ 'samples/zipfind.rb',
38
+ 'test/alltests.rb',
39
+ 'test/data/file1.txt',
40
+ 'test/data/file1.txt.deflatedData',
41
+ 'test/data/file2.txt',
42
+ 'test/data/notzippedruby.rb',
43
+ 'test/data/rubycode.zip',
44
+ 'test/data/rubycode2.zip',
45
+ 'test/data/testDirectory.bin',
46
+ 'test/data/zipWithDirs.zip',
47
+ ]
48
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
49
+ end
50
+ rescue LoadError
51
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
52
+ end
53
+
54
+ require 'rake/testtask'
55
+
56
+ Rake::TestTask.new(:test) do |test|
57
+ test.libs << 'lib' << 'test'
58
+ test.pattern = 'test/**/test_*.rb'
59
+ test.verbose = true
60
+ end
61
+
62
+ task :test => :check_dependencies
@@ -0,0 +1,16 @@
1
+
2
+ * ZipInputStream: Support zip-files with trailing data descriptors
3
+ * Adjust rdoc stylesheet to advertise inherited methods if possible
4
+ * Suggestion: Add ZipFile/ZipInputStream example that demonstrates extracting all entries.
5
+ * Suggestion: ZipFile#extract destination should default to "."
6
+ * Suggestion: ZipEntry should have extract(), get_input_stream() methods etc
7
+ * SUggestion: ZipInputStream/ZipOutputStream should accept an IO object in addition to a filename.
8
+ * (is buffering used anywhere with write?)
9
+ * Inflater.sysread should pass the buffer to produce_input.
10
+ * Implement ZipFsDir.glob
11
+ * ZipFile.checkIntegrity method
12
+ * non-MSDOS permission attributes
13
+ ** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
14
+ * Packager version, required unpacker version in zip headers
15
+ ** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
16
+ * implement storing attributes and ownership information
@@ -0,0 +1 @@
1
+ require 'zip/zip'
@@ -0,0 +1,155 @@
1
+ module IOExtras #:nodoc:
2
+
3
+ CHUNK_SIZE = 32768
4
+
5
+ RANGE_ALL = 0..-1
6
+
7
+ def self.copy_stream(ostream, istream)
8
+ s = ''
9
+ ostream.write(istream.read(CHUNK_SIZE, s)) until istream.eof?
10
+ end
11
+
12
+
13
+ # Implements kind_of? in order to pretend to be an IO object
14
+ module FakeIO
15
+ def kind_of?(object)
16
+ object == IO || super
17
+ end
18
+ end
19
+
20
+ # Implements many of the convenience methods of IO
21
+ # such as gets, getc, readline and readlines
22
+ # depends on: input_finished?, produce_input and read
23
+ module AbstractInputStream
24
+ include Enumerable
25
+ include FakeIO
26
+
27
+ def initialize
28
+ super
29
+ @lineno = 0
30
+ @outputBuffer = ""
31
+ end
32
+
33
+ attr_accessor :lineno
34
+
35
+ def read(numberOfBytes = nil, buf = nil)
36
+ tbuf = nil
37
+
38
+ if @outputBuffer.length > 0
39
+ if numberOfBytes <= @outputBuffer.length
40
+ tbuf = @outputBuffer.slice!(0, numberOfBytes)
41
+ else
42
+ numberOfBytes -= @outputBuffer.length if (numberOfBytes)
43
+ rbuf = sysread(numberOfBytes, buf)
44
+ tbuf = @outputBuffer
45
+ tbuf << rbuf if (rbuf)
46
+ @outputBuffer = ""
47
+ end
48
+ else
49
+ tbuf = sysread(numberOfBytes, buf)
50
+ end
51
+
52
+ return nil unless (tbuf)
53
+
54
+ if buf
55
+ buf.replace(tbuf)
56
+ else
57
+ buf = tbuf
58
+ end
59
+
60
+ buf
61
+ end
62
+
63
+ def readlines(aSepString = $/)
64
+ retVal = []
65
+ each_line(aSepString) { |line| retVal << line }
66
+ return retVal
67
+ end
68
+
69
+ def gets(aSepString=$/)
70
+ @lineno = @lineno.next
71
+ return read if aSepString == nil
72
+ aSepString="#{$/}#{$/}" if aSepString == ""
73
+
74
+ bufferIndex=0
75
+ while ((matchIndex = @outputBuffer.index(aSepString, bufferIndex)) == nil)
76
+ bufferIndex=@outputBuffer.length
77
+ if input_finished?
78
+ return @outputBuffer.empty? ? nil : flush
79
+ end
80
+ @outputBuffer << produce_input
81
+ end
82
+ sepIndex=matchIndex + aSepString.length
83
+ return @outputBuffer.slice!(0...sepIndex)
84
+ end
85
+
86
+ def flush
87
+ retVal=@outputBuffer
88
+ @outputBuffer=""
89
+ return retVal
90
+ end
91
+
92
+ def readline(aSepString = $/)
93
+ retVal = gets(aSepString)
94
+ raise EOFError if retVal == nil
95
+ return retVal
96
+ end
97
+
98
+ def each_line(aSepString = $/)
99
+ while true
100
+ yield readline(aSepString)
101
+ end
102
+ rescue EOFError
103
+ end
104
+
105
+ alias_method :each, :each_line
106
+ end
107
+
108
+
109
+ # Implements many of the output convenience methods of IO.
110
+ # relies on <<
111
+ module AbstractOutputStream
112
+ include FakeIO
113
+
114
+ def write(data)
115
+ self << data
116
+ data.to_s.length
117
+ end
118
+
119
+
120
+ def print(*params)
121
+ self << params.join << $\.to_s
122
+ end
123
+
124
+ def printf(aFormatString, *params)
125
+ self << sprintf(aFormatString, *params)
126
+ end
127
+
128
+ def putc(anObject)
129
+ self << case anObject
130
+ when Fixnum then anObject.chr
131
+ when String then anObject
132
+ else raise TypeError, "putc: Only Fixnum and String supported"
133
+ end
134
+ anObject
135
+ end
136
+
137
+ def puts(*params)
138
+ params << "\n" if params.empty?
139
+ params.flatten.each {
140
+ |element|
141
+ val = element.to_s
142
+ self << val
143
+ self << "\n" unless val[-1,1] == "\n"
144
+ }
145
+ end
146
+
147
+ end
148
+
149
+ end # IOExtras namespace module
150
+
151
+
152
+
153
+ # Copyright (C) 2002-2004 Thomas Sondergaard
154
+ # rubyzip is free software; you can redistribute it and/or
155
+ # modify it under the terms of the ruby license.