commit 78a2065575cea81bf7f3074d04c61bb066755414
Author: Marc Dequenes <duck@Orfeo.duckcorp.org>
Date:   Tue Feb 17 13:54:31 2009 +0100

    [evol] split objects abstraction layer and ldap layer in libs

diff --git a/lib/cyborghood/objects.rb b/lib/cyborghood/objects.rb
new file mode 100644
index 0000000..70aeede
--- /dev/null
+++ b/lib/cyborghood/objects.rb
@@ -0,0 +1,68 @@
+require 'cyborghood/objects/ldap'
+
+class DnsDomain < Delegator
+  attr_reader :ldap, :name
+
+  def initialize(name)
+    @name = name
+    raise "invalid zone name" unless self.is_valid?
+
+    # may not exist (if creating a new one)
+    begin
+      @ldap = LdapDnsDomain.find(name)
+    rescue
+      @ldap = nil
+    end
+  end
+
+  def self.is_valid?(name)
+    name =~ /^[a-z0-9.-]+\.[a-z]{2,4}$/
+  end
+
+  def is_valid?
+    self.class.is_valid?(@name)
+  end
+
+  def hosted?
+    not @ldap.nil?
+  end
+
+  def managed_by?(user)
+    @ldap.managers.include? user.ldap.dn
+  end
+
+  def __getobj__
+    @ldap
+  end
+
+  def self.find_by_manager(user)
+    list = LdapDnsDomain.find(:all, :attribute => 'manager', :value => user.ldap.dn)
+    list.collect do |l_dom|
+      domain = allocate
+      domain.instance_variable_set("@ldap", l_dom)
+    end
+  end
+end
+
+class Person < Delegator
+  attr_reader :ldap
+
+  def self.find_by_fingerprint(fingerprint)
+    list = LdapPerson.find(:all, :attribute => 'keyFingerPrint', :value => fingerprint)
+    case list.size
+    when 0
+      nil
+    when 1
+      person = allocate
+      person.instance_variable_set("@ldap", list.first)
+      person
+    else
+      logger.warn "Multiple users match in database, so i guess there is a mistake. It is safer to skip..."
+      nil
+    end
+  end
+
+  def __getobj__
+    @ldap
+  end
+end
diff --git a/lib/cyborghood/objects/ldap.rb b/lib/cyborghood/objects/ldap.rb
new file mode 100644
index 0000000..5a8d07d
--- /dev/null
+++ b/lib/cyborghood/objects/ldap.rb
@@ -0,0 +1,16 @@
+
+class LdapDnsDomain < ActiveLdap::Base
+  ldap_mapping :dn_attribute => 'cn', :prefix => '', :classes => ['genericDomain']
+
+  def managers
+    list = self.manager
+    return [] if list.nil?
+    return list.collect{|dn| dn.to_s } if list.is_a? Array
+    return [list.to_s]
+  end
+end
+
+class LdapPerson < ActiveLdap::Base
+  ldap_mapping :dn_attribute => 'uid', :prefix => '', :classes => ['person', 'extInetOrgPerson']
+end
+
diff --git a/postman b/postman
index e03f0fc..0b75a37 100755
--- a/postman
+++ b/postman
@@ -16,88 +16,7 @@ require 'gpgme'
 require 'active_ldap'
 require 'shellwords'
 require 'cyborghood/base'
-
-class LdapPerson < ActiveLdap::Base
-  ldap_mapping :dn_attribute => 'uid', :prefix => '', :classes => ['person', 'extInetOrgPerson']
-end
-
-class Person < Delegator
-  attr_reader :ldap
-
-  def self.find_by_fingerprint(fingerprint)
-    list = LdapPerson.find(:all, :attribute => 'keyFingerPrint', :value => fingerprint)
-    case list.size
-    when 0
-      nil
-    when 1
-      person = allocate
-      person.instance_variable_set("@ldap", list.first)
-      person
-    else
-      logger.warn "Multiple users match in database, so i guess there is a mistake. It is safer to skip..."
-      nil
-    end
-  end
-
-  def __getobj__
-    @ldap
-  end
-end
-
-class LdapDnsDomain < ActiveLdap::Base
-  ldap_mapping :dn_attribute => 'cn', :prefix => '', :classes => ['genericDomain']
-
-  def managers
-    list = self.manager
-    return [] if list.nil?
-    return list.collect{|dn| dn.to_s } if list.is_a? Array
-    return [list.to_s]
-  end
-end
-
-class DnsDomain < Delegator
-  attr_reader :ldap, :name
-
-  def initialize(name)
-    @name = name
-    raise "invalid zone name" unless self.is_valid?
-
-    # may not exist (if creating a new one)
-    begin
-      @ldap = LdapDnsDomain.find(name)
-    rescue
-      @ldap = nil
-    end
-  end
-
-  def self.is_valid?(name)
-    name =~ /^[a-z0-9.-]+\.[a-z]{2,4}$/
-  end
-
-  def is_valid?
-    self.class.is_valid?(@name)
-  end
-
-  def hosted?
-    not @ldap.nil?
-  end
-
-  def managed_by?(user)
-    @ldap.managers.include? user.ldap.dn
-  end
-
-  def __getobj__
-    @ldap
-  end
-
-  def self.find_by_manager(user)
-    list = LdapDnsDomain.find(:all, :attribute => 'manager', :value => user.ldap.dn)
-    list.collect do |l_dom|
-      domain = allocate
-      domain.instance_variable_set("@ldap", l_dom)
-    end
-  end
-end
+require 'cyborghood/objects'
 
 #Socket.gethostname
 
