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 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()