Sha256: 46d65c982029e4919c4009c6eb796b10a13d1d7f1378e6ebb6dfad91e88fcf34

Contents?: true

Size: 1.96 KB

Versions: 37

Compression:

Stored size: 1.96 KB

Contents

module ASF
  class Member
    include Enumerable
    attr_accessor :full

    def self.find_text_by_id(value)
      new.each do |id, text|
        return text if id==value
      end
      nil
    end

    def self.each(&block)
      new.each(&block)
    end

    def self.list
      result = Hash[self.new(true).map {|name, text| [name, {text: text}]}]
      self.status.each do |name, value|
        result[name]['status'] = value
      end
      result
    end

    def self.find_by_email(value)
      value = value.downcase
      each do |id, text|
        emails(text).each do |email|
          return Person[id] if email.downcase == value
        end
      end
      nil
    end

    def self.status
      return @status if @status
      status = {}
      foundation = ASF::SVN['private/foundation']
      return status unless foundation
      sections = File.read("#{foundation}/members.txt").split(/(.*\n===+)/)
      sections.shift(3)
      sections.each_slice(2) do |header, text|
        header.sub!(/s\n=+/,'')
        text.scan(/Avail ID: (.*)/).flatten.each {|id| status[id] = header}
      end
      @status = status
    end

    def initialize(full = nil)
      @full = (full.nil? ? ASF::Person.new($USER).asf_member? : full)
    end

    def each
      foundation = ASF::SVN['private/foundation']
      File.read("#{foundation}/members.txt").split(/^ \*\) /).each do |section|
        id = section[/Avail ID: (.*)/,1]
        section = '' unless @full
        yield id, section.sub(/\n.*\n===+\s*?\n(.*\n)+.*/,'').strip if id
      end
      nil
    end

    def self.find(id)
      each {|availid| return true if availid == id}
      return false
    end

    def self.emails(text)
      emails = text.to_s.scan(/Email: (.*(?:\n\s+\S+@.*)*)/).flatten.
        join(' ').split(/\s+/).grep(/@/)
    end
  end

  class Person
    def members_txt
      @members_txt ||= ASF::Member.find_text_by_id(name)
    end

    def member_emails
      ASF::Member.emails(members_txt)
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
whimsy-asf-0.0.67 lib/whimsy/asf/member.rb
whimsy-asf-0.0.66 lib/whimsy/asf/member.rb
whimsy-asf-0.0.65 lib/whimsy/asf/member.rb
whimsy-asf-0.0.64 lib/whimsy/asf/member.rb
whimsy-asf-0.0.63 lib/whimsy/asf/member.rb
whimsy-asf-0.0.62 lib/whimsy/asf/member.rb
whimsy-asf-0.0.61 lib/whimsy/asf/member.rb
whimsy-asf-0.0.60 lib/whimsy/asf/member.rb
whimsy-asf-0.0.59 lib/whimsy/asf/member.rb
whimsy-asf-0.0.58 lib/whimsy/asf/member.rb
whimsy-asf-0.0.57 lib/whimsy/asf/member.rb
whimsy-asf-0.0.56 lib/whimsy/asf/member.rb
whimsy-asf-0.0.55 lib/whimsy/asf/member.rb
whimsy-asf-0.0.54 lib/whimsy/asf/member.rb
whimsy-asf-0.0.53 lib/whimsy/asf/member.rb
whimsy-asf-0.0.52 lib/whimsy/asf/member.rb
whimsy-asf-0.0.51 lib/whimsy/asf/member.rb
whimsy-asf-0.0.50 lib/whimsy/asf/member.rb
whimsy-asf-0.0.49 lib/whimsy/asf/member.rb
whimsy-asf-0.0.48 lib/whimsy/asf/member.rb