diff options
author | 2006-08-26 05:55:19 +0000 | |
---|---|---|
committer | 2006-08-26 05:55:19 +0000 | |
commit | bfed19842e9ef2e421dda243b885b6cc80a8a32e (patch) | |
tree | 1b4e823a5a414135b8304c4aff0c895b32ed0956 | |
parent | Generalized error to catch for parsing rss... since most people's rss is brok... (diff) | |
download | nichoj-bfed19842e9ef2e421dda243b885b6cc80a8a32e.tar.gz nichoj-bfed19842e9ef2e421dda243b885b6cc80a8a32e.tar.bz2 nichoj-bfed19842e9ef2e421dda243b885b6cc80a8a32e.zip |
Added projectparser. Updated developer and devdashboard accordingly.
svn path=/; revision=62
-rwxr-xr-x | projects/devdashboard/devdashboard.rb | 9 | ||||
-rw-r--r-- | projects/devdashboard/developer.rb | 42 | ||||
-rw-r--r-- | projects/devdashboard/projectparser.rb | 92 |
3 files changed, 123 insertions, 20 deletions
diff --git a/projects/devdashboard/devdashboard.rb b/projects/devdashboard/devdashboard.rb index 63d3165..a0d57f4 100755 --- a/projects/devdashboard/devdashboard.rb +++ b/projects/devdashboard/devdashboard.rb @@ -6,11 +6,13 @@ require 'userinfo' require 'docparser' require 'planetiniparser' require 'metadataparser' +require 'projectparser' include Herds include UserInfo include PlanetIniParser include MetadataHelper +include ProjectHelper #dev = Developer.new # @@ -23,13 +25,12 @@ include MetadataHelper developers = UserInfo.indexUsers() herds = Herds.indexHerds(developers) +projects = ProjectHelper.indexProjects(developers) PlanetIniParser.updateDevs(developers) developers.each do |email, dev| - if dev.status == 'active' - dev.print - puts - end + dev.print + puts end diff --git a/projects/devdashboard/developer.rb b/projects/devdashboard/developer.rb index ff34f71..27954fb 100644 --- a/projects/devdashboard/developer.rb +++ b/projects/devdashboard/developer.rb @@ -4,12 +4,13 @@ require 'rss/2.0' require 'open-uri' class Developer - attr_reader :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation, :packages, :status - attr_writer :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation, :packages, :status + attr_reader :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation, :packages, :status, :projects, :projectMembership + attr_writer :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation, :packages, :status, :projectMembership def initialize() self.herds = Array.new self.packages = Array.new + self.projectMembership = {} end def ciaRss() @@ -66,19 +67,19 @@ class Developer puts "Email: #{self.email}" puts "PGP Key: #{self.pgpkey}" unless self.pgpkey.nil? puts "Roles: #{self.roles}" unless self.roles.nil? - unless self.herds.empty? - puts "Herds: " + unless self.herds.nil? + puts "Herds: (#{self.herds.size})" self.herds.each { |herd| puts "\t#{herd.name}"} end puts "Joined: #{self.joined}" unless self.joined.nil? puts "Birthday: #{self.birthday}" unless self.birthday.nil? puts "Location: #{self.location}" unless self.location.nil? - unless self.blogRss.nil? - puts "Blog RSS: #{self.blogRss}" - puts "Blog Posts: " - self.blogItems.each { |item| puts "\t#{item.title}" } - puts "Hackergotchi: #{self.hackergotchi}" unless self.hackergotchi.nil? - end +# unless self.blogRss.nil? +# puts "Blog RSS: #{self.blogRss}" +# puts "Blog Posts: " +# self.blogItems.each { |item| puts "\t#{item.title}" } +# puts "Hackergotchi: #{self.hackergotchi}" unless self.hackergotchi.nil? +# end #puts "Commits RSS: #{self.ciaRss}" #puts "Commits: " #self.commitItems.each { |item| puts "\t#{item.title}" } @@ -89,11 +90,20 @@ class Developer self.packages.each { |package| puts "\t#{package}" } end - unless self.documentation.nil? - puts "Documentation:" - self.documentation.each do |doc| - puts "\t#{doc.title} : #{doc.role}" - end - end + unless self.projectMembership.nil? + puts "Projects: (#{self.projectMembership.size})" + self.projectMembership.each do |key, membership| + puts "\tProject: #{key}" + puts "\tRole: #{membership.role}" unless membership.role.nil? + puts "\tDescription: #{membership.description}" unless membership.description.nil? + puts + end + unless self.documentation.nil? + puts "Documentation:" + self.documentation.each do |doc| + puts "\t#{doc.title} : #{doc.role}" + end + end + end end end diff --git a/projects/devdashboard/projectparser.rb b/projects/devdashboard/projectparser.rb new file mode 100644 index 0000000..290cb12 --- /dev/null +++ b/projects/devdashboard/projectparser.rb @@ -0,0 +1,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 |