rubyzip 1.1.7 → 1.2.0

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

Potentially problematic release.


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

Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -32
  3. data/Rakefile +3 -4
  4. data/lib/zip.rb +3 -5
  5. data/lib/zip/central_directory.rb +7 -7
  6. data/lib/zip/compressor.rb +0 -0
  7. data/lib/zip/constants.rb +2 -2
  8. data/lib/zip/crypto/null_encryption.rb +3 -3
  9. data/lib/zip/crypto/traditional_encryption.rb +5 -5
  10. data/lib/zip/decompressor.rb +2 -2
  11. data/lib/zip/deflater.rb +8 -6
  12. data/lib/zip/dos_time.rb +4 -5
  13. data/lib/zip/entry.rb +68 -80
  14. data/lib/zip/entry_set.rb +11 -11
  15. data/lib/zip/errors.rb +1 -0
  16. data/lib/zip/extra_field.rb +6 -6
  17. data/lib/zip/extra_field/generic.rb +7 -7
  18. data/lib/zip/extra_field/ntfs.rb +14 -16
  19. data/lib/zip/extra_field/old_unix.rb +9 -10
  20. data/lib/zip/extra_field/universal_time.rb +14 -14
  21. data/lib/zip/extra_field/unix.rb +8 -9
  22. data/lib/zip/extra_field/zip64.rb +12 -11
  23. data/lib/zip/extra_field/zip64_placeholder.rb +1 -1
  24. data/lib/zip/file.rb +45 -49
  25. data/lib/zip/filesystem.rb +132 -135
  26. data/lib/zip/inflater.rb +3 -3
  27. data/lib/zip/input_stream.rb +13 -7
  28. data/lib/zip/ioextras.rb +1 -3
  29. data/lib/zip/ioextras/abstract_input_stream.rb +5 -9
  30. data/lib/zip/ioextras/abstract_output_stream.rb +0 -2
  31. data/lib/zip/null_compressor.rb +2 -2
  32. data/lib/zip/null_decompressor.rb +3 -3
  33. data/lib/zip/null_input_stream.rb +0 -0
  34. data/lib/zip/output_stream.rb +8 -9
  35. data/lib/zip/pass_thru_compressor.rb +4 -4
  36. data/lib/zip/pass_thru_decompressor.rb +2 -3
  37. data/lib/zip/streamable_directory.rb +2 -2
  38. data/lib/zip/streamable_stream.rb +2 -2
  39. data/lib/zip/version.rb +1 -1
  40. data/samples/example.rb +29 -39
  41. data/samples/example_filesystem.rb +16 -18
  42. data/samples/example_recursive.rb +33 -24
  43. data/samples/{gtkRubyzip.rb → gtk_ruby_zip.rb} +23 -25
  44. data/samples/qtzip.rb +17 -26
  45. data/samples/write_simple.rb +12 -13
  46. data/samples/zipfind.rb +24 -32
  47. data/test/basic_zip_file_test.rb +11 -15
  48. data/test/case_sensitivity_test.rb +69 -0
  49. data/test/central_directory_entry_test.rb +31 -35
  50. data/test/central_directory_test.rb +46 -50
  51. data/test/crypto/null_encryption_test.rb +2 -2
  52. data/test/crypto/traditional_encryption_test.rb +5 -5
  53. data/test/data/notzippedruby.rb +1 -1
  54. data/test/data/oddExtraField.zip +0 -0
  55. data/test/data/test.xls +0 -0
  56. data/test/deflater_test.rb +10 -12
  57. data/test/encryption_test.rb +2 -2
  58. data/test/entry_set_test.rb +38 -24
  59. data/test/entry_test.rb +76 -78
  60. data/test/errors_test.rb +0 -2
  61. data/test/extra_field_test.rb +19 -21
  62. data/test/file_extract_directory_test.rb +12 -14
  63. data/test/file_extract_test.rb +33 -40
  64. data/test/file_permissions_test.rb +69 -0
  65. data/test/file_split_test.rb +24 -27
  66. data/test/file_test.rb +174 -170
  67. data/test/filesystem/dir_iterator_test.rb +13 -17
  68. data/test/filesystem/directory_test.rb +80 -90
  69. data/test/filesystem/file_mutating_test.rb +51 -63
  70. data/test/filesystem/file_nonmutating_test.rb +222 -228
  71. data/test/filesystem/file_stat_test.rb +17 -19
  72. data/test/gentestfiles.rb +43 -55
  73. data/test/inflater_test.rb +1 -1
  74. data/test/input_stream_test.rb +42 -30
  75. data/test/ioextras/abstract_input_stream_test.rb +21 -22
  76. data/test/ioextras/abstract_output_stream_test.rb +32 -32
  77. data/test/local_entry_test.rb +35 -37
  78. data/test/output_stream_test.rb +20 -21
  79. data/test/pass_thru_compressor_test.rb +5 -6
  80. data/test/pass_thru_decompressor_test.rb +0 -1
  81. data/test/samples/example_recursive_test.rb +37 -0
  82. data/test/settings_test.rb +18 -15
  83. data/test/test_helper.rb +37 -44
  84. data/test/unicode_file_names_and_comments_test.rb +5 -7
  85. data/test/zip64_full_test.rb +9 -11
  86. data/test/zip64_support_test.rb +0 -1
  87. metadata +14 -32
@@ -20,7 +20,7 @@ module Zip
20
20
  end
21
21
 
22
22
  def produce_input
23
- if (@output_buffer.empty?)
23
+ if @output_buffer.empty?
24
24
  internal_produce_input
25
25
  else
26
26
  @output_buffer.slice!(0...(@output_buffer.length))
@@ -33,8 +33,8 @@ module Zip
33
33
  @output_buffer.empty? && internal_input_finished?
34
34
  end
35
35
 
36
- alias :eof :input_finished?
37
- alias :eof? :input_finished?
36
+ alias :eof input_finished?
37
+ alias :eof? input_finished?
38
38
 
39
39
  private
40
40
 
@@ -86,14 +86,14 @@ module Zip
86
86
  @output_buffer.empty? && @decompressor.eof
87
87
  end
88
88
 
89
- alias :eof? :eof
89
+ alias :eof? eof
90
90
 
91
91
  class << self
92
92
  # Same as #initialize but if a block is passed the opened
93
93
  # stream is passed to the block and closed when the block
94
94
  # returns.
95
95
  def open(filename_or_io, offset = 0, decrypter = nil)
96
- zio = self.new(filename_or_io, offset, decrypter)
96
+ zio = new(filename_or_io, offset, decrypter)
97
97
  return zio unless block_given?
98
98
  begin
99
99
  yield zio
@@ -103,16 +103,15 @@ module Zip
103
103
  end
104
104
 
105
105
  def open_buffer(filename_or_io, offset = 0)
106
- puts "open_buffer is deprecated!!! Use open instead!"
107
- self.open(filename_or_io, offset)
106
+ puts 'open_buffer is deprecated!!! Use open instead!'
107
+ open(filename_or_io, offset)
108
108
  end
109
109
  end
110
110
 
111
111
  protected
112
112
 
113
113
  def get_io(io_or_file, offset = 0)
114
- case io_or_file
115
- when IO, StringIO
114
+ if io_or_file.respond_to?(:seek)
116
115
  io = io_or_file.dup
117
116
  io.seek(offset, ::IO::SEEK_SET)
118
117
  io
@@ -125,9 +124,16 @@ module Zip
125
124
 
126
125
  def open_entry
127
126
  @current_entry = ::Zip::Entry.read_local_entry(@archive_io)
128
- if @current_entry and @current_entry.gp_flags & 1 == 1 and @decrypter.is_a? NullEncrypter
127
+ if @current_entry && @current_entry.gp_flags & 1 == 1 && @decrypter.is_a?(NullEncrypter)
129
128
  raise Error, 'password required to decode zip file'
130
129
  end
130
+ if @current_entry && @current_entry.gp_flags & 8 == 8 && @current_entry.crc == 0 \
131
+ && @current_entry.compressed_size == 0 \
132
+ && @current_entry.size == 0 && !@internal
133
+ raise GPFBit3Error,
134
+ 'General purpose flag Bit 3 is set so not possible to get proper info from local header.' \
135
+ 'Please use ::Zip::File instead of ::Zip::InputStream'
136
+ end
131
137
  @decompressor = get_decompressor
132
138
  flush
133
139
  @current_entry
@@ -1,7 +1,6 @@
1
1
  module Zip
2
2
  module IOExtras #:nodoc:
3
-
4
- CHUNK_SIZE = 131072
3
+ CHUNK_SIZE = 131_072
5
4
 
6
5
  RANGE_ALL = 0..-1
7
6
 
@@ -26,7 +25,6 @@ module Zip
26
25
  object == IO || super
27
26
  end
28
27
  end
29
-
30
28
  end # IOExtras namespace module
31
29
  end
32
30
 
@@ -35,7 +35,7 @@ module Zip
35
35
 
36
36
  if tbuf.nil? || tbuf.length == 0
37
37
  return nil if number_of_bytes
38
- return ""
38
+ return ''
39
39
  end
40
40
 
41
41
  @pos += tbuf.length
@@ -75,15 +75,13 @@ module Zip
75
75
  over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
76
76
  while (match_index = @output_buffer.index(a_sep_string, buffer_index)).nil? && !over_limit
77
77
  buffer_index = [buffer_index, @output_buffer.bytesize - a_sep_string.bytesize].max
78
- if input_finished?
79
- return @output_buffer.empty? ? nil : flush
80
- end
78
+ return @output_buffer.empty? ? nil : flush if input_finished?
81
79
  @output_buffer << produce_input
82
80
  over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
83
81
  end
84
82
  sep_index = [match_index + a_sep_string.bytesize, number_of_bytes || @output_buffer.bytesize].min
85
- @pos += sep_index
86
- return @output_buffer.slice!(0...sep_index)
83
+ @pos += sep_index
84
+ @output_buffer.slice!(0...sep_index)
87
85
  end
88
86
 
89
87
  def ungetc(byte)
@@ -103,9 +101,7 @@ module Zip
103
101
  end
104
102
 
105
103
  def each_line(a_sep_string = $/)
106
- while true
107
- yield readline(a_sep_string)
108
- end
104
+ yield readline(a_sep_string) while true
109
105
  rescue EOFError
110
106
  end
111
107
 
@@ -10,7 +10,6 @@ module Zip
10
10
  data.to_s.bytesize
11
11
  end
12
12
 
13
-
14
13
  def print(*params)
15
14
  self << params.join($,) << $\.to_s
16
15
  end
@@ -39,7 +38,6 @@ module Zip
39
38
  self << "\n" unless val[-1, 1] == "\n"
40
39
  end
41
40
  end
42
-
43
41
  end
44
42
  end
45
43
  end
@@ -2,8 +2,8 @@ module Zip
2
2
  class NullCompressor < Compressor #:nodoc:all
3
3
  include Singleton
4
4
 
5
- def <<(data)
6
- raise IOError, "closed stream"
5
+ def <<(_data)
6
+ raise IOError, 'closed stream'
7
7
  end
8
8
 
9
9
  attr_reader :size, :compressed_size
@@ -1,8 +1,8 @@
1
1
  module Zip
2
2
  module NullDecompressor #:nodoc:all
3
- extend self
3
+ module_function
4
4
 
5
- def sysread(numberOfBytes = nil, buf = nil)
5
+ def sysread(_numberOfBytes = nil, _buf = nil)
6
6
  nil
7
7
  end
8
8
 
@@ -18,7 +18,7 @@ module Zip
18
18
  true
19
19
  end
20
20
 
21
- alias :eof? :eof
21
+ alias eof? eof
22
22
  end
23
23
  end
24
24
 
File without changes
@@ -24,7 +24,7 @@ module Zip
24
24
 
25
25
  # Opens the indicated zip file. If a file with that name already
26
26
  # exists it will be overwritten.
27
- def initialize(file_name, stream=false, encrypter=nil)
27
+ def initialize(file_name, stream = false, encrypter = nil)
28
28
  super()
29
29
  @file_name = file_name
30
30
  @output_stream = if stream
@@ -33,7 +33,7 @@ module Zip
33
33
  iostream.rewind
34
34
  iostream
35
35
  else
36
- ::File.new(@file_name, "wb")
36
+ ::File.new(@file_name, 'wb')
37
37
  end
38
38
  @entry_set = ::Zip::EntrySet.new
39
39
  @compressor = ::Zip::NullCompressor.instance
@@ -86,7 +86,7 @@ module Zip
86
86
  # Closes the current entry and opens a new for writing.
87
87
  # +entry+ can be a ZipEntry object or a string.
88
88
  def put_next_entry(entry_name, comment = nil, extra = nil, compression_method = Entry::DEFLATED, level = Zip.default_compression)
89
- raise Error, "zip stream is closed" if @closed
89
+ raise Error, 'zip stream is closed' if @closed
90
90
  if entry_name.kind_of?(Entry)
91
91
  new_entry = entry_name
92
92
  else
@@ -94,7 +94,7 @@ module Zip
94
94
  end
95
95
  new_entry.comment = comment unless comment.nil?
96
96
  unless extra.nil?
97
- new_entry.extra = ExtraField === extra ? extra : ExtraField.new(extra.to_s)
97
+ new_entry.extra = extra.is_a?(ExtraField) ? extra : ExtraField.new(extra.to_s)
98
98
  end
99
99
  new_entry.compression_method = compression_method unless compression_method.nil?
100
100
  init_next_entry(new_entry, level)
@@ -103,8 +103,8 @@ module Zip
103
103
 
104
104
  def copy_raw_entry(entry)
105
105
  entry = entry.dup
106
- raise Error, "zip stream is closed" if @closed
107
- raise Error, "entry is not a ZipEntry" unless entry.is_a?(Entry)
106
+ raise Error, 'zip stream is closed' if @closed
107
+ raise Error, 'entry is not a ZipEntry' unless entry.is_a?(Entry)
108
108
  finalize_current_entry
109
109
  @entry_set << entry
110
110
  src_pos = entry.local_header_offset
@@ -123,7 +123,6 @@ module Zip
123
123
 
124
124
  def finalize_current_entry
125
125
  return unless @current_entry
126
- @output_stream << @encrypter.header(@current_entry.mtime)
127
126
  finish
128
127
  @current_entry.compressed_size = @output_stream.tell - @current_entry.local_header_offset - @current_entry.calculate_local_header_size
129
128
  @current_entry.size = @compressor.size
@@ -139,6 +138,7 @@ module Zip
139
138
  @entry_set << entry
140
139
  entry.write_local_entry(@output_stream)
141
140
  @encrypter.reset!
141
+ @output_stream << @encrypter.header(entry.mtime)
142
142
  @compressor = get_compressor(entry, level)
143
143
  end
144
144
 
@@ -177,11 +177,10 @@ module Zip
177
177
  public
178
178
 
179
179
  # Modeled after IO.<<
180
- def << (data)
180
+ def <<(data)
181
181
  @compressor << data
182
182
  self
183
183
  end
184
-
185
184
  end
186
185
  end
187
186
 
@@ -3,13 +3,13 @@ module Zip
3
3
  def initialize(outputStream)
4
4
  super()
5
5
  @output_stream = outputStream
6
- @crc = Zlib::crc32
6
+ @crc = Zlib.crc32
7
7
  @size = 0
8
8
  end
9
-
10
- def << (data)
9
+
10
+ def <<(data)
11
11
  val = data.to_s
12
- @crc = Zlib::crc32(val, @crc)
12
+ @crc = Zlib.crc32(val, @crc)
13
13
  @size += val.bytesize
14
14
  @output_stream << val
15
15
  end
@@ -1,6 +1,5 @@
1
1
  module Zip
2
2
  class PassThruDecompressor < Decompressor #:nodoc:all
3
-
4
3
  def initialize(input_stream, chars_to_read)
5
4
  super(input_stream)
6
5
  @chars_to_read = chars_to_read
@@ -31,8 +30,8 @@ module Zip
31
30
  @read_so_far >= @chars_to_read
32
31
  end
33
32
 
34
- alias :eof :input_finished?
35
- alias :eof? :input_finished?
33
+ alias eof input_finished?
34
+ alias eof? input_finished?
36
35
  end
37
36
  end
38
37
 
@@ -4,8 +4,8 @@ module Zip
4
4
  super(zipfile, entry)
5
5
 
6
6
  @ftype = :directory
7
- entry.get_extra_attributes_from_path(srcPath) if (srcPath)
8
- @unix_perms = permissionInt if (permissionInt)
7
+ entry.get_extra_attributes_from_path(srcPath) if srcPath
8
+ @unix_perms = permissionInt if permissionInt
9
9
  end
10
10
  end
11
11
  end
@@ -1,5 +1,5 @@
1
1
  module Zip
2
- class StreamableStream < DelegateClass(Entry) #nodoc:all
2
+ class StreamableStream < DelegateClass(Entry) # nodoc:all
3
3
  def initialize(entry)
4
4
  super(entry)
5
5
  dirname = if zipfile.is_a?(::String)
@@ -24,7 +24,7 @@ module Zip
24
24
  end
25
25
 
26
26
  def get_input_stream
27
- if !@temp_file.closed?
27
+ unless @temp_file.closed?
28
28
  raise StandardError, "cannot open entry for reading while its open for writing - #{name}"
29
29
  end
30
30
  @temp_file.open # reopens tempfile from top
@@ -1,3 +1,3 @@
1
1
  module Zip
2
- VERSION = '1.1.7'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -1,89 +1,79 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << "../lib"
4
- system("zip example.zip example.rb gtkRubyzip.rb")
3
+ $: << '../lib'
4
+ system('zip example.zip example.rb gtk_ruby_zip.rb')
5
5
 
6
6
  require 'zip'
7
7
 
8
8
  ####### Using ZipInputStream alone: #######
9
9
 
10
- Zip::InputStream.open("example.zip") {
11
- |zis|
10
+ Zip::InputStream.open('example.zip') do |zis|
12
11
  entry = zis.get_next_entry
13
12
  print "First line of '#{entry.name} (#{entry.size} bytes): "
14
13
  puts "'#{zis.gets.chomp}'"
15
14
  entry = zis.get_next_entry
16
15
  print "First line of '#{entry.name} (#{entry.size} bytes): "
17
16
  puts "'#{zis.gets.chomp}'"
18
- }
19
-
17
+ end
20
18
 
21
19
  ####### Using ZipFile to read the directory of a zip file: #######
22
20
 
23
- zf = Zip::File.new("example.zip")
24
- zf.each_with_index {
25
- |entry, index|
26
-
21
+ zf = Zip::File.new('example.zip')
22
+ zf.each_with_index do |entry, index|
27
23
  puts "entry #{index} is #{entry.name}, size = #{entry.size}, compressed size = #{entry.compressed_size}"
28
24
  # use zf.get_input_stream(entry) to get a ZipInputStream for the entry
29
25
  # entry can be the ZipEntry object or any object which has a to_s method that
30
26
  # returns the name of the entry.
31
- }
32
-
27
+ end
33
28
 
34
29
  ####### Using ZipOutputStream to write a zip file: #######
35
30
 
36
- Zip::OutputStream.open("exampleout.zip") {
37
- |zos|
38
- zos.put_next_entry("the first little entry")
39
- zos.puts "Hello hello hello hello hello hello hello hello hello"
31
+ Zip::OutputStream.open('exampleout.zip') do |zos|
32
+ zos.put_next_entry('the first little entry')
33
+ zos.puts 'Hello hello hello hello hello hello hello hello hello'
40
34
 
41
- zos.put_next_entry("the second little entry")
42
- zos.puts "Hello again"
35
+ zos.put_next_entry('the second little entry')
36
+ zos.puts 'Hello again'
43
37
 
44
38
  # Use rubyzip or your zip client of choice to verify
45
39
  # the contents of exampleout.zip
46
- }
40
+ end
47
41
 
48
42
  ####### Using ZipFile to change a zip file: #######
49
43
 
50
- Zip::File.open("exampleout.zip") {
51
- |zf|
52
- zf.add("thisFile.rb", "example.rb")
53
- zf.rename("thisFile.rb", "ILikeThisName.rb")
54
- zf.add("Again", "example.rb")
55
- }
44
+ Zip::File.open('exampleout.zip') do |zip_file|
45
+ zip_file.add('thisFile.rb', 'example.rb')
46
+ zip_file.rename('thisFile.rb', 'ILikeThisName.rb')
47
+ zip_file.add('Again', 'example.rb')
48
+ end
56
49
 
57
50
  # Lets check
58
- Zip::File.open("exampleout.zip") {
59
- |zf|
60
- puts "Changed zip file contains: #{zf.entries.join(', ')}"
61
- zf.remove("Again")
62
- puts "Without 'Again': #{zf.entries.join(', ')}"
63
- }
51
+ Zip::File.open('exampleout.zip') do |zip_file|
52
+ puts "Changed zip file contains: #{zip_file.entries.join(', ')}"
53
+ zip_file.remove('Again')
54
+ puts "Without 'Again': #{zip_file.entries.join(', ')}"
55
+ end
64
56
 
65
57
  ####### Using ZipFile to split a zip file: #######
66
58
 
67
59
  # Creating large zip file for splitting
68
- Zip::OutputStream.open("large_zip_file.zip") do |zos|
69
- puts "Creating zip file..."
60
+ Zip::OutputStream.open('large_zip_file.zip') do |zos|
61
+ puts 'Creating zip file...'
70
62
  10.times do |i|
71
63
  zos.put_next_entry("large_entry_#{i}.txt")
72
- zos.puts "Hello" * 104857600
64
+ zos.puts 'Hello' * 104_857_600
73
65
  end
74
66
  end
75
67
 
76
68
  # Splitting created large zip file
77
- part_zips_count = Zip::File.split("large_zip_file.zip", 2097152, false)
69
+ part_zips_count = Zip::File.split('large_zip_file.zip', 2_097_152, false)
78
70
  puts "Zip file splitted in #{part_zips_count} parts"
79
71
 
80
72
  # Track splitting an archive
81
- Zip::File.split("large_zip_file.zip", 1048576, true, 'part_zip_file') do
82
- |part_count, part_index, chunk_bytes, segment_bytes|
83
- puts "#{part_index} of #{part_count} part splitting: #{(chunk_bytes.to_f/segment_bytes.to_f * 100).to_i}%"
73
+ Zip::File.split('large_zip_file.zip', 1_048_576, true, 'part_zip_file') do |part_count, part_index, chunk_bytes, segment_bytes|
74
+ puts "#{part_index} of #{part_count} part splitting: #{(chunk_bytes.to_f / segment_bytes.to_f * 100).to_i}%"
84
75
  end
85
76
 
86
-
87
77
  # For other examples, look at zip.rb and ziptest.rb
88
78
 
89
79
  # Copyright (C) 2002 Thomas Sondergaard
@@ -1,30 +1,28 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << "../lib"
3
+ $: << '../lib'
4
4
 
5
- require 'zip/zipfilesystem'
5
+ require 'zip/filesystem'
6
6
 
7
- EXAMPLE_ZIP = "filesystem.zip"
7
+ EXAMPLE_ZIP = 'filesystem.zip'
8
8
 
9
- File.delete(EXAMPLE_ZIP) if File.exists?(EXAMPLE_ZIP)
9
+ File.delete(EXAMPLE_ZIP) if File.exist?(EXAMPLE_ZIP)
10
10
 
11
- Zip::File.open(EXAMPLE_ZIP, Zip::File::CREATE) {
12
- |zf|
13
- zf.file.open("file1.txt", "w") { |os| os.write "first file1.txt" }
14
- zf.dir.mkdir("dir1")
15
- zf.dir.chdir("dir1")
16
- zf.file.open("file1.txt", "w") { |os| os.write "second file1.txt" }
17
- puts zf.file.read("file1.txt")
18
- puts zf.file.read("../file1.txt")
19
- zf.dir.chdir("..")
20
- zf.file.open("file2.txt", "w") { |os| os.write "first file2.txt" }
11
+ Zip::File.open(EXAMPLE_ZIP, Zip::File::CREATE) do |zf|
12
+ zf.file.open('file1.txt', 'w') { |os| os.write 'first file1.txt' }
13
+ zf.dir.mkdir('dir1')
14
+ zf.dir.chdir('dir1')
15
+ zf.file.open('file1.txt', 'w') { |os| os.write 'second file1.txt' }
16
+ puts zf.file.read('file1.txt')
17
+ puts zf.file.read('../file1.txt')
18
+ zf.dir.chdir('..')
19
+ zf.file.open('file2.txt', 'w') { |os| os.write 'first file2.txt' }
21
20
  puts "Entries: #{zf.entries.join(', ')}"
22
- }
21
+ end
23
22
 
24
- Zip::File.open(EXAMPLE_ZIP) {
25
- |zf|
23
+ Zip::File.open(EXAMPLE_ZIP) do |zf|
26
24
  puts "Entries from reloaded zip: #{zf.entries.join(', ')}"
27
- }
25
+ end
28
26
 
29
27
  # For other examples, look at zip.rb and ziptest.rb
30
28