Class: ProcfileUpstartExporter::ProcfileParser

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

Instance Method Summary collapse

Instance Method Details

#parse(procfile) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/procfile_upstart_exporter/procfile_parser.rb', line 2

def parse procfile
  ProcfileUpstartExporter.logger.debug 'Start parsing Procfile ' \
                                       "`#{ procfile }'"
  if File.exists? procfile
    File.read(procfile).split("\n").map do |process_line|
      ProcfileUpstartExporter::Process.new(
        *process_line.scan(/\A([^:]+):(.*)\z/).first.map(&:strip)
      )
    end
  else
    ProcfileUpstartExporter.logger.warn "Procfile file " \
                                        "`#{ procfile }' does not exist"
    []
  end
end