lib/vx/builder/script/cache.rb in vx-builder-0.0.12 vs lib/vx/builder/script/cache.rb in vx-builder-0.0.13
- old
+ new
@@ -3,19 +3,18 @@
class Script
Cache = Struct.new(:app) do
include Helper::Config
- include Helper::Logger
CASHER_URL = "https://raw2.github.com/dima-exe/casher/master/bin/casher"
CASHER_BIN = "$HOME/.casher/bin/casher"
def call(env)
rs = app.call env
- if env.task.cache_url_prefix
+ if env.task.cache_url_prefix && enabled?(env)
assign_url_to_env(env)
prepare(env)
fetch(env)
add(env)
push(env)
@@ -24,10 +23,15 @@
rs
end
private
+ def enabled?(env)
+ puts env.cached_directories.inspect
+ !env.cached_directories.empty?
+ end
+
def casher_cmd
"test -f #{CASHER_BIN} && #{config.casher_ruby} #{CASHER_BIN}"
end
def assign_url_to_env(env)
@@ -71,10 +75,12 @@
urls = env.cache_fetch_url.join(" ")
env.init << "#{casher_cmd} fetch #{urls} || true"
end
def add(env)
- env.init << "#{casher_cmd} add $HOME/cached || true"
+ env.cached_directories.each do |d|
+ env.init << "#{casher_cmd} add #{d} || true"
+ end
env.init << "unset CASHER_DIR"
end
def push(env)
if env.cache_push_url