Okay, I solved this on my own. If you are in same boat, here is here how I did it:
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
Dir.chdir directory
Dir.glob("**/*").reject {|fn| File.directory?(fn) }.each do |file|
puts "Adding #{file}"
zipfile.add(file.sub(directory + '/', ''), file)
end
end
This works exactly I want. the limitation here here is that it doesn't handle empty directories. Hopefully, it would help someone.