File tree 2 files changed +7
-9
lines changed 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 62
62
Copy from [ here] ( https://github.com/rubyzip/rubyzip/blob/05916bf89181e1955118fd3ea059f18acac28cc8/samples/example_recursive.rb )
63
63
64
64
``` ruby
65
- require ' rubygems'
66
65
require ' zip'
66
+
67
67
# This is a simple example which uses rubyzip to
68
68
# recursively generate a zip file from the contents of
69
69
# a specified directory. The directory itself is not
70
70
# included in the archive, rather just its contents.
71
71
#
72
72
# 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()
79
77
class ZipFileGenerator
80
78
# Initialize with the directory to zip and the location of the output archive.
81
79
def initialize (input_dir , output_file )
@@ -117,7 +115,7 @@ class ZipFileGenerator
117
115
118
116
def put_into_archive (disk_file_path , io , zip_file_path )
119
117
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)
121
119
end
122
120
end
123
121
end
Original file line number Diff line number Diff line change 6
6
# included in the archive, rather just its contents.
7
7
#
8
8
# Usage:
9
- # directoryToZip = "/tmp/input"
9
+ # directory_to_zip = "/tmp/input"
10
10
# output_file = "/tmp/out.zip"
11
11
# zf = ZipFileGenerator.new(directory_to_zip, output_file)
12
12
# zf.write()
You can’t perform that action at this time.
0 commit comments