Module: LegacyFacter::Util::Parser::KeyValuePairOutputFormat

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

Class Method Summary collapse

Class Method Details

.parse(output) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/facter/custom_facts/util/parser.rb', line 96

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