Sha256: 9a8bf166676475e9393377ff5c03bc31ff774542305e5194ed5de628a3c66bfe
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
require 'fileutils' module Lono::Utils::Item module Zip def zip(item) if item.directory? zip_directory(item) else zip_file(item) end end def zip_file(item) path = item.output_path zip_file = item.zip_file_name logger.info "Zipping file and generating md5 named file from: #{path}" command = "cd #{File.dirname(path)} && zip -q #{zip_file} #{File.basename(path)}" # create zipfile at same level of file execute_zip(command) end def zip_directory(item) path = item.output_path zip_file = item.zip_file_name logger.info "Zipping folder and generating md5 named file from: #{path}" command = "cd #{path} && zip --symlinks -rq #{zip_file} ." # create zipfile witih directory execute_zip(command) FileUtils.mv("#{path}/#{zip_file}", "#{File.dirname(path)}/#{zip_file}") # move zip back to the parent directory end def execute_zip(command) # logger.info "=> #{command}".color(:green) # uncomment to debug `#{command}` unless $?.success? logger.info "ERROR: Fail to run #{command}".color(:red) logger.info "Maybe zip is not installed or path is incorrect?" exit 1 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lono-8.0.0.pre.rc2 | lib/lono/utils/item/zip.rb |
lono-8.0.0.pre.rc1 | lib/lono/utils/item/zip.rb |