lib/ro_crate/writer.rb in ro-crate-0.4.11 vs lib/ro_crate/writer.rb in ro-crate-0.4.12
- old
+ new
@@ -14,18 +14,18 @@
#
# @param dir [String] A path for the directory for the crate to be written to. All parent directories will be created.
# @param overwrite [Boolean] Whether or not to overwrite existing files.
def write(dir, overwrite: true)
FileUtils.mkdir_p(dir) # Make any parent directories
- @crate.entries.each do |path, entry|
+ @crate.payload.each do |path, entry|
fullpath = ::File.join(dir, path)
next if !overwrite && ::File.exist?(fullpath)
next if entry.directory?
FileUtils.mkdir_p(::File.dirname(fullpath))
temp = Tempfile.new('ro-crate-temp')
begin
- entry.write(temp)
+ entry.write_to(temp)
temp.close
FileUtils.mv(temp, fullpath)
ensure
temp.unlink
end
@@ -36,12 +36,12 @@
# Write the crate to a zip file.
#
# @param destination [String, ::File] The destination where to write the RO-Crate zip.
def write_zip(destination)
Zip::File.open(destination, Zip::File::CREATE) do |zip|
- @crate.entries.each do |path, entry|
+ @crate.payload.each do |path, entry|
next if entry.directory?
- zip.get_output_stream(path) { |s| entry.write(s) }
+ zip.get_output_stream(path) { |s| entry.write_to(s) }
end
end
end
end
end