diff --git a/CHANGELOG b/CHANGELOG
index e8f94e1f..1b02e38a 100755
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+ * TODO:
+ BlueCloth is back (RedCloth didn't do Markdown well enough to replace it).
+
+ * SVN trunk:
+ Handling of line breaks in Textile is as in 0.9 (inserts
tag).
+ Upgraded rubyzip to version 0.5.8
* 0.10.0:
Ported to ActionPack
RedCloth 3.0.3
diff --git a/config/environment.rb b/config/environment.rb
index 67a7b633..fd396c95 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -38,7 +38,7 @@ unless defined? ADDITIONAL_LOAD_PATHS
vendor/rails/actionwebservice/lib
vendor/madeleine-0.7.1/lib
vendor/RedCloth-3.0.3/lib
- vendor/rubyzip-0.5.6
+ vendor/rubyzip-0.5.8/lib
).map { |dir| "#{File.expand_path(File.join(RAILS_ROOT, dir))}"
}.delete_if { |dir| not File.exist?(dir) }
diff --git a/instiki.gemspec b/instiki.gemspec
index 7ca9efb2..34e0e7fb 100755
--- a/instiki.gemspec
+++ b/instiki.gemspec
@@ -26,7 +26,7 @@ spec = Gem::Specification.new do |s|
s.add_dependency('madeleine', '= 0.7.1')
s.add_dependency('RedCloth', '= 3.0.3')
- s.add_dependency('rubyzip', '= 0.5.5')
+ s.add_dependency('rubyzip', '= 0.5.8')
s.add_dependency('rails', '= 0.11.1')
s.requirements << 'none'
s.require_path = 'lib'
diff --git a/vendor/rubyzip-0.5.6/README b/vendor/rubyzip-0.5.6/README
deleted file mode 100755
index 2160e5d7..00000000
--- a/vendor/rubyzip-0.5.6/README
+++ /dev/null
@@ -1,49 +0,0 @@
-= rubyzip
-
-rubyzip is a ruby library for reading and writing zip (pkzip format)
-files, with the restriction that only uncompressed and deflated zip
-entries are supported. All this library does is handling of the zip
-file format. the actual compression/decompression is handled by
-zlib. zlib is accessible from ruby thanks to ruby/zlib (see below)
-
-To run the unit tests you need to have rubyunit or test::unit
-installed.
-
-= Install
-
-ruby install.rb
-
-
-= Prerequisites
-
-This library requires ruby/zlib version 0.5.0 or newer. ruby/zlib is
-included in most recent ruby distributions.
-
-* zlib http://www.gzip.org/zlib/
-* ruby-zlib: http://www.blue.sky.or.jp/atelier/ruby/
-
-
-= Documentation
-
-The samples/ directory is a good place to start to get a feel for
-using the library. For details about the specific behaviour of classes
-and methods refer to the test suite. Finally you can generate the rdoc
-documentation or visit http://rubyzip.sourceforge.net/doc.
-
-
-= License
-
-rubyzip is distributed under the same license as ruby. See
-http://www.ruby-lang.org/en/LICENSE.txt
-
-
-= Project Home
-
-http://rubyzip.sourceforge.net
-
-
-= Author
-
-Thomas Sondergaard (thomas at thomassondergaard.com)
-
-extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)
diff --git a/vendor/rubyzip-0.5.6/rubyzip.gemspec b/vendor/rubyzip-0.5.6/rubyzip.gemspec
deleted file mode 100755
index 70c9d81e..00000000
--- a/vendor/rubyzip-0.5.6/rubyzip.gemspec
+++ /dev/null
@@ -1,20 +0,0 @@
-$:.unshift '../lib'
-require 'rubygems'
-
-spec = Gem::Specification.new do |s|
- s.name = 'rubyzip'
- s.version = "0.5.5"
- s.author = "Thomas Sondergaard"
- s.email = "thomas(at)thomassondergaard.com"
- s.homepage = "http://rubyzip.sourceforge.net/"
- s.platform = Gem::Platform::RUBY
- s.summary = "rubyzip is a ruby module for reading and writing zip files"
- s.files = Dir.glob("{samples,zip,docs}/**/*").delete_if {|item| item.include?("CVS") || item.include?("rdoc")}
- s.require_path = '.'
- s.autorequire = 'zip/zip'
-end
-
-if $0==__FILE__
- Gem::Builder.new(spec).build
-end
-
diff --git a/vendor/rubyzip-0.5.6/ChangeLog b/vendor/rubyzip-0.5.8/ChangeLog
old mode 100755
new mode 100644
similarity index 70%
rename from vendor/rubyzip-0.5.6/ChangeLog
rename to vendor/rubyzip-0.5.8/ChangeLog
index e7683189..1bb67582
--- a/vendor/rubyzip-0.5.6/ChangeLog
+++ b/vendor/rubyzip-0.5.8/ChangeLog
@@ -1,7 +1,132 @@
+2005-03-17 18:11 thomas
+
+ * NEWS, README, lib/zip/zip.rb: [no log message]
+
+2005-03-17 18:04 thomas
+
+ * install.rb: Fixed install.rb
+
+2005-03-03 18:38 thomas
+
+ * Rakefile: [no log message]
+
+2005-02-27 16:23 thomas
+
+ * lib/zip/ziprequire.rb: Added documentation to ziprequire
+
+2005-02-27 16:17 thomas
+
+ * README, TODO, lib/zip/ziprequire.rb: Added documentation to
+ ziprequire
+
+2005-02-27 15:02 thomas
+
+ * Rakefile, test/ziptest.rb: [no log message]
+
+2005-02-19 21:30 thomas
+
+ * lib/zip/ioextras.rb, lib/zip/stdrubyext.rb,
+ lib/zip/tempfile_bugfixed.rb, lib/zip/zip.rb,
+ lib/zip/ziprequire.rb, test/ioextrastest.rb,
+ test/stdrubyexttest.rb, test/zipfilesystemtest.rb,
+ test/ziprequiretest.rb, test/ziptest.rb: Added more rdoc and
+ changed the remaining tests to Test::Unit
+
+2005-02-19 20:28 thomas
+
+ * lib/zip/: ioextras.rb, zip.rb: Added documentation to
+ ZipInputStream and ZipOutputStream
+
+2005-02-18 10:27 thomas
+
+ * README: [no log message]
+
+2005-02-17 23:21 thomas
+
+ * README, Rakefile: Added ppackage (publish package) task to
+ Rakefile
+
+2005-02-17 22:49 thomas
+
+ * README, Rakefile, TODO: Added pdoc (publish doc) task to Rakefile
+
+2005-02-17 21:27 thomas
+
+ * README, Rakefile, TODO, lib/zip/stdrubyext.rb, lib/zip/zip.rb,
+ lib/zip/zipfilesystem.rb: Added a bunch of documentation
+
+2005-02-17 09:47 thomas
+
+ * test/ziptest.rb: [no log message]
+
+2005-02-16 20:04 thomas
+
+ * NEWS, README, Rakefile: Improved documentation and added rdoc
+ task to Rakefile
+
+2005-02-16 19:01 thomas
+
+ * NEWS, Rakefile, lib/zip/zip.rb: [no log message]
+
+2005-02-16 18:47 thomas
+
+ * Rakefile, samples/example.rb, samples/example_filesystem.rb,
+ samples/gtkRubyzip.rb, samples/write_simple.rb,
+ samples/zipfind.rb, test/.cvsignore, test/gentestfiles.rb:
+ Improvements to Rakefile
+
+2005-02-15 23:35 thomas
+
+ * NEWS, TODO: [no log message]
+
+2005-02-15 23:26 thomas
+
+ * Rakefile, rubyzip.gemspec: Now uses Rake to build gem
+
+2005-02-15 22:52 thomas
+
+ * Rakefile: [no log message]
+
+2005-02-15 22:39 thomas
+
+ * lib/zip/zip.rb, test/.cvsignore, test/ziptest.rb, NEWS: Fixed
+ compatibility issue with ruby 1.8.2. Migrated test suite to
+ Test::Unit
+
+2005-02-15 22:10 thomas
+
+ * NEWS, lib/zip/ioextras.rb, lib/zip/stdrubyext.rb,
+ lib/zip/tempfile_bugfixed.rb, lib/zip/zip.rb,
+ lib/zip/zipfilesystem.rb, lib/zip/ziprequire.rb, test/.cvsignore,
+ test/file1.txt, test/file1.txt.deflatedData, test/file2.txt,
+ test/gentestfiles.rb, test/ioextrastest.rb,
+ test/notzippedruby.rb, test/rubycode.zip, test/rubycode2.zip,
+ test/stdrubyexttest.rb, test/testDirectory.bin,
+ test/zipWithDirs.zip, test/zipfilesystemtest.rb,
+ test/ziprequiretest.rb, test/ziptest.rb, test/data/.cvsignore,
+ test/data/file1.txt, test/data/file1.txt.deflatedData,
+ test/data/file2.txt, test/data/notzippedruby.rb,
+ test/data/rubycode.zip, test/data/rubycode2.zip,
+ test/data/testDirectory.bin, test/data/zipWithDirs.zip: Changed
+ directory structure
+
+2005-02-13 22:44 thomas
+
+ * Rakefile, TODO: [no log message]
+
+2005-02-13 22:38 thomas
+
+ * rubyzip.gemspec: [no log message]
+
+2005-02-13 21:53 thomas
+
+ * install.rb: Made install.rb independent of the current path
+ (fixes bug reported by Drew Robinson)
+
2004-12-12 11:22 thomas
- * NEWS, TODO, samples/write_simple.rb, zip/zip.rb: Fixed 'version
- needed to extract'-field wrong in local headers
+ * NEWS, TODO, samples/write_simple.rb: Fixed 'version needed to
+ extract'-field wrong in local headers
2004-05-02 15:17 thomas
@@ -9,68 +134,65 @@
2004-04-02 07:25 thomas
- * NEWS, zip/zip.rb: Fix for FreeBSD 4.9
+ * NEWS: Fix for FreeBSD 4.9
-2004-03-28 15:23 thomas
+2004-03-29 00:28 thomas
- * zip/zip.rb: Use RUBY_VERSION not VERSION constant
+ * NEWS: [no log message]
-2004-03-28 14:51 thomas
+2004-03-28 17:59 thomas
- * zip/zip.rb: Only use bugfixed Tempfile implementation if the ruby
- version hasnt been fixed (contributed by Nobu Nakada)
-
-2004-03-28 14:46 thomas
-
- * zip/tempfile_bugfixed.rb: Compatibility with DelegateClass in
- ruby version 1.8.1 and newer
+ * NEWS: [no log message]
2004-03-27 16:09 thomas
- * test/stdrubyexttest.rb, zip/stdrubyext.rb: Patch for
- stdrubyext.rb from Nobu Nakada
+ * test/stdrubyexttest.rb: Patch for stdrubyext.rb from Nobu Nakada
2004-03-27 15:30 thomas
- * test/ioextrastest.rb, test/stdrubyexttest.rb, zip/ioextras.rb:
- converted some files to unix line-endings
+ * test/: ioextrastest.rb, stdrubyexttest.rb: converted some files
+ to unix line-endings
2004-03-25 16:34 thomas
- * NEWS, install.rb, zip/tempfile_bugfixed.rb, zip/zip.rb:
- Significantly reduced memory footprint when modifying zip files
+ * NEWS, install.rb: Significantly reduced memory footprint when
+ modifying zip files
2004-03-16 18:20 thomas
* install.rb, test/alltests.rb, test/ioextrastest.rb,
- test/stdrubyexttest.rb, test/ziptest.rb, zip/ioextras.rb,
- zip/zip.rb: IO utility classes moved to new file ioextras.rb.
- Tests moved to new file ioextrastest.rb
+ test/stdrubyexttest.rb, test/ziptest.rb: IO utility classes moved
+ to new file ioextras.rb. Tests moved to new file ioextrastest.rb
2004-02-27 13:21 thomas
- * NEWS, zip/zip.rb: Optimization to avoid decompression and
- recompression
+ * NEWS: Optimization to avoid decompression and recompression
+
+2004-01-30 16:17 thomas
+
+ * NEWS: [no log message]
2004-01-30 16:07 thomas
- * README, test/zipfilesystemtest.rb, test/ziptest.rb,
- zip/stdrubyext.rb, zip/zip.rb, zip/zipfilesystem.rb: Applied
+ * README, test/zipfilesystemtest.rb, test/ziptest.rb: Applied
extra-field patch
+2003-12-13 16:57 thomas
+
+ * TODO: [no log message]
+
2003-12-10 00:25 thomas
* test/ziptest.rb: (Temporary) fix to bug reported by Takashi Sano
-2003-10-03 11:05 thomas
-
- * zip/: stdrubyext.rb, zip.rb: Thanks to Clifford Heath for
- noticing that Time.to_binary_dos_date and time were reversed
-
2003-08-23 09:42 thomas
- * test/ziptest.rb, zip/zip.rb, NEWS: Fixed ZipFile.get_ouput_stream
- bug - data was never written to zip
+ * test/ziptest.rb, NEWS: Fixed ZipFile.get_ouput_stream bug - data
+ was never written to zip
+
+2003-08-21 16:05 thomas
+
+ * install.rb: [no log message]
2003-08-21 16:01 thomas
@@ -86,10 +208,12 @@
zipfilesystem.rb, zipfilesystemtest.rb, ziprequire.rb,
ziprequiretest.rb, ziptest.rb, samples/example.rb,
samples/example_filesystem.rb, samples/gtkRubyzip.rb,
- samples/zipfind.rb, zip/stdrubyext.rb, zip/zip.rb,
- zip/zipfilesystem.rb, zip/ziprequire.rb: Moved all production
- source files to zip/ so they are in the same dir as when they are
- installed
+ samples/zipfind.rb: Moved all production source files to zip/ so
+ they are in the same dir as when they are installed
+
+2003-08-21 15:31 thomas
+
+ * NEWS, TODO, alltests.rb: [no log message]
2003-08-21 15:26 thomas
@@ -108,6 +232,10 @@
* zip.rb, ziptest.rb: Fixed mkdir bug. ZipFile.mkdir didn't work if
the zipfile doesn't exist already
+2003-08-21 15:05 thomas
+
+ * ziptest.rb: [no log message]
+
2003-08-21 14:53 thomas
* TODO, zipfilesystemtest.rb: Globbing test placeholder commented
@@ -123,12 +251,28 @@
* zipfilesystem.rb, zipfilesystemtest.rb: Implemented DirFsIterator
and tests
+2003-08-20 22:50 thomas
+
+ * NEWS, TODO: [no log message]
+
+2003-08-20 22:45 thomas
+
+ * zipfilesystemtest.rb: [no log message]
+
2003-08-20 22:44 thomas
* zipfilesystem.rb, zipfilesystemtest.rb: Implemented
ZipFsDir.foreach, ZipFsDir.entries now reimplemented in terms of
it
+2003-08-20 22:25 thomas
+
+ * README: [no log message]
+
+2003-08-20 18:08 thomas
+
+ * zipfilesystem.rb, zipfilesystemtest.rb: [no log message]
+
2003-08-20 17:30 thomas
* zipfilesystem.rb: All access from ZipFsFile and ZipFsDir to
@@ -205,6 +349,10 @@
* simpledist.rb: Moved simpledist to a separate repository called
'misc'
+2003-08-13 16:31 thomas
+
+ * NEWS: [no log message]
+
2003-08-13 16:29 thomas
* stdrubyext.rb, zip.rb, zipfilesystem.rb, zipfilesystemtest.rb,
@@ -274,6 +422,22 @@
* NEWS, zip.rb: ruby-zlib 0.6.0 compatibility fix
+2002-12-22 20:12 thomas
+
+ * zip.rb: [no log message]
+
+2002-09-16 22:11 thomas
+
+ * NEWS: [no log message]
+
+2002-09-15 17:16 thomas
+
+ * samples/zipfind.rb: [no log message]
+
+2002-09-15 00:02 thomas
+
+ * samples/zipfind.rb: [no log message]
+
2002-09-14 22:59 thomas
* samples/zipfind.rb: Added simple zipfind script
@@ -296,11 +460,19 @@
* zipfilesystemtest.rb: Improved ZipFsFile.delete/unlink test
+2002-09-12 00:12 thomas
+
+ * test/.cvsignore: [no log message]
+
2002-09-12 00:10 thomas
* zipfilesystem.rb, zipfilesystemtest.rb: Implemented
ZipFsFile.delete/unlink
+2002-09-11 22:22 thomas
+
+ * alltests.rb: [no log message]
+
2002-09-11 22:18 thomas
* NEWS, zip.rb, zipfilesystem.rb, zipfilesystemtest.rb: Fixed
@@ -317,12 +489,20 @@
* NEWS: Updated NEWS file
+2002-09-10 23:26 thomas
+
+ * zip.rb: [no log message]
+
2002-09-10 22:39 thomas
* NEWS, zip.rb, ziptest.rb: Fix bug: rewind should reset lineno.
Fix bug: Deflater.read uses separate buffer from produceInput
(feeding gets/readline etc)
+2002-09-09 23:48 thomas
+
+ * .cvsignore: [no log message]
+
2002-09-09 22:55 uid26649
* zip.rb, ziptest.rb: Implemented ZipInputStream.rewind and
@@ -334,6 +514,10 @@
AbstractInputStream and AbstractOutputStream now lie about being
kind_of?(IO)
+2002-09-08 16:38 thomas
+
+ * zipfilesystemtest.rb: [no log message]
+
2002-09-08 16:07 thomas
* filearchive.rb, filearchivetest.rb, zip.rb, ziptest.rb: Moved
@@ -451,6 +635,10 @@
zipfilesystem.rb, zipfilesystemtest.rb, ziprequire.rb,
ziptest.rb: Implemented ZipFileSystem::ZipFsFile.size
+2002-07-26 16:41 thomas
+
+ * zipfilesystem.rb, zipfilesystemtest.rb: [no log message]
+
2002-07-26 16:40 thomas
* test/zipWithDirs.zip: Changed zipWithDirs.zip so all the entries
@@ -466,6 +654,18 @@
* test/zipWithDirs.zip: Added a zip file for testing with a
directory structure
+2002-07-22 21:40 thomas
+
+ * TODO: [no log message]
+
+2002-07-22 17:49 thomas
+
+ * TODO: [no log message]
+
+2002-07-21 18:20 thomas
+
+ * NEWS: [no log message]
+
2002-07-21 18:12 thomas
* TODO: Updated TODO with a refactoring idea for FileArchive
@@ -493,10 +693,22 @@
code for creating test files for FileArchive.add tests. Added
fileutils.rb, which is borrowed from ruby 1.7.2
+2002-07-20 16:07 thomas
+
+ * filearchive.rb, filearchivetest.rb: [no log message]
+
2002-07-20 16:05 thomas
* filearchivetest.rb: Added tests for String extensions
+2002-07-20 02:20 thomas
+
+ * alltests.rb, ziprequiretest.rb, ziptest.rb: [no log message]
+
+2002-07-20 00:42 thomas
+
+ * install.rb: [no log message]
+
2002-07-20 00:42 thomas
* TODO: Updated TODO
@@ -506,10 +718,43 @@
* filearchive.rb, filearchivetest.rb: All FileArchive.extract tests
run
+2002-07-19 23:11 thomas
+
+ * filearchive.rb, filearchivetest.rb: [no log message]
+
+2002-07-19 19:41 thomas
+
+ * filearchivetest.rb: [no log message]
+
+2002-07-19 19:06 thomas
+
+ * filearchive.rb, filearchivetest.rb: [no log message]
+
+2002-07-19 18:48 thomas
+
+ * filearchive.rb, filearchivetest.rb, zip.rb: [no log message]
+
+2002-07-08 13:41 thomas
+
+ * TODO: [no log message]
+
+2002-06-11 19:47 thomas
+
+ * filearchive.rb, filearchivetest.rb, zip.rb, ziptest.rb: [no log
+ message]
+
2002-05-25 00:41 thomas
* simpledist.rb: Added hackish script for creating dist files
+2002-04-30 21:22 thomas
+
+ * TODO: [no log message]
+
+2002-04-30 21:16 thomas
+
+ * filearchive.rb, filearchivetest.rb: [no log message]
+
2002-04-30 20:40 thomas
* filearchive.rb, filearchivetest.rb: Improved testing and wrote
@@ -564,6 +809,10 @@
a 'glob pattern' given a list of files - Next step is to use this
module in ZipFile
+2002-04-01 22:55 thomas
+
+ * NEWS: [no log message]
+
2002-04-01 21:16 thomas
* TODO, zip.rb, ziprequire.rb: Added ziprequire.rb which contains a
@@ -571,17 +820,33 @@
can load ruby modules from a zip file. Needs unit tests and
polish.
+2002-03-31 01:13 thomas
+
+ * README: [no log message]
+
+2002-03-30 16:14 thomas
+
+ * TODO: [no log message]
+
2002-03-30 01:52 thomas
* .cvsignore, README, zip.rb: Added rdoc markup (only #:nodoc:all
modifiers) to zip.rb. Made README 'RDoc compliant'
+2002-03-29 23:29 thomas
+
+ * TODO: [no log message]
+
2002-03-29 23:26 thomas
* example.rb, samples/.cvsignore, samples/example.rb,
samples/gtkRubyzip.rb: Moved example.rb to samples/. Added
another sample gtkRubyzip.rb
+2002-03-29 20:12 thomas
+
+ * NEWS, TODO: [no log message]
+
2002-03-29 20:06 thomas
* .cvsignore, file1.txt, file1.txt.deflatedData, testDirectory.bin,
@@ -591,6 +856,10 @@
manually created test data files into it. Changed ziptest.rb so
it runs in test/ directory
+2002-03-29 19:43 thomas
+
+ * TODO: [no log message]
+
2002-03-29 18:15 thomas
* NEWS, zip.rb, ziptest.rb: Don't decompress and recompress zip
@@ -601,6 +870,22 @@
* zip.rb: Performance optimization: Only write new ZipFile, if it
has been changed. The test suite runs in half the time now.
+2002-03-28 22:12 thomas
+
+ * TODO: [no log message]
+
+2002-03-23 17:31 thomas
+
+ * TODO: [no log message]
+
+2002-03-22 22:47 thomas
+
+ * NEWS: [no log message]
+
+2002-03-22 22:25 thomas
+
+ * NEWS, TODO: [no log message]
+
2002-03-22 22:18 thomas
* ziptest.rb: Found the tests that didn't use blocks to make sure
@@ -627,10 +912,22 @@
the remainder of the line including the pipe character and the
following zip -z 4 entry.zip command
+2002-03-21 22:18 thomas
+
+ * NEWS: [no log message]
+
2002-03-21 22:12 thomas
* NEWS, README, TODO, install.rb: Added install.rb
+2002-03-21 21:45 thomas
+
+ * ziptest.rb: [no log message]
+
+2002-03-21 20:54 thomas
+
+ * NEWS, TODO: [no log message]
+
2002-03-21 20:34 thomas
* .cvsignore, TODO, zip.rb, ziptest.rb: Added
@@ -641,6 +938,10 @@
* zip.rb, ziptest.rb: Extraction of directory entries is now
supported
+2002-03-20 21:59 thomas
+
+ * NEWS: [no log message]
+
2002-03-20 21:24 thomas
* COPYING, README, README.txt: Removed COPYING, renamed README.txt
@@ -651,6 +952,10 @@
* example.rb: Fixed example.rb added example that shows zip file
manipulation with Zip::ZipFile
+2002-03-20 21:00 thomas
+
+ * .cvsignore: [no log message]
+
2002-03-20 20:56 thomas
* TODO, zip.rb, ziptest.rb: Directories can now be added (not
@@ -669,6 +974,10 @@
* zip.rb, ziptest.rb: ZipError is now a subclass of StandardError
instead of RuntimeError. ZipError now has several subclasses.
+2002-03-19 22:26 thomas
+
+ * TODO: [no log message]
+
2002-03-19 22:19 thomas
* TODO, ziptest.rb: Unit test ZipFile.getInputStream with block
@@ -683,11 +992,19 @@
* TODO, zip.rb, ziptest.rb: Added unit tests for rename to existing
entry
+2002-03-19 20:42 thomas
+
+ * TODO: [no log message]
+
2002-03-19 20:40 thomas
* TODO, zip.rb, ziptest.rb: Unit test calling ZipFile.extract with
block
+2002-03-18 21:06 thomas
+
+ * TODO: [no log message]
+
2002-03-18 21:05 thomas
* zip.rb, ziptest.rb: ZipFile#commit now reinitializes ZipFile.
@@ -704,6 +1021,10 @@
* zip.rb: Removed method that was never called
+2002-03-17 22:33 thomas
+
+ * TODO: [no log message]
+
2002-03-17 22:25 thomas
* ziptest.rb: Run tests with =true as default
@@ -713,25 +1034,69 @@
* NEWS, TODO, zip.rb, ziptest.rb: Now runs with -w switch without
warnings
+2002-03-17 21:10 thomas
+
+ * .cvsignore: [no log message]
+
2002-03-17 21:04 thomas
* zip.rb, ziptest.rb: Down to one failing test
+2002-03-17 20:36 thomas
+
+ * zip.rb, ziptest.rb: [no log message]
+
+2002-03-17 17:22 thomas
+
+ * TODO, zip.rb, ziptest.rb: [no log message]
+
2002-02-25 19:42 thomas
* TODO: Added more todos
+2002-02-23 15:51 thomas
+
+ * zip.rb: [no log message]
+
+2002-02-23 15:30 thomas
+
+ * zip.rb, ziptest.rb: [no log message]
+
+2002-02-23 14:16 thomas
+
+ * zip.rb, ziptest.rb: [no log message]
+
+2002-02-03 18:47 thomas
+
+ * ziptest.rb: [no log message]
+
+2002-02-02 15:58 thomas
+
+ * example.rb, zip.rb, ziptest.rb: [no log message]
+
+2002-02-02 00:16 thomas
+
+ * .cvsignore: [no log message]
+
2002-02-02 00:14 thomas
* example.rb, zip.rb, ziptest.rb: Renamed SimpleZipFile to
BasicZipFile
+2002-02-02 00:09 thomas
+
+ * TODO: [no log message]
+
2002-02-02 00:01 thomas
* ziptest.rb: More test cases - all of them failing, so now there
are 18 failing test cases. Three more test cases to implement,
then it is time for the production code
+2002-02-01 21:49 thomas
+
+ * ziptest.rb: [no log message]
+
2002-02-01 21:34 thomas
* ziptest.rb: Also run SimpleZipFile tests for ZipFile.
@@ -742,6 +1107,14 @@
The new ZipFile will have many more methods that are useful for
managing archives.
+2002-01-29 20:30 thomas
+
+ * TODO: [no log message]
+
+2002-01-26 00:18 thomas
+
+ * NEWS: [no log message]
+
2002-01-26 00:14 thomas
* ziptest.rb: In unit test: work around ruby/cygwin weirdness. You
@@ -753,20 +1126,44 @@
* ziptest.rb: Fixed test that failed on windows because of CRLF
line ending
+2002-01-25 23:58 thomas
+
+ * ziptest.rb: [no log message]
+
2002-01-25 23:29 thomas
* .cvsignore, example.rb, zip.rb: Fixed bug reading from empty
deflated entry in zip file
+2002-01-25 23:01 thomas
+
+ * .cvsignore: [no log message]
+
+2002-01-25 22:56 thomas
+
+ * ziptest.rb: [no log message]
+
2002-01-25 22:51 thomas
* NEWS, README.txt, zip.rb, ziptest.rb: Zip write support is now
fully functional in the form of ZipOutputStream.
+2002-01-25 21:12 thomas
+
+ * zip.rb, ziptest.rb: [no log message]
+
+2002-01-25 20:37 thomas
+
+ * zip.rb, ziptest.rb: [no log message]
+
2002-01-20 16:00 thomas
* zip.rb, ziptest.rb: Added Deflater and DeflaterTest.
+2002-01-20 00:39 thomas
+
+ * .cvsignore: [no log message]
+
2002-01-20 00:23 thomas
* .cvsignore: Added .cvsignore file
@@ -797,6 +1194,10 @@
* README.txt: License now same as rubys, not just GPL
+2002-01-06 00:19 thomas
+
+ * README.txt: [no log message]
+
2002-01-05 23:09 thomas
* NEWS, README.txt: Updated NEWS file
@@ -818,6 +1219,18 @@
* zip.rb: Changed references to Inflate to Zlib::inflate for
compatibility with ruby-zlib-0.5
+2002-01-05 19:28 thomas
+
+ * README.txt, zip.rb, ziptest.rb: [no log message]
+
+2002-01-05 01:52 thomas
+
+ * example.rb, NEWS: [no log message]
+
+2002-01-05 01:37 thomas
+
+ * COPYING, README.txt: [no log message]
+
2002-01-05 01:31 thomas
* ziptest.rb: Fixed problem with test file creation
diff --git a/vendor/rubyzip-0.5.6/NEWS b/vendor/rubyzip-0.5.8/NEWS
old mode 100755
new mode 100644
similarity index 80%
rename from vendor/rubyzip-0.5.6/NEWS
rename to vendor/rubyzip-0.5.8/NEWS
index d05d6561..37911fdb
--- a/vendor/rubyzip-0.5.6/NEWS
+++ b/vendor/rubyzip-0.5.8/NEWS
@@ -1,32 +1,43 @@
-= Version 0.5.6 =
+= Version 0.5.8
+
+Fixed install script.
+
+= Version 0.5.7
+
+install.rb no longer assumes it is being run from the toplevel source
+dir. Directory structure changed to reflect common ruby library
+project structure. Migrated from RubyUnit to Test::Unit format. Now
+uses Rake to build source packages and gems and run unit tests.
+
+= Version 0.5.6
Fix for FreeBSD 4.9 which returns Errno::EFBIG instead of
Errno::EINVAL for some invalid seeks. Fixed 'version needed to
extract'-field incorrect in local headers.
-= Version 0.5.5 =
+= Version 0.5.5
Fix for a problem with writing zip files that concerns only ruby 1.8.1.
-= Version 0.5.4 =
+= Version 0.5.4
Significantly reduced memory footprint when modifying zip files.
-= Version 0.5.3 =
+= Version 0.5.3
Added optimization to avoid decompressing and recompressing individual
entries when modifying a zip archive.
-= Version 0.5.2 =
+= Version 0.5.2
Fixed ZipFile corruption bug in ZipFile class. Added basic unix
extra-field support.
-= Version 0.5.1 =
+= Version 0.5.1
Fixed ZipFile.get_output_stream bug.
-= Version 0.5.0 =
+= Version 0.5.0
List of changes:
* Ruby 1.8.0 and ruby-zlib 0.6.0 compatibility
@@ -42,7 +53,7 @@ Bug fixes:
* AbstractInputStream.each_line with non-default separator
-= Version 0.5.0a =
+= Version 0.5.0a
Source reorganized. Added ziprequire, which can be used to load ruby
modules from a zip file, in a fashion similar to jar files in
@@ -55,15 +66,15 @@ Bug fixes:
* Fixed read() using separate buffer, causing mix of gets/readline/read to
cause problems.
-= Version 0.4.2 =
+= Version 0.4.2
Performance optimizations. Test suite runs in half the time.
-= Version 0.4.1 =
+= Version 0.4.1
Windows compatibility fixes.
-= Version 0.4.0 =
+= Version 0.4.0
Zip::ZipFile is now mutable and provides a more convenient way of
modifying zip archives than Zip::ZipOutputStream. Operations for
@@ -75,18 +86,18 @@ Runs without warnings with -w switch.
Install script install.rb added.
-= Version 0.3.1 =
+= Version 0.3.1
Rudimentary support for writing zip archives.
-= Version 0.2.2 =
+= Version 0.2.2
Fixed and extended unit test suite. Updated to work with ruby/zlib
0.5. It doesn't work with earlier versions of ruby/zlib.
-= Version 0.2.0 =
+= Version 0.2.0
Class ZipFile added. Where ZipInputStream is used to read the
individual entries in a zip file, ZipFile reads the central directory
@@ -94,6 +105,6 @@ in the zip archive, so you can get to any entry in the zip archive
without having to skipping through all the preceeding entries.
-= Version 0.1.0 =
+= Version 0.1.0
First working version of ZipInputStream.
diff --git a/vendor/rubyzip-0.5.8/README b/vendor/rubyzip-0.5.8/README
new file mode 100644
index 00000000..6ed15a92
--- /dev/null
+++ b/vendor/rubyzip-0.5.8/README
@@ -0,0 +1,70 @@
+= rubyzip
+
+rubyzip is a ruby library for reading and writing zip files.
+
+= Install
+
+If you have rubygems you can install rubyzip directly from the gem
+repository
+
+ gem install rubyzip
+
+Otherwise obtain the source (see below) and run
+
+ ruby install.rb
+
+To run the unit tests you need to have test::unit installed
+
+ rake test
+
+
+= Documentation
+
+There is more than one way to access or create a zip archive with
+rubyzip. The basic API is modeled after the classes in
+java.util.zip from the Java SDK. This means there are classes such
+as Zip::ZipInputStream, Zip::ZipOutputStream and
+Zip::ZipFile. Zip::ZipInputStream provides a basic interface for
+iterating through the entries in a zip archive and reading from the
+entries in the same way as from a regular File or IO
+object. ZipOutputStream is the corresponding basic output
+facility. Zip::ZipFile provides a mean for accessing the archives
+central directory and provides means for accessing any entry without
+having to iterate through the archive. Unlike Java's
+java.util.zip.ZipFile rubyzip's Zip::ZipFile is mutable, which means
+it can be used to change zip files as well.
+
+Another way to access a zip archive with rubyzip is to use rubyzip's
+Zip::ZipFileSystem API. Using this API files can be read from and
+written to the archive in much the same manner as ruby's builtin
+classes allows files to be read from and written to the file system.
+
+rubyzip also features the
+zip/ziprequire.rb[link:files/lib/zip/ziprequire_rb.html] module which
+allows ruby to load ruby modules from zip archives.
+
+For details about the specific behaviour of classes and methods refer
+to the test suite. Finally you can generate the rdoc documentation or
+visit http://rubyzip.sourceforge.net.
+
+= License
+
+rubyzip is distributed under the same license as ruby. See
+http://www.ruby-lang.org/en/LICENSE.txt
+
+
+= Website and Project Home
+
+http://rubyzip.sourceforge.net
+
+http://sourceforge.net/projects/rubyzip
+
+== Download (tarballs and gems)
+
+http://sourceforge.net/project/showfiles.php?group_id=43107&package_id=35377
+
+= Authors
+
+Thomas Sondergaard (thomas at sondergaard.cc)
+
+extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)
diff --git a/vendor/rubyzip-0.5.8/Rakefile b/vendor/rubyzip-0.5.8/Rakefile
new file mode 100644
index 00000000..03b65c2d
--- /dev/null
+++ b/vendor/rubyzip-0.5.8/Rakefile
@@ -0,0 +1,110 @@
+# Rakefile for RubyGems -*- ruby -*-
+
+require 'rubygems'
+require 'rake/clean'
+require 'rake/testtask'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/rdoctask'
+require 'rake/contrib/sshpublisher'
+require 'net/ftp'
+
+PKG_NAME = 'rubyzip'
+PKG_VERSION = File.read('lib/zip/zip.rb').match(/\s+VERSION\s*=\s*'(.*)'/)[1]
+
+PKG_FILES = FileList.new
+
+PKG_FILES.add %w{ README NEWS TODO ChangeLog install.rb Rakefile }
+PKG_FILES.add %w{ samples/*.rb }
+PKG_FILES.add %w{ test/*.rb }
+PKG_FILES.add %w{ test/data/* }
+PKG_FILES.exclude "test/data/generated"
+PKG_FILES.add %w{ lib/**/*.rb }
+
+def clobberFromCvsIgnore(path)
+ CLOBBER.add File.readlines(path+'/.cvsignore').map {
+ |f| File.join(path, f.chomp)
+ }
+end
+
+clobberFromCvsIgnore '.'
+clobberFromCvsIgnore 'samples'
+clobberFromCvsIgnore 'test'
+clobberFromCvsIgnore 'test/data'
+
+task :default => [:test]
+
+desc "Run unit tests"
+task :test do
+ ruby %{-C test alltests.rb}
+end
+
+# Shortcuts for test targets
+task :ut => [:test]
+
+spec = Gem::Specification.new do |s|
+ s.name = PKG_NAME
+ s.version = PKG_VERSION
+ s.author = "Thomas Sondergaard"
+ s.email = "thomas(at)sondergaard.cc"
+ s.homepage = "http://rubyzip.sourceforge.net/"
+ s.platform = Gem::Platform::RUBY
+ s.summary = "rubyzip is a ruby module for reading and writing zip files"
+ s.files = PKG_FILES.to_a #Dir.glob("{samples,lib,test,docs}/**/*").delete_if {|item| item.include?("CVS") || item.include?("rdoc") || item =~ /~$/ }
+ s.require_path = 'lib'
+ s.autorequire = 'zip/zip'
+end
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.need_zip = true
+ pkg.need_tar = true
+end
+
+Rake::RDocTask.new do |rd|
+ rd.main = "README"
+ rd.rdoc_files.add %W{ lib/zip/*.rb README NEWS TODO ChangeLog }
+ rd.options << "--title 'rubyzip documentation' --webcvs http://cvs.sourceforge.net/viewcvs.py/rubyzip/rubyzip/"
+# rd.options << "--all"
+end
+
+desc "Publish documentation"
+task :pdoc => [:rdoc] do
+ Rake::SshFreshDirPublisher.
+ new("thomas@rubyzip.sourceforge.net", "rubyzip/htdocs", "html").upload
+end
+
+desc "Publish package"
+task :ppackage => [:package] do
+ Net::FTP.open("upload.sourceforge.net",
+ "ftp",
+ ENV['USER']+"@"+ENV['HOSTNAME']) {
+ |ftpclient|
+ ftpclient.chdir "incoming"
+ Dir['pkg/*.{tgz,zip,gem}'].each {
+ |e|
+ ftpclient.putbinaryfile(e, File.basename(e))
+ }
+ }
+end
+
+desc "Generate the ChangeLog file"
+task :ChangeLog do
+ puts "Updating ChangeLog"
+ system %{cvs2cl}
+end
+
+desc "Make a release"
+task :release => [:tag_release, :pdoc, :ppackage] do
+end
+
+desc "Make a release tag"
+task :tag_release do
+ tag = "release-#{PKG_VERSION.gsub('.','-')}"
+
+ puts "Checking for tag '#{tag}'"
+ if (Regexp.new("^\\s+#{tag}") =~ `cvs log README`)
+ abort "Tag '#{tag}' already exists"
+ end
+ puts "Tagging module with '#{tag}'"
+ system("cvs tag #{tag}")
+end
diff --git a/vendor/rubyzip-0.5.6/TODO b/vendor/rubyzip-0.5.8/TODO
old mode 100755
new mode 100644
similarity index 75%
rename from vendor/rubyzip-0.5.6/TODO
rename to vendor/rubyzip-0.5.8/TODO
index 05746880..457298c6
--- a/vendor/rubyzip-0.5.6/TODO
+++ b/vendor/rubyzip-0.5.8/TODO
@@ -1,10 +1,9 @@
-* Fix problem with mixing AbstractInputStream::gets and AbstractInputStream::red
+
+* Fix problem with mixing AbstractInputStream::gets and AbstractInputStream::read
* Implement ZipFsDir.glob
* ZipFile.checkIntegrity method
* non-MSDOS permission attributes
** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
* Packager version, required unpacker version in zip headers
** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
-* implement small gui app on top, to exercise library and to discover
-what features should be added to rubyzip next.
* implement storing attributes and ownership information
diff --git a/vendor/rubyzip-0.5.6/install.rb b/vendor/rubyzip-0.5.8/install.rb
old mode 100755
new mode 100644
similarity index 73%
rename from vendor/rubyzip-0.5.6/install.rb
rename to vendor/rubyzip-0.5.8/install.rb
index d806acb0..405e2b0b
--- a/vendor/rubyzip-0.5.6/install.rb
+++ b/vendor/rubyzip-0.5.8/install.rb
@@ -12,10 +12,11 @@ files = %w{ stdrubyext.rb ioextras.rb zip.rb zipfilesystem.rb ziprequire.rb temp
INSTALL_DIR = File.join(CONFIG["sitelibdir"], "zip")
File.makedirs(INSTALL_DIR)
-Dir.chdir "zip"
+
+SOURCE_DIR = File.join(File.dirname($0), "lib/zip")
+
files.each {
|filename|
installPath = File.join(INSTALL_DIR, filename)
- File::install(filename, installPath, 0644, true)
+ File::install(File.join(SOURCE_DIR, filename), installPath, 0644, true)
}
-Dir.chdir ".."
diff --git a/vendor/rubyzip-0.5.6/zip/ioextras.rb b/vendor/rubyzip-0.5.8/lib/zip/ioextras.rb
old mode 100755
new mode 100644
similarity index 93%
rename from vendor/rubyzip-0.5.6/zip/ioextras.rb
rename to vendor/rubyzip-0.5.8/lib/zip/ioextras.rb
index 85785d6e..7129e933
--- a/vendor/rubyzip-0.5.6/zip/ioextras.rb
+++ b/vendor/rubyzip-0.5.8/lib/zip/ioextras.rb
@@ -1,4 +1,6 @@
-module IOExtras
+module IOExtras #:nodoc:
+
+ # Implements kind_of? in order to pretend to be an IO object
module FakeIO
def kind_of?(object)
object == IO || super
@@ -66,7 +68,8 @@ module IOExtras
end
- #relies on <<
+ # Implements many of the output convenience methods of IO.
+ # relies on <<
module AbstractOutputStream
include FakeIO
diff --git a/vendor/rubyzip-0.5.6/zip/stdrubyext.rb b/vendor/rubyzip-0.5.8/lib/zip/stdrubyext.rb
old mode 100755
new mode 100644
similarity index 94%
rename from vendor/rubyzip-0.5.6/zip/stdrubyext.rb
rename to vendor/rubyzip-0.5.8/lib/zip/stdrubyext.rb
index c3fc2acc..833365db
--- a/vendor/rubyzip-0.5.6/zip/stdrubyext.rb
+++ b/vendor/rubyzip-0.5.8/lib/zip/stdrubyext.rb
@@ -16,7 +16,7 @@ module Enumerable #:nodoc:all
end
unless Object.method_defined?(:object_id)
- class Object
+ class Object #:nodoc:all
# Using object_id which is the new thing, so we need
# to make that work in versions prior to 1.8.0
alias object_id id
@@ -24,7 +24,7 @@ unless Object.method_defined?(:object_id)
end
unless File.respond_to?(:read)
- class File
+ class File # :nodoc:all
# singleton method read does not exist in 1.6.x
def self.read(fileName)
open(fileName) { |f| f.read }
@@ -32,7 +32,7 @@ unless File.respond_to?(:read)
end
end
-class String
+class String #:nodoc:all
def starts_with(aString)
rindex(aString, 0) == 0
end
@@ -50,7 +50,7 @@ class String
end
end
-class Time
+class Time #:nodoc:all
#MS-DOS File Date and Time format as used in Interrupt 21H Function 57H:
#
@@ -95,7 +95,7 @@ class Time
end
end
-class Module
+class Module #:nodoc:all
def forward_message(forwarder, *messagesToForward)
methodDefs = messagesToForward.map {
|msg|
diff --git a/vendor/rubyzip-0.5.6/zip/tempfile_bugfixed.rb b/vendor/rubyzip-0.5.8/lib/zip/tempfile_bugfixed.rb
old mode 100755
new mode 100644
similarity index 97%
rename from vendor/rubyzip-0.5.6/zip/tempfile_bugfixed.rb
rename to vendor/rubyzip-0.5.8/lib/zip/tempfile_bugfixed.rb
index ae82508f..6cf8e0af
--- a/vendor/rubyzip-0.5.6/zip/tempfile_bugfixed.rb
+++ b/vendor/rubyzip-0.5.8/lib/zip/tempfile_bugfixed.rb
@@ -1,13 +1,13 @@
#
# tempfile - manipulates temporary files
#
-# $Id: tempfile_bugfixed.rb,v 1.1 2005/01/07 23:08:02 alexeyv Exp $
+# $Id: tempfile_bugfixed.rb,v 1.2 2005/02/19 20:30:33 thomas Exp $
#
require 'delegate'
require 'tmpdir'
-module BugFix
+module BugFix #:nodoc:all
# A class for managing temporary files. This library is written to be
# thread safe.
diff --git a/vendor/rubyzip-0.5.6/zip/zip.rb b/vendor/rubyzip-0.5.8/lib/zip/zip.rb
old mode 100755
new mode 100644
similarity index 81%
rename from vendor/rubyzip-0.5.6/zip/zip.rb
rename to vendor/rubyzip-0.5.8/lib/zip/zip.rb
index 2ad17658..57c0b4fa
--- a/vendor/rubyzip-0.5.6/zip/zip.rb
+++ b/vendor/rubyzip-0.5.8/lib/zip/zip.rb
@@ -11,7 +11,7 @@ if Tempfile.superclass == SimpleDelegator
Tempfile = BugFix::Tempfile
end
-module Zlib
+module Zlib #:nodoc:all
if ! const_defined? :MAX_WBITS
MAX_WBITS = Zlib::Deflate.MAX_WBITS
end
@@ -19,6 +19,8 @@ end
module Zip
+ VERSION = '0.5.8'
+
RUBY_MINOR_VERSION = RUBY_VERSION.split(".")[1].to_i
# Ruby 1.7.x compatibility
@@ -26,10 +28,54 @@ module Zip
# an empty string the first time and then nil.
# not so in 1.7.x
EMPTY_FILE_RETURNS_EMPTY_STRING_FIRST = RUBY_MINOR_VERSION != 7
-
+
+ # ZipInputStream is the basic class for reading zip entries in a
+ # zip file. It is possible to create a ZipInputStream object directly,
+ # passing the zip file name to the constructor, but more often than not
+ # the ZipInputStream will be obtained from a ZipFile (perhaps using the
+ # ZipFileSystem interface) object for a particular entry in the zip
+ # archive.
+ #
+ # A ZipInputStream inherits IOExtras::AbstractInputStream in order
+ # to provide an IO-like interface for reading from a single zip
+ # entry. Beyond methods for mimicking an IO-object it contains
+ # the method get_next_entry for iterating through the entries of
+ # an archive. get_next_entry returns a ZipEntry object that describes
+ # the zip entry the ZipInputStream is currently reading from.
+ #
+ # Example that creates a zip archive with ZipOutputStream and reads it
+ # back again with a ZipInputStream.
+ #
+ # require 'zip/zip'
+ #
+ # Zip::ZipOutputStream::open("my.zip") {
+ # |io|
+ #
+ # io.put_next_entry("first_entry.txt")
+ # io.write "Hello world!"
+ #
+ # io.put_next_entry("adir/first_entry.txt")
+ # io.write "Hello again!"
+ # }
+ #
+ #
+ # Zip::ZipInputStream::open("my.zip") {
+ # |io|
+ #
+ # while (entry = io.get_next_entry)
+ # puts "Contents of #{entry.name}: '#{io.read}'"
+ # end
+ # }
+ #
+ # java.util.zip.ZipInputStream is the original inspiration for this
+ # class.
+
class ZipInputStream
include IOExtras::AbstractInputStream
+ # Opens the indicated zip file. An exception is thrown
+ # if the specified offset in the specified filename is
+ # not a local zip entry header.
def initialize(filename, offset = 0)
super()
@archiveIO = File.open(filename, "rb")
@@ -41,7 +87,10 @@ module Zip
def close
@archiveIO.close
end
-
+
+ # Same as #initialize but if a block is passed the opened
+ # stream is passed to the block and closed when the block
+ # returns.
def ZipInputStream.open(filename)
return new(filename) unless block_given?
@@ -51,12 +100,17 @@ module Zip
zio.close if zio
end
+ # Returns a ZipEntry object. It is necessary to call this
+ # method on a newly created ZipInputStream before reading from
+ # the first entry in the archive. Returns nil when there are
+ # no more entries.
def get_next_entry
@archiveIO.seek(@currentEntry.next_header_offset,
IO::SEEK_SET) if @currentEntry
open_entry
end
+ # Rewinds the stream to the beginning of the current entry
def rewind
return if @currentEntry.nil?
@lineno = 0
@@ -65,6 +119,13 @@ module Zip
open_entry
end
+ # Modeled after IO.read
+ def read(numberOfBytes = nil)
+ @decompressor.read(numberOfBytes)
+ end
+
+ protected
+
def open_entry
@currentEntry = ZipEntry.read_local_entry(@archiveIO)
if (@currentEntry == nil)
@@ -82,10 +143,6 @@ module Zip
return @currentEntry
end
- def read(numberOfBytes = nil)
- @decompressor.read(numberOfBytes)
- end
- protected
def produce_input
@decompressor.produce_input
end
@@ -505,11 +562,31 @@ module Zip
end
+ # ZipOutputStream is the basic class for writing zip files. It is
+ # possible to create a ZipOutputStream object directly, passing
+ # the zip file name to the constructor, but more often than not
+ # the ZipOutputStream will be obtained from a ZipFile (perhaps using the
+ # ZipFileSystem interface) object for a particular entry in the zip
+ # archive.
+ #
+ # A ZipOutputStream inherits IOExtras::AbstractOutputStream in order
+ # to provide an IO-like interface for writing to a single zip
+ # entry. Beyond methods for mimicking an IO-object it contains
+ # the method put_next_entry that closes the current entry
+ # and creates a new.
+ #
+ # Please refer to ZipInputStream for example code.
+ #
+ # java.util.zip.ZipOutputStream is the original inspiration for this
+ # class.
+
class ZipOutputStream
include IOExtras::AbstractOutputStream
attr_accessor :comment
+ # Opens the indicated zip file. If a file with that name already
+ # exists it will be overwritten.
def initialize(fileName)
super()
@fileName = fileName
@@ -521,6 +598,9 @@ module Zip
@comment = nil
end
+ # Same as #initialize but if a block is passed the opened
+ # stream is passed to the block and closed when the block
+ # returns.
def ZipOutputStream.open(fileName)
return new(fileName) unless block_given?
zos = new(fileName)
@@ -529,6 +609,7 @@ module Zip
zos.close if zos
end
+ # Closes the stream and writes the central directory to the zip file
def close
return if @closed
finalize_current_entry
@@ -538,6 +619,8 @@ module Zip
@closed = true
end
+ # Closes the current entry and opens a new for writing.
+ # +entry+ can be a ZipEntry object or a string.
def put_next_entry(entry, level = Zlib::DEFAULT_COMPRESSION)
raise ZipError, "zip stream is closed" if @closed
newEntry = entry.kind_of?(ZipEntry) ? entry : ZipEntry.new(@fileName, entry.to_s)
@@ -613,6 +696,7 @@ module Zip
end
public
+ # Modeled after IO.<<
def << (data)
@compressor << data
end
@@ -678,7 +762,7 @@ module Zip
end
- class ZipEntrySet
+ class ZipEntrySet #:nodoc:all
include Enumerable
def initialize(anEnumerable = [])
@@ -733,7 +817,7 @@ module Zip
end
- class ZipCentralDirectory #:nodoc:all
+ class ZipCentralDirectory
include Enumerable
END_OF_CENTRAL_DIRECTORY_SIGNATURE = 0x06054b50
@@ -741,24 +825,25 @@ module Zip
STATIC_EOCD_SIZE = 22
attr_reader :comment
-
+
+ # Returns an Enumerable containing the entries.
def entries
@entrySet.entries
end
- def initialize(entries = ZipEntrySet.new, comment = "")
+ def initialize(entries = ZipEntrySet.new, comment = "") #:nodoc:
super()
@entrySet = entries.kind_of?(ZipEntrySet) ? entries : ZipEntrySet.new(entries)
@comment = comment
end
- def write_to_stream(io)
+ def write_to_stream(io) #:nodoc:
offset = io.tell
@entrySet.each { |entry| entry.write_c_dir_entry(io) }
write_e_o_c_d(io, offset)
end
- def write_e_o_c_d(io, offset)
+ def write_e_o_c_d(io, offset) #:nodoc:
io <<
[END_OF_CENTRAL_DIRECTORY_SIGNATURE,
0 , # @numberOfThisDisk
@@ -772,13 +857,13 @@ module Zip
end
private :write_e_o_c_d
- def cdir_size
+ def cdir_size #:nodoc:
# does not include eocd
@entrySet.inject(0) { |value, entry| entry.cdir_header_size + value }
end
private :cdir_size
- def read_e_o_c_d(io)
+ def read_e_o_c_d(io) #:nodoc:
buf = get_e_o_c_d(io)
@numberOfThisDisk = ZipEntry::read_zip_short(buf)
@numberOfDiskWithStartOfCDir = ZipEntry::read_zip_short(buf)
@@ -791,7 +876,7 @@ module Zip
raise ZipError, "Zip consistency problem while reading eocd structure" unless buf.size == 0
end
- def read_central_directory_entries(io)
+ def read_central_directory_entries(io) #:nodoc:
begin
io.seek(@cdirOffset, IO::SEEK_SET)
rescue Errno::EINVAL
@@ -803,12 +888,12 @@ module Zip
}
end
- def read_from_stream(io)
+ def read_from_stream(io) #:nodoc:
read_e_o_c_d(io)
read_central_directory_entries(io)
end
- def get_e_o_c_d(io)
+ def get_e_o_c_d(io) #:nodoc:
begin
io.seek(-MAX_END_OF_CENTRAL_DIRECTORY_STRUCTURE_SIZE, IO::SEEK_END)
rescue Errno::EINVAL
@@ -825,16 +910,19 @@ module Zip
end
return buf
end
-
+
+ # For iterating over the entries.
def each(&proc)
@entrySet.each(&proc)
end
+ # Returns the number of entries in the central directory (and
+ # consequently in the zip archive).
def size
@entrySet.size
end
- def ZipCentralDirectory.read_from_stream(io)
+ def ZipCentralDirectory.read_from_stream(io) #:nodoc:
cdir = new
cdir.read_from_stream(io)
return cdir
@@ -842,7 +930,7 @@ module Zip
return nil
end
- def == (other)
+ def == (other) #:nodoc:
return false unless other.kind_of?(ZipCentralDirectory)
@entrySet.entries.sort == other.entries.sort && comment == other.comment
end
@@ -856,19 +944,64 @@ module Zip
class ZipCompressionMethodError < ZipError; end
class ZipEntryNameError < ZipError; end
+ # ZipFile is modeled after java.util.zip.ZipFile from the Java SDK.
+ # The most important methods are those inherited from
+ # ZipCentralDirectory for accessing information about the entries in
+ # the archive and methods such as get_input_stream and
+ # get_output_stream for reading from and writing entries to the
+ # archive. The class includes a few convenience methods such as
+ # #extract for extracting entries to the filesystem, and #remove,
+ # #replace, #rename and #mkdir for making simple modifications to
+ # the archive.
+ #
+ # Modifications to a zip archive are not committed until #commit or
+ # #close is called. The method #open accepts a block following
+ # the pattern from File.open offering a simple way to
+ # automatically close the archive when the block returns.
+ #
+ # The following example opens zip archive my.zip
+ # (creating it if it doesn't exist) and adds an entry
+ # first.txt
and a directory entry a_dir
+ # to it.
+ #
+ # require 'zip/zip'
+ #
+ # Zip::ZipFile.open("my.zip", Zip::ZipFile::CREATE) {
+ # |zipfile|
+ # zipfile.get_output_stream("first.txt") { |f| f.puts "Hello from ZipFile" }
+ # zipfile.mkdir("a_dir")
+ # }
+ #
+ # The next example reopens my.zip
writes the contents of
+ # first.txt
to standard out and deletes the entry from
+ # the archive.
+ #
+ # require 'zip/zip'
+ #
+ # Zip::ZipFile.open("my.zip", Zip::ZipFile::CREATE) {
+ # |zipfile|
+ # puts zipfile.read("first.txt")
+ # zipfile.remove("first.txt")
+ # }
+ #
+ # ZipFileSystem offers an alternative API that emulates ruby's
+ # interface for accessing the filesystem, ie. the File and Dir classes.
+
class ZipFile < ZipCentralDirectory
CREATE = 1
attr_reader :name
+ # Opens a zip archive. Pass true as the second parameter to create
+ # a new archive if it doesn't exist already.
def initialize(fileName, create = nil)
super()
@name = fileName
@comment = ""
if (File.exists?(fileName))
File.open(name, "rb") { |f| read_from_stream(f) }
- elsif (create == ZipFile::CREATE)
+ elsif (create)
@entrySet = ZipEntrySet.new
else
raise ZipError, "File #{fileName} not found"
@@ -876,7 +1009,10 @@ module Zip
@create = create
@storedEntries = @entrySet.dup
end
-
+
+ # Same as #new. If a block is passed the ZipFile object is passed
+ # to the block and is automatically closed afterwards just as with
+ # ruby's builtin File.open method.
def ZipFile.open(fileName, create = nil)
zf = ZipFile.new(fileName, create)
if block_given?
@@ -890,8 +1026,15 @@ module Zip
end
end
+ # Returns the zip files comment, if it has one
attr_accessor :comment
+ # Iterates over the contents of the ZipFile. This is more efficient
+ # than using a ZipInputStream since this methods simply iterates
+ # through the entries in the central directory structure in the archive
+ # whereas ZipInputStream jumps through the entire archive accessing the
+ # local entry headers (which contain the same information as the
+ # central directory).
def ZipFile.foreach(aZipFileName, &block)
ZipFile.open(aZipFileName) {
|zipFile|
@@ -899,10 +1042,16 @@ module Zip
}
end
+ # Returns an input stream to the specified entry. If a block is passed
+ # the stream object is passed to the block and the stream is automatically
+ # closed afterwards just as with ruby's builtin File.open method.
def get_input_stream(entry, &aProc)
get_entry(entry).get_input_stream(&aProc)
end
+ # Returns an output stream to the specified entry. If a block is passed
+ # the stream object is passed to the block and the stream is automatically
+ # closed afterwards just as with ruby's builtin File.open method.
def get_output_stream(entry, &aProc)
newEntry = entry.kind_of?(ZipEntry) ? entry : ZipEntry.new(@name, entry.to_s)
if newEntry.directory?
@@ -914,14 +1063,17 @@ module Zip
zipStreamableEntry.get_output_stream(&aProc)
end
+ # Returns the name of the zip archive
def to_s
@name
end
+ # Returns a string containing the contents of the specified entry
def read(entry)
get_input_stream(entry) { |is| is.read }
end
+ # Convenience method for adding the contents of a file to the archive
def add(entry, srcPath, &continueOnExistsProc)
continueOnExistsProc ||= proc { false }
check_entry_exists(entry, continueOnExistsProc, "add")
@@ -933,21 +1085,26 @@ module Zip
end
end
+ # Removes the specified entry.
def remove(entry)
@entrySet.delete(get_entry(entry))
end
+ # Renames the specified entry.
def rename(entry, newName, &continueOnExistsProc)
foundEntry = get_entry(entry)
check_entry_exists(newName, continueOnExistsProc, "rename")
foundEntry.name=newName
end
+ # Replaces the specified entry with the contents of srcPath (from
+ # the file system).
def replace(entry, srcPath)
check_file(srcPath)
add(remove(entry), srcPath)
end
-
+
+ # Extracts entry to file destPath.
def extract(entry, destPath, &onExistsProc)
onExistsProc ||= proc { false }
foundEntry = get_entry(entry)
@@ -957,7 +1114,9 @@ module Zip
write_file(foundEntry, destPath, &onExistsProc)
end
end
-
+
+ # Commits changes that has been made since the previous commit to
+ # the zip archive.
def commit
return if ! commit_required?
on_success_replace(name) {
@@ -972,22 +1131,29 @@ module Zip
}
initialize(name)
end
-
+
+ # Closes the zip file committing any changes that has been made.
def close
commit
end
+ # Returns true if any changes has been made to this archive since
+ # the previous commit
def commit_required?
return @entrySet != @storedEntries || @create == ZipFile::CREATE
end
+ # Searches for entry with the specified name. Returns nil if
+ # no entry is found. See also get_entry
def find_entry(entry)
@entrySet.detect {
|e|
e.name.sub(/\/$/, "") == entry.to_s.sub(/\/$/, "")
}
end
-
+
+ # Searches for an entry just as find_entry, but throws Errno::ENOENT
+ # if no entry is found.
def get_entry(entry)
selectedEntry = find_entry(entry)
unless selectedEntry
@@ -996,6 +1162,7 @@ module Zip
return selectedEntry
end
+ # Creates a directory
def mkdir(entryName, permissionInt = 0) #permissionInt ignored
if find_entry(entryName)
raise Errno::EEXIST, "File exists - #{entryName}"
@@ -1256,8 +1423,8 @@ module Zip
register_map
def initialize(binstr = nil)
- @uid = nil
- @gid = nil
+ @uid = 0
+ @gid = 0
binstr and merge(binstr)
end
attr_accessor :uid, :gid
diff --git a/vendor/rubyzip-0.5.6/zip/zipfilesystem.rb b/vendor/rubyzip-0.5.8/lib/zip/zipfilesystem.rb
old mode 100755
new mode 100644
similarity index 84%
rename from vendor/rubyzip-0.5.6/zip/zipfilesystem.rb
rename to vendor/rubyzip-0.5.8/lib/zip/zipfilesystem.rb
index 3db200f5..75645b43
--- a/vendor/rubyzip-0.5.6/zip/zipfilesystem.rb
+++ b/vendor/rubyzip-0.5.8/lib/zip/zipfilesystem.rb
@@ -1,9 +1,42 @@
require 'zip/zip'
module Zip
+
+ # The ZipFileSystem API provides an API for accessing entries in
+ # a zip archive that is similar to ruby's builtin File and Dir
+ # classes.
+ #
+ # Requiring 'zip/zipfilesystem' includes this module in ZipFile
+ # making the methods in this module available on ZipFile objects.
+ #
+ # Using this API the following example creates a new zip file
+ # my.zip
containing a normal entry with the name
+ # first.txt
, a directory entry named mydir
+ # and finally another normal entry named second.txt
+ #
+ # require 'zip/zipfilesystem'
+ #
+ # Zip::ZipFile.open("my.zip", Zip::ZipFile::CREATE) {
+ # |zipfile|
+ # zipfile.file.open("first.txt", "w") { |f| f.puts "Hello world" }
+ # zipfile.dir.mkdir("mydir")
+ # zipfile.file.open("mydir/second.txt", "w") { |f| f.puts "Hello again" }
+ # }
+ #
+ # Reading is as easy as writing, as the following example shows. The
+ # example writes the contents of first.txt
from zip archive
+ # my.zip
to standard out.
+ #
+ # require 'zip/zipfilesystem'
+ #
+ # Zip::ZipFile.open("my.zip") {
+ # |zipfile|
+ # puts zipfile.file.read("first.txt")
+ # }
+
module ZipFileSystem
- def initialize
+ def initialize # :nodoc:
mappedZip = ZipFileNameMapper.new(self)
@zipFsDir = ZipFsDir.new(mappedZip)
@zipFsFile = ZipFsFile.new(mappedZip)
@@ -11,14 +44,26 @@ module Zip
@zipFsFile.dir = @zipFsDir
end
+ # Returns a ZipFsDir which is much like ruby's builtin Dir (class)
+ # object, except it works on the ZipFile on which this method is
+ # invoked
def dir
@zipFsDir
end
+ # Returns a ZipFsFile which is much like ruby's builtin File (class)
+ # object, except it works on the ZipFile on which this method is
+ # invoked
def file
@zipFsFile
end
-
+
+ # Instances of this class are normally accessed via the accessor
+ # ZipFile::file. An instance of ZipFsFile behaves like ruby's
+ # builtin File (class) object, except it works on ZipFile entries.
+ #
+ # The individual methods are not documented due to their
+ # similarity with the methods in File
class ZipFsFile
attr_writer :dir
@@ -198,7 +243,7 @@ module Zip
@mappedZip.get_entry(fileName).size
end
- # nil for not found and nil for directories
+ # Returns nil for not found and nil for directories
def size?(fileName)
entry = @mappedZip.find_entry(fileName)
return (entry == nil || entry.directory?) ? nil : entry.size
@@ -367,6 +412,12 @@ module Zip
end
end
+ # Instances of this class are normally accessed via the accessor
+ # ZipFile::dir. An instance of ZipFsDir behaves like ruby's
+ # builtin Dir (class) object, except it works on ZipFile entries.
+ #
+ # The individual methods are not documented due to their
+ # similarity with the methods in Dir
class ZipFsDir
def initialize(mappedZip)
@@ -441,7 +492,7 @@ module Zip
end
- class ZipFsDirIterator
+ class ZipFsDirIterator # :nodoc:all
include Enumerable
def initialize(arrayOfFileNames)
@@ -481,7 +532,7 @@ module Zip
# All access to ZipFile from ZipFsFile and ZipFsDir goes through a
# ZipFileNameMapper, which has one responsibility: ensure
- class ZipFileNameMapper
+ class ZipFileNameMapper # :nodoc:all
include Enumerable
def initialize(zipFile)
diff --git a/vendor/rubyzip-0.5.6/zip/ziprequire.rb b/vendor/rubyzip-0.5.8/lib/zip/ziprequire.rb
old mode 100755
new mode 100644
similarity index 57%
rename from vendor/rubyzip-0.5.6/zip/ziprequire.rb
rename to vendor/rubyzip-0.5.8/lib/zip/ziprequire.rb
index 9cd4411c..5a4c4d48
--- a/vendor/rubyzip-0.5.6/zip/ziprequire.rb
+++ b/vendor/rubyzip-0.5.8/lib/zip/ziprequire.rb
@@ -1,6 +1,35 @@
+# With ziprequire you can load ruby modules from a zip file. This means
+# ruby's module include path can include zip-files.
+#
+# The following example creates a zip file with a single entry
+# log/simplelog.rb
that contains a single function
+# simpleLog
:
+#
+# require 'zip/zipfilesystem'
+#
+# Zip::ZipFile.open("my.zip", true) {
+# |zf|
+# zf.file.open("log/simplelog.rb", "w") {
+# |f|
+# f.puts "def simpleLog(v)"
+# f.puts ' Kernel.puts "INFO: #{v}"'
+# f.puts "end"
+# }
+# }
+#
+# To use the ruby module stored in the zip archive simply require
+# zip/ziprequire
and include the my.zip
zip
+# file in the module search path. The following command shows one
+# way to do this:
+#
+# ruby -rzip/ziprequire -Imy.zip -e " require 'log/simplelog'; simpleLog 'Hello world' "
+
+#$: << 'data/rubycode.zip' << 'data/rubycode2.zip'
+
+
require 'zip/zip'
-class ZipList
+class ZipList #:nodoc:all
def initialize(zipFileList)
@zipFileList = zipFileList
end
@@ -23,7 +52,7 @@ class ZipList
end
-module Kernel
+module Kernel #:nodoc:all
alias :oldRequire :require
def require(moduleName)
diff --git a/vendor/rubyzip-0.5.6/samples/example.rb b/vendor/rubyzip-0.5.8/samples/example.rb
old mode 100755
new mode 100644
similarity index 99%
rename from vendor/rubyzip-0.5.6/samples/example.rb
rename to vendor/rubyzip-0.5.8/samples/example.rb
index 35ceb09d..741afa76
--- a/vendor/rubyzip-0.5.6/samples/example.rb
+++ b/vendor/rubyzip-0.5.8/samples/example.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-$: << ".."
+$: << "../lib"
system("zip example.zip example.rb gtkRubyzip.rb")
require 'zip/zip'
diff --git a/vendor/rubyzip-0.5.6/samples/example_filesystem.rb b/vendor/rubyzip-0.5.8/samples/example_filesystem.rb
old mode 100755
new mode 100644
similarity index 98%
rename from vendor/rubyzip-0.5.6/samples/example_filesystem.rb
rename to vendor/rubyzip-0.5.8/samples/example_filesystem.rb
index 8fc5ef83..867e8d4f
--- a/vendor/rubyzip-0.5.6/samples/example_filesystem.rb
+++ b/vendor/rubyzip-0.5.8/samples/example_filesystem.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-$: << ".."
+$: << "../lib"
require 'zip/zipfilesystem'
require 'ftools'
diff --git a/vendor/rubyzip-0.5.6/samples/gtkRubyzip.rb b/vendor/rubyzip-0.5.8/samples/gtkRubyzip.rb
old mode 100755
new mode 100644
similarity index 99%
rename from vendor/rubyzip-0.5.6/samples/gtkRubyzip.rb
rename to vendor/rubyzip-0.5.8/samples/gtkRubyzip.rb
index d2c3a204..5d91829d
--- a/vendor/rubyzip-0.5.6/samples/gtkRubyzip.rb
+++ b/vendor/rubyzip-0.5.8/samples/gtkRubyzip.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-$: << ".."
+$: << "../lib"
$VERBOSE = true
diff --git a/vendor/rubyzip-0.5.6/samples/write_simple.rb b/vendor/rubyzip-0.5.8/samples/write_simple.rb
old mode 100755
new mode 100644
similarity index 90%
rename from vendor/rubyzip-0.5.6/samples/write_simple.rb
rename to vendor/rubyzip-0.5.8/samples/write_simple.rb
index 47b72adb..648989a2
--- a/vendor/rubyzip-0.5.6/samples/write_simple.rb
+++ b/vendor/rubyzip-0.5.8/samples/write_simple.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-$: << ".."
+$: << "../lib"
require 'zip/zip'
@@ -10,4 +10,4 @@ ZipOutputStream.open('simple.zip') {
|zos|
ze = zos.put_next_entry 'entry.txt'
zos.puts "Hello world"
-}
\ No newline at end of file
+}
diff --git a/vendor/rubyzip-0.5.6/samples/zipfind.rb b/vendor/rubyzip-0.5.8/samples/zipfind.rb
old mode 100755
new mode 100644
similarity index 98%
rename from vendor/rubyzip-0.5.6/samples/zipfind.rb
rename to vendor/rubyzip-0.5.8/samples/zipfind.rb
index 96c489d4..54ad936e
--- a/vendor/rubyzip-0.5.6/samples/zipfind.rb
+++ b/vendor/rubyzip-0.5.8/samples/zipfind.rb
@@ -2,7 +2,7 @@
$VERBOSE = true
-$: << ".."
+$: << "../lib"
require 'zip/zip'
require 'find'
diff --git a/vendor/rubyzip-0.5.6/test/alltests.rb b/vendor/rubyzip-0.5.8/test/alltests.rb
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/alltests.rb
rename to vendor/rubyzip-0.5.8/test/alltests.rb
diff --git a/vendor/rubyzip-0.5.6/test/file1.txt b/vendor/rubyzip-0.5.8/test/data/file1.txt
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/file1.txt
rename to vendor/rubyzip-0.5.8/test/data/file1.txt
diff --git a/vendor/rubyzip-0.5.6/test/file1.txt.deflatedData b/vendor/rubyzip-0.5.8/test/data/file1.txt.deflatedData
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/file1.txt.deflatedData
rename to vendor/rubyzip-0.5.8/test/data/file1.txt.deflatedData
diff --git a/vendor/rubyzip-0.5.6/test/file2.txt b/vendor/rubyzip-0.5.8/test/data/file2.txt
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/file2.txt
rename to vendor/rubyzip-0.5.8/test/data/file2.txt
diff --git a/vendor/rubyzip-0.5.6/test/notzippedruby.rb b/vendor/rubyzip-0.5.8/test/data/notzippedruby.rb
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/notzippedruby.rb
rename to vendor/rubyzip-0.5.8/test/data/notzippedruby.rb
diff --git a/vendor/rubyzip-0.5.6/test/rubycode.zip b/vendor/rubyzip-0.5.8/test/data/rubycode.zip
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/rubycode.zip
rename to vendor/rubyzip-0.5.8/test/data/rubycode.zip
diff --git a/vendor/rubyzip-0.5.6/test/rubycode2.zip b/vendor/rubyzip-0.5.8/test/data/rubycode2.zip
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/rubycode2.zip
rename to vendor/rubyzip-0.5.8/test/data/rubycode2.zip
diff --git a/vendor/rubyzip-0.5.6/test/testDirectory.bin b/vendor/rubyzip-0.5.8/test/data/testDirectory.bin
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/testDirectory.bin
rename to vendor/rubyzip-0.5.8/test/data/testDirectory.bin
diff --git a/vendor/rubyzip-0.5.6/test/zipWithDirs.zip b/vendor/rubyzip-0.5.8/test/data/zipWithDirs.zip
old mode 100755
new mode 100644
similarity index 100%
rename from vendor/rubyzip-0.5.6/test/zipWithDirs.zip
rename to vendor/rubyzip-0.5.8/test/data/zipWithDirs.zip
diff --git a/vendor/rubyzip-0.5.8/test/gentestfiles.rb b/vendor/rubyzip-0.5.8/test/gentestfiles.rb
new file mode 100644
index 00000000..1b579702
--- /dev/null
+++ b/vendor/rubyzip-0.5.8/test/gentestfiles.rb
@@ -0,0 +1,155 @@
+#!/usr/bin/env ruby
+
+$VERBOSE = true
+
+class TestFiles
+ RANDOM_ASCII_FILE1 = "data/generated/randomAscii1.txt"
+ RANDOM_ASCII_FILE2 = "data/generated/randomAscii2.txt"
+ RANDOM_ASCII_FILE3 = "data/generated/randomAscii3.txt"
+ RANDOM_BINARY_FILE1 = "data/generated/randomBinary1.bin"
+ RANDOM_BINARY_FILE2 = "data/generated/randomBinary2.bin"
+
+ EMPTY_TEST_DIR = "data/generated/emptytestdir"
+
+ ASCII_TEST_FILES = [ RANDOM_ASCII_FILE1, RANDOM_ASCII_FILE2, RANDOM_ASCII_FILE3 ]
+ BINARY_TEST_FILES = [ RANDOM_BINARY_FILE1, RANDOM_BINARY_FILE2 ]
+ TEST_DIRECTORIES = [ EMPTY_TEST_DIR ]
+ TEST_FILES = [ ASCII_TEST_FILES, BINARY_TEST_FILES, EMPTY_TEST_DIR ].flatten!
+
+ def TestFiles.create_test_files(recreate)
+ if (recreate ||
+ ! (TEST_FILES.inject(true) { |accum, element| accum && File.exists?(element) }))
+
+ Dir.mkdir "data/generated" rescue Errno::EEXIST
+
+ ASCII_TEST_FILES.each_with_index {
+ |filename, index|
+ create_random_ascii(filename, 1E4 * (index+1))
+ }
+
+ BINARY_TEST_FILES.each_with_index {
+ |filename, index|
+ create_random_binary(filename, 1E4 * (index+1))
+ }
+
+ ensure_dir(EMPTY_TEST_DIR)
+ end
+ end
+
+ private
+ def TestFiles.create_random_ascii(filename, size)
+ File.open(filename, "wb") {
+ |file|
+ while (file.tell < size)
+ file << rand
+ end
+ }
+ end
+
+ def TestFiles.create_random_binary(filename, size)
+ File.open(filename, "wb") {
+ |file|
+ while (file.tell < size)
+ file << [rand].pack("V")
+ end
+ }
+ end
+
+ def TestFiles.ensure_dir(name)
+ if File.exists?(name)
+ return if File.stat(name).directory?
+ File.delete(name)
+ end
+ Dir.mkdir(name)
+ end
+
+end
+
+
+
+# For representation and creation of
+# test data
+class TestZipFile
+ attr_accessor :zip_name, :entry_names, :comment
+
+ def initialize(zip_name, entry_names, comment = "")
+ @zip_name=zip_name
+ @entry_names=entry_names
+ @comment = comment
+ end
+
+ def TestZipFile.create_test_zips(recreate)
+ files = Dir.entries("data/generated")
+ if (recreate ||
+ ! (files.index(File.basename(TEST_ZIP1.zip_name)) &&
+ files.index(File.basename(TEST_ZIP2.zip_name)) &&
+ files.index(File.basename(TEST_ZIP3.zip_name)) &&
+ files.index(File.basename(TEST_ZIP4.zip_name)) &&
+ files.index("empty.txt") &&
+ files.index("short.txt") &&
+ files.index("longAscii.txt") &&
+ files.index("longBinary.bin") ))
+ raise "failed to create test zip '#{TEST_ZIP1.zip_name}'" unless
+ system("zip #{TEST_ZIP1.zip_name} data/file2.txt")
+ raise "failed to remove entry from '#{TEST_ZIP1.zip_name}'" unless
+ system("zip #{TEST_ZIP1.zip_name} -d data/file2.txt")
+
+ File.open("data/generated/empty.txt", "w") {}
+
+ File.open("data/generated/short.txt", "w") { |file| file << "ABCDEF" }
+ ziptestTxt=""
+ File.open("data/file2.txt") { |file| ziptestTxt=file.read }
+ File.open("data/generated/longAscii.txt", "w") {
+ |file|
+ while (file.tell < 1E5)
+ file << ziptestTxt
+ end
+ }
+
+ testBinaryPattern=""
+ File.open("data/generated/empty.zip") { |file| testBinaryPattern=file.read }
+ testBinaryPattern *= 4
+
+ File.open("data/generated/longBinary.bin", "wb") {
+ |file|
+ while (file.tell < 3E5)
+ file << testBinaryPattern << rand
+ end
+ }
+ raise "failed to create test zip '#{TEST_ZIP2.zip_name}'" unless
+ system("zip #{TEST_ZIP2.zip_name} #{TEST_ZIP2.entry_names.join(' ')}")
+
+ # without bash system interprets everything after echo as parameters to
+ # echo including | zip -z ...
+ raise "failed to add comment to test zip '#{TEST_ZIP2.zip_name}'" unless
+ system("bash -c \"echo #{TEST_ZIP2.comment} | zip -z #{TEST_ZIP2.zip_name}\"")
+
+ raise "failed to create test zip '#{TEST_ZIP3.zip_name}'" unless
+ system("zip #{TEST_ZIP3.zip_name} #{TEST_ZIP3.entry_names.join(' ')}")
+
+ raise "failed to create test zip '#{TEST_ZIP4.zip_name}'" unless
+ system("zip #{TEST_ZIP4.zip_name} #{TEST_ZIP4.entry_names.join(' ')}")
+ end
+ rescue
+ raise $!.to_s +
+ "\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" +
+ "to create test data. If you don't have it you can download\n" +
+ "the necessary test files at http://sf.net/projects/rubyzip."
+ end
+
+ TEST_ZIP1 = TestZipFile.new("data/generated/empty.zip", [])
+ TEST_ZIP2 = TestZipFile.new("data/generated/4entry.zip", %w{ data/generated/longAscii.txt data/generated/empty.txt data/generated/short.txt data/generated/longBinary.bin},
+ "my zip comment")
+ TEST_ZIP3 = TestZipFile.new("data/generated/test1.zip", %w{ data/file1.txt })
+ TEST_ZIP4 = TestZipFile.new("data/generated/zipWithDir.zip", [ "data/file1.txt",
+ TestFiles::EMPTY_TEST_DIR])
+end
+
+
+END {
+ TestFiles::create_test_files(ARGV.index("recreate") != nil ||
+ ARGV.index("recreateonly") != nil)
+ TestZipFile::create_test_zips(ARGV.index("recreate") != nil ||
+ ARGV.index("recreateonly") != nil)
+ exit if ARGV.index("recreateonly") != nil
+}
diff --git a/vendor/rubyzip-0.5.6/test/ioextrastest.rb b/vendor/rubyzip-0.5.8/test/ioextrastest.rb
old mode 100755
new mode 100644
similarity index 62%
rename from vendor/rubyzip-0.5.6/test/ioextrastest.rb
rename to vendor/rubyzip-0.5.8/test/ioextrastest.rb
index 673e3029..b18e9db9
--- a/vendor/rubyzip-0.5.6/test/ioextrastest.rb
+++ b/vendor/rubyzip-0.5.8/test/ioextrastest.rb
@@ -2,14 +2,14 @@
$VERBOSE = true
-$: << ".."
+$: << "../lib"
-require 'rubyunit'
+require 'test/unit'
require 'zip/ioextras'
include IOExtras
-class FakeIOTest < RUNIT::TestCase
+class FakeIOTest < Test::Unit::TestCase
class FakeIOUsingClass
include FakeIO
end
@@ -25,7 +25,7 @@ class FakeIOTest < RUNIT::TestCase
end
end
-class AbstractInputStreamTest < RUNIT::TestCase
+class AbstractInputStreamTest < Test::Unit::TestCase
# AbstractInputStream subclass that provides a read method
TEST_LINES = [ "Hello world#{$/}",
@@ -60,32 +60,32 @@ class AbstractInputStreamTest < RUNIT::TestCase
end
def test_gets
- assert_equals(TEST_LINES[0], @io.gets)
- assert_equals(1, @io.lineno)
- assert_equals(TEST_LINES[1], @io.gets)
- assert_equals(2, @io.lineno)
- assert_equals(TEST_LINES[2], @io.gets)
- assert_equals(3, @io.lineno)
- assert_equals(nil, @io.gets)
- assert_equals(4, @io.lineno)
+ assert_equal(TEST_LINES[0], @io.gets)
+ assert_equal(1, @io.lineno)
+ assert_equal(TEST_LINES[1], @io.gets)
+ assert_equal(2, @io.lineno)
+ assert_equal(TEST_LINES[2], @io.gets)
+ assert_equal(3, @io.lineno)
+ assert_equal(nil, @io.gets)
+ assert_equal(4, @io.lineno)
end
def test_getsMultiCharSeperator
- assert_equals("Hell", @io.gets("ll"))
- assert_equals("o world#{$/}this is the second l", @io.gets("d l"))
+ assert_equal("Hell", @io.gets("ll"))
+ assert_equal("o world#{$/}this is the second l", @io.gets("d l"))
end
def test_each_line
lineNumber=0
@io.each_line {
|line|
- assert_equals(TEST_LINES[lineNumber], line)
+ assert_equal(TEST_LINES[lineNumber], line)
lineNumber+=1
}
end
def test_readlines
- assert_equals(TEST_LINES, @io.readlines)
+ assert_equal(TEST_LINES, @io.readlines)
end
def test_readline
@@ -98,7 +98,7 @@ class AbstractInputStreamTest < RUNIT::TestCase
end
end
-class AbstractOutputStreamTest < RUNIT::TestCase
+class AbstractOutputStreamTest < Test::Unit::TestCase
class TestOutputStream
include AbstractOutputStream
@@ -128,77 +128,77 @@ class AbstractOutputStreamTest < RUNIT::TestCase
def test_write
count = @outputStream.write("a little string")
- assert_equals("a little string", @outputStream.buffer)
- assert_equals("a little string".length, count)
+ assert_equal("a little string", @outputStream.buffer)
+ assert_equal("a little string".length, count)
count = @outputStream.write(". a little more")
- assert_equals("a little string. a little more", @outputStream.buffer)
- assert_equals(". a little more".length, count)
+ assert_equal("a little string. a little more", @outputStream.buffer)
+ assert_equal(". a little more".length, count)
end
def test_print
$\ = nil # record separator set to nil
@outputStream.print("hello")
- assert_equals("hello", @outputStream.buffer)
+ assert_equal("hello", @outputStream.buffer)
@outputStream.print(" world.")
- assert_equals("hello world.", @outputStream.buffer)
+ assert_equal("hello world.", @outputStream.buffer)
@outputStream.print(" You ok ", "out ", "there?")
- assert_equals("hello world. You ok out there?", @outputStream.buffer)
+ assert_equal("hello world. You ok out there?", @outputStream.buffer)
$\ = "\n"
@outputStream.print
- assert_equals("hello world. You ok out there?\n", @outputStream.buffer)
+ assert_equal("hello world. You ok out there?\n", @outputStream.buffer)
@outputStream.print("I sure hope so!")
- assert_equals("hello world. You ok out there?\nI sure hope so!\n", @outputStream.buffer)
+ assert_equal("hello world. You ok out there?\nI sure hope so!\n", @outputStream.buffer)
$, = "X"
@outputStream.buffer = ""
@outputStream.print("monkey", "duck", "zebra")
- assert_equals("monkeyXduckXzebra\n", @outputStream.buffer)
+ assert_equal("monkeyXduckXzebra\n", @outputStream.buffer)
$\ = nil
@outputStream.buffer = ""
@outputStream.print(20)
- assert_equals("20", @outputStream.buffer)
+ assert_equal("20", @outputStream.buffer)
end
def test_printf
@outputStream.printf("%d %04x", 123, 123)
- assert_equals("123 007b", @outputStream.buffer)
+ assert_equal("123 007b", @outputStream.buffer)
end
def test_putc
@outputStream.putc("A")
- assert_equals("A", @outputStream.buffer)
+ assert_equal("A", @outputStream.buffer)
@outputStream.putc(65)
- assert_equals("AA", @outputStream.buffer)
+ assert_equal("AA", @outputStream.buffer)
end
def test_puts
@outputStream.puts
- assert_equals("\n", @outputStream.buffer)
+ assert_equal("\n", @outputStream.buffer)
@outputStream.puts("hello", "world")
- assert_equals("\nhello\nworld\n", @outputStream.buffer)
+ assert_equal("\nhello\nworld\n", @outputStream.buffer)
@outputStream.buffer = ""
@outputStream.puts("hello\n", "world\n")
- assert_equals("hello\nworld\n", @outputStream.buffer)
+ assert_equal("hello\nworld\n", @outputStream.buffer)
@outputStream.buffer = ""
@outputStream.puts(["hello\n", "world\n"])
- assert_equals("hello\nworld\n", @outputStream.buffer)
+ assert_equal("hello\nworld\n", @outputStream.buffer)
@outputStream.buffer = ""
@outputStream.puts(["hello\n", "world\n"], "bingo")
- assert_equals("hello\nworld\nbingo\n", @outputStream.buffer)
+ assert_equal("hello\nworld\nbingo\n", @outputStream.buffer)
@outputStream.buffer = ""
@outputStream.puts(16, 20, 50, "hello")
- assert_equals("16\n20\n50\nhello\n", @outputStream.buffer)
+ assert_equal("16\n20\n50\nhello\n", @outputStream.buffer)
end
end
diff --git a/vendor/rubyzip-0.5.6/test/stdrubyexttest.rb b/vendor/rubyzip-0.5.8/test/stdrubyexttest.rb
old mode 100755
new mode 100644
similarity index 63%
rename from vendor/rubyzip-0.5.6/test/stdrubyexttest.rb
rename to vendor/rubyzip-0.5.8/test/stdrubyexttest.rb
index f2c63e66..f11608f7
--- a/vendor/rubyzip-0.5.6/test/stdrubyexttest.rb
+++ b/vendor/rubyzip-0.5.8/test/stdrubyexttest.rb
@@ -2,20 +2,20 @@
$VERBOSE = true
-$: << ".."
+$: << "../lib"
-require 'rubyunit'
+require 'test/unit'
require 'zip/stdrubyext'
-class ModuleTest < RUNIT::TestCase
+class ModuleTest < Test::Unit::TestCase
def test_select_map
- assert_equals([2, 4, 8, 10], [1, 2, 3, 4, 5].select_map { |e| e == 3 ? nil : 2*e })
+ assert_equal([2, 4, 8, 10], [1, 2, 3, 4, 5].select_map { |e| e == 3 ? nil : 2*e })
end
end
-class StringExtensionsTest < RUNIT::TestCase
+class StringExtensionsTest < Test::Unit::TestCase
def test_starts_with
assert("hello".starts_with(""))
@@ -24,7 +24,7 @@ class StringExtensionsTest < RUNIT::TestCase
assert(! "hello".starts_with("hello there"))
assert(! "hello".starts_with(" he"))
- assert_exception(TypeError, "type mismatch: NilClass given") {
+ assert_raise(TypeError, "type mismatch: NilClass given") {
"hello".starts_with(nil)
}
end
@@ -40,10 +40,10 @@ class StringExtensionsTest < RUNIT::TestCase
end
def test_ensure_end
- assert_equals("hello!", "hello!".ensure_end("!"))
- assert_equals("hello!", "hello!".ensure_end("o!"))
- assert_equals("hello!", "hello".ensure_end("!"))
- assert_equals("hello!", "hel".ensure_end("lo!"))
+ assert_equal("hello!", "hello!".ensure_end("!"))
+ assert_equal("hello!", "hello!".ensure_end("o!"))
+ assert_equal("hello!", "hello".ensure_end("!"))
+ assert_equal("hello!", "hel".ensure_end("lo!"))
end
end
diff --git a/vendor/rubyzip-0.5.6/test/zipfilesystemtest.rb b/vendor/rubyzip-0.5.8/test/zipfilesystemtest.rb
old mode 100755
new mode 100644
similarity index 65%
rename from vendor/rubyzip-0.5.6/test/zipfilesystemtest.rb
rename to vendor/rubyzip-0.5.8/test/zipfilesystemtest.rb
index c1aa91ba..10140e10
--- a/vendor/rubyzip-0.5.6/test/zipfilesystemtest.rb
+++ b/vendor/rubyzip-0.5.8/test/zipfilesystemtest.rb
@@ -2,10 +2,10 @@
$VERBOSE = true
-$: << ".."
+$: << "../lib"
require 'zip/zipfilesystem'
-require 'rubyunit'
+require 'test/unit'
module ExtraAssertions
@@ -20,8 +20,8 @@ module ExtraAssertions
end
end_eval
- assert_equals(retVal, yield) # Invoke test
- assert_equals(expectedArgs, callArgs)
+ assert_equal(retVal, yield) # Invoke test
+ assert_equal(expectedArgs, callArgs)
ensure
anObject.instance_eval "alias #{method} #{method}_org"
end
@@ -30,9 +30,9 @@ end
include Zip
-class ZipFsFileNonmutatingTest < RUNIT::TestCase
+class ZipFsFileNonmutatingTest < Test::Unit::TestCase
def setup
- @zipFile = ZipFile.new("zipWithDirs.zip")
+ @zipFile = ZipFile.new("data/zipWithDirs.zip")
end
def teardown
@@ -40,7 +40,7 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
end
def test_umask
- assert_equals(File.umask, @zipFile.file.umask)
+ assert_equal(File.umask, @zipFile.file.umask)
@zipFile.file.umask(0006)
end
@@ -62,7 +62,7 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
@zipFile.file.open("file1", "r") {
|f|
blockCalled = true
- assert_equals("this is the entry 'file1' in my test archive!",
+ assert_equal("this is the entry 'file1' in my test archive!",
f.readline.chomp)
}
assert(blockCalled)
@@ -72,19 +72,19 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
@zipFile.file.open("file21", "r") {
|f|
blockCalled = true
- assert_equals("this is the entry 'dir2/file21' in my test archive!",
+ assert_equal("this is the entry 'dir2/file21' in my test archive!",
f.readline.chomp)
}
assert(blockCalled)
@zipFile.dir.chdir "/"
- assert_exception(Errno::ENOENT) {
+ assert_raise(Errno::ENOENT) {
@zipFile.file.open("noSuchEntry")
}
begin
is = @zipFile.file.open("file1")
- assert_equals("this is the entry 'file1' in my test archive!",
+ assert_equal("this is the entry 'file1' in my test archive!",
is.readline.chomp)
ensure
is.close if is
@@ -94,7 +94,7 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
def test_new
begin
is = @zipFile.file.new("file1")
- assert_equals("this is the entry 'file1' in my test archive!",
+ assert_equal("this is the entry 'file1' in my test archive!",
is.readline.chomp)
ensure
is.close if is
@@ -109,27 +109,27 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
end
def test_symlink
- assert_exception(NotImplementedError) {
+ assert_raise(NotImplementedError) {
@zipFile.file.symlink("file1", "aSymlink")
}
end
def test_size
- assert_exception(Errno::ENOENT) { @zipFile.file.size("notAFile") }
- assert_equals(72, @zipFile.file.size("file1"))
- assert_equals(0, @zipFile.file.size("dir2/dir21"))
+ assert_raise(Errno::ENOENT) { @zipFile.file.size("notAFile") }
+ assert_equal(72, @zipFile.file.size("file1"))
+ assert_equal(0, @zipFile.file.size("dir2/dir21"))
- assert_equals(72, @zipFile.file.stat("file1").size)
- assert_equals(0, @zipFile.file.stat("dir2/dir21").size)
+ assert_equal(72, @zipFile.file.stat("file1").size)
+ assert_equal(0, @zipFile.file.stat("dir2/dir21").size)
end
def test_size?
- assert_equals(nil, @zipFile.file.size?("notAFile"))
- assert_equals(72, @zipFile.file.size?("file1"))
- assert_equals(nil, @zipFile.file.size?("dir2/dir21"))
+ assert_equal(nil, @zipFile.file.size?("notAFile"))
+ assert_equal(72, @zipFile.file.size?("file1"))
+ assert_equal(nil, @zipFile.file.size?("dir2/dir21"))
- assert_equals(72, @zipFile.file.stat("file1").size?)
- assert_equals(nil, @zipFile.file.stat("dir2/dir21").size?)
+ assert_equal(72, @zipFile.file.stat("file1").size?)
+ assert_equal(nil, @zipFile.file.stat("dir2/dir21").size?)
end
@@ -166,19 +166,19 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
end
def test_join
- assert_equals("a/b/c", @zipFile.file.join("a/b", "c"))
- assert_equals("a/b/c/d", @zipFile.file.join("a/b", "c/d"))
- assert_equals("/c/d", @zipFile.file.join("", "c/d"))
- assert_equals("a/b/c/d", @zipFile.file.join("a", "b", "c", "d"))
+ assert_equal("a/b/c", @zipFile.file.join("a/b", "c"))
+ assert_equal("a/b/c/d", @zipFile.file.join("a/b", "c/d"))
+ assert_equal("/c/d", @zipFile.file.join("", "c/d"))
+ assert_equal("a/b/c/d", @zipFile.file.join("a", "b", "c", "d"))
end
def test_utime
t_now = Time.now
t_bak = @zipFile.file.mtime("file1")
@zipFile.file.utime(t_now, "file1")
- assert_equals(t_now, @zipFile.file.mtime("file1"))
+ assert_equal(t_now, @zipFile.file.mtime("file1"))
@zipFile.file.utime(t_bak, "file1")
- assert_equals(t_bak, @zipFile.file.mtime("file1"))
+ assert_equal(t_bak, @zipFile.file.mtime("file1"))
end
@@ -219,26 +219,26 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
end
def test_truncate
- assert_exception(StandardError, "truncate not supported") {
+ assert_raise(StandardError, "truncate not supported") {
@zipFile.file.truncate("file1", 100)
}
end
def assert_e_n_o_e_n_t(operation, args = ["NoSuchFile"])
- assert_exception(Errno::ENOENT) {
+ assert_raise(Errno::ENOENT) {
@zipFile.file.send(operation, *args)
}
end
def test_ftype
assert_e_n_o_e_n_t(:ftype)
- assert_equals("file", @zipFile.file.ftype("file1"))
- assert_equals("directory", @zipFile.file.ftype("dir1/dir11"))
- assert_equals("directory", @zipFile.file.ftype("dir1/dir11/"))
+ assert_equal("file", @zipFile.file.ftype("file1"))
+ assert_equal("directory", @zipFile.file.ftype("dir1/dir11"))
+ assert_equal("directory", @zipFile.file.ftype("dir1/dir11/"))
end
def test_link
- assert_exception(NotImplementedError) {
+ assert_raise(NotImplementedError) {
@zipFile.file.link("file1", "someOtherString")
}
end
@@ -259,10 +259,10 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
end
def test_chown
- assert_equals(2, @zipFile.file.chown(1,2, "dir1", "file1"))
- assert_equals(1, @zipFile.file.stat("dir1").uid)
- assert_equals(2, @zipFile.file.stat("dir1").gid)
- assert_equals(2, @zipFile.file.chown(nil, nil, "dir1", "file1"))
+ assert_equal(2, @zipFile.file.chown(1,2, "dir1", "file1"))
+ assert_equal(1, @zipFile.file.stat("dir1").uid)
+ assert_equal(2, @zipFile.file.stat("dir1").gid)
+ assert_equal(2, @zipFile.file.chown(nil, nil, "dir1", "file1"))
end
def test_zero?
@@ -270,48 +270,48 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
assert(! @zipFile.file.zero?("file1"))
assert(@zipFile.file.zero?("dir1"))
blockCalled = false
- ZipFile.open("4entry.zip") {
+ ZipFile.open("data/generated/4entry.zip") {
|zf|
blockCalled = true
- assert(zf.file.zero?("empty.txt"))
+ assert(zf.file.zero?("data/generated/empty.txt"))
}
assert(blockCalled)
assert(! @zipFile.file.stat("file1").zero?)
assert(@zipFile.file.stat("dir1").zero?)
blockCalled = false
- ZipFile.open("4entry.zip") {
+ ZipFile.open("data/generated/4entry.zip") {
|zf|
blockCalled = true
- assert(zf.file.stat("empty.txt").zero?)
+ assert(zf.file.stat("data/generated/empty.txt").zero?)
}
assert(blockCalled)
end
def test_expand_path
- ZipFile.open("zipWithDirs.zip") {
+ ZipFile.open("data/zipWithDirs.zip") {
|zf|
- assert_equals("/", zf.file.expand_path("."))
+ assert_equal("/", zf.file.expand_path("."))
zf.dir.chdir "dir1"
- assert_equals("/dir1", zf.file.expand_path("."))
- assert_equals("/dir1/file12", zf.file.expand_path("file12"))
- assert_equals("/", zf.file.expand_path(".."))
- assert_equals("/dir2/dir21", zf.file.expand_path("../dir2/dir21"))
+ assert_equal("/dir1", zf.file.expand_path("."))
+ assert_equal("/dir1/file12", zf.file.expand_path("file12"))
+ assert_equal("/", zf.file.expand_path(".."))
+ assert_equal("/dir2/dir21", zf.file.expand_path("../dir2/dir21"))
}
end
def test_mtime
- assert_equals(Time.at(1027694306),
+ assert_equal(Time.at(1027694306),
@zipFile.file.mtime("dir2/file21"))
- assert_equals(Time.at(1027690863),
+ assert_equal(Time.at(1027690863),
@zipFile.file.mtime("dir2/dir21"))
- assert_exception(Errno::ENOENT) {
+ assert_raise(Errno::ENOENT) {
@zipFile.file.mtime("noSuchEntry")
}
- assert_equals(Time.at(1027694306),
+ assert_equal(Time.at(1027694306),
@zipFile.file.stat("dir2/file21").mtime)
- assert_equals(Time.at(1027690863),
+ assert_equal(Time.at(1027690863),
@zipFile.file.stat("dir2/dir21").mtime)
end
@@ -394,7 +394,7 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
end
def test_readlink
- assert_exception(NotImplementedError) {
+ assert_raise(NotImplementedError) {
@zipFile.file.readlink("someString")
}
end
@@ -402,7 +402,7 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
def test_stat
s = @zipFile.file.stat("file1")
assert(s.kind_of?(File::Stat)) # It pretends
- assert_exception(Errno::ENOENT, "No such file or directory - noSuchFile") {
+ assert_raise(Errno::ENOENT, "No such file or directory - noSuchFile") {
@zipFile.file.stat("noSuchFile")
}
end
@@ -413,50 +413,50 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
def test_chmod
- assert_exception(Errno::ENOENT, "No such file or directory - noSuchFile") {
+ assert_raise(Errno::ENOENT, "No such file or directory - noSuchFile") {
@zipFile.file.chmod(0644, "file1", "NoSuchFile")
}
- assert_equals(2, @zipFile.file.chmod(0644, "file1", "dir1"))
+ assert_equal(2, @zipFile.file.chmod(0644, "file1", "dir1"))
end
def test_pipe
- assert_exception(NotImplementedError) {
+ assert_raise(NotImplementedError) {
@zipFile.file.pipe
}
end
def test_foreach
- ZipFile.open("zipWithDir.zip") {
+ ZipFile.open("data/generated/zipWithDir.zip") {
|zf|
ref = []
- File.foreach("file1.txt") { |e| ref << e }
+ File.foreach("data/file1.txt") { |e| ref << e }
index = 0
- zf.file.foreach("file1.txt") {
+ zf.file.foreach("data/file1.txt") {
|l|
- assert_equals(ref[index], l)
+ assert_equal(ref[index], l)
index = index.next
}
- assert_equals(ref.size, index)
+ assert_equal(ref.size, index)
}
- ZipFile.open("zipWithDir.zip") {
+ ZipFile.open("data/generated/zipWithDir.zip") {
|zf|
ref = []
- File.foreach("file1.txt", " ") { |e| ref << e }
+ File.foreach("data/file1.txt", " ") { |e| ref << e }
index = 0
- zf.file.foreach("file1.txt", " ") {
+ zf.file.foreach("data/file1.txt", " ") {
|l|
- assert_equals(ref[index], l)
+ assert_equal(ref[index], l)
index = index.next
}
- assert_equals(ref.size, index)
+ assert_equal(ref.size, index)
}
end
def test_popen
- assert_equals(File.popen("ls") { |f| f.read },
+ assert_equal(File.popen("ls") { |f| f.read },
@zipFile.file.popen("ls") { |f| f.read })
end
@@ -466,27 +466,27 @@ class ZipFsFileNonmutatingTest < RUNIT::TestCase
# end
def test_readlines
- ZipFile.open("zipWithDir.zip") {
+ ZipFile.open("data/generated/zipWithDir.zip") {
|zf|
- assert_equals(File.readlines("file1.txt"),
- zf.file.readlines("file1.txt"))
+ assert_equal(File.readlines("data/file1.txt"),
+ zf.file.readlines("data/file1.txt"))
}
end
def test_read
- ZipFile.open("zipWithDir.zip") {
+ ZipFile.open("data/generated/zipWithDir.zip") {
|zf|
- assert_equals(File.read("file1.txt"),
- zf.file.read("file1.txt"))
+ assert_equal(File.read("data/file1.txt"),
+ zf.file.read("data/file1.txt"))
}
end
end
-class ZipFsFileStatTest < RUNIT::TestCase
+class ZipFsFileStatTest < Test::Unit::TestCase
def setup
- @zipFile = ZipFile.new("zipWithDirs.zip")
+ @zipFile = ZipFile.new("data/zipWithDirs.zip")
end
def teardown
@@ -494,51 +494,51 @@ class ZipFsFileStatTest < RUNIT::TestCase
end
def test_blocks
- assert_equals(nil, @zipFile.file.stat("file1").blocks)
+ assert_equal(nil, @zipFile.file.stat("file1").blocks)
end
def test_ino
- assert_equals(0, @zipFile.file.stat("file1").ino)
+ assert_equal(0, @zipFile.file.stat("file1").ino)
end
def test_uid
- assert_equals(0, @zipFile.file.stat("file1").uid)
+ assert_equal(0, @zipFile.file.stat("file1").uid)
end
def test_gid
- assert_equals(0, @zipFile.file.stat("file1").gid)
+ assert_equal(0, @zipFile.file.stat("file1").gid)
end
def test_ftype
- assert_equals("file", @zipFile.file.stat("file1").ftype)
- assert_equals("directory", @zipFile.file.stat("dir1").ftype)
+ assert_equal("file", @zipFile.file.stat("file1").ftype)
+ assert_equal("directory", @zipFile.file.stat("dir1").ftype)
end
def test_mode
- assert_equals(0600, @zipFile.file.stat("file1").mode & 0777)
- assert_equals(0600, @zipFile.file.stat("file1").mode & 0777)
- assert_equals(0755, @zipFile.file.stat("dir1").mode & 0777)
- assert_equals(0755, @zipFile.file.stat("dir1").mode & 0777)
+ assert_equal(0600, @zipFile.file.stat("file1").mode & 0777)
+ assert_equal(0600, @zipFile.file.stat("file1").mode & 0777)
+ assert_equal(0755, @zipFile.file.stat("dir1").mode & 0777)
+ assert_equal(0755, @zipFile.file.stat("dir1").mode & 0777)
end
def test_dev
- assert_equals(0, @zipFile.file.stat("file1").dev)
+ assert_equal(0, @zipFile.file.stat("file1").dev)
end
def test_rdev
- assert_equals(0, @zipFile.file.stat("file1").rdev)
+ assert_equal(0, @zipFile.file.stat("file1").rdev)
end
def test_rdev_major
- assert_equals(0, @zipFile.file.stat("file1").rdev_major)
+ assert_equal(0, @zipFile.file.stat("file1").rdev_major)
end
def test_rdev_minor
- assert_equals(0, @zipFile.file.stat("file1").rdev_minor)
+ assert_equal(0, @zipFile.file.stat("file1").rdev_minor)
end
def test_nlink
- assert_equals(1, @zipFile.file.stat("file1").nlink)
+ assert_equal(1, @zipFile.file.stat("file1").nlink)
end
def test_blksize
@@ -547,10 +547,10 @@ class ZipFsFileStatTest < RUNIT::TestCase
end
-class ZipFsFileMutatingTest < RUNIT::TestCase
+class ZipFsFileMutatingTest < Test::Unit::TestCase
TEST_ZIP = "zipWithDirs_copy.zip"
def setup
- File.copy("zipWithDirs.zip", TEST_ZIP)
+ File.copy("data/zipWithDirs.zip", TEST_ZIP)
end
def teardown
@@ -573,7 +573,7 @@ class ZipFsFileMutatingTest < RUNIT::TestCase
blockCalled = true
f.write "This is what I'm writing"
}
- assert_equals("This is what I'm writing",
+ assert_equal("This is what I'm writing",
zf.file.read("test_open_write_entry"))
# Test with existing entry
@@ -582,7 +582,7 @@ class ZipFsFileMutatingTest < RUNIT::TestCase
blockCalled = true
f.write "This is what I'm writing too"
}
- assert_equals("This is what I'm writing too",
+ assert_equal("This is what I'm writing too",
zf.file.read("file1"))
}
end
@@ -590,7 +590,7 @@ class ZipFsFileMutatingTest < RUNIT::TestCase
def test_rename
ZipFile.open(TEST_ZIP) {
|zf|
- assert_exception(Errno::ENOENT, "") {
+ assert_raise(Errno::ENOENT, "") {
zf.file.rename("NoSuchFile", "bimse")
}
zf.file.rename("file1", "newNameForFile1")
@@ -616,9 +616,9 @@ class ZipFsFileMutatingTest < RUNIT::TestCase
assert(! zf.file.exists?("dir1/file11"))
assert(! zf.file.exists?("dir1/file12"))
- assert_exception(Errno::ENOENT) { zf.file.send(symbol, "noSuchFile") }
- assert_exception(Errno::EISDIR) { zf.file.send(symbol, "dir1/dir11") }
- assert_exception(Errno::EISDIR) { zf.file.send(symbol, "dir1/dir11/") }
+ assert_raise(Errno::ENOENT) { zf.file.send(symbol, "noSuchFile") }
+ assert_raise(Errno::EISDIR) { zf.file.send(symbol, "dir1/dir11") }
+ assert_raise(Errno::EISDIR) { zf.file.send(symbol, "dir1/dir11/") }
}
ZipFile.open(TEST_ZIP) {
@@ -634,20 +634,20 @@ class ZipFsFileMutatingTest < RUNIT::TestCase
end
-class ZipFsDirectoryTest < RUNIT::TestCase
+class ZipFsDirectoryTest < Test::Unit::TestCase
TEST_ZIP = "zipWithDirs_copy.zip"
def setup
- File.copy("zipWithDirs.zip", TEST_ZIP)
+ File.copy("data/zipWithDirs.zip", TEST_ZIP)
end
def test_delete
ZipFile.open(TEST_ZIP) {
|zf|
- assert_exception(Errno::ENOENT, "No such file or directory - NoSuchFile.txt") {
+ assert_raise(Errno::ENOENT, "No such file or directory - NoSuchFile.txt") {
zf.dir.delete("NoSuchFile.txt")
}
- assert_exception(Errno::EINVAL, "Invalid argument - file1") {
+ assert_raise(Errno::EINVAL, "Invalid argument - file1") {
zf.dir.delete("file1")
}
assert(zf.file.exists?("dir1"))
@@ -659,10 +659,10 @@ class ZipFsDirectoryTest < RUNIT::TestCase
def test_mkdir
ZipFile.open(TEST_ZIP) {
|zf|
- assert_exception(Errno::EEXIST, "File exists - dir1") {
+ assert_raise(Errno::EEXIST, "File exists - dir1") {
zf.dir.mkdir("file1")
}
- assert_exception(Errno::EEXIST, "File exists - dir1") {
+ assert_raise(Errno::EEXIST, "File exists - dir1") {
zf.dir.mkdir("dir1")
}
assert(!zf.file.exists?("newDir"))
@@ -677,24 +677,24 @@ class ZipFsDirectoryTest < RUNIT::TestCase
def test_pwd_chdir_entries
ZipFile.open(TEST_ZIP) {
|zf|
- assert_equals("/", zf.dir.pwd)
+ assert_equal("/", zf.dir.pwd)
- assert_exception(Errno::ENOENT, "No such file or directory - no such dir") {
+ assert_raise(Errno::ENOENT, "No such file or directory - no such dir") {
zf.dir.chdir "no such dir"
}
- assert_exception(Errno::EINVAL, "Invalid argument - file1") {
+ assert_raise(Errno::EINVAL, "Invalid argument - file1") {
zf.dir.chdir "file1"
}
- assert_equals(["dir1", "dir2", "file1"].sort, zf.dir.entries(".").sort)
+ assert_equal(["dir1", "dir2", "file1"].sort, zf.dir.entries(".").sort)
zf.dir.chdir "dir1"
- assert_equals("/dir1", zf.dir.pwd)
- assert_equals(["dir11", "file11", "file12"], zf.dir.entries(".").sort)
+ assert_equal("/dir1", zf.dir.pwd)
+ assert_equal(["dir11", "file11", "file12"], zf.dir.entries(".").sort)
zf.dir.chdir "../dir2/dir21"
- assert_equals("/dir2/dir21", zf.dir.pwd)
- assert_equals(["dir221"].sort, zf.dir.entries(".").sort)
+ assert_equal("/dir2/dir21", zf.dir.pwd)
+ assert_equal(["dir221"].sort, zf.dir.entries(".").sort)
}
end
@@ -703,30 +703,30 @@ class ZipFsDirectoryTest < RUNIT::TestCase
|zf|
blockCalled = false
- assert_exception(Errno::ENOENT, "No such file or directory - noSuchDir") {
+ assert_raise(Errno::ENOENT, "No such file or directory - noSuchDir") {
zf.dir.foreach("noSuchDir") { |e| blockCalled = true }
}
assert(! blockCalled)
- assert_exception(Errno::ENOTDIR, "Not a directory - file1") {
+ assert_raise(Errno::ENOTDIR, "Not a directory - file1") {
zf.dir.foreach("file1") { |e| blockCalled = true }
}
assert(! blockCalled)
entries = []
zf.dir.foreach(".") { |e| entries << e }
- assert_equals(["dir1", "dir2", "file1"].sort, entries.sort)
+ assert_equal(["dir1", "dir2", "file1"].sort, entries.sort)
entries = []
zf.dir.foreach("dir1") { |e| entries << e }
- assert_equals(["dir11", "file11", "file12"], entries.sort)
+ assert_equal(["dir11", "file11", "file12"], entries.sort)
}
end
def test_chroot
ZipFile.open(TEST_ZIP) {
|zf|
- assert_exception(NotImplementedError) {
+ assert_raise(NotImplementedError) {
zf.dir.chroot
}
}
@@ -742,28 +742,28 @@ class ZipFsDirectoryTest < RUNIT::TestCase
ZipFile.open(TEST_ZIP) {
|zf|
- assert_exception(Errno::ENOTDIR, "Not a directory - file1") {
+ assert_raise(Errno::ENOTDIR, "Not a directory - file1") {
zf.dir.new("file1")
}
- assert_exception(Errno::ENOENT, "No such file or directory - noSuchFile") {
+ assert_raise(Errno::ENOENT, "No such file or directory - noSuchFile") {
zf.dir.new("noSuchFile")
}
d = zf.dir.new(".")
- assert_equals(["file1", "dir1", "dir2"].sort, d.entries.sort)
+ assert_equal(["file1", "dir1", "dir2"].sort, d.entries.sort)
d.close
zf.dir.open("dir1") {
|d|
- assert_equals(["dir11", "file11", "file12"].sort, d.entries.sort)
+ assert_equal(["dir11", "file11", "file12"].sort, d.entries.sort)
}
}
end
end
-class ZipFsDirIteratorTest < RUNIT::TestCase
+class ZipFsDirIteratorTest < Test::Unit::TestCase
FILENAME_ARRAY = [ "f1", "f2", "f3", "f4", "f5", "f6" ]
@@ -773,19 +773,19 @@ class ZipFsDirIteratorTest < RUNIT::TestCase
def test_close
@dirIt.close
- assert_exception(IOError, "closed directory") {
+ assert_raise(IOError, "closed directory") {
@dirIt.each { |e| p e }
}
- assert_exception(IOError, "closed directory") {
+ assert_raise(IOError, "closed directory") {
@dirIt.read
}
- assert_exception(IOError, "closed directory") {
+ assert_raise(IOError, "closed directory") {
@dirIt.rewind
}
- assert_exception(IOError, "closed directory") {
+ assert_raise(IOError, "closed directory") {
@dirIt.seek(0)
}
- assert_exception(IOError, "closed directory") {
+ assert_raise(IOError, "closed directory") {
@dirIt.tell
}
@@ -793,22 +793,22 @@ class ZipFsDirIteratorTest < RUNIT::TestCase
def test_each
# Tested through Enumerable.entries
- assert_equals(FILENAME_ARRAY, @dirIt.entries)
+ assert_equal(FILENAME_ARRAY, @dirIt.entries)
end
def test_read
FILENAME_ARRAY.size.times {
|i|
- assert_equals(FILENAME_ARRAY[i], @dirIt.read)
+ assert_equal(FILENAME_ARRAY[i], @dirIt.read)
}
end
def test_rewind
@dirIt.read
@dirIt.read
- assert_equals(FILENAME_ARRAY[2], @dirIt.read)
+ assert_equal(FILENAME_ARRAY[2], @dirIt.read)
@dirIt.rewind
- assert_equals(FILENAME_ARRAY[0], @dirIt.read)
+ assert_equal(FILENAME_ARRAY[0], @dirIt.read)
end
def test_tell_seek
@@ -818,7 +818,7 @@ class ZipFsDirIteratorTest < RUNIT::TestCase
valAtPos = @dirIt.read
@dirIt.read
@dirIt.seek(pos)
- assert_equals(valAtPos, @dirIt.read)
+ assert_equal(valAtPos, @dirIt.read)
end
end
diff --git a/vendor/rubyzip-0.5.6/test/ziprequiretest.rb b/vendor/rubyzip-0.5.8/test/ziprequiretest.rb
old mode 100755
new mode 100644
similarity index 67%
rename from vendor/rubyzip-0.5.6/test/ziprequiretest.rb
rename to vendor/rubyzip-0.5.8/test/ziprequiretest.rb
index e27c400d..68d2c714
--- a/vendor/rubyzip-0.5.6/test/ziprequiretest.rb
+++ b/vendor/rubyzip-0.5.8/test/ziprequiretest.rb
@@ -2,17 +2,17 @@
$VERBOSE = true
-$: << ".."
+$: << "../lib"
-require 'rubyunit'
+require 'test/unit'
require 'zip/ziprequire'
-$: << 'rubycode.zip' << 'rubycode2.zip'
+$: << 'data/rubycode.zip' << 'data/rubycode2.zip'
-class ZipRequireTest < RUNIT::TestCase
+class ZipRequireTest < Test::Unit::TestCase
def test_require
- assert(require('notzippedruby'))
- assert(!require('notzippedruby'))
+ assert(require('data/notzippedruby'))
+ assert(!require('data/notzippedruby'))
assert(require('zippedruby1'))
assert(!require('zippedruby1'))
@@ -27,13 +27,13 @@ class ZipRequireTest < RUNIT::TestCase
assert(c1.returnTrue)
assert(ZippedRuby1.returnTrue)
assert(!ZippedRuby2.returnFalse)
- assert_equals(4, ZippedRuby3.multiplyValues(2, 2))
+ assert_equal(4, ZippedRuby3.multiplyValues(2, 2))
end
def test_get_resource
get_resource("aResource.txt") {
|f|
- assert_equals("Nothing exciting in this file!", f.read)
+ assert_equal("Nothing exciting in this file!", f.read)
}
end
end
diff --git a/vendor/rubyzip-0.5.6/test/ziptest.rb b/vendor/rubyzip-0.5.8/test/ziptest.rb
old mode 100755
new mode 100644
similarity index 70%
rename from vendor/rubyzip-0.5.6/test/ziptest.rb
rename to vendor/rubyzip-0.5.8/test/ziptest.rb
index d8852006..cd5c7c2b
--- a/vendor/rubyzip-0.5.6/test/ziptest.rb
+++ b/vendor/rubyzip-0.5.8/test/ziptest.rb
@@ -2,15 +2,16 @@
$VERBOSE = true
-$: << ".."
+$: << "../lib"
-require 'rubyunit'
+require 'test/unit'
require 'zip/zip'
+require 'gentestfiles'
include Zip
-class ZipEntryTest < RUNIT::TestCase
+class ZipEntryTest < Test::Unit::TestCase
TEST_ZIPFILE = "someZipFile.zip"
TEST_COMMENT = "a comment"
TEST_COMPRESSED_SIZE = 1234
@@ -31,14 +32,14 @@ class ZipEntryTest < RUNIT::TestCase
TEST_COMPRESSIONMETHOD,
TEST_SIZE)
- assert_equals(TEST_COMMENT, entry.comment)
- assert_equals(TEST_COMPRESSED_SIZE, entry.compressed_size)
- assert_equals(TEST_CRC, entry.crc)
+ assert_equal(TEST_COMMENT, entry.comment)
+ assert_equal(TEST_COMPRESSED_SIZE, entry.compressed_size)
+ assert_equal(TEST_CRC, entry.crc)
assert_instance_of(Zip::ZipExtraField, entry.extra)
- assert_equals(TEST_COMPRESSIONMETHOD, entry.compression_method)
- assert_equals(TEST_NAME, entry.name)
- assert_equals(TEST_SIZE, entry.size)
- assert_equals(TEST_ISDIRECTORY, entry.is_directory)
+ assert_equal(TEST_COMPRESSIONMETHOD, entry.compression_method)
+ assert_equal(TEST_NAME, entry.name)
+ assert_equal(TEST_SIZE, entry.size)
+ assert_equal(TEST_ISDIRECTORY, entry.is_directory)
end
def test_is_directoryAndIsFile
@@ -81,8 +82,8 @@ class ZipEntryTest < RUNIT::TestCase
"something extraXX", 12, 123,
ZipEntry::STORED, 100000)
- assert_equals(entry1, entry1)
- assert_equals(entry1, entry2)
+ assert_equal(entry1, entry1)
+ assert_equal(entry1, entry2)
assert(entry2 != entry3)
assert(entry3 != entry4)
@@ -98,9 +99,9 @@ class ZipEntryTest < RUNIT::TestCase
end
def test_compare
- assert_equals(0, (ZipEntry.new("zf.zip", "a") <=> ZipEntry.new("zf.zip", "a")))
- assert_equals(1, (ZipEntry.new("zf.zip", "b") <=> ZipEntry.new("zf.zip", "a")))
- assert_equals(-1, (ZipEntry.new("zf.zip", "a") <=> ZipEntry.new("zf.zip", "b")))
+ assert_equal(0, (ZipEntry.new("zf.zip", "a") <=> ZipEntry.new("zf.zip", "a")))
+ assert_equal(1, (ZipEntry.new("zf.zip", "b") <=> ZipEntry.new("zf.zip", "a")))
+ assert_equal(-1, (ZipEntry.new("zf.zip", "a") <=> ZipEntry.new("zf.zip", "b")))
entries = [
ZipEntry.new("zf.zip", "5"),
@@ -112,12 +113,12 @@ class ZipEntryTest < RUNIT::TestCase
]
entries.sort!
- assert_equals("0", entries[0].to_s)
- assert_equals("1", entries[1].to_s)
- assert_equals("2", entries[2].to_s)
- assert_equals("3", entries[3].to_s)
- assert_equals("4", entries[4].to_s)
- assert_equals("5", entries[5].to_s)
+ assert_equal("0", entries[0].to_s)
+ assert_equal("1", entries[1].to_s)
+ assert_equal("2", entries[2].to_s)
+ assert_equal("3", entries[3].to_s)
+ assert_equal("4", entries[4].to_s)
+ assert_equal("5", entries[5].to_s)
end
def test_parentAsString
@@ -128,16 +129,16 @@ class ZipEntryTest < RUNIT::TestCase
entry5 = ZipEntry.new("zf.zip", "aa/bb/cc")
entry6 = ZipEntry.new("zf.zip", "aa/bb/cc/")
- assert_equals(nil, entry1.parent_as_string)
- assert_equals(nil, entry2.parent_as_string)
- assert_equals("aa/", entry3.parent_as_string)
- assert_equals("aa/", entry4.parent_as_string)
- assert_equals("aa/bb/", entry5.parent_as_string)
- assert_equals("aa/bb/", entry6.parent_as_string)
+ assert_equal(nil, entry1.parent_as_string)
+ assert_equal(nil, entry2.parent_as_string)
+ assert_equal("aa/", entry3.parent_as_string)
+ assert_equal("aa/", entry4.parent_as_string)
+ assert_equal("aa/bb/", entry5.parent_as_string)
+ assert_equal("aa/bb/", entry6.parent_as_string)
end
def test_entry_name_cannot_start_with_slash
- assert_exception(ZipEntryNameError) { ZipEntry.new("zf.zip", "/hej/der") }
+ assert_raise(ZipEntryNameError) { ZipEntry.new("zf.zip", "/hej/der") }
end
end
@@ -176,7 +177,7 @@ module IOizeString
end
end
-class ZipLocalEntryTest < RUNIT::TestCase
+class ZipLocalEntryTest < Test::Unit::TestCase
def test_read_local_entryHeaderOfFirstTestZipEntry
File.open(TestZipFile::TEST_ZIP3.zip_name, "rb") {
|file|
@@ -197,18 +198,18 @@ class ZipLocalEntryTest < RUNIT::TestCase
end
def test_readDateTime
- File.open("rubycode.zip", "rb") {
+ File.open("data/rubycode.zip", "rb") {
|file|
entry = ZipEntry.read_local_entry(file)
- assert_equals("zippedruby1.rb", entry.name)
- assert_equals(Time.at(1019261638), entry.time)
+ assert_equal("zippedruby1.rb", entry.name)
+ assert_equal(Time.at(1019261638), entry.time)
}
end
def test_read_local_entryFromNonZipFile
- File.open("file2.txt") {
+ File.open("data/file2.txt") {
|file|
- assert_equals(nil, ZipEntry.read_local_entry(file))
+ assert_equal(nil, ZipEntry.read_local_entry(file))
}
end
@@ -234,18 +235,18 @@ class ZipLocalEntryTest < RUNIT::TestCase
private
def compare_local_entry_headers(entry1, entry2)
- assert_equals(entry1.compressed_size , entry2.compressed_size)
- assert_equals(entry1.crc , entry2.crc)
- assert_equals(entry1.extra , entry2.extra)
- assert_equals(entry1.compression_method, entry2.compression_method)
- assert_equals(entry1.name , entry2.name)
- assert_equals(entry1.size , entry2.size)
- assert_equals(entry1.localHeaderOffset, entry2.localHeaderOffset)
+ assert_equal(entry1.compressed_size , entry2.compressed_size)
+ assert_equal(entry1.crc , entry2.crc)
+ assert_equal(entry1.extra , entry2.extra)
+ assert_equal(entry1.compression_method, entry2.compression_method)
+ assert_equal(entry1.name , entry2.name)
+ assert_equal(entry1.size , entry2.size)
+ assert_equal(entry1.localHeaderOffset, entry2.localHeaderOffset)
end
def compare_c_dir_entry_headers(entry1, entry2)
compare_local_entry_headers(entry1, entry2)
- assert_equals(entry1.comment, entry2.comment)
+ assert_equal(entry1.comment, entry2.comment)
end
def write_to_file(localFileName, centralFileName, entry)
@@ -266,7 +267,7 @@ end
module DecompressorTests
# expects @refText, @refLines and @decompressor
- TEST_FILE="file1.txt"
+ TEST_FILE="data/file1.txt"
def setup
@refText=""
@@ -275,15 +276,15 @@ module DecompressorTests
end
def test_readEverything
- assert_equals(@refText, @decompressor.read)
+ assert_equal(@refText, @decompressor.read)
end
def test_readInChunks
chunkSize = 5
while (decompressedChunk = @decompressor.read(chunkSize))
- assert_equals(@refText.slice!(0, chunkSize), decompressedChunk)
+ assert_equal(@refText.slice!(0, chunkSize), decompressedChunk)
end
- assert_equals(0, @refText.size)
+ assert_equal(0, @refText.size)
end
def test_mixingReadsAndProduceInput
@@ -292,20 +293,20 @@ module DecompressorTests
assert(@refLines.length > 40)
- assert_equals(@refText[0...100], @decompressor.read(100))
+ assert_equal(@refText[0...100], @decompressor.read(100))
assert(! @decompressor.input_finished?)
buf = @decompressor.produce_input
- assert_equals(@refText[100...(100+buf.length)], buf)
+ assert_equal(@refText[100...(100+buf.length)], buf)
end
end
-class InflaterTest < RUNIT::TestCase
+class InflaterTest < Test::Unit::TestCase
include DecompressorTests
def setup
super
- @file = File.new("file1.txt.deflatedData", "rb")
+ @file = File.new("data/file1.txt.deflatedData", "rb")
@decompressor = Inflater.new(@file)
end
@@ -315,7 +316,7 @@ class InflaterTest < RUNIT::TestCase
end
-class PassThruDecompressorTest < RUNIT::TestCase
+class PassThruDecompressorTest < Test::Unit::TestCase
include DecompressorTests
def setup
super
@@ -335,7 +336,7 @@ module AssertEntry
end
def assert_entry(filename, zis, entryName)
- assert_equals(filename, entryName)
+ assert_equal(filename, entryName)
assert_entryContentsForStream(filename, zis, entryName)
end
@@ -350,7 +351,7 @@ module AssertEntry
File.open(zipEntryFilename, "wb") { |file| file << actual }
fail("File '#{filename}' is different from '#{zipEntryFilename}'")
else
- assert_equals(expected, actual)
+ assert_equal(expected, actual)
end
end
}
@@ -365,7 +366,7 @@ module AssertEntry
File.open(stringFile, "wb") { |f| f << aString }
fail("File '#{filename}' is different from contents of string stored in '#{stringFile}'")
else
- assert_equals(fileContents, aString)
+ assert_equal(fileContents, aString)
end
end
end
@@ -376,7 +377,7 @@ module AssertEntry
|entryName|
assert_next_entry(entryName, zis)
}
- assert_equals(nil, zis.get_next_entry)
+ assert_equal(nil, zis.get_next_entry)
end
def assert_test_zip_contents(testZipFile)
@@ -396,7 +397,7 @@ end
-class ZipInputStreamTest < RUNIT::TestCase
+class ZipInputStreamTest < Test::Unit::TestCase
include AssertEntry
def test_new
@@ -421,17 +422,17 @@ class ZipInputStreamTest < RUNIT::TestCase
ZipInputStream.open(TestZipFile::TEST_ZIP2.zip_name) {
|zis|
entry = zis.get_next_entry
- assert_equals(TestZipFile::TEST_ZIP2.entry_names[0], entry.name)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names[0], entry.name)
assert zis.gets.length > 0
entry = zis.get_next_entry
- assert_equals(TestZipFile::TEST_ZIP2.entry_names[1], entry.name)
- assert_equals(0, entry.size)
- assert_equals(nil, zis.gets)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names[1], entry.name)
+ assert_equal(0, entry.size)
+ assert_equal(nil, zis.gets)
entry = zis.get_next_entry
- assert_equals(TestZipFile::TEST_ZIP2.entry_names[2], entry.name)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names[2], entry.name)
assert zis.gets.length > 0
entry = zis.get_next_entry
- assert_equals(TestZipFile::TEST_ZIP2.entry_names[3], entry.name)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names[3], entry.name)
assert zis.gets.length > 0
}
end
@@ -440,7 +441,7 @@ class ZipInputStreamTest < RUNIT::TestCase
ZipInputStream.open(TestZipFile::TEST_ZIP2.zip_name) {
|zis|
e = zis.get_next_entry
- assert_equals(TestZipFile::TEST_ZIP2.entry_names[0], e.name)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names[0], e.name)
# Do a little reading
buf = ""
@@ -455,7 +456,7 @@ class ZipInputStreamTest < RUNIT::TestCase
buf2 << (zis.gets || "")
buf2 << (zis.gets || "")
- assert_equals(buf, buf2)
+ assert_equal(buf, buf2)
zis.rewind
@@ -465,145 +466,6 @@ class ZipInputStreamTest < RUNIT::TestCase
end
-class TestFiles
- RANDOM_ASCII_FILE1 = "randomAscii1.txt"
- RANDOM_ASCII_FILE2 = "randomAscii2.txt"
- RANDOM_ASCII_FILE3 = "randomAscii3.txt"
- RANDOM_BINARY_FILE1 = "randomBinary1.bin"
- RANDOM_BINARY_FILE2 = "randomBinary2.bin"
-
- EMPTY_TEST_DIR = "emptytestdir"
-
- ASCII_TEST_FILES = [ RANDOM_ASCII_FILE1, RANDOM_ASCII_FILE2, RANDOM_ASCII_FILE3 ]
- BINARY_TEST_FILES = [ RANDOM_BINARY_FILE1, RANDOM_BINARY_FILE2 ]
- TEST_DIRECTORIES = [ EMPTY_TEST_DIR ]
- TEST_FILES = [ ASCII_TEST_FILES, BINARY_TEST_FILES, EMPTY_TEST_DIR ].flatten!
-
- def TestFiles.create_test_files(recreate)
- if (recreate ||
- ! (TEST_FILES.inject(true) { |accum, element| accum && File.exists?(element) }))
-
- ASCII_TEST_FILES.each_with_index {
- |filename, index|
- create_random_ascii(filename, 1E4 * (index+1))
- }
-
- BINARY_TEST_FILES.each_with_index {
- |filename, index|
- create_random_binary(filename, 1E4 * (index+1))
- }
-
- ensure_dir(EMPTY_TEST_DIR)
- end
- end
-
- private
- def TestFiles.create_random_ascii(filename, size)
- File.open(filename, "wb") {
- |file|
- while (file.tell < size)
- file << rand
- end
- }
- end
-
- def TestFiles.create_random_binary(filename, size)
- File.open(filename, "wb") {
- |file|
- while (file.tell < size)
- file << [rand].pack("V")
- end
- }
- end
-
- def TestFiles.ensure_dir(name)
- if File.exists?(name)
- return if File.stat(name).directory?
- File.delete(name)
- end
- Dir.mkdir(name)
- end
-
-end
-
-# For representation and creation of
-# test data
-class TestZipFile
- attr_accessor :zip_name, :entry_names, :comment
-
- def initialize(zip_name, entry_names, comment = "")
- @zip_name=zip_name
- @entry_names=entry_names
- @comment = comment
- end
-
- def TestZipFile.create_test_zips(recreate)
- files = Dir.entries(".")
- if (recreate ||
- ! (files.index(TEST_ZIP1.zip_name) &&
- files.index(TEST_ZIP2.zip_name) &&
- files.index(TEST_ZIP3.zip_name) &&
- files.index(TEST_ZIP4.zip_name) &&
- files.index("empty.txt") &&
- files.index("short.txt") &&
- files.index("longAscii.txt") &&
- files.index("longBinary.bin") ))
- raise "failed to create test zip '#{TEST_ZIP1.zip_name}'" unless
- system("zip #{TEST_ZIP1.zip_name} file2.txt")
- raise "failed to remove entry from '#{TEST_ZIP1.zip_name}'" unless
- system("zip #{TEST_ZIP1.zip_name} -d file2.txt")
-
- File.open("empty.txt", "w") {}
-
- File.open("short.txt", "w") { |file| file << "ABCDEF" }
- ziptestTxt=""
- File.open("file2.txt") { |file| ziptestTxt=file.read }
- File.open("longAscii.txt", "w") {
- |file|
- while (file.tell < 1E5)
- file << ziptestTxt
- end
- }
-
- testBinaryPattern=""
- File.open("empty.zip") { |file| testBinaryPattern=file.read }
- testBinaryPattern *= 4
-
- File.open("longBinary.bin", "wb") {
- |file|
- while (file.tell < 3E5)
- file << testBinaryPattern << rand
- end
- }
- raise "failed to create test zip '#{TEST_ZIP2.zip_name}'" unless
- system("zip #{TEST_ZIP2.zip_name} #{TEST_ZIP2.entry_names.join(' ')}")
-
- # without bash system interprets everything after echo as parameters to
- # echo including | zip -z ...
- raise "failed to add comment to test zip '#{TEST_ZIP2.zip_name}'" unless
- system("bash -c \"echo #{TEST_ZIP2.comment} | zip -z #{TEST_ZIP2.zip_name}\"")
-
- raise "failed to create test zip '#{TEST_ZIP3.zip_name}'" unless
- system("zip #{TEST_ZIP3.zip_name} #{TEST_ZIP3.entry_names.join(' ')}")
-
- raise "failed to create test zip '#{TEST_ZIP4.zip_name}'" unless
- system("zip #{TEST_ZIP4.zip_name} #{TEST_ZIP4.entry_names.join(' ')}")
- end
- rescue
- raise $!.to_s +
- "\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" +
- "to create test data. If you don't have it you can download\n" +
- "the necessary test files at http://sf.net/projects/rubyzip."
- end
-
- TEST_ZIP1 = TestZipFile.new("empty.zip", [])
- TEST_ZIP2 = TestZipFile.new("4entry.zip", %w{ longAscii.txt empty.txt short.txt longBinary.bin},
- "my zip comment")
- TEST_ZIP3 = TestZipFile.new("test1.zip", %w{ file1.txt })
- TEST_ZIP4 = TestZipFile.new("zipWithDir.zip", [ "file1.txt",
- TestFiles::EMPTY_TEST_DIR])
-end
-
module CrcTest
@@ -628,13 +490,13 @@ module CrcTest
deflater = compressorClass.new(fakeOut)
deflater << str
- assert_equals(0x919920fc, deflater.crc)
+ assert_equal(0x919920fc, deflater.crc)
end
end
-class PassThruCompressorTest < RUNIT::TestCase
+class PassThruCompressorTest < Test::Unit::TestCase
include CrcTest
def test_size
@@ -642,20 +504,20 @@ class PassThruCompressorTest < RUNIT::TestCase
|file|
compressor = PassThruCompressor.new(file)
- assert_equals(0, compressor.size)
+ assert_equal(0, compressor.size)
t1 = "hello world"
t2 = ""
t3 = "bingo"
compressor << t1
- assert_equals(compressor.size, t1.size)
+ assert_equal(compressor.size, t1.size)
compressor << t2
- assert_equals(compressor.size, t1.size + t2.size)
+ assert_equal(compressor.size, t1.size + t2.size)
compressor << t3
- assert_equals(compressor.size, t1.size + t2.size + t3.size)
+ assert_equal(compressor.size, t1.size + t2.size + t3.size)
}
end
@@ -664,14 +526,14 @@ class PassThruCompressorTest < RUNIT::TestCase
end
end
-class DeflaterTest < RUNIT::TestCase
+class DeflaterTest < Test::Unit::TestCase
include CrcTest
def test_outputOperator
- txt = load_file("file2.txt")
+ txt = load_file("data/file2.txt")
deflate(txt, "deflatertest.bin")
inflatedTxt = inflate("deflatertest.bin")
- assert_equals(txt, inflatedTxt)
+ assert_equal(txt, inflatedTxt)
end
private
@@ -686,7 +548,7 @@ class DeflaterTest < RUNIT::TestCase
deflater = Deflater.new(file)
deflater << data
deflater.finish
- assert_equals(deflater.size, data.size)
+ assert_equal(deflater.size, data.size)
file << "trailing data for zlib with -MAX_WBITS"
}
end
@@ -705,7 +567,7 @@ class DeflaterTest < RUNIT::TestCase
end
end
-class ZipOutputStreamTest < RUNIT::TestCase
+class ZipOutputStreamTest < Test::Unit::TestCase
include AssertEntry
TEST_ZIP = TestZipFile::TEST_ZIP2.clone
@@ -747,7 +609,7 @@ class ZipOutputStreamTest < RUNIT::TestCase
end
def assert_i_o_error_in_closed_stream
- assert_exception(IOError) {
+ assert_raise(IOError) {
zos = ZipOutputStream.new("test_putOnClosedStream.zip")
zos.close
yield zos
@@ -778,46 +640,46 @@ module Enumerable
end
-class ZipCentralDirectoryEntryTest < RUNIT::TestCase
+class ZipCentralDirectoryEntryTest < Test::Unit::TestCase
def test_read_from_stream
- File.open("testDirectory.bin", "rb") {
+ File.open("data/testDirectory.bin", "rb") {
|file|
entry = ZipEntry.read_c_dir_entry(file)
- assert_equals("longAscii.txt", entry.name)
- assert_equals(ZipEntry::DEFLATED, entry.compression_method)
- assert_equals(106490, entry.size)
- assert_equals(3784, entry.compressed_size)
- assert_equals(0xfcd1799c, entry.crc)
- assert_equals("", entry.comment)
+ assert_equal("longAscii.txt", entry.name)
+ assert_equal(ZipEntry::DEFLATED, entry.compression_method)
+ assert_equal(106490, entry.size)
+ assert_equal(3784, entry.compressed_size)
+ assert_equal(0xfcd1799c, entry.crc)
+ assert_equal("", entry.comment)
entry = ZipEntry.read_c_dir_entry(file)
- assert_equals("empty.txt", entry.name)
- assert_equals(ZipEntry::STORED, entry.compression_method)
- assert_equals(0, entry.size)
- assert_equals(0, entry.compressed_size)
- assert_equals(0x0, entry.crc)
- assert_equals("", entry.comment)
+ assert_equal("empty.txt", entry.name)
+ assert_equal(ZipEntry::STORED, entry.compression_method)
+ assert_equal(0, entry.size)
+ assert_equal(0, entry.compressed_size)
+ assert_equal(0x0, entry.crc)
+ assert_equal("", entry.comment)
entry = ZipEntry.read_c_dir_entry(file)
- assert_equals("short.txt", entry.name)
- assert_equals(ZipEntry::STORED, entry.compression_method)
- assert_equals(6, entry.size)
- assert_equals(6, entry.compressed_size)
- assert_equals(0xbb76fe69, entry.crc)
- assert_equals("", entry.comment)
+ assert_equal("short.txt", entry.name)
+ assert_equal(ZipEntry::STORED, entry.compression_method)
+ assert_equal(6, entry.size)
+ assert_equal(6, entry.compressed_size)
+ assert_equal(0xbb76fe69, entry.crc)
+ assert_equal("", entry.comment)
entry = ZipEntry.read_c_dir_entry(file)
- assert_equals("longBinary.bin", entry.name)
- assert_equals(ZipEntry::DEFLATED, entry.compression_method)
- assert_equals(1000024, entry.size)
- assert_equals(70847, entry.compressed_size)
- assert_equals(0x10da7d59, entry.crc)
- assert_equals("", entry.comment)
+ assert_equal("longBinary.bin", entry.name)
+ assert_equal(ZipEntry::DEFLATED, entry.compression_method)
+ assert_equal(1000024, entry.size)
+ assert_equal(70847, entry.compressed_size)
+ assert_equal(0x10da7d59, entry.crc)
+ assert_equal("", entry.comment)
entry = ZipEntry.read_c_dir_entry(file)
- assert_equals(nil, entry)
+ assert_equal(nil, entry)
# Fields that are not check by this test:
# version made by 2 bytes
# version needed to extract 2 bytes
@@ -840,7 +702,7 @@ class ZipCentralDirectoryEntryTest < RUNIT::TestCase
def test_ReadEntryFromTruncatedZipFile
fragment=""
- File.open("testDirectory.bin") { |f| fragment = f.read(12) } # cdir entry header is at least 46 bytes
+ File.open("data/testDirectory.bin") { |f| fragment = f.read(12) } # cdir entry header is at least 46 bytes
fragment.extend(IOizeString)
entry = ZipEntry.new
entry.read_c_dir_entry(fragment)
@@ -851,7 +713,7 @@ class ZipCentralDirectoryEntryTest < RUNIT::TestCase
end
-class ZipEntrySetTest < RUNIT::TestCase
+class ZipEntrySetTest < Test::Unit::TestCase
ZIP_ENTRIES = [
ZipEntry.new("zipfile.zip", "name1", "comment1"),
ZipEntry.new("zipfile.zip", "name2", "comment1"),
@@ -871,10 +733,10 @@ class ZipEntrySetTest < RUNIT::TestCase
end
def test_size
- assert_equals(ZIP_ENTRIES.size, @zipEntrySet.size)
- assert_equals(ZIP_ENTRIES.size, @zipEntrySet.length)
+ assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
+ assert_equal(ZIP_ENTRIES.size, @zipEntrySet.length)
@zipEntrySet << ZipEntry.new("a", "b", "c")
- assert_equals(ZIP_ENTRIES.size + 1, @zipEntrySet.length)
+ assert_equal(ZIP_ENTRIES.size + 1, @zipEntrySet.length)
end
def test_add
@@ -888,13 +750,13 @@ class ZipEntrySetTest < RUNIT::TestCase
end
def test_delete
- assert_equals(ZIP_ENTRIES.size, @zipEntrySet.size)
+ assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
entry = @zipEntrySet.delete(ZIP_ENTRIES.first)
- assert_equals(ZIP_ENTRIES.size - 1, @zipEntrySet.size)
- assert_equals(ZIP_ENTRIES.first, entry)
+ assert_equal(ZIP_ENTRIES.size - 1, @zipEntrySet.size)
+ assert_equal(ZIP_ENTRIES.first, entry)
entry = @zipEntrySet.delete(ZIP_ENTRIES.first)
- assert_equals(ZIP_ENTRIES.size - 1, @zipEntrySet.size)
+ assert_equal(ZIP_ENTRIES.size - 1, @zipEntrySet.size)
assert_nil(entry)
end
@@ -906,27 +768,27 @@ class ZipEntrySetTest < RUNIT::TestCase
assert(ZIP_ENTRIES.include?(entry))
count = count.succ
}
- assert_equals(ZIP_ENTRIES.size, count)
+ assert_equal(ZIP_ENTRIES.size, count)
end
def test_entries
- assert_equals(ZIP_ENTRIES.sort, @zipEntrySet.entries.sort)
+ assert_equal(ZIP_ENTRIES.sort, @zipEntrySet.entries.sort)
end
def test_compound
newEntry = ZipEntry.new("zf.zip", "new entry", "new entry's comment")
- assert_equals(ZIP_ENTRIES.size, @zipEntrySet.size)
+ assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
@zipEntrySet << newEntry
- assert_equals(ZIP_ENTRIES.size + 1, @zipEntrySet.size)
+ assert_equal(ZIP_ENTRIES.size + 1, @zipEntrySet.size)
assert(@zipEntrySet.include?(newEntry))
@zipEntrySet.delete(newEntry)
- assert_equals(ZIP_ENTRIES.size, @zipEntrySet.size)
+ assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
end
def test_dup
copy = @zipEntrySet.dup
- assert_equals(@zipEntrySet, copy)
+ assert_equal(@zipEntrySet, copy)
# demonstrate that this is a deep copy
copy.entries[0].name = "a totally different name"
@@ -944,34 +806,34 @@ class ZipEntrySetTest < RUNIT::TestCase
]
entrySet = ZipEntrySet.new(entries)
- assert_equals(nil, entrySet.parent(entries[0]))
- assert_equals(nil, entrySet.parent(entries[1]))
- assert_equals(entries[1], entrySet.parent(entries[2]))
- assert_equals(entries[1], entrySet.parent(entries[3]))
- assert_equals(entries[3], entrySet.parent(entries[4]))
- assert_equals(entries[3], entrySet.parent(entries[5]))
+ assert_equal(nil, entrySet.parent(entries[0]))
+ assert_equal(nil, entrySet.parent(entries[1]))
+ assert_equal(entries[1], entrySet.parent(entries[2]))
+ assert_equal(entries[1], entrySet.parent(entries[3]))
+ assert_equal(entries[3], entrySet.parent(entries[4]))
+ assert_equal(entries[3], entrySet.parent(entries[5]))
end
end
-class ZipCentralDirectoryTest < RUNIT::TestCase
+class ZipCentralDirectoryTest < Test::Unit::TestCase
def test_read_from_stream
File.open(TestZipFile::TEST_ZIP2.zip_name, "rb") {
|zipFile|
cdir = ZipCentralDirectory.read_from_stream(zipFile)
- assert_equals(TestZipFile::TEST_ZIP2.entry_names.size, cdir.size)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names.size, cdir.size)
assert(cdir.entries.sort.compare_enumerables(TestZipFile::TEST_ZIP2.entry_names.sort) {
|cdirEntry, testEntryName|
cdirEntry.name == testEntryName
})
- assert_equals(TestZipFile::TEST_ZIP2.comment, cdir.comment)
+ assert_equal(TestZipFile::TEST_ZIP2.comment, cdir.comment)
}
end
def test_readFromInvalidStream
- File.open("file2.txt", "rb") {
+ File.open("data/file2.txt", "rb") {
|zipFile|
cdir = ZipCentralDirectory.new
cdir.read_from_stream(zipFile)
@@ -982,7 +844,7 @@ class ZipCentralDirectoryTest < RUNIT::TestCase
def test_ReadFromTruncatedZipFile
fragment=""
- File.open("testDirectory.bin") { |f| fragment = f.read }
+ File.open("data/testDirectory.bin") { |f| fragment = f.read }
fragment.slice!(12) # removed part of first cdir entry. eocd structure still complete
fragment.extend(IOizeString)
entry = ZipCentralDirectory.new
@@ -1000,7 +862,7 @@ class ZipCentralDirectoryTest < RUNIT::TestCase
cdirReadback = ZipCentralDirectory.new
File.open("cdirtest.bin", "rb") { |f| cdirReadback.read_from_stream(f) }
- assert_equals(cdir.entries.sort, cdirReadback.entries.sort)
+ assert_equal(cdir.entries.sort, cdirReadback.entries.sort)
end
def test_equality
@@ -1023,8 +885,8 @@ class ZipCentralDirectoryTest < RUNIT::TestCase
"somethingExtra"),
ZipEntry.new("file.zip", "lastEntry.txt") ],
"comment?")
- assert_equals(cdir1, cdir1)
- assert_equals(cdir1, cdir2)
+ assert_equal(cdir1, cdir1)
+ assert_equal(cdir1, cdir2)
assert(cdir1 != cdir3)
assert(cdir2 != cdir3)
@@ -1036,7 +898,7 @@ class ZipCentralDirectoryTest < RUNIT::TestCase
end
-class BasicZipFileTest < RUNIT::TestCase
+class BasicZipFileTest < Test::Unit::TestCase
include AssertEntry
def setup
@@ -1045,7 +907,7 @@ class BasicZipFileTest < RUNIT::TestCase
end
def test_entries
- assert_equals(TestZipFile::TEST_ZIP2.entry_names.sort,
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names.sort,
@zipFile.entries.entries.sort.map {|e| e.name} )
end
@@ -1059,7 +921,7 @@ class BasicZipFileTest < RUNIT::TestCase
visited[entry.name] = nil
count = count.succ
}
- assert_equals(TestZipFile::TEST_ZIP2.entry_names.length, count)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
end
def test_foreach
@@ -1072,7 +934,7 @@ class BasicZipFileTest < RUNIT::TestCase
visited[entry.name] = nil
count = count.succ
}
- assert_equals(TestZipFile::TEST_ZIP2.entry_names.length, count)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
end
def test_get_input_stream
@@ -1085,7 +947,7 @@ class BasicZipFileTest < RUNIT::TestCase
visited[entry.name] = nil
count = count.succ
}
- assert_equals(TestZipFile::TEST_ZIP2.entry_names.length, count)
+ assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
end
def test_get_input_streamBlock
@@ -1099,7 +961,7 @@ class BasicZipFileTest < RUNIT::TestCase
end
end
-class CommonZipFileFixture < RUNIT::TestCase
+module CommonZipFileFixture
include AssertEntry
EMPTY_FILENAME = "emptyZipFile.zip"
@@ -1113,7 +975,8 @@ class CommonZipFileFixture < RUNIT::TestCase
end
end
-class ZipFileTest < CommonZipFileFixture
+class ZipFileTest < Test::Unit::TestCase
+ include CommonZipFileFixture
def test_createFromScratch
comment = "a short comment"
@@ -1125,8 +988,8 @@ class ZipFileTest < CommonZipFileFixture
zf.close
zfRead = ZipFile.new(EMPTY_FILENAME)
- assert_equals(comment, zfRead.comment)
- assert_equals(2, zfRead.entries.length)
+ assert_equal(comment, zfRead.comment)
+ assert_equal(2, zfRead.entries.length)
end
def test_get_output_stream
@@ -1138,28 +1001,28 @@ class ZipFileTest < CommonZipFileFixture
|os|
os.write "Putting stuff in newEntry.txt"
}
- assert_equals(entryCount+1, zf.size)
- assert_equals("Putting stuff in newEntry.txt", zf.read("newEntry.txt"))
+ assert_equal(entryCount+1, zf.size)
+ assert_equal("Putting stuff in newEntry.txt", zf.read("newEntry.txt"))
- zf.get_output_stream(zf.get_entry('empty.txt')) {
+ zf.get_output_stream(zf.get_entry('data/generated/empty.txt')) {
|os|
- os.write "Putting stuff in empty.txt"
+ os.write "Putting stuff in data/generated/empty.txt"
}
- assert_equals(entryCount+1, zf.size)
- assert_equals("Putting stuff in empty.txt", zf.read("empty.txt"))
+ assert_equal(entryCount+1, zf.size)
+ assert_equal("Putting stuff in data/generated/empty.txt", zf.read("data/generated/empty.txt"))
}
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
- assert_equals(entryCount+1, zf.size)
- assert_equals("Putting stuff in newEntry.txt", zf.read("newEntry.txt"))
- assert_equals("Putting stuff in empty.txt", zf.read("empty.txt"))
+ assert_equal(entryCount+1, zf.size)
+ assert_equal("Putting stuff in newEntry.txt", zf.read("newEntry.txt"))
+ assert_equal("Putting stuff in data/generated/empty.txt", zf.read("data/generated/empty.txt"))
}
end
def test_add
- srcFile = "file2.txt"
+ srcFile = "data/file2.txt"
entryName = "newEntryName.rb"
assert(File.exists?(srcFile))
zf = ZipFile.new(EMPTY_FILENAME, ZipFile::CREATE)
@@ -1167,18 +1030,18 @@ class ZipFileTest < CommonZipFileFixture
zf.close
zfRead = ZipFile.new(EMPTY_FILENAME)
- assert_equals("", zfRead.comment)
- assert_equals(1, zfRead.entries.length)
- assert_equals(entryName, zfRead.entries.first.name)
+ assert_equal("", zfRead.comment)
+ assert_equal(1, zfRead.entries.length)
+ assert_equal(entryName, zfRead.entries.first.name)
AssertEntry.assert_contents(srcFile,
zfRead.get_input_stream(entryName) { |zis| zis.read })
end
def test_addExistingEntryName
- assert_exception(ZipEntryExistsError) {
+ assert_raise(ZipEntryExistsError) {
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
- zf.add(zf.entries.first.name, "file2.txt")
+ zf.add(zf.entries.first.name, "data/file2.txt")
}
}
end
@@ -1189,12 +1052,12 @@ class ZipFileTest < CommonZipFileFixture
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
replacedEntry = zf.entries.first.name
- zf.add(replacedEntry, "file2.txt") { gotCalled = true; true }
+ zf.add(replacedEntry, "data/file2.txt") { gotCalled = true; true }
}
assert(gotCalled)
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
- assert_contains(zf, replacedEntry, "file2.txt")
+ assert_contains(zf, replacedEntry, "data/file2.txt")
}
end
@@ -1219,12 +1082,12 @@ class ZipFileTest < CommonZipFileFixture
assert(zf.entries.map { |e| e.name }.include?(entryToRemove))
zf.remove(entryToRemove)
assert(! zf.entries.map { |e| e.name }.include?(entryToRemove))
- assert_equals(zf.entries.map {|x| x.name }.sort, remainingEntries.sort)
+ assert_equal(zf.entries.map {|x| x.name }.sort, remainingEntries.sort)
zf.close
zfRead = ZipFile.new(TEST_ZIP.zip_name)
assert(! zfRead.entries.map { |e| e.name }.include?(entryToRemove))
- assert_equals(zfRead.entries.map {|x| x.name }.sort, remainingEntries.sort)
+ assert_equal(zfRead.entries.map {|x| x.name }.sort, remainingEntries.sort)
zfRead.close
end
@@ -1252,7 +1115,7 @@ class ZipFileTest < CommonZipFileFixture
oldEntries = nil
ZipFile.open(TEST_ZIP.zip_name) { |zf| oldEntries = zf.entries }
- assert_exception(ZipEntryExistsError) {
+ assert_raise(ZipEntryExistsError) {
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
zf.rename(zf.entries[0], zf.entries[1].name)
@@ -1261,7 +1124,7 @@ class ZipFileTest < CommonZipFileFixture
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
- assert_equals(oldEntries.sort.map{ |e| e.name }, zf.entries.sort.map{ |e| e.name })
+ assert_equal(oldEntries.sort.map{ |e| e.name }, zf.entries.sort.map{ |e| e.name })
}
end
@@ -1281,7 +1144,7 @@ class ZipFileTest < CommonZipFileFixture
oldEntries.delete_if { |e| e.name == renamedEntryName }
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
- assert_equals(oldEntries.sort.map{ |e| e.name },
+ assert_equal(oldEntries.sort.map{ |e| e.name },
zf.entries.sort.map{ |e| e.name })
}
end
@@ -1291,7 +1154,7 @@ class ZipFileTest < CommonZipFileFixture
target_entry = "target_entryName"
zf = ZipFile.new(TEST_ZIP.zip_name)
assert(! zf.entries.include?(nonEntry))
- assert_exception(Errno::ENOENT) {
+ assert_raise(Errno::ENOENT) {
zf.rename(nonEntry, target_entry)
}
zf.commit
@@ -1303,7 +1166,7 @@ class ZipFileTest < CommonZipFileFixture
def test_renameEntryToExistingEntry
entry1, entry2, *remaining = TEST_ZIP.entry_names
zf = ZipFile.new(TEST_ZIP.zip_name)
- assert_exception(ZipEntryExistsError) {
+ assert_raise(ZipEntryExistsError) {
zf.rename(entry1, entry2)
}
ensure
@@ -1312,7 +1175,7 @@ class ZipFileTest < CommonZipFileFixture
def test_replace
entryToReplace = TEST_ZIP.entry_names[2]
- newEntrySrcFilename = "file2.txt"
+ newEntrySrcFilename = "data/file2.txt"
zf = ZipFile.new(TEST_ZIP.zip_name)
zf.replace(entryToReplace, newEntrySrcFilename)
@@ -1333,8 +1196,8 @@ class ZipFileTest < CommonZipFileFixture
entryToReplace = "nonExistingEntryname"
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
- assert_exception(Errno::ENOENT) {
- zf.replace(entryToReplace, "file2.txt")
+ assert_raise(Errno::ENOENT) {
+ zf.replace(entryToReplace, "data/file2.txt")
}
}
end
@@ -1370,7 +1233,7 @@ class ZipFileTest < CommonZipFileFixture
# def test_close
# zf = ZipFile.new(TEST_ZIP.zip_name)
# zf.close
-# assert_exception(IOError) {
+# assert_raise(IOError) {
# zf.extract(TEST_ZIP.entry_names.first, "hullubullu")
# }
# end
@@ -1434,7 +1297,7 @@ class ZipFileTest < CommonZipFileFixture
zf.add(filename, filename)
assert_contains(zf, filename)
}
- assert_equals(zf.entries.sort.map { |e| e.name }, TestFiles::ASCII_TEST_FILES)
+ assert_equal(zf.entries.sort.map { |e| e.name }, TestFiles::ASCII_TEST_FILES)
zf.rename(TestFiles::ASCII_TEST_FILES[0], "newName")
assert_not_contains(zf, TestFiles::ASCII_TEST_FILES[0])
@@ -1468,7 +1331,8 @@ class ZipFileTest < CommonZipFileFixture
end
end
-class ZipFileExtractTest < CommonZipFileFixture
+class ZipFileExtractTest < Test::Unit::TestCase
+ include CommonZipFileFixture
EXTRACTED_FILENAME = "extEntry"
ENTRY_TO_EXTRACT, *REMAINING_ENTRIES = TEST_ZIP.entry_names.reverse
@@ -1492,7 +1356,7 @@ class ZipFileExtractTest < CommonZipFileFixture
writtenText = "written text"
File.open(EXTRACTED_FILENAME, "w") { |f| f.write(writtenText) }
- assert_exception(ZipDestinationFileExistsError) {
+ assert_raise(ZipDestinationFileExistsError) {
ZipFile.open(TEST_ZIP.zip_name) {
|zf|
zf.extract(zf.entries.first, EXTRACTED_FILENAME)
@@ -1500,7 +1364,7 @@ class ZipFileExtractTest < CommonZipFileFixture
}
File.open(EXTRACTED_FILENAME, "r") {
|f|
- assert_equals(writtenText, f.read)
+ assert_equal(writtenText, f.read)
}
end
@@ -1528,14 +1392,14 @@ class ZipFileExtractTest < CommonZipFileFixture
def test_extractNonEntry
zf = ZipFile.new(TEST_ZIP.zip_name)
- assert_exception(Errno::ENOENT) { zf.extract("nonExistingEntry", "nonExistingEntry") }
+ assert_raise(Errno::ENOENT) { zf.extract("nonExistingEntry", "nonExistingEntry") }
ensure
zf.close if zf
end
def test_extractNonEntry2
outFile = "outfile"
- assert_exception(Errno::ENOENT) {
+ assert_raise(Errno::ENOENT) {
zf = ZipFile.new(TEST_ZIP.zip_name)
nonEntry = "hotdog-diddelidoo"
assert(! zf.entries.include?(nonEntry))
@@ -1547,7 +1411,8 @@ class ZipFileExtractTest < CommonZipFileFixture
end
-class ZipFileExtractDirectoryTest < CommonZipFileFixture
+class ZipFileExtractDirectoryTest < Test::Unit::TestCase
+ include CommonZipFileFixture
TEST_OUT_NAME = "emptyOutDir"
def open_zip(&aProc)
@@ -1582,7 +1447,7 @@ class ZipFileExtractDirectoryTest < CommonZipFileFixture
def test_extractDirectoryExistsAsFile
File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
- assert_exception(ZipDestinationFileExistsError) { extract_test_dir }
+ assert_raise(ZipDestinationFileExistsError) { extract_test_dir }
end
def test_extractDirectoryExistsAsFileOverwrite
@@ -1591,7 +1456,7 @@ class ZipFileExtractDirectoryTest < CommonZipFileFixture
extract_test_dir {
|entry, destPath|
gotCalled = true
- assert_equals(TEST_OUT_NAME, destPath)
+ assert_equal(TEST_OUT_NAME, destPath)
assert(entry.is_directory)
true
}
@@ -1600,7 +1465,7 @@ class ZipFileExtractDirectoryTest < CommonZipFileFixture
end
end
-class ZipStreamableFileTest < RUNIT::TestCase
+class ZipStreamableFileTest < Test::Unit::TestCase
def test_equality
zipEntry1 = ZipEntry.new("zf.zip", "entryname1", "comment")
zipEntry2 = ZipEntry.new("zf.zip", "entryname2", "comment")
@@ -1610,8 +1475,8 @@ class ZipStreamableFileTest < RUNIT::TestCase
zipStreamableFile3 = ZipStreamableFile.new(zipEntry1, "anotherPath")
zipStreamableFile4 = ZipStreamableFile.new(zipEntry2, "path")
- assert_equals(zipStreamableFile1, zipStreamableFile1)
- assert_equals(zipStreamableFile1, zipStreamableFile2)
+ assert_equal(zipStreamableFile1, zipStreamableFile1)
+ assert_equal(zipStreamableFile1, zipStreamableFile2)
assert(zipStreamableFile1 != zipStreamableFile3)
assert(zipStreamableFile1 != zipStreamableFile4)
assert(zipStreamableFile1 != zipEntry1)
@@ -1619,15 +1484,7 @@ class ZipStreamableFileTest < RUNIT::TestCase
end
end
-END {
- TestFiles::create_test_files(ARGV.index("recreate") != nil ||
- ARGV.index("recreateonly") != nil)
- TestZipFile::create_test_zips(ARGV.index("recreate") != nil ||
- ARGV.index("recreateonly") != nil)
- exit if ARGV.index("recreateonly") != nil
-}
-
-class ZipExtraFieldTest < RUNIT::TestCase
+class ZipExtraFieldTest < Test::Unit::TestCase
def test_new
extra_pure = ZipExtraField.new("")
extra_withstr = ZipExtraField.new("foo")
@@ -1637,11 +1494,11 @@ class ZipExtraFieldTest < RUNIT::TestCase
def test_unknownfield
extra = ZipExtraField.new("foo")
- assert_equals(extra["Unknown"], "foo")
+ assert_equal(extra["Unknown"], "foo")
extra.merge("a")
- assert_equals(extra["Unknown"], "fooa")
+ assert_equal(extra["Unknown"], "fooa")
extra.merge("barbaz")
- assert_equals(extra.to_s, "fooabarbaz")
+ assert_equal(extra.to_s, "fooabarbaz")
end
@@ -1652,17 +1509,17 @@ class ZipExtraFieldTest < RUNIT::TestCase
assert(! extra1.member?("UniversalTime"))
assert(extra2.member?("UniversalTime"))
extra1.merge(str)
- assert_equals(extra1["UniversalTime"].mtime, extra2["UniversalTime"].mtime)
+ assert_equal(extra1["UniversalTime"].mtime, extra2["UniversalTime"].mtime)
end
def test_length
str = "UT\x5\0\x3\250$\r@Ux\0\0Te\0\0testit"
extra = ZipExtraField.new(str)
- assert_equals(extra.local_length, extra.to_local_bin.length)
- assert_equals(extra.c_dir_length, extra.to_c_dir_bin.length)
+ assert_equal(extra.local_length, extra.to_local_bin.length)
+ assert_equal(extra.c_dir_length, extra.to_c_dir_bin.length)
extra.merge("foo")
- assert_equals(extra.local_length, extra.to_local_bin.length)
- assert_equals(extra.c_dir_length, extra.to_c_dir_bin.length)
+ assert_equal(extra.local_length, extra.to_local_bin.length)
+ assert_equal(extra.c_dir_length, extra.to_c_dir_bin.length)
end
@@ -1673,7 +1530,7 @@ class ZipExtraFieldTest < RUNIT::TestCase
s = extra.to_s
extra.merge("foo")
- assert_equals(s.length + 3, extra.to_s.length)
+ assert_equal(s.length + 3, extra.to_s.length)
end
def test_equality
@@ -1681,7 +1538,7 @@ class ZipExtraFieldTest < RUNIT::TestCase
extra1 = ZipExtraField.new(str)
extra2 = ZipExtraField.new(str)
extra3 = ZipExtraField.new(str)
- assert_equals(extra1, extra2)
+ assert_equal(extra1, extra2)
extra2["UniversalTime"].mtime = Time.now
assert(extra1 != extra2)
@@ -1690,7 +1547,7 @@ class ZipExtraFieldTest < RUNIT::TestCase
assert(extra1 != extra3)
extra1.create("IUnix")
- assert_equals(extra1, extra3)
+ assert_equal(extra1, extra3)
end
end