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, 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.



480
481
482
# File 'lib/whimsy/asf/ldap.rb', line 480

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.



480
481
482
# File 'lib/whimsy/asf/ldap.rb', line 480

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

.find(name) ⇒ Object



118
119
120
121
122
# File 'lib/whimsy/asf/committee.rb', line 118

def self.find(name)
  result = super(@@namemap.call(name))
  result.display_name = name if name =~ /[A-Z]/
  result
end

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



464
465
466
# File 'lib/whimsy/asf/ldap.rb', line 464

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
62
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
# 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

  list = Hash.new {|hash, name| hash[name] = find(name)}

  @committee_mtime = File.mtime(file)
  @@svn_change = Time.parse(
    `svn info #{file}`[/Last Changed Date: (.*) \(/, 1]).gmtime

  # Split the file on lines starting "* ", i.e. the start of each group in section 3
  info = File.read(file).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.*?)\s+\(/,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
    committee.roster = Hash[roster.gsub(/\(\w+\)/, '').
      scan(/^\s*(.*?)\s*<(.*?)@apache\.org>\s+(\[(.*?)\])?/).
      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(/^   \s*(.*)/).each do |committee|
      committee, comment = committee.first.split(/\s+#\s+/,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

.nonpmcsObject



114
115
116
# File 'lib/whimsy/asf/committee.rb', line 114

def self.nonpmcs
  @nonpmcs
end

.preloadObject



468
469
470
471
472
473
474
475
476
477
478
# File 'lib/whimsy/asf/ldap.rb', line 468

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

.svn_changeObject



124
125
126
# File 'lib/whimsy/asf/committee.rb', line 124

def self.svn_change
  @@svn_change
end

Instance Method Details

#add(people) ⇒ Object



505
506
507
508
509
510
# File 'lib/whimsy/asf/ldap.rb', line 505

def add(people)
  people = Array(people).map(&:dn)
  mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_ADD, 'member', people)
  ASF.ldap.modify(self.dn, [mod])
  @members = nil
end

#chairObject



128
129
130
131
132
133
134
135
# File 'lib/whimsy/asf/committee.rb', line 128

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



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

def display_name
  Committee.load_committee_info
  @display_name || name
end

#display_name=(name) ⇒ Object



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

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

#dnObject



494
495
496
# File 'lib/whimsy/asf/ldap.rb', line 494

def dn
  @dn ||= ASF.search_one(base, "cn=#{name}", 'dn').first.first
end

#mail_listObject



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
# File 'lib/whimsy/asf/mail.rb', line 82

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



486
487
488
489
490
491
492
# File 'lib/whimsy/asf/ldap.rb', line 486

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



482
483
484
# File 'lib/whimsy/asf/ldap.rb', line 482

def members=(members)
  @members = WeakRef.new(members)
end

#namesObject



154
155
156
157
# File 'lib/whimsy/asf/committee.rb', line 154

def names
  Committee.load_committee_info
  Hash[@roster.map {|id, info| [id, info[:name]]}]
end

#nonpmc?Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/whimsy/asf/committee.rb', line 159

def nonpmc?
  Committee.nonpmcs.include? self
end

#remove(people) ⇒ Object



498
499
500
501
502
503
# File 'lib/whimsy/asf/ldap.rb', line 498

def remove(people)
  people = Array(people).map(&:dn)
  mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_DELETE, 'member', people)
  ASF.ldap.modify(self.dn, [mod])
  @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