class ASF::MemberFiles

Public Class Methods

board_nominees() click to toggle source

Return hash of board nominees

# File lib/whimsy/asf/member-files.rb, line 78
def self.board_nominees
  nominees = {}
  ASF::MemberFiles.parse_file('board_nominations.txt') do |hdr, nominee|
    # for board, the header currentl looks like this:
    # <PUBLIC NAME>
    id = ASF::Person.find_by_name!(hdr) || hdr # default to full name
    nominee['Public Name'] = hdr # the board file does not have ids
    nominees[id] = nominee
  end
  nominees
end
member_nominees() click to toggle source

Return hash of member nominees

# File lib/whimsy/asf/member-files.rb, line 66
def self.member_nominees
  nominees = {}
  ASF::MemberFiles.parse_file('nominated-members.txt') do |hdr, nominee|
    # for members, the header looks like this:
    # <NOMINATED PERSON'S APACHE ID> <PUBLIC NAME>
    id, nominee['Public Name'] = hdr.split(' ',2)
    nominees[id] = nominee
  end
  nominees
end
parse_file(name) { |header, nominee| ... } click to toggle source

Return a hash of nominees. key: availid (name for board nominees) value: hash of entries: keys: Public Name Nominee email Nominated by Seconded by => array of seconders

Nomination Statement => array of text lines

# File lib/whimsy/asf/member-files.rb, line 17
def self.parse_file(name)
  # N.B. The format has changed over the years. This is the syntax as of 2021.
  # -----------------------------------------
  # <empty line>
  #  header line
  #    Nominee email:
  #    Nominated by:
  #    Seconded by:
  
  #    Nomination Statement:
  
  # Find most recent file:
  nomfile = Dir[File.join(ASF::SVN['Meetings'], '*', name)].max

  # It does not appear to be possible to have file open or read
  # automatically transcode strings, so we do it here.
  # This is necessary to avoid issues with matching Regexes.
  File.open(nomfile, mode='rb:UTF-8')
    .map(&:scrub)
    .slice_before(/^\s*---+--\s*/)
    .drop(2) # instructions and sample block
    .each do |block|
    block.shift(2) # divider and blank line
    nominee = {}
    header = nil
    block
        .slice_before(/^ +(\S+ \S+):\s*/) # split on the header names
        .each_with_index do |para, idx|
      if idx == 0 # id and name (or just name for board)
        header = para.first.strip
      else
        key, value = para.shift.strip.split(': ',2)
        if para.size == 0 # no more data to follow
          nominee[key] = value
        else
          tmp = [value,para.map(&:chomp)].flatten.compact
          tmp.pop if tmp[-1].empty? # drop trailing empty line only
          nominee[key] = tmp
        end
      end
    end
    yield header, nominee unless header.nil? || header.empty?
  end
end