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
Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP
Constants included from Purgeable
Purgeable::FN_MATCH_OPTS, Purgeable::HIDDEN_FILE
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_directories ⇒ Array
private
Return the path of the basedir.
- #purge! ⇒ Object private
Methods included from Logging
add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Methods included from Purgeable
#current_contents, #logger, #matches?, #pending_contents, #potentially_purgeable, #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<#desired_contents>, 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 53 54 |
# File 'lib/r10k/util/basedir.rb', line 50 def desired_contents @sources.flat_map do |src| src.desired_contents.collect { |env| File.join(@path, env) } end end |
#managed_directories ⇒ Array
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_directories [@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.
56 57 58 59 60 61 62 |
# File 'lib/r10k/util/basedir.rb', line 56 def purge! @sources.each do |source| logger.debug1 _("Source %{source_name} in %{path} manages contents %{contents}") % {source_name: source.name, path: @path, contents: source.desired_contents.inspect} end super end |