class ProcfileUpstartExporter::ProcfileParser

Public Instance Methods

parse(procfile) click to toggle source
# 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