rubyzip 0.5.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubyzip might be problematic. Click here for more details.

data/NEWS ADDED
@@ -0,0 +1,106 @@
1
+ = Version 0.5.7
2
+
3
+ install.rb no longer assumes it is being run from the toplevel source
4
+ dir. Directory structure changed to reflect common ruby library
5
+ project structure. Migrated from RubyUnit to Test::Unit format. Now
6
+ uses Rake to build source packages and gems and run unit tests
7
+
8
+ = Version 0.5.6
9
+
10
+ Fix for FreeBSD 4.9 which returns Errno::EFBIG instead of
11
+ Errno::EINVAL for some invalid seeks. Fixed 'version needed to
12
+ extract'-field incorrect in local headers.
13
+
14
+ = Version 0.5.5
15
+
16
+ Fix for a problem with writing zip files that concerns only ruby 1.8.1.
17
+
18
+ = Version 0.5.4
19
+
20
+ Significantly reduced memory footprint when modifying zip files.
21
+
22
+ = Version 0.5.3
23
+
24
+ Added optimization to avoid decompressing and recompressing individual
25
+ entries when modifying a zip archive.
26
+
27
+ = Version 0.5.2
28
+
29
+ Fixed ZipFile corruption bug in ZipFile class. Added basic unix
30
+ extra-field support.
31
+
32
+ = Version 0.5.1
33
+
34
+ Fixed ZipFile.get_output_stream bug.
35
+
36
+ = Version 0.5.0
37
+
38
+ List of changes:
39
+ * Ruby 1.8.0 and ruby-zlib 0.6.0 compatibility
40
+ * Changed method names from camelCase to rubys underscore style.
41
+ * Installs to zip/ subdir instead of directly to site_ruby
42
+ * Added ZipFile.directory and ZipFile.file - each method return an
43
+ object that can be used like Dir and File only for the contents of the
44
+ zip file.
45
+ * Added sample application zipfind which works like Find.find, only
46
+ Zip::ZipFind.find traverses into zip archives too.
47
+
48
+ Bug fixes:
49
+ * AbstractInputStream.each_line with non-default separator
50
+
51
+
52
+ = Version 0.5.0a
53
+
54
+ Source reorganized. Added ziprequire, which can be used to load ruby
55
+ modules from a zip file, in a fashion similar to jar files in
56
+ Java. Added gtkRubyzip, another sample application. Implemented
57
+ ZipInputStream.lineno and ZipInputStream.rewind
58
+
59
+ Bug fixes:
60
+
61
+ * Read and write date and time information correctly for zip entries.
62
+ * Fixed read() using separate buffer, causing mix of gets/readline/read to
63
+ cause problems.
64
+
65
+ = Version 0.4.2
66
+
67
+ Performance optimizations. Test suite runs in half the time.
68
+
69
+ = Version 0.4.1
70
+
71
+ Windows compatibility fixes.
72
+
73
+ = Version 0.4.0
74
+
75
+ Zip::ZipFile is now mutable and provides a more convenient way of
76
+ modifying zip archives than Zip::ZipOutputStream. Operations for
77
+ adding, extracting, renaming, replacing and removing entries to zip
78
+ archives are now available.
79
+
80
+ Runs without warnings with -w switch.
81
+
82
+ Install script install.rb added.
83
+
84
+
85
+ = Version 0.3.1
86
+
87
+ Rudimentary support for writing zip archives.
88
+
89
+
90
+ = Version 0.2.2
91
+
92
+ Fixed and extended unit test suite. Updated to work with ruby/zlib
93
+ 0.5. It doesn't work with earlier versions of ruby/zlib.
94
+
95
+
96
+ = Version 0.2.0
97
+
98
+ Class ZipFile added. Where ZipInputStream is used to read the
99
+ individual entries in a zip file, ZipFile reads the central directory
100
+ in the zip archive, so you can get to any entry in the zip archive
101
+ without having to skipping through all the preceeding entries.
102
+
103
+
104
+ = Version 0.1.0
105
+
106
+ First working version of ZipInputStream.
data/README ADDED
@@ -0,0 +1,69 @@
1
+ = rubyzip
2
+
3
+ rubyzip is a ruby library for reading and writing zip files.
4
+
5
+ = Install
6
+
7
+ To install from source run
8
+
9
+ ruby install.rb
10
+
11
+ If you have Rake installed you can build a rubyzip gem with
12
+
13
+ rake package
14
+
15
+ To run the unit tests you need to have test::unit installed.
16
+
17
+ rake test
18
+
19
+
20
+ = Documentation
21
+
22
+ There is more than one way to access or create a zip archive with
23
+ rubyzip. The basic API is modeled after the classes in
24
+ java.util.zip from the Java SDK. This means there are classes such
25
+ as Zip::ZipInputStream, Zip::ZipOutputStream and
26
+ Zip::ZipFile. Zip::ZipInputStream provides a basic interface for
27
+ iterating through the entries in a zip archive and reading from the
28
+ entries in the same way as from a regular File or IO
29
+ object. ZipOutputStream is the corresponding basic output
30
+ facility. Zip::ZipFile provides a mean for accessing the archives
31
+ central directory and provides means for accessing any entry without
32
+ having to iterate through the archive. Unlike Java's
33
+ java.util.zip.ZipFile rubyzip's Zip::ZipFile is mutable, which means
34
+ it can be used to change zip files as well.
35
+
36
+ Another way to access a zip archive with rubyzip is to use rubyzip's
37
+ Zip::ZipFileSystem API. Using this API files can be read from and
38
+ written to the archive in much the same manner as ruby's builtin
39
+ classes allows files to be read from and written to the file system.
40
+
41
+ rubyzip also features the
42
+ zip/ziprequire.rb[link:files/lib/zip/ziprequire_rb.html] module which
43
+ allows ruby to load ruby modules from zip archives.
44
+
45
+ For details about the specific behaviour of classes and methods refer
46
+ to the test suite. Finally you can generate the rdoc documentation or
47
+ visit http://rubyzip.sourceforge.net.
48
+
49
+ = License
50
+
51
+ rubyzip is distributed under the same license as ruby. See
52
+ http://www.ruby-lang.org/en/LICENSE.txt
53
+
54
+
55
+ = Website and Project Home
56
+
57
+ http://rubyzip.sourceforge.net
58
+
59
+ http://sourceforge.net/projects/rubyzip
60
+
61
+ == Download (tarballs and gems)
62
+
63
+ http://sourceforge.net/project/showfiles.php?group_id=43107&package_id=35377
64
+
65
+ = Authors
66
+
67
+ Thomas Sondergaard (thomas at sondergaard.cc)
68
+
69
+ extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)
@@ -0,0 +1,110 @@
1
+ # Rakefile for RubyGems -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'rake/clean'
5
+ require 'rake/testtask'
6
+ require 'rake/packagetask'
7
+ require 'rake/gempackagetask'
8
+ require 'rake/rdoctask'
9
+ require 'rake/contrib/sshpublisher'
10
+ require 'net/ftp'
11
+
12
+ PKG_NAME = 'rubyzip'
13
+ PKG_VERSION = File.read('lib/zip/zip.rb').match(/\s+VERSION\s*=\s*'(.*)'/)[1]
14
+
15
+ PKG_FILES = FileList.new
16
+
17
+ PKG_FILES.add %w{ README NEWS TODO ChangeLog install.rb Rakefile }
18
+ PKG_FILES.add %w{ samples/*.rb }
19
+ PKG_FILES.add %w{ test/*.rb }
20
+ PKG_FILES.add %w{ test/data/* }
21
+ PKG_FILES.exclude "test/data/generated"
22
+ PKG_FILES.add %w{ lib/**/*.rb }
23
+
24
+ def clobberFromCvsIgnore(path)
25
+ CLOBBER.add File.readlines(path+'/.cvsignore').map {
26
+ |f| File.join(path, f.chomp)
27
+ }
28
+ end
29
+
30
+ clobberFromCvsIgnore '.'
31
+ clobberFromCvsIgnore 'samples'
32
+ clobberFromCvsIgnore 'test'
33
+ clobberFromCvsIgnore 'test/data'
34
+
35
+ task :default => [:test]
36
+
37
+ desc "Run unit tests"
38
+ task :test do
39
+ ruby %{-C test alltests.rb}
40
+ end
41
+
42
+ # Shortcuts for test targets
43
+ task :ut => [:test]
44
+
45
+ spec = Gem::Specification.new do |s|
46
+ s.name = PKG_NAME
47
+ s.version = PKG_VERSION
48
+ s.author = "Thomas Sondergaard"
49
+ s.email = "thomas(at)sondergaard.cc"
50
+ s.homepage = "http://rubyzip.sourceforge.net/"
51
+ s.platform = Gem::Platform::RUBY
52
+ s.summary = "rubyzip is a ruby module for reading and writing zip files"
53
+ s.files = PKG_FILES.to_a #Dir.glob("{samples,lib,test,docs}/**/*").delete_if {|item| item.include?("CVS") || item.include?("rdoc") || item =~ /~$/ }
54
+ s.require_path = 'lib'
55
+ s.autorequire = 'zip/zip'
56
+ end
57
+
58
+ Rake::GemPackageTask.new(spec) do |pkg|
59
+ pkg.need_zip = true
60
+ pkg.need_tar = true
61
+ end
62
+
63
+ Rake::RDocTask.new do |rd|
64
+ rd.main = "README"
65
+ rd.rdoc_files.add %W{ lib/zip/*.rb README NEWS TODO ChangeLog }
66
+ rd.options << "--title 'rubyzip documentation' --webcvs http://cvs.sourceforge.net/viewcvs.py/rubyzip/rubyzip/"
67
+ # rd.options << "--all"
68
+ end
69
+
70
+ desc "Publish documentation"
71
+ task :pdoc => [:rdoc] do
72
+ Rake::SshFreshDirPublisher.
73
+ new("thomas@rubyzip.sourceforge.net", "rubyzip/htdocs", "html").upload
74
+ end
75
+
76
+ desc "Publish package"
77
+ task :ppackage => [:package] do
78
+ Net::FTP.open("upload.sourceforge.net",
79
+ "ftp",
80
+ ENV['USER']+"@"+ENV['HOSTNAME']) {
81
+ |ftpclient|
82
+ ftpclient.chdir "incoming"
83
+ Dir['pkg/*.{tgz,zip,gem}'].each {
84
+ |e|
85
+ ftpclient.putbinaryfile(e, File.basename(e))
86
+ }
87
+ }
88
+ end
89
+
90
+ desc "Generate the ChangeLog file"
91
+ task :ChangeLog do
92
+ puts "Updating ChangeLog"
93
+ system %{cvs2cl}
94
+ end
95
+
96
+ desc "Make a release"
97
+ task :release => [:tag_release, :pdoc, :ppackage] do
98
+ end
99
+
100
+ desc "Make a release tag"
101
+ task :tag_release do
102
+ tag = "release-#{PKG_VERSION.gsub('.','-')}"
103
+
104
+ puts "Checking for tag '#{tag}'"
105
+ if (Regexp.new("^\\s+#{tag}") =~ `cvs log README`)
106
+ abort "Tag '#{tag}' already exists"
107
+ end
108
+ puts "Tagging module with '#{tag}'"
109
+ system("cvs tag #{tag}")
110
+ end
data/TODO ADDED
@@ -0,0 +1,9 @@
1
+
2
+ * Fix problem with mixing AbstractInputStream::gets and AbstractInputStream::read
3
+ * Implement ZipFsDir.glob
4
+ * ZipFile.checkIntegrity method
5
+ * non-MSDOS permission attributes
6
+ ** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
7
+ * Packager version, required unpacker version in zip headers
8
+ ** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
9
+ * implement storing attributes and ownership information
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $VERBOSE = true
4
+
5
+ require 'rbconfig'
6
+ require 'find'
7
+ require 'ftools'
8
+
9
+ include Config
10
+
11
+ files = %w{ stdrubyext.rb ioextras.rb zip.rb zipfilesystem.rb ziprequire.rb tempfile_bugfixed.rb }
12
+
13
+ INSTALL_DIR = File.join(CONFIG["sitelibdir"], "zip")
14
+ File.makedirs(INSTALL_DIR)
15
+
16
+ SOURCE_DIR = File.join(File.dirname($0), "zip")
17
+
18
+ files.each {
19
+ |filename|
20
+ installPath = File.join(INSTALL_DIR, filename)
21
+ File::install(File.join(SOURCE_DIR, filename), installPath, 0644, true)
22
+ }
@@ -0,0 +1,117 @@
1
+ module IOExtras #:nodoc:
2
+
3
+ # Implements kind_of? in order to pretend to be an IO object
4
+ module FakeIO
5
+ def kind_of?(object)
6
+ object == IO || super
7
+ end
8
+ end
9
+
10
+ # Implements many of the convenience methods of IO
11
+ # such as gets, getc, readline and readlines
12
+ # depends on: input_finished?, produce_input and read
13
+ module AbstractInputStream
14
+ include Enumerable
15
+ include FakeIO
16
+
17
+ def initialize
18
+ super
19
+ @lineno = 0
20
+ @outputBuffer = ""
21
+ end
22
+
23
+ attr_accessor :lineno
24
+
25
+ def readlines(aSepString = $/)
26
+ retVal = []
27
+ each_line(aSepString) { |line| retVal << line }
28
+ return retVal
29
+ end
30
+
31
+ def gets(aSepString=$/)
32
+ @lineno = @lineno.next
33
+ return read if aSepString == nil
34
+ aSepString="#{$/}#{$/}" if aSepString == ""
35
+
36
+ bufferIndex=0
37
+ while ((matchIndex = @outputBuffer.index(aSepString, bufferIndex)) == nil)
38
+ bufferIndex=@outputBuffer.length
39
+ if input_finished?
40
+ return @outputBuffer.empty? ? nil : flush
41
+ end
42
+ @outputBuffer << produce_input
43
+ end
44
+ sepIndex=matchIndex + aSepString.length
45
+ return @outputBuffer.slice!(0...sepIndex)
46
+ end
47
+
48
+ def flush
49
+ retVal=@outputBuffer
50
+ @outputBuffer=""
51
+ return retVal
52
+ end
53
+
54
+ def readline(aSepString = $/)
55
+ retVal = gets(aSepString)
56
+ raise EOFError if retVal == nil
57
+ return retVal
58
+ end
59
+
60
+ def each_line(aSepString = $/)
61
+ while true
62
+ yield readline(aSepString)
63
+ end
64
+ rescue EOFError
65
+ end
66
+
67
+ alias_method :each, :each_line
68
+ end
69
+
70
+
71
+ # Implements many of the output convenience methods of IO.
72
+ # relies on <<
73
+ module AbstractOutputStream
74
+ include FakeIO
75
+
76
+ def write(data)
77
+ self << data
78
+ data.to_s.length
79
+ end
80
+
81
+
82
+ def print(*params)
83
+ self << params.to_s << $\.to_s
84
+ end
85
+
86
+ def printf(aFormatString, *params)
87
+ self << sprintf(aFormatString, *params)
88
+ end
89
+
90
+ def putc(anObject)
91
+ self << case anObject
92
+ when Fixnum then anObject.chr
93
+ when String then anObject
94
+ else raise TypeError, "putc: Only Fixnum and String supported"
95
+ end
96
+ anObject
97
+ end
98
+
99
+ def puts(*params)
100
+ params << "\n" if params.empty?
101
+ params.flatten.each {
102
+ |element|
103
+ val = element.to_s
104
+ self << val
105
+ self << "\n" unless val[-1,1] == "\n"
106
+ }
107
+ end
108
+
109
+ end
110
+
111
+ end # IOExtras namespace module
112
+
113
+
114
+
115
+ # Copyright (C) 2002-2004 Thomas Sondergaard
116
+ # rubyzip is free software; you can redistribute it and/or
117
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,111 @@
1
+ unless Enumerable.method_defined?(:inject)
2
+ module Enumerable #:nodoc:all
3
+ def inject(n = 0)
4
+ each { |value| n = yield(n, value) }
5
+ n
6
+ end
7
+ end
8
+ end
9
+
10
+ module Enumerable #:nodoc:all
11
+ # returns a new array of all the return values not equal to nil
12
+ # This implementation could be faster
13
+ def select_map(&aProc)
14
+ map(&aProc).reject { |e| e.nil? }
15
+ end
16
+ end
17
+
18
+ unless Object.method_defined?(:object_id)
19
+ class Object #:nodoc:all
20
+ # Using object_id which is the new thing, so we need
21
+ # to make that work in versions prior to 1.8.0
22
+ alias object_id id
23
+ end
24
+ end
25
+
26
+ unless File.respond_to?(:read)
27
+ class File # :nodoc:all
28
+ # singleton method read does not exist in 1.6.x
29
+ def self.read(fileName)
30
+ open(fileName) { |f| f.read }
31
+ end
32
+ end
33
+ end
34
+
35
+ class String #:nodoc:all
36
+ def starts_with(aString)
37
+ rindex(aString, 0) == 0
38
+ end
39
+
40
+ def ends_with(aString)
41
+ index(aString, -aString.size)
42
+ end
43
+
44
+ def ensure_end(aString)
45
+ ends_with(aString) ? self : self + aString
46
+ end
47
+
48
+ def lchop
49
+ slice(1, length)
50
+ end
51
+ end
52
+
53
+ class Time #:nodoc:all
54
+
55
+ #MS-DOS File Date and Time format as used in Interrupt 21H Function 57H:
56
+ #
57
+ # Register CX, the Time:
58
+ # Bits 0-4 2 second increments (0-29)
59
+ # Bits 5-10 minutes (0-59)
60
+ # bits 11-15 hours (0-24)
61
+ #
62
+ # Register DX, the Date:
63
+ # Bits 0-4 day (1-31)
64
+ # bits 5-8 month (1-12)
65
+ # bits 9-15 year (four digit year minus 1980)
66
+
67
+
68
+ def to_binary_dos_time
69
+ (sec/2) +
70
+ (min << 5) +
71
+ (hour << 11)
72
+ end
73
+
74
+ def to_binary_dos_date
75
+ (day) +
76
+ (month << 5) +
77
+ ((year - 1980) << 9)
78
+ end
79
+
80
+ # Dos time is only stored with two seconds accuracy
81
+ def dos_equals(other)
82
+ to_i/2 == other.to_i/2
83
+ end
84
+
85
+ def self.parse_binary_dos_format(binaryDosDate, binaryDosTime)
86
+ second = 2 * ( 0b11111 & binaryDosTime)
87
+ minute = ( 0b11111100000 & binaryDosTime) >> 5
88
+ hour = (0b1111100000000000 & binaryDosTime) >> 11
89
+ day = ( 0b11111 & binaryDosDate)
90
+ month = ( 0b111100000 & binaryDosDate) >> 5
91
+ year = ((0b1111111000000000 & binaryDosDate) >> 9) + 1980
92
+ begin
93
+ return Time.local(year, month, day, hour, minute, second)
94
+ end
95
+ end
96
+ end
97
+
98
+ class Module #:nodoc:all
99
+ def forward_message(forwarder, *messagesToForward)
100
+ methodDefs = messagesToForward.map {
101
+ |msg|
102
+ "def #{msg}; #{forwarder}(:#{msg}); end"
103
+ }
104
+ module_eval(methodDefs.join("\n"))
105
+ end
106
+ end
107
+
108
+
109
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
110
+ # rubyzip is free software; you can redistribute it and/or
111
+ # modify it under the terms of the ruby license.