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.77 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.76 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.75 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.74 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.73 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.72 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.71 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.70 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.69 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.68 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.67 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.66 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.65 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.64 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.63 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.62 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.61 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.60 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.59 lib/whimsy/asf/agenda/front.rb
whimsy-asf-0.0.58 lib/whimsy/asf/agenda/front.rb