Class: ProcfileUpstartExporter::Destroyer

Inherits:
Object
  • Object
show all
Defined in:
lib/procfile_upstart_exporter/destroyer.rb

Instance Method Summary collapse

Constructor Details

#initialize(procfile_parser = ProcfileUpstartExporter::ProcfileParser.new) ⇒ Destroyer

Returns a new instance of Destroyer.



2
3
4
# File 'lib/procfile_upstart_exporter/destroyer.rb', line 2

def initialize procfile_parser = ProcfileUpstartExporter::ProcfileParser.new
  self.procfile_parser = procfile_parser
end

Instance Method Details

#destroy(application, path, procfile = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/procfile_upstart_exporter/destroyer.rb', line 6

def destroy application, path, procfile = nil
  ProcfileUpstartExporter.logger.debug 'Starting Upstart jobs deletion ' \
                                       "for `#{ application }'"
  if procfile
    destroy_jobs application, path, procfile_parser.parse(procfile)
                                                   .map(&:name)
  else
    destroy_all_jobs application, path
  end
  ProcfileUpstartExporter.logger.debug 'Deleted Upstart jobs for ' \
                                       "`#{ application }'"
end