Class: R10K::Action::Environment::Purge

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/r10k/action/environment.rb

Instance Method Summary collapse

Methods included from Logging

formatter, included, level, level=, #logger, outputter

Constructor Details

#initialize(app, path) ⇒ Purge

Returns a new instance of Purge.

Parameters:

  • app (Object)

    The next application in the middlware stack

  • path (String)

    The directory path to purge



56
57
58
# File 'lib/r10k/action/environment.rb', line 56

def initialize(app, path)
  @app, @path = app, path
end

Instance Method Details

#call(env) ⇒ Object

Parameters:

  • env (Hash)


61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/r10k/action/environment.rb', line 61

def call(env)
  @env = env

  stale_directories = R10K::Deployment.collection.stale(@path)

  stale_directories.each do |dir|
    logger.info "Purging stale environment #{dir.inspect}"
    FileUtils.rm_rf(dir, :secure => true)
  end

  @app.call(@env)
end