RubyZip help needed

  • Thread starter THAKUR PRASHANT SINGH
  • Start date
T

THAKUR PRASHANT SINGH

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 ?

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DClass =
function=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

require 'zip/zip'

class ZipUtils
attr :filename
def initialize(filename)
@filename=3Dfilename
end =20
def createkmzfile
kml_name=3D@filename
puts kml_name
kmz_file =3D kml_name.sub(".kml",".kmz")
=20
File.delete(kmz_file) if File.exists?(kmz_file)
=20
Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) {
|zf|
zf.add(kml_name, "kml/#{kml_name}")
zf.mkdir("images")
imglist=3DDir.glob("images/*.png")
puts imglist=20
for i in 0..imglist.size-1
zf.add(imglist, imglist)
end =20
}
=20
end
end
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3Dexternal =
file=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
require 'zip/zip'

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

=20
end
end


kml_name=3D"LOC_0.kml"
kmz_file =3D kml_name.sub(".kml",".kmz")
puts kml_name
File.delete(kmz_file) if File.exists?(kmz_file)
=20
Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) {
|zf|
zf.add(kml_name, "kml/#{kml_name}")
zf.mkdir("images")
imglist=3DDir.glob("images/*.png")
puts imglist=20
for i in 0..imglist.size-1
zf.add(imglist, imglist)
end
}
 
R

Roger Pack

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Class Function call vs Normal Function call 7
Win32OLE + DRb - Windows = Fun 2
Hash keys 3
Negative nums 1
[ANN] rs 0.1.2 0
awk to ruby 1.9 11
A solution for public-keyed SFTP and Ruby 0
problems with dates? 0

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top