Sha256: 4549bf4de946d9abc310f0f78c4651d8565914ef3b1df43b56a279f8cad430b7
Contents?: true
Size: 1.08 KB
Versions: 7
Compression:
Stored size: 1.08 KB
Contents
require "find" require "excon" require "rubygems/package" module Baleen class Builder def initialize(project, docker_url) @project = project @docker_url = docker_url end def build config = Configuration.instance url = @project.ci[:url] repo = @project.ci[:repo] tmp_dir = File.join(config.dir, "tmp/build") dir = File.join(tmp_dir, repo) output = StringIO.new connection = Docker::Connection.new(@docker_url, {}) FileUtils.mkdir_p(tmp_dir) if File.exists?(dir) Dir::chdir(dir) `git pull` else `git clone #{url} #{dir}` Dir::chdir(dir) end Gem::Package::TarWriter.new(output) do |tar| Find.find("./") do |f| if File::ftype(f) == "directory" tar.mkdir(f, 0640) else tar.add_file(f, 0640) { |tar_file| tar_file.write(File.open(f){|fl| fl.read})} end end end tar = output.tap(&:rewind).string connection.post('/build', {}, :body => tar) end end end
Version data entries
7 entries across 7 versions & 1 rubygems