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