Created
November 7, 2016 13:28
-
-
Save ys/6b933d2371ba5adcfed4623ade25631d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tar(path) | |
base_path = path.split("/")[0..-2].join("/") | |
folder = path.split("/")[-1] | |
if File.exist?(".gitignore") | |
ok = system("/usr/bin/tar -C \"#{base_path}\" --exclude='.git' --exclude-from=.gitignore -cvzf \"#{tempfile}\" \"#{folder}\"") | |
else | |
ok = system("/usr/bin/tar -C \"#{base_path}\" -cvzf \"#{tempfile}\" \"#{folder}\"") | |
end | |
unless ok | |
raise StandardError, $? | |
end | |
tempfile | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment