Class: Goz::Group::Grouper
- Defined in:
- lib/goz/group/grouper.rb,
lib/goz/group/grouper/stemmed_groups.rb
Overview
:nodoc:
Direct Known Subclasses
Defined Under Namespace
Classes: StemmedGroups
Constant Summary collapse
- TAG =
self.name
Instance Attribute Summary
Attributes inherited from Base
#display_name, #identifier, #klass, #name
Class Method Summary collapse
-
.extension(name) ⇒ Object
TODO.
-
.find_by_name(name) ⇒ Object
Find Goz::Group by name or return
nil
. -
.groups(user) ⇒ Object
Return groups where
user
is an admin. -
.memberships(user) ⇒ Object
Return groups where
user
is a member. -
.stem(name) ⇒ Object
TODO.
-
.stemmed_group?(name) ⇒ Boolean
TODO.
Instance Method Summary collapse
-
#admins ⇒ Object
TODO.
-
#initialize(g) ⇒ Grouper
constructor
A new instance of Grouper.
-
#members ⇒ Object
TODO.
Methods inherited from Base
#[], configuration, #to_hash, #to_s
Constructor Details
#initialize(g) ⇒ Grouper
Returns a new instance of Grouper.
30 31 32 33 34 35 |
# File 'lib/goz/group/grouper.rb', line 30 def initialize(g) @display_name = _prettify_name g['name'] @identifier = g['uuid'] @klass = self.class.name @name = g['name'] end |
Class Method Details
.extension(name) ⇒ Object
TODO
67 68 69 70 |
# File 'lib/goz/group/grouper.rb', line 67 def self.extension(name) m = name.match( /^.+:(.+)$/ ) m ? m[1] : nil end |
.find_by_name(name) ⇒ Object
Find Goz::Group by name or return nil
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/goz/group/grouper.rb', line 41 def self.find_by_name(name) Goz::Logger.debug TAG, "find_by_name( name=#{name} )" connect do |grouper| g = grouper.group(name.rstrip) # TODO Sigh... if g.nil? Goz::Logger.warn TAG, "find_by_name( name=#{name} ) - not found" return nil end group = new g yield group if block_given? return group end nil end |
.groups(user) ⇒ Object
Return groups where user
is an admin.
89 90 91 92 |
# File 'lib/goz/group/grouper.rb', line 89 def self.groups(user) Goz::Logger.debug TAG, "groups( user.login=#{user.login} ) - not implemented" [] end |
.memberships(user) ⇒ Object
Return groups where user
is a member.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/goz/group/grouper.rb', line 97 def self.memberships(user) if user.nil? Goz::Logger.warn TAG, "memberships( user=nil )" return [] end Goz::Logger.debug TAG, "memberships( user.login=#{user.login} )" groups = [] self.connect do |grouper| subject = grouper.subject user.identifier if subject.nil? Goz::Logger.warn TAG, "memberships( user.login=#{user.login} ) - could not find user with identifier=#{ user.identifier }" break end groups = subject.groups( @@cf['base'] ).collect { |g| new g } end groups.each { |g| yield g } if block_given? groups end |
.stem(name) ⇒ Object
TODO
119 120 121 122 |
# File 'lib/goz/group/grouper.rb', line 119 def self.stem(name) m = name.match( /^(.+):.+$/ ) m ? m[1] : nil end |
.stemmed_group?(name) ⇒ Boolean
TODO
127 128 129 130 |
# File 'lib/goz/group/grouper.rb', line 127 def self.stemmed_group?(name) suffixes = @@cf['admin_suffix'] | @@cf['member_suffix'] Regexp.new( "^.*?:(#{ suffixes.join('|') })$" ).match(name) ? true : false end |
Instance Method Details
#admins ⇒ Object
TODO
59 60 61 62 |
# File 'lib/goz/group/grouper.rb', line 59 def admins() Goz::Logger.debug TAG, "name=#{self.name} - #admins() - not implemented" [] # TODO end |
#members ⇒ Object
TODO
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/goz/group/grouper.rb', line 75 def members() Goz::Logger.debug TAG, "#{self.name} - #members()" users = [] Goz::Group::Grouper.connect do |grouper| users = grouper.group(self.name).members.collect { |m| Goz::User.find_by_identifier m['id'] } users.delete_if { |_| _.nil? } end users.each { |u| yield u } if block_given? users end |