Method: ALib::Util#zip

Defined in:
lib/alib-0.5.0/util.rb

#zip(path, z_ext = nil) ⇒ Object Also known as: gzip

zip a file - return zipped name



826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
# File 'lib/alib-0.5.0/util.rb', line 826

def zip path, z_ext = nil 
#--{{{
  path = path.to_s 
  z_ext ||= '.gz'
  z_ext.gsub! %r/^\s*\.+/, '.'
  spawn "gzip --suffix #{ z_ext } --force #{ path }"
  zipped = "#{ path }#{ z_ext }"
  raise "could not create <#{ zipped }>" unless test ?e, zipped
  if block_given?
    yield zipped
  else
    zipped
  end
#--}}}
end