# Front sections: # * Call to Order # * Roll Call class ASF::Board::Agenda @@people_cache = {} parse do pattern = / ^\n\x20(?
[12]\.) \s(?.*?)\n\n+ (?<text>.*?) (?=\n\s[23]\.) /mx scan @file, pattern do |attr| if attr['title'] == 'Roll Call' attr['people'] = {} list = nil absent = attr['text'].scan(/Absent:\n\n.*?\n\n/m).join directors = attr['text'].scan(/^ +Directors[ \S]*?:\n\n.*?\n\n/m).join officers = attr['text'].scan(/^ +Executive[ \S]*?:\n\n.*?\n\n/m).join # attempt to identify the people mentioned in the Roll Call people = attr['text'].scan(/ {8}(\w.*)/).flatten.each do |sname| next if sname == 'none' name = sname role = :guest role = :director if directors.include? name role = :officer if officers.include? name sort_name = name.split(' ').rotate(-1).join(' ') if sort_name.start_with? '(' sort_name = sort_name.split(' ').rotate(-1).join(' ') end if @quick attr['people'][name.gsub(/\W/, '_')] = { name: name, sortName: sort_name, role: role, attending: !absent.include?(name) } else # first try the cache person = @@people_cache[name] # next try a simple name look up if not person search = ASF::Person.list("cn=#{name}") person = search.first if search.length == 1 end # finally try harder to match the name if not person sname = sname.strip.downcase.split(/\s+/) if not list ASF::Person.preload('cn') list = ASF::Person.list end search = [] list.select do |person| next if person == 'none' pname = person.public_name.downcase.split(/\s+/) if sname.all? {|t1| pname.any? {|t2| t2.start_with? t1}} search << person elsif pname.all? {|t1| sname.any? {|t2| t2.start_with? t1}} search << person end end person = search.first if search.length == 1 end # save results in both the cache and the attributes if person @@people_cache[name] = person attr['people'][person.id] = { name: name, sortName: sort_name, role: role, member: person.asf_member?, attending: !absent.include?(name) } end end end if attr['people'] attr['people'] = Hash[attr['people']. sort_by {|id, person| person[:sortName]}] end elsif attr['title'] == 'Call to order' attr['timestamp'] = timestamp(attr['text'][/\d+:\d+([ap]m)?/]) end end end end