Class: ASF::Person

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from ASF::Base

Class Method Details

.find_by_email(value) ⇒ Object



48
49
50
51
52
53
# File 'lib/whimsy/asf/mail.rb', line 48

def self.find_by_email(value)
  value.downcase!

  person = Mail.list[value]
  return person if person
end

.list(filter = 'uid=*') ⇒ Object



122
123
124
# File 'lib/whimsy/asf/ldap.rb', line 122

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



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/whimsy/asf/ldap.rb', line 127

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



66
67
68
# File 'lib/whimsy/asf/mail.rb', line 66

def active_emails
  (mail + alt_email + member_emails).uniq
end

#all_mail ⇒ Object



70
71
72
# File 'lib/whimsy/asf/mail.rb', line 70

def all_mail
  active_emails + obsolete_emails
end

#alt_email ⇒ Object



173
174
175
# File 'lib/whimsy/asf/ldap.rb', line 173

def alt_email
  attrs['asf-altEmail'] || []
end

#asf_member? ⇒ Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/whimsy/asf/ldap.rb', line 161

def asf_member?
  ASF::Member.status[name] or ASF.members.include? self
end

#attrs ⇒ Object



149
150
151
# File 'lib/whimsy/asf/ldap.rb', line 149

def attrs
  @attrs ||= LazyHash.new {ASF.search_one(base, "uid=#{name}").first}
end

#auth ⇒ Object



24
25
26
# File 'lib/whimsy/asf/auth.rb', line 24

def auth
  @auths ||= ASF::Authorization.find_by_id(name)
end

#banned? ⇒ Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/whimsy/asf/ldap.rb', line 165

def banned?
  not attrs['loginShell'] or attrs['loginShell'].include? "/usr/bin/false"
end

#committees ⇒ Object



185
186
187
# File 'lib/whimsy/asf/ldap.rb', line 185

def committees
  Committee.list("member=uid=#{name},#{base}")
end

#groups ⇒ Object



189
190
191
# File 'lib/whimsy/asf/ldap.rb', line 189

def groups
  Group.list("memberUid=#{name}")
end

#icla ⇒ Object



41
42
43
# File 'lib/whimsy/asf/icla.rb', line 41

def icla
  @icla ||= ASF::ICLA.find_by_id(name)
end

#icla? ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/whimsy/asf/icla.rb', line 45

def icla?
  ICLA.availids.include? name
end

#mail ⇒ Object



169
170
171
# File 'lib/whimsy/asf/ldap.rb', line 169

def mail
  attrs['mail'] || []
end

#member_emails ⇒ Object



78
79
80
# File 'lib/whimsy/asf/member.rb', line 78

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



74
75
76
# File 'lib/whimsy/asf/member.rb', line 74

def members_txt
  @members_txt ||= ASF::Member.find_text_by_id(name)
end

#obsolete_emails ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/whimsy/asf/mail.rb', line 55

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



177
178
179
# File 'lib/whimsy/asf/ldap.rb', line 177

def pgp_key_fingerprints
  attrs['asf-pgpKeyFingerprint']
end

#public_name ⇒ Object



153
154
155
156
157
158
159
# File 'lib/whimsy/asf/ldap.rb', line 153

def public_name
  cn = [attrs['cn']].flatten.first
  cn.force_encoding('utf-8') if cn.respond_to? :force_encoding
  return cn if cn
  return icla.name if icla
  ASF.search_archive_by_id(name)
end

#urls ⇒ Object



181
182
183
# File 'lib/whimsy/asf/ldap.rb', line 181

def urls
  attrs['asf-personalURL'] || []
end