# File lib/puppet/provider/nameservice/directoryservice.rb, line 138 138: def self.parse_dscl_url_data(dscl_output) 139: # we need to construct a Hash from the dscl -url output to match 140: # that returned by the dscl -plist output for 10.5+ clients. 141: # 142: # Nasty assumptions: 143: # a) no values *end* in a colon ':', only keys 144: # b) if a line ends in a colon and the next line does start with 145: # a space, then the second line is a value of the first. 146: # c) (implied by (b)) keys don't start with spaces. 147: 148: dscl_plist = {} 149: dscl_output.split("\n").inject([]) do |array, line| 150: if line =~ /^\s+/ # it's a value 151: array[-1] << line # add the value to the previous key 152: else 153: array << line 154: end 155: array 156: end.compact 157: 158: dscl_output.each do |line| 159: # This should be a 'normal' entry. key and value on one line. 160: # We split on ': ' to deal with keys/values with a colon in them. 161: split_array = line.split(/:\s+/) 162: key = split_array.first 163: value = CGI::unescape(split_array.last.strip.chomp) 164: # We need to treat GroupMembership separately as it is currently 165: # the only attribute we care about multiple values for, and 166: # the values can never contain spaces (shortnames) 167: # We also make every value an array to be consistent with the 168: # output of dscl -plist under 10.5 169: if key == "GroupMembership" 170: dscl_plist[key] = value.split(/\s/) 171: else 172: dscl_plist[key] = [value] 173: end 174: end 175: dscl_plist 176: end