You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sebastian Bazley <se...@apache.org> on 2016/03/10 23:22:08 UTC
[whimsy.git] [1/1] Commit 4420daa: Use common json handling
Commit 4420daab9a61e1206b91c830cb2e344016f32cb3:
Use common json handling
Branch: refs/heads/master
Author: Sebb <se...@apache.org>
Committer: Sebb <se...@apache.org>
Pusher: sebb <se...@apache.org>
------------------------------------------------------------
www/roster/public_committee_info.rb | +++++ ----
------------------------------------------------------------
66 changes: 37 additions, 29 deletions.
------------------------------------------------------------
diff --git a/www/roster/public_committee_info.rb b/www/roster/public_committee_info.rb
index 2735213..42332f0 100644
--- a/www/roster/public_committee_info.rb
+++ b/www/roster/public_committee_info.rb
@@ -1,33 +1,43 @@
-require 'bundler/setup'
+# Creates JSON output from committee-info.txt with the following format:
+#{
+# "last_updated": "2016-03-04 04:50:00 UTC",
+# "committees": {
+# "abdera": {
+# "display_name": "Abdera",
+# "site": "http://abdera.apache.org/",
+# "description": "Atom Publishing Protocol Implementation",
+# "mail_list": "abdera",
+# "established": "11/2008",
+# "report": [
+# "Next month: missing in February",
+# "February",
+# "May",
+# "August",
+# "November"
+# ],
+# "chair": {
+# "availid": {
+# "name": "Some One"
+# }
+# },
+# "roster": {
+# "availid": {
+# "name": "Some One",
+# "date": "2009-10-21"
+# },
+# ...
+# },
+# "pmc": true
+# },
-require 'json'
-require 'whimsy/asf'
-
-GEMVERSION = Gem.loaded_specs['whimsy-asf'].version.to_s rescue nil
- # rescue is to allow for running with local library rather than a Gem
-
-# parse arguments for output file name
-if ARGV.length == 0 or ARGV.first == '-'
- output = STDOUT
-else
- # exit quickly if there has been no change
- if File.exist? ARGV.first
- source = "#{ASF::SVN['private/committers/board']}/committee-info.txt"
- lib = File.expand_path('../../../lib', __FILE__)
- mtime = Dir["#{lib}/**/*"].map {|file| File.mtime(file)}.max
- mtime = [mtime, File.mtime(source), File.mtime(__FILE__)].max
- if File.mtime(ARGV.first) >= mtime
- previous_results = JSON.parse(File.read ARGV.first) rescue {}
- exit 0 if previous_results['gem_version'] == GEMVERSION
- end
- end
-
- output = File.open(ARGV.first, 'w')
-end
+require_relative 'public_json_common'
# gather committee info
committees = ASF::Committee.load_committee_info
-info = {last_updated: ASF::Committee.svn_change, gem_version: GEMVERSION}
+
+# reformat the data
+info = {last_updated: ASF::Committee.svn_change}
+
info[:committees] = Hash[committees.map {|committee|
schedule = committee.schedule.to_s.split(/,\s*/)
schedule.unshift committee.report if committee.report != committee.schedule
@@ -48,6 +58,4 @@
}]
}]
-# output results
-output.puts JSON.pretty_generate(info)
-output.close
+public_json_output(info)