8000 Merge pull request #283 from entwanderer/master · rubyzip/rubyzip@2569a65 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2569a65

Browse files
authored
Merge pull request #283 from entwanderer/master
Fixing outdated/incorrect example code in Readme and some typos
2 parents bf8ffa4 + 63c0ef0 commit 2569a65

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,18 @@ end
6262
Copy from [here](https://github.com/rubyzip/rubyzip/blob/05916bf89181e1955118fd3ea059f18acac28cc8/samples/example_recursive.rb )
6363

6464
```ruby
65-
require 'rubygems'
6665
require 'zip'
66+
6767
# This is a simple example which uses rubyzip to
6868
# recursively generate a zip file from the contents of
6969
# a specified directory. The directory itself is not
7070
# included in the archive, rather just its contents.
7171
#
7272
# Usage:
73-
# require /path/to/the/ZipFileGenerator/Class
74-
# directoryToZip = "/tmp/input"
75-
# outputFile = "/tmp/out.zip"
76-
# zf = ZipFileGenerator.new(directoryToZip, outputFile)
77-
# zf.write()
78-
73+
# directory_to_zip = "/tmp/input"
74+
# output_file = "/tmp/out.zip"
75+
# zf = ZipFileGenerator.new(directory_to_zip, output_file)
76+
# zf.write()
7977
class ZipFileGenerator
8078
# Initialize with the directory to zip and the location of the output archive.
8179
def initialize(input_dir, output_file)
@@ -117,7 +115,7 @@ class ZipFileGenerator
117115

118116
def put_into_archive(disk_file_path, io, zip_file_path)
119117
io.get_output_stream(zip_file_path) do |f|
120-
f.puts(File.open(disk_file_path, 'rb').read)
118+
f.write(File.open(disk_file_path, 'rb').read)
121119
end
122120
end
123121
end

samples/example_recursive.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# included in the archive, rather just its contents.
77
#
88
# Usage:
9-
# directoryToZip = "/tmp/input"
9+
# directory_to_zip = "/tmp/input"
1010
# output_file = "/tmp/out.zip"
1111
# zf = ZipFileGenerator.new(directory_to_zip, output_file)
1212
# zf.write()

0 commit comments

Comments
 (0)
0