[Ultrapossum-cvs 492] projects/yubin/gui 1.2,1.3,yubin.rb

Back to archive index

Masato Taruishi taru****@users*****
2004年 9月 21日 (火) 15:30:30 JST


===================================================================
RCS file: projects/yubin/gui/yubin.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- projects/yubin/gui/yubin.rb	2004/09/21 06:07:02	1.2
+++ projects/yubin/gui/yubin.rb	2004/09/21 06:30:30	1.3
@@ -10,22 +10,50 @@
     @base = base
   end
 
+  def each_entry( io )
+    buf = ""
+    io.each_line do |line|
+      case line
+      when /^$/
+        yield( buf )
+	buf = ""
+      else
+        buf << line
+      end
+    end
+    yield( buf ) if buf != ""
+  end
+
+  def each_attr( entry )
+    buf = ""
+    entry.each_line do |line|
+      case line
+      when /^ (.*)/
+        buf << line
+      else
+        yield( buf.delete(" \n") ) if buf != ""
+	buf = line
+      end
+    end
+    yield( buf.delete(" \n") ) if buf != ""
+  end
+
   def create( filter )
    puts "ldapsearch -LLL -x -h #{@host} -b #{@base} #{filter}" if $DEBUG
    open("|ldapsearch -LLL -x -h #{@host} -b #{@base} #{filter}") { |io|
      postalCode = nil
      postalAddress = nil
-     io.each_line do |line|
-       puts line if $DEBUG
-       case line
-       when /o:: (.*)/
-         postalAddress = Base64::decode64($1)
-       when /postalCode: (.*)/
-         postalCode = $1
-       when /^$/
-         yield( postalCode, postalAddress )
-	 postalCode = postalAddress = nil
+     each_entry(io) do |entry|
+       each_attr(entry) do |attr|
+         case attr
+         when /^o::(.*)$/
+           postalAddress = Base64::decode64($1)
+         when /postalCode:(.*)/
+           postalCode = $1
+         end
        end
+       yield( postalCode, postalAddress )
+       postalCode = postalAddress = nil
      end
      yield( postalCode, postalAddress ) if ! postalCode.nil?
    }



Ultrapossum-cvs メーリングリストの案内
Back to archive index