whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Initial implementation of podlings.xml as JSON output
Date Sat, 20 Aug 2016 21:06:16 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  f68af09   Initial implementation of podlings.xml as JSON output
f68af09 is described below

commit f68af09273e23c35bc3f58e0cbc5f14168cb71ff
Author: Sebb <sebb@apache.org>
AuthorDate: Sat Aug 20 22:06:08 2016 +0100

    Initial implementation of podlings.xml as JSON output
---
 lib/whimsy/asf/podlings.rb    | 27 ++++++++++++++
 www/roster/public_podlings.rb | 83 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+)

diff --git a/lib/whimsy/asf/podlings.rb b/lib/whimsy/asf/podlings.rb
index 7107623..bb139aa 100644
--- a/lib/whimsy/asf/podlings.rb
+++ b/lib/whimsy/asf/podlings.rb
@@ -167,6 +167,33 @@ module ASF
       return true if list.start_with?("incubator-#{_name}-")
     end
 
+    # Return the instance as a hash
+    def as_hash # might be confusing to use to_h here?
+      hash = {
+        name: @name,
+        status: status,
+        description: description,
+        mentors: mentors,
+        startdate: startdate,
+      }
+      hash[:enddate] = enddate if enddate
+      hash[:champion] = champion if champion
+
+      # Tidy up the reporting output
+      r = @reporting
+      if r.instance_of? Nokogiri::XML::Element
+        group = r['group']
+        hash[:reporting] = {
+          group: group
+        }
+        hash[:reporting][:text] = r.text if r.text.length > 0
+        hash[:reporting][:monthly] = r.text.split(/,\s*/) if r['monthly']
+      else
+        hash[:reporting] = r if r
+      end
+      hash
+    end
+
   end
 
   # more backwards compatibility
diff --git a/www/roster/public_podlings.rb b/www/roster/public_podlings.rb
new file mode 100644
index 0000000..276339a
--- /dev/null
+++ b/www/roster/public_podlings.rb
@@ -0,0 +1,83 @@
+##   Licensed to the Apache Software Foundation (ASF) under one or more
+##   contributor license agreements.  See the NOTICE file distributed with
+##   this work for additional information regarding copyright ownership.
+##   The ASF licenses this file to You under the Apache License, Version 2.0
+##   (the "License"); you may not use this file except in compliance with
+##   the License.  You may obtain a copy of the License at
+## 
+##       http://www.apache.org/licenses/LICENSE-2.0
+## 
+##   Unless required by applicable law or agreed to in writing, software
+##   distributed under the License is distributed on an "AS IS" BASIS,
+##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##   See the License for the specific language governing permissions and
+##   limitations under the License.
+
+# Reads the incubator podlings.xml file and generates a summary status file
+# If a second file name is provided, also generates a detailed file with all the fields
+#
+# Podling status file format:
+# {
+#   "last_updated": "2016-06-15 13:50:05 +0100",
+#   "podling": {
+#     "abdera": "graduated",
+#     ....
+#   }
+# }
+
+# Podling detailed file format:
+# {
+#   "last_updated": "2016-06-15 13:50:05 +0100",
+#   "podling": {
+#     ...
+#     "airflow": {
+#       "name": "Airflow",
+#       "resource": "airflow",
+#       "status": "current",
+#       "startdate": "2016-03-31",
+#       "description": "Airflow is a workflow automation and scheduling system that can be
used to author and manage data pipelines.",
+#       "mentors": [
+#         "cnauroth",
+#         "hitesh",
+#         "jghoman"
+#       ],
+#       "reporting": { # PROVISIONAL FORMAT
+#          "group": "1",
+#          "text": "May, June, July",
+#          "monthly": [
+#            "May",
+#            "June",
+#            "July"
+#          ]
+#         },
+#         "champion": "criccomini"
+#     },
+#     "accumulo": {
+#       ...
+#     },
+#     ...
+#   }
+# }
+#
+# =====================================================
+# N.B. The "reporting" hash format is subject to change
+# =====================================================
+
+require_relative 'public_json_common'
+
+pods = Hash[ASF::Podling.list.map {|podling| [podling.name, podling.status]}]
+
+mtime =  ASF::Podling.mtime # must be after call to list()
+
+public_json_output(
+ last_updated: mtime,
+ podling: pods
+)
+
+if ARGV.length == 2
+  podh = Hash[ASF::Podling.list.map {|podling| [podling.name, podling.as_hash]}]
+  public_json_output_file({
+    last_updated: mtime,
+    podling: podh    
+  }, ARGV[1])
+end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message