Class: ASF::Committee
- Inherits:
-
Base
- Object
- Base
- ASF::Committee
show all
- Defined in:
- lib/whimsy/asf/ldap.rb,
lib/whimsy/asf/mail.rb,
lib/whimsy/asf/site.rb,
lib/whimsy/asf/committee.rb
Constant Summary
collapse
- @@aliases =
mapping of committee names to canonical names (generally from ldap) See also www/roster/committee.cgi
Hash.new {|hash, name| name}
- @@namemap =
Proc.new do |name|
cname = @@aliases[name.sub(/\s+\(.*?\)/, '').downcase]
cname
end
Instance Attribute Summary collapse
Attributes inherited from Base
#name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#<=>, [], base, #base, collection, #id, mod_add, mod_delete, mod_replace, new, #reference, #weakref
Constructor Details
#initialize(*args) ⇒ Committee
Returns a new instance of Committee.
11
12
13
14
15
16
|
# File 'lib/whimsy/asf/committee.rb', line 11
def initialize(*args)
@info = []
@chairs = []
@roster = {}
super
end
|
Instance Attribute Details
#chairs ⇒ Object
Returns the value of attribute chairs.
9
10
11
|
# File 'lib/whimsy/asf/committee.rb', line 9
def chairs
@chairs
end
|
#createTimestamp ⇒ Object
Returns the value of attribute createTimestamp.
664
665
666
|
# File 'lib/whimsy/asf/ldap.rb', line 664
def createTimestamp
@createTimestamp
end
|
#established ⇒ Object
Returns the value of attribute established.
9
10
11
|
# File 'lib/whimsy/asf/committee.rb', line 9
def established
@established
end
|
#info ⇒ Object
Returns the value of attribute info.
9
10
11
|
# File 'lib/whimsy/asf/committee.rb', line 9
def info
@info
end
|
#modifyTimestamp ⇒ Object
Returns the value of attribute modifyTimestamp.
664
665
666
|
# File 'lib/whimsy/asf/ldap.rb', line 664
def modifyTimestamp
@modifyTimestamp
end
|
#report ⇒ Object
Returns the value of attribute report.
9
10
11
|
# File 'lib/whimsy/asf/committee.rb', line 9
def report
@report
end
|
#roster ⇒ Object
Returns the value of attribute roster.
9
10
11
|
# File 'lib/whimsy/asf/committee.rb', line 9
def roster
@roster
end
|
#schedule ⇒ Object
Returns the value of attribute schedule.
9
10
11
|
# File 'lib/whimsy/asf/committee.rb', line 9
def schedule
@schedule
end
|
Class Method Details
.add(name, people) ⇒ Object
701
702
703
704
705
706
707
708
709
|
# File 'lib/whimsy/asf/ldap.rb', line 701
def self.add(name, people)
entry = [
mod_add('objectClass', ['groupOfNames', 'top']),
mod_add('cn', name),
mod_add('member', Array(people).map(&:dn))
]
ASF.ldap.add("cn=#{name},#{base}", entry)
end
|
.find(name) ⇒ Object
124
125
126
127
128
|
# File 'lib/whimsy/asf/committee.rb', line 124
def self.find(name)
result = super(@@namemap.call(name))
result.display_name = name if name =~ /[A-Z]/
result
end
|
.list(filter = 'cn=*') ⇒ Object
648
649
650
|
# File 'lib/whimsy/asf/ldap.rb', line 648
def self.list(filter='cn=*')
ASF.search_one(base, filter, 'cn').flatten.map {|cn| Committee.find(cn)}
end
|
.load_committee_info ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/whimsy/asf/committee.rb', line 46
def self.load_committee_info
board = ASF::SVN['private/committers/board']
file = "#{board}/committee-info.txt"
return unless File.exist? file
if @committee_info and File.mtime(file) == @committee_mtime
return @committee_info
end
@committee_mtime = File.mtime(file)
@@svn_change = Time.parse(
`svn info #{file}`[/Last Changed Date: (.*) \(/, 1]).gmtime
parse_committee_info File.read(file)
end
|
.nonpmcs ⇒ Object
120
121
122
|
# File 'lib/whimsy/asf/committee.rb', line 120
def self.nonpmcs
@nonpmcs
end
|
.parse_committee_info(contents) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/whimsy/asf/committee.rb', line 63
def self.parse_committee_info(contents)
list = Hash.new {|hash, name| hash[name] = find(name)}
info = contents.split(/^\* /)
head, report = info.shift.split(/^\d\./)[1..2]
head.gsub! /^\s+NAME\s+CHAIR\s*$/,''
head.scan(/^[ \t]+(\w.*?)[ \t][ \t]+(.*)[ \t]+<(.*?)@apache\.org>/).
each do |committee, name, id|
list[committee].chairs << {name: name, id: id}
end
@nonpmcs = head.sub(/.*?also has /m,'').
scan(/^[ \t]+(\w.*?)(?:[ \t][ \t]|[ \t]?$)/).flatten.uniq.
map {|name| list[name]}
info.each do |roster|
committee = list[@@namemap.call(roster[/(\w.*?)[ \t]+\(/,1])]
committee.established = roster[/\(est\. (.*?)\)/, 1]
committee.info = roster.scan(/<(.*?)@apache\.org>/).flatten
committee.roster = Hash[roster.gsub(/\(\w+\)/, '').
scan(/^[ \t]*(.*?)[ \t]*<(.*?)@apache\.org>(?:[ \t]+(\[(.*?)\]))?/).
map {|list| [list[1], {name: list[0], date: list[3]}]}]
end
report.scan(/^([^\n]+)\n---+\n(.*?)\n\n/m).each do |period, committees|
committees.scan(/^ [ \t]*(.*)/).each do |committee|
committee, = committee.first.split(/[ \t]+#[ \t]+/,2)
committee = list[committee]
if
committee.report = "#{period}: #{}"
elsif period == 'Next month'
committee.report = 'Every month'
else
committee.schedule = period
end
end
end
@committee_info = list.values.uniq
end
|
.preload ⇒ Object
652
653
654
655
656
657
658
659
660
661
662
|
# File 'lib/whimsy/asf/ldap.rb', line 652
def self.preload
Hash[ASF.search_one(base, "cn=*", %w(dn member modifyTimestamp createTimestamp)).map do |results|
cn = results['dn'].first[/^cn=(.*?),/, 1]
committee = ASF::Committee.find(cn)
committee.modifyTimestamp = results['modifyTimestamp'].first committee.createTimestamp = results['createTimestamp'].first members = results['member'] || []
committee.members = members
[committee, members]
end]
end
|
.remove(name) ⇒ Object
712
713
714
|
# File 'lib/whimsy/asf/ldap.rb', line 712
def self.remove(name)
ASF.ldap.delete("cn=#{name},#{base}")
end
|
.svn_change ⇒ Object
130
131
132
|
# File 'lib/whimsy/asf/committee.rb', line 130
def self.svn_change
@@svn_change
end
|
Instance Method Details
#add(people) ⇒ Object
add people to a committee
692
693
694
695
696
697
698
|
# File 'lib/whimsy/asf/ldap.rb', line 692
def add(people)
@members = nil
people = (Array(people) - members).map(&:dn)
ASF.ldap.modify(self.dn, [ASF::Base.mod_add('member', people)])
ensure
@members = nil
end
|
#description ⇒ Object
100
101
102
103
|
# File 'lib/whimsy/asf/site.rb', line 100
def description
site = ASF::Site.find(name)
site[:text] if site
end
|
#display_name=(name) ⇒ Object
148
149
150
|
# File 'lib/whimsy/asf/committee.rb', line 148
def display_name=(name)
@display_name ||= name
end
|
#dn ⇒ Object
678
679
680
|
# File 'lib/whimsy/asf/ldap.rb', line 678
def dn
@dn ||= ASF.search_one(base, "cn=#{name}", 'dn').first.first
end
|
#mail_list ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/whimsy/asf/mail.rb', line 106
def mail_list
case name.downcase
when 'comdev'
'community'
when 'httpcomponents'
'hc'
when 'whimsy'
'whimsical'
when 'brand management'
'[email protected]'
when 'executive assistant'
'[email protected]'
when 'legal affairs'
'[email protected]'
when 'marketing and publicity'
'[email protected]'
when 'tac'
'[email protected]'
when 'w3c relations'
'[email protected]'
else
name
end
end
|
#members ⇒ Object
670
671
672
673
674
675
676
|
# File 'lib/whimsy/asf/ldap.rb', line 670
def members
members = weakref(:members) do
ASF.search_one(base, "cn=#{name}", 'member').flatten
end
members.map {|uid| Person.find uid[/uid=(.*?),/,1]}
end
|
#members=(members) ⇒ Object
666
667
668
|
# File 'lib/whimsy/asf/ldap.rb', line 666
def members=(members)
@members = WeakRef.new(members)
end
|
#names ⇒ Object
160
161
162
163
|
# File 'lib/whimsy/asf/committee.rb', line 160
def names
Committee.load_committee_info
Hash[@roster.map {|id, info| [id, info[:name]]}]
end
|
#nonpmc? ⇒ Boolean
165
166
167
|
# File 'lib/whimsy/asf/committee.rb', line 165
def nonpmc?
Committee.nonpmcs.include? self
end
|
#remove(people) ⇒ Object
remove people from a committee
683
684
685
686
687
688
689
|
# File 'lib/whimsy/asf/ldap.rb', line 683
def remove(people)
@members = nil
people = (Array(people) & members).map(&:dn)
ASF.ldap.modify(self.dn, [ASF::Base.mod_delete('member', people)])
ensure
@members = nil
end
|
#site ⇒ Object
95
96
97
98
|
# File 'lib/whimsy/asf/site.rb', line 95
def site
site = ASF::Site.find(name)
site[:link] if site
end
|