Class: ASF::Board::Agenda

Inherits:
Object
  • Object
show all
Defined in:
lib/whimsy/asf/agenda/back.rb,
lib/whimsy/asf/agenda.rb,
lib/whimsy/asf/agenda/front.rb,
lib/whimsy/asf/agenda/minutes.rb,
lib/whimsy/asf/agenda/special.rb,
lib/whimsy/asf/agenda/committee.rb,
lib/whimsy/asf/agenda/attachments.rb,
lib/whimsy/asf/agenda/exec-officer.rb

Overview

Executive Officer Reports

Constant Summary collapse

CONTENTS =
{
  '2.' => 'Roll Call',
  '3A' => 'Minutes',
  '4A' => 'Executive Officer',
  '1'  => 'Additional Officer',
  'A'  => 'Committee Reports',
  '7A' => 'Special Orders',
  '8.' => 'Discussion Items',
  '9.' => 'Action Items'
}
@@parsers =
[]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAgenda

Returns a new instance of Agenda.



31
32
33
# File 'lib/whimsy/asf/agenda.rb', line 31

def initialize
  @sections = {}
end

Class Method Details

.parse(file = nil, quick = false, &block) ⇒ Object



26
27
28
29
# File 'lib/whimsy/asf/agenda.rb', line 26

def self.parse(file=nil, quick=false, &block)
  @@parsers << block if block
  new.parse(file, quick)  if file
end

Instance Method Details

#minutes(title) ⇒ Object



139
140
141
# File 'lib/whimsy/asf/agenda.rb', line 139

def minutes(title)
  "https://whimsy.apache.org/board/minutes/#{title.gsub(/\W/,'_')}"
end

#parse(file, quick = false) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/whimsy/asf/agenda.rb', line 56

def parse(file, quick=false)
  @file = file
  @quick = quick
  
  if not @file.valid_encoding?
    filter = Proc.new {|c| c.unpack('U').first rescue 0xFFFD}
    @file = @file.chars.map(&filter).pack('U*').force_encoding('utf-8')
  end

  @@parsers.each { |parser| instance_exec(&parser) }

  # add index markers for major sections
  CONTENTS.each do |section, index|
    @sections[section][:index] = index if @sections[section]
  end

  # look for flags
  flagged_reports = Hash[@file[/ \d\. Committee Reports.*?\n\s+A\./m].
    scan(/# (.*?) \[(.*)\]/)]

  president = @sections.values.find {|item| item['title'] == 'President'}
  preports = Range.new(*president['report'][/\d+ through \d+\.$/].scan(/\d+/)) 
  # cleanup text and comment whitespace, add flags
  @sections.each do |section, hash|
    text = hash['text'] || hash['report']
    if text
      text.sub!(/\A\s*\n/, '')
      text.sub!(/\s+\Z/, '')
      unindent = text.sub(/s+\Z/,'').scan(/^ *\S/).map(&:length).min || 1
      text.gsub! /^ {#{unindent-1}}/, ''
    end

    text = hash['comments']
    if text
      text.sub!(/\A\s*\n/, '')
      text.sub!(/\s+\Z/, '')
      unindent = text.sub(/s+\Z/,'').scan(/^ *\S/).map(&:length).min || 1
      text.gsub! /^ {#{unindent-1}}/, ''
    end

    # add flags
    flags = flagged_reports[hash['title']]
    hash['flagged_by'] = flags.split(', ') if flags

    # mark president reports
    hash['to'] = 'president' if preports.include? section
  end

  unless @quick
    # add roster and prior report link
    whimsy = 'https://whimsy.apache.org'
    @sections.each do |section, hash|
      next unless section =~ /^(4[A-Z]|\d+|[A-Z][A-Z]?)$/
      committee = ASF::Committee.find(hash['title'] ||= 'UNKNOWN')
      unless section =~ /^4[A-Z]$/
        hash['roster'] = 
          "#{whimsy}/roster/committee/#{CGI.escape committee.name}"
      end
      if section =~ /^[A-Z][A-Z]?$/
        hash['stats'] = 
          "https://reporter.apache.org/?#{CGI.escape committee.name}"
      end
      hash['prior_reports'] = minutes(committee.display_name)
    end
  end

  # add attach to section
  @sections.each do |section, hash|
    hash[:attach] = section
  end

  # look for missing titles
  @sections.each do |section, hash|
    hash['title'] ||= "UNKNOWN"

    if hash['title'] == "UNKNOWN"
      hash['warnings'] = ['unable to find attachment']
    end
  end

  @sections.values
end

#scan(text, pattern, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/whimsy/asf/agenda.rb', line 35

def scan(text, pattern, &block)
  # convert tabs to spaces
  text.gsub!(/^(\t+)/) {|tabs| ' ' * (8*tabs.length)}

  text.scan(pattern).each do |matches|
    hash = Hash[pattern.names.zip(matches)]
    yield hash if block

    section = hash.delete('section')
    section ||= hash.delete('attach')

    if section
      hash['approved'] &&= hash['approved'].strip.split(/[ ,]+/)

      @sections[section] ||= {}
      next if hash['text'] and @sections[section]['text']
      @sections[section].merge!(hash)
    end
  end
end

#timestamp(time) ⇒ Object



143
144
145
146
147
# File 'lib/whimsy/asf/agenda.rb', line 143

def timestamp(time)
  date = @file[/(\w+ \d+, \d+)/]
  tz = TZInfo::Timezone.get('America/Los_Angeles')
  tz.local_to_utc(Time.parse("#{date} #{time}")).to_i * 1000
end