Module: PodPrebuild::ZipUtils
- Defined in:
- lib/command/helper/zip.rb
Class Method Summary collapse
Class Method Details
.unzip(path, to_dir: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/command/helper/zip.rb', line 18 def self.unzip(path, to_dir: nil) cmd = [] cmd << "unzip -oq" << path cmd << "-d" << to_dir unless to_dir.nil? `#{cmd.join(" ")}` if $? != 0 return false end return true end |
.zip(path, to_dir: nil, name: nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/command/helper/zip.rb', line 3 def self.zip(path, to_dir: nil, name: nil) basename = File.basename(path) toname = name.nil? ? basename : name unless to_dir.nil? FileUtils.mkdir_p(to_dir) end out_path = to_dir.nil? ? "#{toname}.zip" : "#{to_dir}/#{toname}.zip" cmd = [] cmd << "cd" << File.dirname(path) cmd << "&& zip -r --symlinks" << out_path << basename cmd << "&& cd -" `#{cmd.join(" ")}` end |