Skip to content

Commit

Permalink
add a quick (no LDAP) parse option
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Feb 20, 2015
1 parent b1407e4 commit 68b6ee9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 57 deletions.
2 changes: 1 addition & 1 deletion asf.version
@@ -1 +1 @@
0.0.9
0.0.10
27 changes: 15 additions & 12 deletions lib/whimsy/asf/agenda.rb
Expand Up @@ -23,9 +23,9 @@ class ASF::Board::Agenda
}

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

def initialize
Expand All @@ -50,8 +50,9 @@ def scan(text, pattern, &block)
end
end

def parse(file)
def parse(file, quick=false)
@file = file
@quick = quick

if not @file.valid_encoding?
filter = Proc.new {|c| c.unpack('U').first rescue 0xFFFD}
Expand Down Expand Up @@ -84,16 +85,18 @@ def parse(file)
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}"
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
hash['prior_reports'] = minutes(committee.display_name)
end
hash['prior_reports'] = minutes(committee.display_name)
end

# add attach to section
Expand Down
14 changes: 8 additions & 6 deletions lib/whimsy/asf/agenda/attachments.rb
Expand Up @@ -32,12 +32,14 @@ class ASF::Board::Agenda

attrs['missing'] = true if attrs['report'].strip.empty?

begin
committee = ASF::Committee.find(attrs['title'])
attrs['chair_email'] = committee.chair.mail.first
attrs['mail_list'] = committee.mail_list
attrs.delete('mail_list') if attrs['mail_list'].include? ' '
rescue
unless @quick
begin
committee = ASF::Committee.find(attrs['title'])
attrs['chair_email'] = committee.chair.mail.first
attrs['mail_list'] = committee.mail_list
attrs.delete('mail_list') if attrs['mail_list'].include? ' '
rescue
end
end

if attrs['report'].to_s.include? "\uFFFD"
Expand Down
78 changes: 40 additions & 38 deletions lib/whimsy/asf/agenda/front.rb
Expand Up @@ -20,52 +20,54 @@ class ASF::Board::Agenda

absent = attr['text'].scan(/Absent:\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 |sname|
name = sname
unless @quick
# attempt to identify the people mentioned in the Roll Call
people = attr['text'].scan(/ {8}(\w.*)/).flatten.each do |sname|
name = sname

# first try the cache
person = @@people_cache[name]
# first try the cache
person = @@people_cache[name]

# next try a simple name look up
if not person
search = ASF::Person.list("cn=#{name}")
person = search.first if search.length == 1
end
# next try a simple name look up
if not person
search = ASF::Person.list("cn=#{name}")
person = search.first if search.length == 1
end

# finally try harder to match the name
if not person
sname = sname.strip.downcase.split(/\s+/)
# finally try harder to match the name
if not person
sname = sname.strip.downcase.split(/\s+/)

if not list
ASF::Person.preload('cn')
list = ASF::Person.list
end
if not list
ASF::Person.preload('cn')
list = ASF::Person.list
end

search = []
list.select do |person|
next if person == 'none'
pname = person.public_name.downcase.split(/\s+/)
if sname.all? {|t1| pname.any? {|t2| t2.start_with? t1}}
search << person
elsif pname.all? {|t1| sname.any? {|t2| t2.start_with? t1}}
search << person
end
end
search = []
list.select do |person|
next if person == 'none'
pname = person.public_name.downcase.split(/\s+/)
if sname.all? {|t1| pname.any? {|t2| t2.start_with? t1}}
search << person
elsif pname.all? {|t1| sname.any? {|t2| t2.start_with? t1}}
search << person
end
end

person = search.first if search.length == 1
end
person = search.first if search.length == 1
end

# save results in both the cache and the attributes
if person
@@people_cache[name] = person
# save results in both the cache and the attributes
if person
@@people_cache[name] = person

attr['people'][person.id] = {
name: name,
member: person.asf_member?,
attending: !absent.include?(name)
}
end
attr['people'][person.id] = {
name: name,
member: person.asf_member?,
attending: !absent.include?(name)
}
end
end
end
elsif attr['title'] == 'Call to order'
attr['timestamp'] = timestamp(attr['text'][/\d+:\d+([ap]m)?/])
Expand Down
2 changes: 2 additions & 0 deletions lib/whimsy/asf/agenda/special.rb
Expand Up @@ -43,6 +43,8 @@ class ASF::Board::Agenda
attrs.delete 'indent'
attrs.delete 'warnings' if attrs['warnings'].empty?

next if @quick

asfid = '[a-z][-.a-z0-9_]+' # dot added to help detect errors
list_item = '^\s*(?:[-*\u2022]\s*)?(.*?)\s+'

Expand Down

0 comments on commit 68b6ee9

Please sign in to comment.