You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/10/25 00:05:04 UTC
[whimsy] branch master updated: Move ASF::Site code to
ASF::Committee
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 0aaf3c8 Move ASF::Site code to ASF::Committee
0aaf3c8 is described below
commit 0aaf3c8c228bb07fb9f1f84ce2747391a957762f
Author: Sebb <se...@apache.org>
AuthorDate: Fri Oct 25 01:05:00 2019 +0100
Move ASF::Site code to ASF::Committee
ASF::Committee now processes committee-info.txt and committee-info.yaml
---
lib/spec/lib/{site_spec.rb => committee_spec.rb} | 24 +++----
lib/whimsy/asf.rb | 1 -
lib/whimsy/asf/committee.rb | 73 ++++++++++++++++++++-
lib/whimsy/asf/site.rb | 80 ------------------------
www/board/agenda/views/actions/todos.json.rb | 2 +-
5 files changed, 82 insertions(+), 98 deletions(-)
diff --git a/lib/spec/lib/site_spec.rb b/lib/spec/lib/committee_spec.rb
similarity index 74%
rename from lib/spec/lib/site_spec.rb
rename to lib/spec/lib/committee_spec.rb
index f5f8a8b..f574257 100644
--- a/lib/spec/lib/site_spec.rb
+++ b/lib/spec/lib/committee_spec.rb
@@ -1,11 +1,10 @@
# encoding: utf-8
# frozen_string_literal: true
-# test ASF::Site
require 'spec_helper'
require 'whimsy/asf'
-describe ASF::Site do
+describe ASF::Committee do
describe "ASF::Committee::site" do
it "should return string for 'httpd'" do
res = ASF::Committee.find('HTTP Server').site
@@ -28,52 +27,49 @@ describe ASF::Site do
expect(res.class).to eq(NilClass)
end
end
-end
-describe ASF::Site do
-
- describe "ASF::Site.find" do
+ describe "ASF::Committee.metadata" do
it "should return hash for 'httpd'" do
- res = ASF::Site.find('httpd')
+ res = ASF::Committee.metadata('httpd')
expect(res.class).to eq(Hash)
expect(res[:site]).to match(%r{https?://httpd\.apache\.org/?})
end
it "should return nil for 'z-z-z'" do
- res = ASF::Site.find('z-z-z')
+ res = ASF::Committee.metadata('z-z-z')
expect(res.class).to eq(NilClass)
end
it "should return hash for 'httpd Committee'" do
cttee = ASF::Committee.find('HTTP Server')
- res = ASF::Site.find(cttee)
+ res = ASF::Committee.metadata(cttee)
expect(res.class).to eq(Hash)
expect(res[:site]).to match(%r{https?://httpd\.apache\.org/?})
end
it "should return hash for 'comdev'" do
- res = ASF::Site.find('comdev')
+ res = ASF::Committee.metadata('comdev')
expect(res.class).to eq(Hash)
expect(res[:site]).to match(%r{https?://community\.apache\.org/?})
end
end
- describe "ASF::Site.appendtlp" do
+ describe "ASF::Committee.appendtlpmetadata" do
board = ASF::SVN.find('board')
file = File.join(board, 'committee-info.yaml')
input = File.read(file)
it "should fail for 'httpd'" do
res = nil
# Wunderbar.logger = nil; is needed to ensure logging output works as expected
- expect { Wunderbar.logger = nil; res = ASF::Site.appendtlp(input,'httpd','description') }.to output("_WARN Entry for 'httpd' already exists under :tlps\n").to_stderr
+ expect { Wunderbar.logger = nil; res = ASF::Committee.appendtlpmetadata(input,'httpd','description') }.to output("_WARN Entry for 'httpd' already exists under :tlps\n").to_stderr
expect(res).to equal(input)
end
it "should fail for 'comdev'" do
res = nil
# Wunderbar.logger = nil; is needed to ensure logging output works as expected
- expect { Wunderbar.logger = nil; res = ASF::Site.appendtlp(input,'comdev','description') }.to output("_WARN Entry for 'comdev' already exists under :cttees\n").to_stderr
+ expect { Wunderbar.logger = nil; res = ASF::Committee.appendtlpmetadata(input,'comdev','description') }.to output("_WARN Entry for 'comdev' already exists under :cttees\n").to_stderr
expect(res).to equal(input)
end
@@ -81,7 +77,7 @@ describe ASF::Site do
it "should succeed for '#{pmc}'" do
res = nil
desc = 'Description of A-B-C'
- expect { res = ASF::Site.appendtlp(input,pmc,desc) }.to output("").to_stderr
+ expect { res = ASF::Committee.appendtlpmetadata(input,pmc,desc) }.to output("").to_stderr
expect(res).not_to eq(input)
tlps = YAML.load(res)[:tlps]
abc = tlps[pmc]
diff --git a/lib/whimsy/asf.rb b/lib/whimsy/asf.rb
index 60d2f0e..d1ba48b 100644
--- a/lib/whimsy/asf.rb
+++ b/lib/whimsy/asf.rb
@@ -9,7 +9,6 @@ require_relative 'asf/nominees'
require_relative 'asf/icla'
require_relative 'asf/auth'
require_relative 'asf/member'
-require_relative 'asf/site'
require_relative 'asf/podling'
require_relative 'asf/person'
require_relative 'asf/themes'
diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb
index aa7f559..047d027 100644
--- a/lib/whimsy/asf/committee.rb
+++ b/lib/whimsy/asf/committee.rb
@@ -10,8 +10,8 @@ module ASF
#
# Representation for a committee (either a PMC, a board committee, or
# a President's committee). This data is parsed from
- # <tt>committee-info.txt</tt>, and is augmened by data from LDAP,
- # ASF::Site, and ASF::Mail.
+ # <tt>committee-info.txt|.yaml</tt>, and is augmened by data from LDAP,
+ # and ASF::Mail.
#
# Note that the simple attributes which are sourced from
# <tt>committee-info.txt</tt> data is generally not available until
@@ -592,5 +592,74 @@ module ASF
Committee.load_committee_info # ensure data is there
Committee.pmcs.include? self
end
+
+
+ # load committee metadata from <tt>committee-info.yaml</tt>. Will not reparse
+ # if the file has already been parsed and the underlying file has not changed.
+ def self.load_committee_metadata()
+ board = ASF::SVN.find('board')
+ return unless board
+ file = File.join(board, 'committee-info.yaml')
+ return unless File.exist? file
+
+ return @committee_metadata if @committee_metadata and @committee_metadata_mtime and File.mtime(file) <= @committee_metadata_mtime
+
+ @committee_metadata_mtime = File.mtime(file)
+ @committee_metadata = YAML.load_file file
+ end
+
+ # get the metadata for a given committee.
+ def self.metadata(committee)
+ committee = committee.name if committee.is_a? ASF::Committee
+ load_committee_metadata[:tlps][committee] || load_committee_metadata[:cttees][committee]
+ end
+
+
+ # website for this committee.
+ def site()
+ meta = ASF::Committee.metadata(name)
+ meta[:site] if meta
+ end
+
+ # description for this committee.
+ def description()
+ meta = ASF::Committee.metadata(name)
+ meta[:description] if meta
+ end
+
+
+ # append the description for a new tlp committee.
+ # this is intended to be called from todos.json.rb in the block for ASF::SVN.update
+ def self.appendtlpmetadata(input,committee,description)
+ output = input # default no change
+ yaml = YAML.load input
+ if yaml[:cttees][committee]
+ Wunderbar.warn "Entry for '#{committee}' already exists under :cttees"
+ elsif yaml[:tlps][committee]
+ Wunderbar.warn "Entry for '#{committee}' already exists under :tlps"
+ else
+ data = { # create single entry in :tlps hierarchy
+ tlps: {
+ committee => {
+ site: "http://#{committee}.apache.org",
+ description: description,
+ }
+ }
+ }
+ # Use YAML dump to ensure correct syntax
+ # drop the YAML header
+ newtlp = YAML.dump(data).sub(%r{^---\n:tlps:\n}m,'')
+ # add the new section just before the ... terminator
+ output = input.sub(%r{^\.\.\.},newtlp+"...")
+ # Check it worked
+ check = YAML.load(output)
+ unless data[:tlps][committee] == check[:tlps][committee]
+ Wunderbar.warn "Failed to add section for #{committee}"
+ output = input # don't change anything
+ end
+ end
+ output
+ end
+
end
end
diff --git a/lib/whimsy/asf/site.rb b/lib/whimsy/asf/site.rb
deleted file mode 100644
index ef127cf..0000000
--- a/lib/whimsy/asf/site.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require 'yaml'
-
-module ASF
-
- # A list of ASF sites, formed by parsing
- # <tt>private/committers/board/committee-info.yaml</tt> from svn.
-
- class Site
- @@list = {}
- @@mtime = 0
-
- # parse the data file
- def self.list
- board = ASF::SVN.find('board')
- file = File.join(board, 'committee-info.yaml')
- if not File.exist?(file)
- Wunderbar.error "Unable to find 'committee-info.yaml'"
- return {}
- end
- return @@list if not @@list.empty? and File.mtime(file) == @@mtime
- yaml = YAML.load_file file
- @@mtime = File.mtime(file)
- @@list = yaml[:cttees].merge yaml[:tlps]
- end
-
- # find the data for a given committee.
- def self.find(committee)
- committee = committee.name if committee.is_a? ASF::Committee
- list[committee]
- end
-
- # append the description for a new tlp committee.
- # this is intended to be called from todos.json.rb in the block for ASF::SVN.update
- def self.appendtlp(input,committee,description)
- output = input # default no change
- yaml = YAML.load input
- if yaml[:cttees][committee]
- Wunderbar.warn "Entry for '#{committee}' already exists under :cttees"
- elsif yaml[:tlps][committee]
- Wunderbar.warn "Entry for '#{committee}' already exists under :tlps"
- else
- data = { # create single entry in :tlps hierarchy
- tlps: {
- committee => {
- site: "http://#{committee}.apache.org",
- description: description,
- }
- }
- }
- # Use YAML dump to ensure correct syntax
- # drop the YAML header
- newtlp = YAML.dump(data).sub(%r{^---\n:tlps:\n}m,'')
- # add the new section just before the ... terminator
- output = input.sub(%r{^\.\.\.},newtlp+"...")
- # Check it worked
- check = YAML.load(output)
- unless data[:tlps][committee] == check[:tlps][committee]
- Wunderbar.warn "Failed to add section for #{committee}"
- output = input # don't change anything
- end
- end
- output
- end
-
- end
-
- class Committee
- # website for this committee. Data is sourced from ASF::Site.
- def site
- site = ASF::Site.find(name)
- site[:site] if site
- end
-
- # description for this committee. Data is sourced from ASF::Site.
- def description
- site = ASF::Site.find(name)
- site[:description] if site
- end
- end
-end
diff --git a/www/board/agenda/views/actions/todos.json.rb b/www/board/agenda/views/actions/todos.json.rb
index 6503589..6883025 100644
--- a/www/board/agenda/views/actions/todos.json.rb
+++ b/www/board/agenda/views/actions/todos.json.rb
@@ -135,7 +135,7 @@ if @establish and env.password
# # update ci.yaml
# cinfoy = File.join(ASF::SVN['board'], 'committee-info.yaml')
# ASF::SVN.update cinfoy, title, env, _ do |tmpdir, contents|
-# ASF::Site.append(contents,pmc.downcase,charter)
+# ASF::Committee.appendtlpmetadata(contents,pmc.downcase,charter)
# end
# end
end