class ASF::OrgChart

Reads and provides access to the officers/personnel-duties/ROLENAME.yaml files.

Public Class Methods

[](name) click to toggle source

Access data from a specific role

# File lib/whimsy/asf/orgchart.rb, line 44
def self.[](name)
  self.load
  @@duties[name]
end
desc() click to toggle source

Access descriptions of the ['info'] section fields

# File lib/whimsy/asf/orgchart.rb, line 51
def self.desc
  self.load
  @@desc
end
load() click to toggle source

parse any changed YAML role files.

# File lib/whimsy/asf/orgchart.rb, line 14
def self.load
  @@source ||= ASF::SVN['private/foundation/officers/personnel-duties']
  @@source.untaint
  Dir["#{@@source}/*.txt"].each do |file|
    file.untaint # Since it's our own svn repo, trust it
    name = file[/.*\/(.*?)\.txt/, 1]
    next if @@duties[name] and @@duties[name]['mtime'] > File.mtime(file).to_f
    data = Hash[*File.read(file).split(/^\[(.*)\]\n/)[1..-1].map(&:strip)]
    next unless data['info']
    data['info'] = YAML.load(data['info'])
    data['mtime'] = File.mtime(file).to_f
    @@duties[name] = data
  end
  
  file = "#{@@source}/README".untaint
  unless @@desc['mtime'] and @@desc['mtime'] > File.mtime(file).to_f
    data = Hash[*File.read(file).split(/^\[(.*)\]\n/)[1..-1].map(&:strip)]
    if data['info'] then
      data = YAML.load(data['info'])
      data['mtime'] = File.mtime(file).to_f
      @@desc = data
    end
  end
  
  @@duties
end