1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/usr/bin/ruby -w
require 'rexml/document'
include REXML
module ProjectHelper
class ProjectMember
attr_reader :role, :description, :developer, :project
attr_writer :role, :description, :developer, :project
def initialize()
end
end
class Project
attr_reader :name, :longname, :lastUpdated, :description, :members
attr_writer :name, :longname, :lastUpdated, :description, :members
def initialize()
self.members = []
end
def get_member_by_handle(handle)
end
end
def yank_single_text(elements, target)
result = nil
elements.each(target) do |node|
result = node.text
end
return result
end
def yank_attribute(node, target)
node.attributes[target]
end
def ProjectHelper.indexProjects(developers)
projects = []
target_dir = "/local/home/checkouts/gentoo-website/xml/htdocs/proj/*/**/index.xml"
Dir.glob(target_dir).each do |index|
puts "Reading #{index}..."
project = Project.new()
doc = Document.new(File.new(index))
root = doc.root
project.name = yank_single_text(root.elements, 'name')
if project.name.nil?
puts "No <name> defined in #{index}... trying to guess"
project.name = File.basename(File.dirname(index))
end
project.longname = yank_single_text(root.elements, 'longname')
project.description = yank_single_text(root.elements, 'description')
root.elements.each('dev') do |devnode|
developer = developers["#{devnode.text}@gentoo.org"]
member = ProjectMember.new
member.role = yank_attribute(devnode, 'role')
member.description = yank_attribute(devnode, 'description')
member.developer = developer
member.project = project
developer.projectMembership[project.name] = member unless developer.nil?
project.members.push(member)
end
projects.push(project)
end
return projects
end
def ProjectHelper.print(projects)
projects.each do |project|
puts "*#{project.name}:"
puts "\tLong Name: #{project.longname}"
puts "\tDescription: #{project.description}"
puts "\tMembers:"
project.members.each do |member|
puts "\t\tHandle: #{member.handle}"
puts "\t\tRole: #{member.role}"
puts "\t\tDescription: #{member.description}"
puts
end
end
end
end
|