class Travis::CLI::Cache
Public Instance Methods
run()
click to toggle source
# File lib/travis/cli/cache.rb, line 12 def run error "not allowed to access caches for #{color(repository.slug, :bold)}" unless repository.push? branches = caches.group_by(&:branch) check_caches warn "Deleted the following caches:\n" if delete? branches.each { |name, list| display_branch(name, list) } size = caches.inject(0) { |s,c| s + c.size } say "Overall size of above caches: " << formatter.file_size(size) end
Private Instance Methods
caches()
click to toggle source
# File lib/travis/cli/cache.rb, line 52 def caches @caches ||= drop? ? repository.delete_caches(params) : repository.caches(params) end
check_caches()
click to toggle source
# File lib/travis/cli/cache.rb, line 25 def check_caches return if caches.any? say "no caches found" exit end
description()
click to toggle source
# File lib/travis/cli/cache.rb, line 68 def description description = color("all caches", :important) description << " on branch #{color(branch, :important)}" if branch? description << " that match #{color(match, :important)}" if match? description end
display_branch(name, list)
click to toggle source
# File lib/travis/cli/cache.rb, line 31 def display_branch(name, list) say color(name ? "On branch #{name}:" : "Global:", :important) list.each { |c| display_cache(c) } puts end
display_cache(cache)
click to toggle source
# File lib/travis/cli/cache.rb, line 37 def display_cache(cache) say [ color(cache.slug.ljust(space), :bold), "last modified: " << formatter.time(cache.last_modified), "size: " << formatter.file_size(cache.size) ].join(" ") << "\n" end
drop?()
click to toggle source
# File lib/travis/cli/cache.rb, line 60 def drop? return false unless delete? return true if force? error "not deleting caches without --force" unless interactive? error "aborted" unless danger_zone? "Do you really want to delete #{description}?" true end
params()
click to toggle source
# File lib/travis/cli/cache.rb, line 45 def params params = {} params[:branch] = branch if branch? params[:match] = match if match? params end
space()
click to toggle source
# File lib/travis/cli/cache.rb, line 56 def space @space ||= caches.map(&:slug).map(&:size).max end