RubyZip help needed

I am creating zip file using ruby zip there are two versions of creating
the zip file 1st version part of class and in 2nd version running it
alone.
The kmz file created with 1st version doesn’t contain complete text of
LOC_0.kml
Whereas the 2nd version does contain the complete file contents…
I.e. if LOC_0.kml has 100 lines then 1st version kmz file contains only
95 lines while 2nd version contains complete 100 lines.
Can you please suggest what can be the reason ?

====================Class function======================
require ‘zip/zip’

class ZipUtils
attr :filename
def initialize(filename)
@filename=filename
end
def createkmzfile
[email protected]
puts kml_name
kmz_file = kml_name.sub(".kml",".kmz")

File.delete(kmz_file) if File.exists?(kmz_file)

Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) {
  |zf|
  zf.add(kml_name, "kml/#{kml_name}")
  zf.mkdir("images")
  imglist=Dir.glob("images/*.png")
  puts imglist
  for i in 0..imglist.size-1
    zf.add(imglist[i], imglist[i])
  end
}

end
end
==========================external file===========================
require ‘zip/zip’

class ZipUtils
attr :filename
def initialize(filename)
@filename=filename
end
def createkmzfile

end
end

kml_name="LOC_0.kml"
kmz_file = kml_name.sub(".kml",".kmz")
   puts kml_name
File.delete(kmz_file) if File.exists?(kmz_file)

Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) {
  |zf|
  zf.add(kml_name, "kml/#{kml_name}")
  zf.mkdir("images")
  imglist=Dir.glob("images/*.png")
  puts imglist
  for i in 0..imglist.size-1
    zf.add(imglist[i], imglist[i])
  end
}

Whereas the 2nd version does contain the complete file contents…
I.e. if LOC_0.kml has 100 lines then 1st version kmz file contains only
95 lines while 2nd version contains complete 100 lines.
Can you please suggest what can be the reason ?

Did you try different versions of ruby? What platform?
-r

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs