Forum: Ruby error while zipping with rubyzip

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ccd9be37f5bd322e9d3968f767328928?d=identicon&s=25 Sebastjan H. (sebastjan_h)
on 2014-07-22 14:43

I need help with the error I get when zipping a folder.

Background info:

I'm expanding a computer aided translation tool I've build in Ruby. The
expansion will support file selection and extraction of the text for
translation (the current version only supports one string translation).

I'm currently working on the parser functionality to get the text for
translation from a file. I've started with libre office writer file

Process flow:

1. Change the file extension from »odt« to »zip« (since libre office
file type is basically zipped content).
2. Unzip the zip file.
3. Parse the content.xml file.
4. Translation and replacing the xml content.
5. Zip the folder.
6. Change the file extension from »zip« to »odt«.

Later on I'd like to expand this to other LO file types as well MS
Office file types (at least the new .docx and alike).

However I'm having problems with 5th step. I'm using rubyzip for
unzipping and zipping and I've tried as stated in the instructions:
require 'zip'

directory = '/Users/me/Desktop/directory_to_zip/'
zipfile_name = '/Users/me/Desktop/', Zip::File::CREATE) do |zipfile|
    Dir[File.join(directory, '**', '**')].each do |file|
      zipfile.add(file.sub(directory, ''), file)

This gives me the following error:
`check_name': Illegal ZipEntry name '/Configurations2', name must not
start with / (Zip::EntryNameError)

There is also a problem if I manually zip the folder via system archive
manager (on linux mint). LibreOffice reports an error even without any
changes to the content.xml.

Nevertheless I'd like to give it a try with rubyzip and see what

Can anyone tell me what would a possible solution for the above error
be, or is there another way to get the folder zipped?

This topic is locked and can not be replied to.