Sha256: 41b1265f6966de16496835fe137634b1f982dc47e6102b6a1283abb39dcaa90e
Contents?: true
Size: 1.93 KB
Versions: 5
Compression:
Stored size: 1.93 KB
Contents
module Evrone module CI class Router class ScriptBuilder WebdavCache = Struct.new(:app) do include Helper::Config include Helper::Logger CASHER_URL = "https://raw.github.com/travis-ci/casher/master/bin/casher" CASHER_BIN = "$HOME/.casher/bin/casher" def call(env) if config.webdav_cache_url assign_url_to_env(env) prepare(env) fetch(env) add(env) push(env) end app.call env end private def assign_url_to_env(env) name = [] name << env.build.message.name.dup # convert keys from ["rvm:2.0.0"] to "rvm 2.0.0" name += env.travis.matrix_keys.map{|i| i.split(":").join(" ") } # replace non word chars to ' ' name = name.join("-").gsub(/[^a-z0-9_\-.]/, ' ') name = name.strip().gsub(/ +/, '-').downcase name << ".tgz" env.webdav_cache_url = "#{config.webdav_cache_url}/#{name}" end def prepare(env) cmd = %{ export CASHER_DIR=$HOME/.casher && ( mkdir -p $CASHER_DIR/bin && curl #{CASHER_URL} -s -o #{CASHER_BIN} && chmod +x #{CASHER_BIN} && echo casher successfuly downloaded ) || true }.compact env.init << cmd end def fetch(env) env.init << "#{CASHER_BIN} fetch #{env.webdav_cache_url} || true" end def add(env) env.init << "#{CASHER_BIN} add $HOME/cached || true" env.init << "unset CASHER_DIR" end def push(env) env.after_script << "#{CASHER_BIN} push #{env.webdav_cache_url}" end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems