Class: ASF::Member

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/whimsy/asf/member.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full = nil) ⇒ Member

Returns a new instance of Member.



49
50
51
# File 'lib/whimsy/asf/member.rb', line 49

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

Instance Attribute Details

#fullObject

Returns the value of attribute full.



4
5
6
# File 'lib/whimsy/asf/member.rb', line 4

def full
  @full
end

Class Method Details

.each(&block) ⇒ Object



13
14
15
# File 'lib/whimsy/asf/member.rb', line 13

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

.emails(text) ⇒ Object



68
69
70
71
# File 'lib/whimsy/asf/member.rb', line 68

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

.find(id) ⇒ Object



63
64
65
66
# File 'lib/whimsy/asf/member.rb', line 63

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

.find_by_email(value) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/whimsy/asf/member.rb', line 25

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

.find_text_by_id(value) ⇒ Object



6
7
8
9
10
11
# File 'lib/whimsy/asf/member.rb', line 6

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

.listObject



17
18
19
20
21
22
23
# File 'lib/whimsy/asf/member.rb', line 17

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

.statusObject



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

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

.svn_changeObject



73
74
75
76
77
# File 'lib/whimsy/asf/member.rb', line 73

def self.svn_change
  foundation = ASF::SVN['private/foundation']
  file = "#{foundation}/members.txt"
  return Time.parse(`svn info #{file}`[/Last Changed Date: (.*) \(/, 1]).gmtime
end

Instance Method Details

#eachObject



53
54
55
56
57
58
59
60
61
# File 'lib/whimsy/asf/member.rb', line 53

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