whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] 02/02: refactor
Date Tue, 02 Aug 2016 15:05:50 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

commit bce0bd156e8252891a5b438fe7eb638ce1c0b4c3
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Tue Aug 2 11:05:34 2016 -0400

    refactor
---
 lib/whimsy/asf/ldap.rb | 77 +++++++++-----------------------------------------
 1 file changed, 13 insertions(+), 64 deletions(-)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index fc48b00..ed87740 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -759,13 +759,24 @@ module ASF
     end
 
     def dn
-      "cn=#{id},#{self.class.base}"
+      return @dn if @dn
+      dns = ASF.search_subtree(self.class.base, "cn=#{name}", 'dn')
+      @dn = dns.first.first unless dns.empty?
+      @dn
+    end
+
+    def base
+      if dn
+        dn.sub(/^cn=.*?,/, '')
+      else
+        super
+      end
     end
 
     def self.preload
       Hash[ASF.search_one(base, "cn=*", %w(dn member modifyTimestamp createTimestamp)).map
do |results|
         cn = results['dn'].first[/^cn=(.*?),/, 1]
-        service = ASF::Service.find(cn)
+        service = self.find(cn)
         service.modifyTimestamp = results['modifyTimestamp'].first # it is returned as an
array of 1 entry
         service.createTimestamp = results['createTimestamp'].first # it is returned as an
array of 1 entry
         members = results['member'] || []
@@ -807,72 +818,10 @@ module ASF
 
   class AppGroup < Service
     @base = 'ou=apps,ou=groups,dc=apache,dc=org'
-
-    def dn
-      return @dn if @dn
-      dns = ASF.search_subtree(self.class.base, "cn=#{name}", 'dn')
-      @dn = dns.first.first unless dns.empty?
-      @dn
-    end
-
-    def base
-      if dn
-        dn.sub(/^cn=.*?,/, '')
-      else
-        super
-      end
-    end
-
-    def self.list(filter='cn=*')
-      ASF.search_subtree(base, filter, 'cn').flatten
-    end
-
-    def self.preload
-      Hash[ASF.search_subtree(base, "cn=*", %w(dn member modifyTimestamp createTimestamp)).map
do |results|
-        cn = results['dn'].first[/^cn=(.*?),/, 1]
-        service = ASF::Service.find(cn)
-        service.modifyTimestamp = results['modifyTimestamp'].first # it is returned as an
array of 1 entry
-        service.createTimestamp = results['createTimestamp'].first # it is returned as an
array of 1 entry
-        members = results['member'] || []
-        service.members = members
-        [service, members]
-      end]
-    end
   end
 
   class AuthGroup < Service
     @base = 'ou=auth,ou=groups,dc=apache,dc=org'
-
-    def dn
-      return @dn if @dn
-      dns = ASF.search_subtree(self.class.base, "cn=#{name}", 'dn')
-      @dn = dns.first.first unless dns.empty?
-      @dn
-    end
-
-    def base
-      if dn
-        dn.sub(/^cn=.*?,/, '')
-      else
-        super
-      end
-    end
-
-    def self.list(filter='cn=*')
-      ASF.search_subtree(base, filter, 'cn').flatten
-    end
-
-    def self.preload
-      Hash[ASF.search_subtree(base, "cn=*", %w(dn member modifyTimestamp createTimestamp)).map
do |results|
-        cn = results['dn'].first[/^cn=(.*?),/, 1]
-        service = self.find(cn)
-        service.modifyTimestamp = results['modifyTimestamp'].first # it is returned as an
array of 1 entry
-        service.createTimestamp = results['createTimestamp'].first # it is returned as an
array of 1 entry
-        members = results['member'] || []
-        service.members = members
-        [service, members]
-      end]
-    end
   end
 
 end

-- 
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <commits@whimsical.apache.org>.

Mime
View raw message