Class: ASF::Person
- Inherits:
-
Base
show all
- Defined in:
- lib/whimsy/asf/auth.rb,
lib/whimsy/asf/icla.rb,
lib/whimsy/asf/ldap.rb,
lib/whimsy/asf/mail.rb,
lib/whimsy/asf/watch.rb,
lib/whimsy/asf/member.rb,
lib/whimsy/asf/nominees.rb
Instance Attribute Summary
Attributes inherited from Base
#name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
[], #base, base, collection, find, #id, #initialize, new, #reference
Constructor Details
This class inherits a constructor from ASF::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# File 'lib/whimsy/asf/ldap.rb', line 249
def method_missing(name, *args)
if name.to_s.end_with? '=' and args.length == 1
return modify(name.to_s[0..-2], args)
end
return super unless args.empty?
result = self.attrs[name.to_s]
return super unless result
if result.empty?
return nil
else
result.map! do |value|
value = value.dup.force_encoding('utf-8') if String === value
value
end
if result.length == 1
result.first
else
result
end
end
end
|
Class Method Details
.find_by_email(value) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/whimsy/asf/mail.rb', line 49
def self.find_by_email(value)
value.downcase!
person = Mail.list[value]
return person if person
end
|
.list(filter = 'uid=*') ⇒ Object
169
170
171
|
# File 'lib/whimsy/asf/ldap.rb', line 169
def self.list(filter='uid=*')
ASF.search_one(base, filter, 'uid').flatten.map {|uid| find(uid)}
end
|
.member_nominees ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/whimsy/asf/nominees.rb', line 5
def self.member_nominees
return @member_nominees if @member_nominees
meetings = ASF::SVN['private/foundation/Meetings']
nominations = Dir["#{meetings}/*/nominated-members.txt"].sort.last.untaint
nominations = File.read(nominations).split(/^\s*---+\s*/)
nominations.shift(2)
nominees = {}
nominations.each do |nomination|
id = nomination[/^\s?\w+.*<(\S+)@apache.org>/,1]
id ||= nomination[/^\s?\w+.*\((\S+)@apache.org\)/,1]
id ||= nomination[/^\s?\w+.*\(([a-z]+)\)/,1]
next unless id
nominees[find(id)] = nomination
end
@member_nominees = nominees
end
|
.member_watch_list ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/whimsy/asf/watch.rb', line 5
def self.member_watch_list
return @member_watch_list if @member_watch_list
foundation = ASF::SVN['private/foundation']
text = File.read "#{foundation}/potential-member-watch-list.txt"
nominations = text.scan(/^\s+\*\)\s+\w.*?\n\s*(?:---|\Z)/m)
i = 0
member_watch_list = {}
nominations.each do |nomination|
id = nil
name = nomination[/\*\)\s+(.+?)\s+(\(|\<|$)/,1]
id ||= nomination[/\*\)\s.+?\s\((.*?)\)/,1]
id ||= nomination[/\*\)\s.+?\s<(.*?)@apache.org>/,1]
unless id
id = "notinavail_#{i+=1}"
find(id).attrs['cn'] = name
end
member_watch_list[find(id)] = nomination
end
@member_watch_list = member_watch_list
end
|
.preload(attributes, people = {}) ⇒ Object
pre-fetch a given attribute, for a given list of people
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/whimsy/asf/ldap.rb', line 174
def self.preload(attributes, people={})
attributes = [attributes].flatten
if people.empty?
filter = "(|#{attributes.map {|attribute| "(#{attribute}=*)"}.join})"
else
filter = "(|#{people.map {|person| "(uid=#{person.name})"}.join})"
end
zero = Hash[attributes.map {|attribute| [attribute,nil]}]
data = ASF.search_one(base, filter, attributes + ['uid'])
data = Hash[data.map! {|hash| [find(hash['uid'].first), hash]}]
data.each {|person, hash| person.attrs.merge!(zero.merge(hash))}
if people.empty?
(collection.values - data.keys).each do |person|
person.attrs.merge! zero
end
end
end
|
Instance Method Details
#active_emails ⇒ Object
67
68
69
|
# File 'lib/whimsy/asf/mail.rb', line 67
def active_emails
(mail + alt_email + member_emails).uniq
end
|
#all_mail ⇒ Object
71
72
73
|
# File 'lib/whimsy/asf/mail.rb', line 71
def all_mail
active_emails + obsolete_emails
end
|
#alt_email ⇒ Object
224
225
226
|
# File 'lib/whimsy/asf/ldap.rb', line 224
def alt_email
attrs['asf-altEmail'] || []
end
|
#asf_committer? ⇒ Boolean
212
213
214
|
# File 'lib/whimsy/asf/ldap.rb', line 212
def asf_committer?
ASF::Group.new('committers').include? self
end
|
#asf_member? ⇒ Boolean
208
209
210
|
# File 'lib/whimsy/asf/ldap.rb', line 208
def asf_member?
ASF::Member.status[name] or ASF.members.include? self
end
|
#attrs ⇒ Object
196
197
198
|
# File 'lib/whimsy/asf/ldap.rb', line 196
def attrs
@attrs ||= LazyHash.new {ASF.search_one(base, "uid=#{name}").first}
end
|
#banned? ⇒ Boolean
216
217
218
|
# File 'lib/whimsy/asf/ldap.rb', line 216
def banned?
not attrs['loginShell'] or attrs['loginShell'].include? "/usr/bin/false"
end
|
#committees ⇒ Object
236
237
238
|
# File 'lib/whimsy/asf/ldap.rb', line 236
def committees
Committee.list("member=uid=#{name},#{base}")
end
|
#dn ⇒ Object
244
245
246
247
|
# File 'lib/whimsy/asf/ldap.rb', line 244
def dn
value = attrs['dn']
value.first if Array === value
end
|
#groups ⇒ Object
240
241
242
|
# File 'lib/whimsy/asf/ldap.rb', line 240
def groups
Group.list("memberUid=#{name}")
end
|
#icla ⇒ Object
200
201
202
|
# File 'lib/whimsy/asf/icla.rb', line 200
def icla
@icla ||= ASF::ICLA.find_by_id(name)
end
|
#icla=(icla) ⇒ Object
204
205
206
|
# File 'lib/whimsy/asf/icla.rb', line 204
def icla=(icla)
@icla = icla
end
|
#icla? ⇒ Boolean
208
209
210
|
# File 'lib/whimsy/asf/icla.rb', line 208
def icla?
@icla || ICLA.availids.include?(name)
end
|
#mail ⇒ Object
220
221
222
|
# File 'lib/whimsy/asf/ldap.rb', line 220
def mail
attrs['mail'] || []
end
|
#member_emails ⇒ Object
85
86
87
|
# File 'lib/whimsy/asf/member.rb', line 85
def member_emails
ASF::Member.emails(members_txt)
end
|
#member_nomination ⇒ Object
28
29
30
|
# File 'lib/whimsy/asf/nominees.rb', line 28
def member_nomination
Person.member_nominees[self]
end
|
#member_watch ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/whimsy/asf/watch.rb', line 32
def member_watch
text = Person.member_watch_list[self]
if text
text.sub!(/\A\s*\n/,'')
text.sub!(/\n---\Z/,'')
end
text
end
|
#members_txt ⇒ Object
81
82
83
|
# File 'lib/whimsy/asf/member.rb', line 81
def members_txt
@members_txt ||= ASF::Member.find_text_by_id(name)
end
|
#modify(attr, value) ⇒ Object
274
275
276
277
278
279
|
# File 'lib/whimsy/asf/ldap.rb', line 274
def modify(attr, value)
value = Array(value) unless Hash === value
mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_REPLACE, attr.to_s, value)
ASF.ldap.modify(self.dn, [mod])
attrs[attr.to_s] = value
end
|
#obsolete_emails ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/whimsy/asf/mail.rb', line 56
def obsolete_emails
return @obsolete_emails if @obsolete_emails
result = []
if icla
unless active_emails.any? {|mail| mail.downcase == icla.email.downcase}
result << icla.email
end
end
@obsolete_emails = result
end
|
#pgp_key_fingerprints ⇒ Object
228
229
230
|
# File 'lib/whimsy/asf/ldap.rb', line 228
def pgp_key_fingerprints
attrs['asf-pgpKeyFingerprint']
end
|
#public_name ⇒ Object
200
201
202
203
204
205
206
|
# File 'lib/whimsy/asf/ldap.rb', line 200
def public_name
return icla.name if icla
cn = [attrs['cn']].flatten.first
cn.force_encoding('utf-8') if cn.respond_to? :force_encoding
return cn if cn
ASF.search_archive_by_id(name)
end
|
#urls ⇒ Object
232
233
234
|
# File 'lib/whimsy/asf/ldap.rb', line 232
def urls
attrs['asf-personalURL'] || []
end
|