Module: Facter::Util::Parser::KeyValuePairOutputFormat

Defined in:
lib/facter/util/parser.rb

Class Method Summary collapse

Class Method Details

.parse(output) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/facter/util/parser.rb', line 68

def self.parse(output)
  return {} if output.nil?

  result = {}
  re = /^(.+?)=(.+)$/
  output.each_line do |line|
    if match_data = re.match(line.chomp)
      result[match_data[1]] = match_data[2]
    end
  end
  result
end