Sha256: acf67aa6d690329b02b6ec654b7590c8c5d000f5273c62c2addc68d2d8193089

Contents?: true

Size: 1.92 KB

Versions: 30

Compression:

Stored size: 1.92 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']
      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

30 entries across 30 versions & 1 rubygems

Version Path
whimsy-asf-0.0.30 lib/whimsy/asf/member.rb
whimsy-asf-0.0.29 lib/whimsy/asf/member.rb
whimsy-asf-0.0.28 lib/whimsy/asf/member.rb
whimsy-asf-0.0.27 lib/whimsy/asf/member.rb
whimsy-asf-0.0.26 lib/whimsy/asf/member.rb
whimsy-asf-0.0.25 lib/whimsy/asf/member.rb
whimsy-asf-0.0.24 lib/whimsy/asf/member.rb
whimsy-asf-0.0.23 lib/whimsy/asf/member.rb
whimsy-asf-0.0.22 lib/whimsy/asf/member.rb
whimsy-asf-0.0.21 lib/whimsy/asf/member.rb
whimsy-asf-0.0.20 lib/whimsy/asf/member.rb
whimsy-asf-0.0.19 lib/whimsy/asf/member.rb
whimsy-asf-0.0.18 lib/whimsy/asf/member.rb
whimsy-asf-0.0.17 lib/whimsy/asf/member.rb
whimsy-asf-0.0.16 lib/whimsy/asf/member.rb
whimsy-asf-0.0.15 lib/whimsy/asf/member.rb
whimsy-asf-0.0.14 lib/whimsy/asf/member.rb
whimsy-asf-0.0.13 lib/whimsy/asf/member.rb
whimsy-asf-0.0.12 lib/whimsy/asf/member.rb
whimsy-asf-0.0.11 lib/whimsy/asf/member.rb