in lib/whimsy/asf/committee.rb [515:630]
def self.parse_committee_info_nocache(contents)
list = Hash.new {|hash, name| hash[name] = find(name, true)}
info = contents.split(/^\* /)
head, report = info.shift.split(/^\d\./)[1..2]
head.gsub! %r{^\s+NAME\s+CHAIR\s*$}, ''
head.gsub! %r{^\s+Office\s+Officer\s*$}i, ''
head.scan(/^[ \t]+\w.*?[ \t]+.*[ \t]+<.*?@apache\.org>/).each do |line|
m = line.match(/^[ \t]+(\w.*?)[ \t][ \t]+(.*)[ \t]+<(.*?)@apache\.org>/)
if m
committee, name, id = m.captures
unless list[committee].chairs.any? {|chair| chair[:id] == id}
list[committee].chairs << {name: name, id: id}
end
else
Wunderbar.warn "Missing separator before chair name in: '#{line}'"
end
end
dupes = list.group_by{|x| x.first.downcase}.select{|k,v|v.size!=1}
if dupes.size > 0
Wunderbar.warn "Duplicate chairs: #{dupes}}"
end
nonpmcs = head.sub(/.*?also has /m, '').sub(/ Officers:.*/m, '').
scan(/^[ \t]+(\w.*?)(?:[ \t][ \t]|[ \t]?$)/).flatten.uniq.
map {|name| list[name]}
officers = head.sub(/.*?also has .*? Officers/m, '').
scan(/^[ \t]+(\w.*?)(?:[ \t][ \t]|[ \t]?$)/).flatten.uniq.
map {|name| list[name]}
head_parts = head.split(/^The ASF also has the following +/)
(1..head_parts.size - 1).each do |h|
part = head_parts[h]
type = part[/^([^:]+)/, 1]
part.scan(/^[ \t]+(\w.*?)(?:[ \t][ \t]|[ \t]?$)/).flatten.uniq.each do |cttee|
list[cttee].paragraph = type
end
end
info.each do |roster|
name = roster[/(\w.*?)[ \t]+\(est/, 1]
unless list.include?(name)
Wunderbar.warn "No chair entry detected for #{name} in section 3"
end
committee = list[name]
established = roster[/\(est\. (.*?)\)/, 1]
established = "0#{established}" if established =~ /^\d\//
committee.established = established
roster.scan(/^[ \t]+.+$/) do |line|
Wunderbar.warn "Invalid syntax: #{committee.name} '#{line}'" unless line =~ /\s<(.*?)@apache\.org>\s/
end
committee.info = roster.scan(/<(.*?)@apache\.org>/).flatten
committee.roster = Hash[roster.gsub(/\(\w+\)/, '').
scan(/^[ \t]*(.*?)[ \t]*<(.*?)@apache\.org>(?:[ \t]+(\[(.*?)\]))?/).
map {|l| [l[1], {name: l[0], date: l[3]}]}]
end
report.scan(/^([^\n]+)\n---+\n(.*?)\n\n/m).each do |period, committees|
committees.scan(/^ [ \t]*(.*)/).each do |committee|
committee, comment = committee.first.split(/[ \t]+
unless list.include? committee
Wunderbar.warn "Unexpected name '#{committee}' in report section; ignored"
next
end
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 - officers).uniq
committee_info.each do |c|
if c.chairs.length != 1 && c.name != 'fundraising'
Wunderbar.warn "Unexpected chair count for #{c.display_name}: #{c.chairs.inspect rescue ''}"
end
end
return nonpmcs, officers, committee_info
end