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 =
[]
@@people_cache =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Agenda

Returns a new instance of Agenda.



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

def initialize
  @sections = {}
end

Class Method Details

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



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

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

Instance Method Details

#minutes(title) ⇒ Object



100
101
102
# File 'lib/whimsy/asf/agenda.rb', line 100

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

#parse(file) ⇒ Object



52
53
54
55
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
# File 'lib/whimsy/asf/agenda.rb', line 52

def parse(file)
  @file = file
  @@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

  # cleanup text and comment whitespace
  @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
  end

  # 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
    hash['prior_reports'] = minutes(committee.display_name)
  end

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

  @sections.values
end

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



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

def scan(text, pattern, &block)
  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



104
105
106
107
108
# File 'lib/whimsy/asf/agenda.rb', line 104

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