# File lib/net/ldap/dataset.rb, line 39
39:   def Dataset::read_ldif io
40:     ds = Dataset.new
41: 
42:     line = io.gets && chomp
43:     dn = nil
44: 
45:     while line
46:       io.gets and chomp
47:       if $_ =~ /^[\s]+/
48:         line << " " << $'
49:       else
50:         nextline = $_
51: 
52:         if line =~ /^\#/
53:           ds.comments << line
54:         elsif line =~ /^dn:[\s]*/i
55:           dn = $'
56:           ds[dn] = Hash.new {|k,v| k[v] = []}
57:         elsif line.length == 0
58:           dn = nil
59:         elsif line =~ /^([^:]+):([\:]?)[\s]*/
60:           # $1 is the attribute name
61:           # $2 is a colon iff the attr-value is base-64 encoded
62:           # $' is the attr-value
63:           # Avoid the Base64 class because not all Ruby versions have it.
64:           attrvalue = ($2 == ":") ? $'.unpack('m').shift : $'
65:           ds[dn][$1.downcase.intern] << attrvalue
66:         end
67: 
68:         line = nextline
69:       end
70:     end
71:   
72:     ds
73:   end