class Fourchette::Tarball
Public Instance Methods
filepath(uuid, expiration)
click to toggle source
# File lib/fourchette/tarball.rb, line 10 def filepath(uuid, expiration) "tmp/#{uuid}/#{expiration}.tar.gz" end
url(github_git_url, branch_name, github_repo)
click to toggle source
# File lib/fourchette/tarball.rb, line 5 def url(github_git_url, branch_name, github_repo) filepath = prepare_tarball(github_git_url, branch_name) tarball_to_url(filepath, github_repo) end
Private Instance Methods
clone(github_git_url, branch_name, clone_path)
click to toggle source
# File lib/fourchette/tarball.rb, line 22 def clone(github_git_url, branch_name, clone_path) logger.info 'Cloning repository...' repo = Git.clone(github_git_url, clone_path, recursive: true) repo.checkout(branch_name) end
expiration_timestamp()
click to toggle source
# File lib/fourchette/tarball.rb, line 35 def expiration_timestamp Time.now.to_i + 300 end
prepare_tarball(github_git_url, branch_name)
click to toggle source
# File lib/fourchette/tarball.rb, line 16 def prepare_tarball(github_git_url, branch_name) clone_path = "tmp/#{SecureRandom.uuid}" clone(github_git_url, branch_name, clone_path) tar(clone_path) end
tar(path)
click to toggle source
# File lib/fourchette/tarball.rb, line 28 def tar(path) logger.info 'Preparing tarball...' filepath = "#{path}/#{expiration_timestamp}.tar.gz" system("tar -zcf #{filepath} -C #{path} .") filepath end
tarball_to_url(filepath, github_repo)
click to toggle source
# File lib/fourchette/tarball.rb, line 39 def tarball_to_url(filepath, github_repo) logger.info 'Tarball to URL as a service in progress...' cleaned_path = filepath.gsub('tmp/', '').gsub('.tar.gz', '') "#{ENV['FOURCHETTE_APP_URL']}/#{github_repo}/#{cleaned_path}" end