Class: ASF::Podling
- Inherits:
-
Object
- Object
- ASF::Podling
- Extended by:
- Enumerable
- Includes:
- Enumerable
- Defined in:
- lib/whimsy/asf/podlings.rb
Instance Attribute Summary collapse
-
#champion ⇒ Object
Returns the value of attribute champion.
-
#description ⇒ Object
Returns the value of attribute description.
-
#mentors ⇒ Object
Returns the value of attribute mentors.
-
#name ⇒ Object
map resource to name.
-
#reporting ⇒ Object
lazy evaluation of reporting.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
-
.each(&block) ⇒ Object
provide a list of podling names and descriptions.
-
.find(name) ⇒ Object
find a podling by name.
-
.list ⇒ Object
list of podlings.
-
.to_h ⇒ Object
return the entire list as a hash.
Instance Method Summary collapse
-
#[](name) ⇒ Object
allow attributes to be accessed as hash.
-
#display_name ⇒ Object
map name to display_name.
-
#enddate ⇒ Object
parse enddate.
-
#id ⇒ Object
also map resource to id.
-
#initialize(node) ⇒ Podling
constructor
create a podling from a Nokogiri node built from podlings.xml.
-
#quarter ⇒ Object
three consecutive months, starting with this one.
-
#startdate ⇒ Object
parse startdate.
Constructor Details
#initialize(node) ⇒ Podling
create a podling from a Nokogiri node built from podlings.xml
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/whimsy/asf/podlings.rb', line 20 def initialize(node) @name = node['name'] @resource = node['resource'] @status = node['status'] @enddate = node['enddate'] @startdate = node['startdate'] @description = node.at('description').text @mentors = node.search('mentor').map {|mentor| mentor['username']} @champion = node.at('champion')['availid'] if node.at('champion') @reporting = node.at('reporting') end |
Instance Attribute Details
#champion ⇒ Object
Returns the value of attribute champion.
8 9 10 |
# File 'lib/whimsy/asf/podlings.rb', line 8 def champion @champion end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/whimsy/asf/podlings.rb', line 8 def description @description end |
#mentors ⇒ Object
Returns the value of attribute mentors.
8 9 10 |
# File 'lib/whimsy/asf/podlings.rb', line 8 def mentors @mentors end |
#name ⇒ Object
map resource to name
34 35 36 |
# File 'lib/whimsy/asf/podlings.rb', line 34 def name @name end |
#reporting ⇒ Object
lazy evaluation of reporting
67 68 69 |
# File 'lib/whimsy/asf/podlings.rb', line 67 def reporting @reporting end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/whimsy/asf/podlings.rb', line 8 def status @status end |
Class Method Details
.each(&block) ⇒ Object
provide a list of podling names and descriptions
119 120 121 |
# File 'lib/whimsy/asf/podlings.rb', line 119 def self.each(&block) list.each {|podling| block.call podling.name, podling} end |
.find(name) ⇒ Object
find a podling by name
102 103 104 |
# File 'lib/whimsy/asf/podlings.rb', line 102 def self.find(name) list.find {|podling| podling.name == name} end |
.list ⇒ Object
list of podlings
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/whimsy/asf/podlings.rb', line 86 def self.list incubator_content = ASF::SVN['asf/incubator/public/trunk/content'] podlings_xml = "#{incubator_content}/podlings.xml" if @mtime != File.mtime(podlings_xml) @list = [] podlings = Nokogiri::XML(File.read(podlings_xml)) podlings.search('podling').map do |node| @list << new(node) end end @list end |
.to_h ⇒ Object
return the entire list as a hash
114 115 116 |
# File 'lib/whimsy/asf/podlings.rb', line 114 def self.to_h Hash[self.to_a] end |
Instance Method Details
#[](name) ⇒ Object
allow attributes to be accessed as hash
124 125 126 |
# File 'lib/whimsy/asf/podlings.rb', line 124 def [](name) return self.send name if self.respond_to? name end |
#display_name ⇒ Object
map name to display_name
44 45 46 |
# File 'lib/whimsy/asf/podlings.rb', line 44 def display_name @name || @resource end |
#enddate ⇒ Object
parse enddate
58 59 60 61 62 63 64 |
# File 'lib/whimsy/asf/podlings.rb', line 58 def enddate return unless @enddate return Date.parse("#@enddate-15") if @enddate.length < 8 Date.parse(@enddate) rescue ArgumentError nil end |
#id ⇒ Object
also map resource to id
39 40 41 |
# File 'lib/whimsy/asf/podlings.rb', line 39 def id @resource end |
#quarter ⇒ Object
three consecutive months, starting with this one
11 12 13 14 15 16 17 |
# File 'lib/whimsy/asf/podlings.rb', line 11 def quarter [ Date.today.strftime('%B'), Date.today.next_month.strftime('%B'), Date.today.next_month.next_month.strftime('%B') ] end |
#startdate ⇒ Object
parse startdate
49 50 51 52 53 54 55 |
# File 'lib/whimsy/asf/podlings.rb', line 49 def startdate return unless @startdate return Date.parse("#@startdate-15") if @startdate.length < 8 Date.parse(@startdate) rescue ArgumentError nil end |