Sha256: c150645022aba0ecf96307f54eb8e1912dc0024647b02936010ad6a4204317f9

Contents?: true

Size: 1.95 KB

Versions: 30

Compression:

Stored size: 1.95 KB

Contents

# Front sections:
# * Call to Order
# * Roll Call

class ASF::Board::Agenda
  parse do
    pattern = /
      ^\n\x20(?<section>[12]\.)
      \s(?<title>.*?)\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 |name|
          next if name == 'none'
          name.gsub! /\s*\(.*?\)/, ''

          role = :guest
          role = :director if directors.include? name
          role = :officer if officers.include? name

          sort_name = name.sub(/\(.*\)\s*$/, '').split(' ').rotate(-1).join(' ')

          if @quick
            attr['people']['_' + name.gsub(/\W/, '_')] = {
              name: name,
              sortName: sort_name,
              role: role,
              attending: !absent.include?(name)
            }
          else

            # look up name
            search = ASF::Person.list("cn=#{name}")

            # if found, save results in the attributes
            if search.length == 1
              person = search.first

              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

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
whimsy-asf-0.0.57 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.56 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.55 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.54 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.53 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.52 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.51 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.50 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.49 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.48 lib/whimsy/asf/agenda/front.rb