From 66d6076871ea9f1d6a62f9f831540535ccc9b73b Mon Sep 17 00:00:00 2001 From: beyrle Date: Tue, 22 Mar 2016 11:24:28 +0100 Subject: [PATCH 1/2] - revised typo --- samples/example_recursive.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/example_recursive.rb b/samples/example_recursive.rb index d1ea5669..a13661be 100644 --- a/samples/example_recursive.rb +++ b/samples/example_recursive.rb @@ -6,7 +6,7 @@ # included in the archive, rather just its contents. # # Usage: -# directoryToZip = "/tmp/input" +# directory_to_zip = "/tmp/input" # output_file = "/tmp/out.zip" # zf = ZipFileGenerator.new(directory_to_zip, output_file) # zf.write() From 63c0ef078210cc893645139deb978531ccbb0bb4 Mon Sep 17 00:00:00 2001 From: beyrle Date: Tue, 22 Mar 2016 11:25:11 +0100 Subject: [PATCH 2/2] - copied current version of example_recursive.rb to readme (old version was buggy on windows systems) --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 208c2001..0b370844 100644 --- a/README.md +++ b/README.md @@ -62,20 +62,18 @@ end Copy from [here](https://github.com/rubyzip/rubyzip/blob/05916bf89181e1955118fd3ea059f18acac28cc8/samples/example_recursive.rb ) ```ruby -require 'rubygems' require 'zip' + # This is a simple example which uses rubyzip to # recursively generate a zip file from the contents of # a specified directory. The directory itself is not # included in the archive, rather just its contents. # # Usage: -# require /path/to/the/ZipFileGenerator/Class -# directoryToZip = "/tmp/input" -# outputFile = "/tmp/out.zip" -# zf = ZipFileGenerator.new(directoryToZip, outputFile) -# zf.write() - +# directory_to_zip = "/tmp/input" +# output_file = "/tmp/out.zip" +# zf = ZipFileGenerator.new(directory_to_zip, output_file) +# zf.write() class ZipFileGenerator # Initialize with the directory to zip and the location of the output archive. def initialize(input_dir, output_file) @@ -117,7 +115,7 @@ class ZipFileGenerator def put_into_archive(disk_file_path, io, zip_file_path) io.get_output_stream(zip_file_path) do |f| - f.puts(File.open(disk_file_path, 'rb').read) + f.write(File.open(disk_file_path, 'rb').read) end end end