Class: ASF::Committee

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

#chairsObject

Returns the value of attribute chairs.



9
10
11
# File 'lib/whimsy/asf/committee.rb', line 9

def chairs
  @chairs
end

#createTimestampObject

Returns the value of attribute createTimestamp.



664
665
666
# File 'lib/whimsy/asf/ldap.rb', line 664

def createTimestamp
  @createTimestamp
end

#establishedObject

Returns the value of attribute established.



9
10
11
# File 'lib/whimsy/asf/committee.rb', line 9

def established
  @established
end

#infoObject

Returns the value of attribute info.



9
10
11
# File 'lib/whimsy/asf/committee.rb', line 9

def info
  @info
end

#modifyTimestampObject

Returns the value of attribute modifyTimestamp.



664
665
666
# File 'lib/whimsy/asf/ldap.rb', line 664

def modifyTimestamp
  @modifyTimestamp
end

#reportObject

Returns the value of attribute report.



9
10
11
# File 'lib/whimsy/asf/committee.rb', line 9

def report
  @report
end

#rosterObject

Returns the value of attribute roster.



9
10
11
# File 'lib/whimsy/asf/committee.rb', line 9

def roster
  @roster
end

#scheduleObject

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

add a new committee



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_infoObject



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

.nonpmcsObject



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)}

  # Split the file on lines starting "* ", i.e. the start of each group in section 3
  info = contents.split(/^\* /)
  # Extract the text before first entry in section 3 and split on section headers,
  # keeping sections 1 (COMMITTEES) and 2 (REPORTING).
  head, report = info.shift.split(/^\d\./)[1..2]
  # Drop lines which could match group entries
  head.gsub! /^\s+NAME\s+CHAIR\s*$/,'' # otherwise could match an entry with no e-mail

  # extract the committee chairs (e-mail address is required here)
  # Note: this includes the non-PMC entries
  head.scan(/^[ \t]+(\w.*?)[ \t][ \t]+(.*)[ \t]+<(.*?)@apache\.org>/).
    each do |committee, name, id|
      list[committee].chairs << {name: name, id: id}
    end

  # Extract the non-PMC committees (e-mail address may be absent)
  # first drop leading text so we only match non-PMCs
  @nonpmcs = head.sub(/.*?also has /m,'').
    scan(/^[ \t]+(\w.*?)(?:[ \t][ \t]|[ \t]?$)/).flatten.uniq.
    map {|name| list[name]}

  # for each committee in section 3
  info.each do |roster|
    # extract the committee name and canonicalise
    committee = list[@@namemap.call(roster[/(\w.*?)[ \t]+\(/,1])]
    # get the start date
    committee.established = roster[/\(est\. (.*?)\)/, 1]
    # extract the availids (is this used?)
    committee.info = roster.scan(/<(.*?)@apache\.org>/).flatten
    # drop (chair) markers and extract 0: name, 1: availid, 2: [date], 3: date
    # the date is optional (e.g. infrastructure)
    committee.roster = Hash[roster.gsub(/\(\w+\)/, '').
      scan(/^[ \t]*(.*?)[ \t]*<(.*?)@apache\.org>(?:[ \t]+(\[(.*?)\]))?/).
      map {|list| [list[1], {name: list[0], date: list[3]}]}]
  end

  # process report section
  report.scan(/^([^\n]+)\n---+\n(.*?)\n\n/m).each do |period, committees|
    committees.scan(/^   [ \t]*(.*)/).each do |committee|
      committee, comment = committee.first.split(/[ \t]+#[ \t]+/,2)
      committee = list[committee]
      if comment
        committee.report = "#{period}: #{comment}"
      elsif period == 'Next month'
        committee.report = 'Every month'
      else
        committee.schedule = period
      end
    end
  end

  @committee_info = list.values.uniq
end

.preloadObject



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 # it is returned as an array of 1 entry
    committee.createTimestamp = results['createTimestamp'].first # it is returned as an array of 1 entry
    members = results['member'] || []
    committee.members = members
    [committee, members]
  end]
end

.remove(name) ⇒ Object

remove a committee



712
713
714
# File 'lib/whimsy/asf/ldap.rb', line 712

def self.remove(name)
  ASF.ldap.delete("cn=#{name},#{base}")
end

.svn_changeObject



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

#chairObject



134
135
136
137
138
139
140
141
# File 'lib/whimsy/asf/committee.rb', line 134

def chair
  Committee.load_committee_info
  if @chairs.length >= 1
    ASF::Person.find(@chairs.first[:id])
  else
    nil
  end
end

#descriptionObject



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_nameObject



143
144
145
146
# File 'lib/whimsy/asf/committee.rb', line 143

def display_name
  Committee.load_committee_info
  @display_name || name
end

#display_name=(name) ⇒ Object



148
149
150
# File 'lib/whimsy/asf/committee.rb', line 148

def display_name=(name)
  @display_name ||= name
end

#dnObject



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_listObject



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

#membersObject



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

#namesObject



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

Returns:

  • (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

#siteObject



95
96
97
98
# File 'lib/whimsy/asf/site.rb', line 95

def site
  site = ASF::Site.find(name)
  site[:link] if site
end