You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by cu...@apache.org on 2019/05/31 16:03:01 UTC

[whimsy] branch master updated: Also unwrap any local CONST values

This is an automated email from the ASF dual-hosted git repository.

curcuru 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 87c4329  Also unwrap any local CONST values
87c4329 is described below

commit 87c43299610e9594f9e195a63e0a69baa2cce156
Author: Shane Curcuru <as...@shanecurcuru.org>
AuthorDate: Fri May 31 12:02:52 2019 -0400

    Also unwrap any local CONST values
---
 tools/wwwdocs.rb | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/tools/wwwdocs.rb b/tools/wwwdocs.rb
index d18e663..bf94887 100755
--- a/tools/wwwdocs.rb
+++ b/tools/wwwdocs.rb
@@ -16,9 +16,10 @@ AUTHMAP = { # From whimsy-vm4.apache.org.yaml
 }
 AUTHPUBLIC = 'glyphicon-eye-open'
 IS_PRIVATE = /\A(private|infra\/infrastructure)/
-ASFSVN = 'ASF::SVN'
+ASFSVN = /ASF::SVN/
 SCANDIRSVN = "../"
 WWWAUTH = /WWW-Authenticate: Basic realm/
+CONSTANT_DEF = /(?<matchconst>[A-Z_]+)\s+=\s+['"](?<matchval>[^#]+)['"]/ # Attempt to capture CONSTANT = "value"
 
 # Output ul of key of AUTHMAP for use in helpblock
 def emit_authmap
@@ -132,23 +133,32 @@ end
 def build_regexp(list)
   r = []
   list.each do |itm|
-    r << "#{ASFSVN}\['#{itm}']"
+    r << "#{ASFSVN.source}\['#{itm}']"
   end
   return Regexp.union(r)
 end
 
-# Scan file for use of ASF::SVN symbolic names like apmail_bin
+# Scan file for use of ASF::SVN symbolic names like apmail_bin; unmapping any CONSTANT_DEF
 # @return [["x = ASF::SVN['Meetings'] # Whole line of code accessing private repo", ...], [<public repos same>], 'WWW-Authenticate code line' ]
 def scan_file_svn(f, regexs)
   repos = [[], [], []]
+  consts = {}  
   begin
     File.open(f).each_line.map(&:chomp).each do |line|
-      if line =~ WWWAUTH then # Fastest compare first
-        repos[2] << line.strip
-      elsif line =~ regexs[0] then
-        repos[0] << line.strip
-      elsif line =~ regexs[1] then
-        repos[1] << line.strip
+      line.strip!
+      if line =~ WWWAUTH # Fastest compare first
+        repos[2] << line
+      elsif line =~ ASFSVN # Find all ASF::SVN and also map if it uses a CONSTANT_DEF
+        consts.each do |k,v|
+          line.sub!(k, v)
+        end
+        if line =~ regexs[0]
+          repos[0] << line
+        elsif line =~ regexs[1]
+          repos[1] << line
+        end
+      elsif line =~ CONSTANT_DEF
+        consts[$~['matchconst']] = "'#{$~['matchval']}'"
       end
     end
     return repos