Class: R10K::Util::Basedir Private
- Inherits:
-
Object
- Object
- R10K::Util::Basedir
- Defined in:
- lib/r10k/util/basedir.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
pick a better name than basedir. Expect this class to be renamed.
Represents a directory that can purge unmanaged contents
Constant Summary
Constants included from Logging
Class Method Summary collapse
-
.from_deployment(path, deployment) ⇒ R10K::Util::Basedir
private
Create a new Basedir by selecting sources from a deployment that match the specified path.
Instance Method Summary collapse
-
#desired_contents ⇒ Array<String>
private
List all environments that should exist in this basedir.
-
#initialize(path, sources) ⇒ Basedir
constructor
private
A new instance of Basedir.
-
#managed_directory ⇒ String
private
Return the path of the basedir.
- #purge! ⇒ Object private
Methods included from Logging
formatter, included, level, level=, levels, #logger, #logger_name, outputter, parse_level
Methods included from Purgeable
#current_contents, #logger, #pending_contents, #stale_contents
Constructor Details
#initialize(path, sources) ⇒ Basedir
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Basedir.
32 33 34 35 36 37 38 |
# File 'lib/r10k/util/basedir.rb', line 32 def initialize(path, sources) if sources.is_a? R10K::Deployment raise ArgumentError, "Expected Array<Purgeable>, got R10K::Deployment" end @path = path @sources = sources end |
Class Method Details
.from_deployment(path, deployment) ⇒ R10K::Util::Basedir
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new Basedir by selecting sources from a deployment that match the specified path.
25 26 27 28 |
# 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 |
Instance Method Details
#desired_contents ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This implements a required method for the Purgeable mixin
List all environments that should exist in this basedir
50 51 52 |
# File 'lib/r10k/util/basedir.rb', line 50 def desired_contents @sources.map(&:desired_contents).flatten end |
#managed_directory ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This implements a required method for the Purgeable mixin
Return the path of the basedir
43 44 45 |
# File 'lib/r10k/util/basedir.rb', line 43 def managed_directory @path end |
#purge! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 60 61 62 |
# File 'lib/r10k/util/basedir.rb', line 54 def purge! @sources.each do |source| logger.debug1 "Source #{source.name} in #{@path} claimed contents #{source.desired_contents.inspect}" end if !stale_contents.empty? logger.debug "No sources in #{@path} claimed contents #{stale_contents.inspect}" end super end |