You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2017/06/19 12:25:36 UTC

[whimsy] branch master updated: Return array rather than requiring block

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 722d37c  Return array rather than requiring block
722d37c is described below

commit 722d37c95a5cc3f74ef04e4cdc6bd40431e088ea
Author: Sebb <se...@apache.org>
AuthorDate: Mon Jun 19 13:25:34 2017 +0100

    Return array rather than requiring block
    
    Update Group and Committee: add usesproject? method
---
 lib/whimsy/asf/auth.rb | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/lib/whimsy/asf/auth.rb b/lib/whimsy/asf/auth.rb
index b1d8868..5ca13ae 100644
--- a/lib/whimsy/asf/auth.rb
+++ b/lib/whimsy/asf/auth.rb
@@ -19,19 +19,19 @@ module ASF
     # Iteratively return each non_LDAP entry in the authorization file as a pair
     # of values: a name and list of ids.
     def each
-      read_auth.
-        scan(/^([-\w]+)=(\w.*)$/).each do |pmc, ids|
+      read_auth.scan(/^([-\w]+)=(\w.*)$/).each do |pmc, ids|
         yield pmc, ids.split(',')
       end
     end
 
-    # Iteratively return each ou=project entry in the authorization file as the group name
+    # Return an array of the ou=project entries in the authorization file
     def projects
+      arr = []
       #incubator={ldap:cn=incubator,ou=project,ou=groups,dc=apache,dc=org;attr=member}
-      read_auth.
-        scan(/^\w[^=]+={ldap:cn=(\w[^,]+),ou=project,ou=groups/).each do |group|
-        yield group[0]
+      read_auth.scan(/^\w[^=]+={ldap:cn=(\w[^,]+),ou=project,ou=groups/).each do |group|
+        arr << group[0]
       end
+      arr
     end
 
     unless Enumerable.instance_methods.include? :to_h
@@ -64,4 +64,18 @@ module ASF
       @auths ||= ASF::Authorization.find_by_id(name)
     end
   end
+
+  class Group
+    # does this group use ou=project?
+    def usesproject?
+      @usesproject ||= ASF::Authorization.new('asf').projects.include?(name)
+    end
+  end
+
+  class Committee
+    # does this committee use ou=project?
+    def usesproject?
+      @usesproject ||= ASF::Authorization.new('pit').projects.include?(name)
+    end
+  end
 end

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