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, #weakref
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
# File 'lib/whimsy/asf/ldap.rb', line 367
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
54
55
56
57
58
59
|
# File 'lib/whimsy/asf/mail.rb', line 54
def self.find_by_email(value)
value.downcase!
person = Mail.list[value]
return person if person
end
|
.list(filter = 'uid=*') ⇒ Object
279
280
281
|
# File 'lib/whimsy/asf/ldap.rb', line 279
def self.list(filter='uid=*')
ASF.search_one(base, filter, 'uid').flatten.map {|uid| find(uid)}
end
|
.member_nominees ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/whimsy/asf/nominees.rb', line 7
def self.member_nominees
begin
return Hash[@member_nominees.to_a] if @member_nominees
rescue NoMethodError, WeakRef::RefError
end
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 = WeakRef.new(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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'lib/whimsy/asf/ldap.rb', line 284
def self.preload(attributes, people={})
list = Hash.new {|hash, name| hash[name] = find(name)}
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| [list[hash['uid'].first], hash]}]
data.each {|person, hash| person.attrs.merge!(zero.merge(hash))}
if people.empty?
(list.values - data.keys).each do |person|
person.attrs.merge! zero
end
end
list.values
end
|
Instance Method Details
#active_emails ⇒ Object
72
73
74
|
# File 'lib/whimsy/asf/mail.rb', line 72
def active_emails
(mail + alt_email + member_emails).uniq
end
|
#all_mail ⇒ Object
76
77
78
|
# File 'lib/whimsy/asf/mail.rb', line 76
def all_mail
active_emails + obsolete_emails
end
|
#alt_email ⇒ Object
342
343
344
|
# File 'lib/whimsy/asf/ldap.rb', line 342
def alt_email
attrs['asf-altEmail'] || []
end
|
#asf_committer? ⇒ Boolean
330
331
332
|
# File 'lib/whimsy/asf/ldap.rb', line 330
def asf_committer?
ASF::Group.new('committers').include? self
end
|
#asf_member? ⇒ Boolean
322
323
324
|
# File 'lib/whimsy/asf/ldap.rb', line 322
def asf_member?
ASF::Member.status[name] or ASF.members.include? self
end
|
#asf_officer_or_member? ⇒ Boolean
326
327
328
|
# File 'lib/whimsy/asf/ldap.rb', line 326
def asf_officer_or_member?
asf_member? or ASF.pmc_chairs.include? self
end
|
#attrs ⇒ Object
310
311
312
|
# File 'lib/whimsy/asf/ldap.rb', line 310
def attrs
@attrs ||= LazyHash.new {ASF.search_one(base, "uid=#{name}").first}
end
|
#banned? ⇒ Boolean
334
335
336
|
# File 'lib/whimsy/asf/ldap.rb', line 334
def banned?
not attrs['loginShell'] or %w(/usr/bin/false bin/nologin bin/no-cla).any? {|a| attrs['loginShell'].first.include? a}
end
|
#committees ⇒ Object
354
355
356
|
# File 'lib/whimsy/asf/ldap.rb', line 354
def committees
Committee.list("member=uid=#{name},#{base}")
end
|
#dn ⇒ Object
362
363
364
365
|
# File 'lib/whimsy/asf/ldap.rb', line 362
def dn
value = attrs['dn']
value.first if Array === value
end
|
#groups ⇒ Object
358
359
360
|
# File 'lib/whimsy/asf/ldap.rb', line 358
def groups
Group.list("memberUid=#{name}")
end
|
#icla ⇒ Object
215
216
217
|
# File 'lib/whimsy/asf/icla.rb', line 215
def icla
@icla ||= ASF::ICLA.find_by_id(name)
end
|
#icla=(icla) ⇒ Object
219
220
221
|
# File 'lib/whimsy/asf/icla.rb', line 219
def icla=(icla)
@icla = icla
end
|
#icla? ⇒ Boolean
223
224
225
|
# File 'lib/whimsy/asf/icla.rb', line 223
def icla?
@icla || ICLA.availids.include?(name)
end
|
#mail ⇒ Object
338
339
340
|
# File 'lib/whimsy/asf/ldap.rb', line 338
def mail
attrs['mail'] || []
end
|
#member_emails ⇒ Object
94
95
96
|
# File 'lib/whimsy/asf/member.rb', line 94
def member_emails
ASF::Member.emails(members_txt)
end
|
#member_nomination ⇒ Object
34
35
36
|
# File 'lib/whimsy/asf/nominees.rb', line 34
def member_nomination
@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
90
91
92
|
# File 'lib/whimsy/asf/member.rb', line 90
def members_txt
@members_txt ||= ASF::Member.find_text_by_id(id)
end
|
#modify(attr, value) ⇒ Object
392
393
394
395
396
397
|
# File 'lib/whimsy/asf/ldap.rb', line 392
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
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/whimsy/asf/mail.rb', line 61
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
346
347
348
|
# File 'lib/whimsy/asf/ldap.rb', line 346
def pgp_key_fingerprints
attrs['asf-pgpKeyFingerprint'] || []
end
|
#public_name ⇒ Object
314
315
316
317
318
319
320
|
# File 'lib/whimsy/asf/ldap.rb', line 314
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
350
351
352
|
# File 'lib/whimsy/asf/ldap.rb', line 350
def urls
attrs['asf-personalURL'] || []
end
|