Module: R10K::Util::Purgeable
- Included in:
- Deployment::Basedir, Puppetfile, Source::Git, Source::SVN
- Defined in:
- lib/r10k/util/purgeable.rb
Instance Method Summary collapse
-
#current_contents ⇒ Array<String>
The present directory entries in ‘self.managed_directory`.
-
#desired_contents ⇒ Array<String>
abstract
A list of directory contents that should be present.
-
#managed_directory ⇒ String
abstract
The path to the directory to be purged.
-
#pending_contents ⇒ Array<String>
Directory contents that are expected but not present.
-
#purge! ⇒ Object
Forcibly remove all unmanaged content in ‘self.managed_directory`.
-
#stale_contents ⇒ Array<String>
Directory contents that are present but not expected.
Instance Method Details
#current_contents ⇒ Array<String>
Returns The present directory entries in ‘self.managed_directory`.
21 22 23 24 25 26 27 28 |
# File 'lib/r10k/util/purgeable.rb', line 21 def current_contents dir = self.managed_directory glob_exp = File.join(dir, '*') Dir.glob(glob_exp).map do |fname| File.basename fname end end |
#desired_contents ⇒ Array<String>
Including classes must implement this method to list the expected filenames of managed_directory
Returns A list of directory contents that should be present.
|
# File 'lib/r10k/util/purgeable.rb', line 10
|
#managed_directory ⇒ String
Including classes must implement this method to return the path to the directory that can be purged
Returns The path to the directory to be purged.
|
# File 'lib/r10k/util/purgeable.rb', line 15
|
#pending_contents ⇒ Array<String>
Returns Directory contents that are expected but not present.
31 32 33 |
# File 'lib/r10k/util/purgeable.rb', line 31 def pending_contents desired_contents - current_contents end |
#purge! ⇒ Object
Forcibly remove all unmanaged content in ‘self.managed_directory`
41 42 43 44 45 46 |
# File 'lib/r10k/util/purgeable.rb', line 41 def purge! stale_contents.each do |fname| fpath = File.join(self.managed_directory, fname) FileUtils.rm_rf fpath, :secure => true end end |
#stale_contents ⇒ Array<String>
Returns Directory contents that are present but not expected.
36 37 38 |
# File 'lib/r10k/util/purgeable.rb', line 36 def stale_contents current_contents - desired_contents end |