From d055cbc8caa215301bbc81ce551571c82594d7ae Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Sat, 6 Oct 2007 13:24:01 +0100 Subject: Make it apparent that absent fields in a record have a value of :absent, which is different from what appears in a line. --- test/util/fileparsing.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/util/fileparsing.rb b/test/util/fileparsing.rb index 127dbe1d1..e1a5d39b5 100755 --- a/test/util/fileparsing.rb +++ b/test/util/fileparsing.rb @@ -456,12 +456,21 @@ billy three four\n" :separator => " " # A single space end - ["a b c d", "a b * d", "a b * *", "a b c *"].each do |line| + { "a b c d" => [], + "a b * d" => [:three], + "a b * *" => [:three, :four], + "a b c *" => [:four] + }.each do |line, absentees| record = nil assert_nothing_raised do record = @parser.parse_line(line) end + # Absent field is :absent, not "*" inside the record + absentees.each do |absentee| + assert_equal(:absent, record[absentee]) + end + # Now regenerate the line newline = nil assert_nothing_raised do -- cgit From 5c32c8e8382d800968225734d06663c1a75d80b2 Mon Sep 17 00:00:00 2001 From: Marcin Owsiany Date: Sat, 6 Oct 2007 13:29:17 +0100 Subject: Somewhat better documentation of the :absent field feature in fileparsing. --- lib/puppet/util/fileparsing.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index 7552e8141..8e39719c8 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -268,7 +268,9 @@ module Puppet::Util::FileParsing # Define a new type of record. These lines get split into hashes. Valid # options are: - # * :absent: What to use when a field is absent. Defaults to "". + # * :absent: What to use as value within a line, when a field is + # absent. Note that in the record object, the literal :absent symbol is + # used, and not this value. Defaults to "". # * :fields: The list of fields, as an array. By default, all # fields are considered required. # * :joiner: How to join fields together. Defaults to '\t'. -- cgit