Class: ASF::Member
- Inherits:
-
Object
- Object
- ASF::Member
- Includes:
- Enumerable
- Defined in:
- lib/whimsy/asf/member.rb
Instance Attribute Summary collapse
-
#full ⇒ Object
Returns the value of attribute full.
Class Method Summary collapse
- .each(&block) ⇒ Object
- .emails(text) ⇒ Object
- .find(id) ⇒ Object
- .find_by_email(value) ⇒ Object
- .find_text_by_id(value) ⇒ Object
- .list ⇒ Object
- .status ⇒ Object
- .svn_change ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#full ⇒ Object
Returns the value of attribute full.
6 7 8 |
# File 'lib/whimsy/asf/member.rb', line 6 def full @full end |
Class Method Details
.each(&block) ⇒ Object
15 16 17 |
# File 'lib/whimsy/asf/member.rb', line 15 def self.each(&block) new.each(&block) end |
.emails(text) ⇒ Object
77 78 79 80 |
# File 'lib/whimsy/asf/member.rb', line 77 def self.emails(text) emails = text.to_s.scan(/Email: (.*(?:\n\s+\S+@.*)*)/).flatten. join(' ').split(/\s+/).grep(/@/) end |
.find(id) ⇒ Object
72 73 74 75 |
# File 'lib/whimsy/asf/member.rb', line 72 def self.find(id) each {|availid| return true if availid == id} return false end |
.find_by_email(value) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/whimsy/asf/member.rb', line 33 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
8 9 10 11 12 13 |
# File 'lib/whimsy/asf/member.rb', line 8 def self.find_text_by_id(value) new.each do |id, text| return text if id==value end nil end |
.list ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/whimsy/asf/member.rb', line 19 def self.list result = Hash[self.new.map {|id, text| # extract 1st line and remove any trailing /* comment */ name = text[/(.*?)\n/, 1].sub(/\s+\/\*.*/,'') [id, {text: text, name: name}] }] self.status.each do |name, value| result[name]['status'] = value end result end |
.status ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/whimsy/asf/member.rb', line 43 def self.status begin return Hash[@status.to_a] if @status rescue NoMethodError, WeakRef::RefError end 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 = WeakRef.new(status) status end |
Instance Method Details
#each ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/whimsy/asf/member.rb', line 63 def each foundation = ASF::SVN['private/foundation'] File.read("#{foundation}/members.txt").split(/^ \*\) /).each do |section| id = section[/Avail ID: (.*)/,1] yield id, section.sub(/\n.*\n===+\s*?\n(.*\n)+.*/,'').strip if id end nil end |