Sha256: ae8e799335f130b65a40c090cb9d3c6ba7ed6755efc04ecdd278e0f194c2c027

Contents?: true

Size: 632 Bytes

Versions: 5

Compression:

Stored size: 632 Bytes

Contents

require "foreman"

# A valid Procfile entry is captured by this regex.
# All other lines are ignored.
#
# /^([A-Za-z0-9_]+):\s*(.+)$/
#
# $1 = name
# $2 = command
#
class Foreman::Procfile

  attr_reader :processes

  def initialize(filename)
    @processes = parse_procfile(filename)
  end

  def process_names
    processes.map(&:name)
  end

  def [](name)
    processes.detect { |process| process.name == name }
  end

private

  def parse_procfile(filename)
    File.read(filename).split("\n").map do |line|
      if line =~ /^([A-Za-z0-9_]+):\s*(.+)$/
        Foreman::Process.new($1, $2)
      end
    end.compact
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman-0.27.0 lib/foreman/procfile.rb
foreman-0.26.1 lib/foreman/procfile.rb
foreman-0.26.0 lib/foreman/procfile.rb
foreman-0.25.0 lib/foreman/procfile.rb
foreman-0.24.0 lib/foreman/procfile.rb