class R10K::Util::Basedir
Represents a directory that can purge unmanaged contents
@todo pick a better name than basedir. Expect this class to be renamed.
@api private
Public Class Methods
from_deployment(path, deployment)
click to toggle source
Create a new Basedir by selecting sources from a deployment that match the specified path.
@param path [String] @param deployment [R10K::Deployment]
@return [R10K::Util::Basedir]
# File lib/r10k/util/basedir.rb, line 25 def self.from_deployment(path, deployment) sources = deployment.sources.select { |source| source.managed_directory == path } new(path, sources) end
new(path, sources)
click to toggle source
@param path [String] The path to the directory to manage @param sources [Array<#desired_contents>] A list of objects that may create filesystem entries
# File lib/r10k/util/basedir.rb, line 32 def initialize(path, sources) if sources.is_a? R10K::Deployment raise ArgumentError, "Expected Array<#desired_contents>, got R10K::Deployment" end @path = path @sources = sources end
Public Instance Methods
desired_contents()
click to toggle source
List all environments that should exist in this basedir @note This implements a required method for the Purgeable mixin @return [Array<String>]
# File lib/r10k/util/basedir.rb, line 50 def desired_contents @sources.map(&:desired_contents).flatten end
managed_directory()
click to toggle source
Return the path of the basedir @note This implements a required method for the Purgeable mixin @return [String]
# File lib/r10k/util/basedir.rb, line 43 def managed_directory @path end
purge!()
click to toggle source
Calls superclass method
R10K::Util::Purgeable#purge!
# File lib/r10k/util/basedir.rb, line 54 def purge! @sources.each do |source| logger.debug1 "Source #{source.name} in #{@path} manages contents #{source.desired_contents.inspect}" end if !stale_contents.empty? logger.debug "The path #{@path} has unmanaged contents #{stale_contents.inspect}" end super end