[jboss-svn-commits] JBL Code SVN: r18016 - labs/jbossrules/trunk/lib/utility-scripts.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jan 21 17:59:50 EST 2008


Author: michael.neale at jboss.com
Date: 2008-01-21 17:59:49 -0500 (Mon, 21 Jan 2008)
New Revision: 18016

Added:
   labs/jbossrules/trunk/lib/utility-scripts/style_usage.rb
Modified:
   labs/jbossrules/trunk/lib/utility-scripts/image_usage.rb
Log:
some more scripts to do tidy up.

Modified: labs/jbossrules/trunk/lib/utility-scripts/image_usage.rb
===================================================================
--- labs/jbossrules/trunk/lib/utility-scripts/image_usage.rb	2008-01-21 19:33:34 UTC (rev 18015)
+++ labs/jbossrules/trunk/lib/utility-scripts/image_usage.rb	2008-01-21 22:59:49 UTC (rev 18016)
@@ -1,5 +1,5 @@
 #
-# This looks for unuses image in GWT code. 
+# This looks for unused images in GWT code. 
 # Gets a list of images, and looks to find if they are used. 
 #
 # Author: Michael Neale
@@ -9,7 +9,7 @@
 def mapdir(dir, predicate, action) 
     Dir.foreach(dir) do |d| 
       if d != "." && d != ".." then
-        sub = dir + "/" + d        
+        sub = "#{dir}/#{d}"        
         if not File.directory? sub and predicate.call(sub) then
           action.call(sub)
         else 

Added: labs/jbossrules/trunk/lib/utility-scripts/style_usage.rb
===================================================================
--- labs/jbossrules/trunk/lib/utility-scripts/style_usage.rb	                        (rev 0)
+++ labs/jbossrules/trunk/lib/utility-scripts/style_usage.rb	2008-01-21 22:59:49 UTC (rev 18016)
@@ -0,0 +1,47 @@
+# This looks for unused styles in GWT code. 
+# Gets a list of images, and looks to find if they are used. 
+#
+# Author: Michael Neale
+#
+
+#directory recursive processor...
+def mapdir(dir, predicate, action) 
+    Dir.foreach(dir) do |d| 
+      if d != "." && d != ".." then
+        sub = "#{dir}/#{d}"        
+        if not File.directory? sub and predicate.call(sub) then
+          action.call(sub)
+        else 
+          if File.directory? sub and not sub.include? ".svn" 
+	  then mapdir(sub, predicate, action) end
+        end        
+      end
+    end
+end
+
+
+def process(css, sources_root) 
+  style_names = []
+  IO.foreach(css) do |line|
+    #rip the name from the line if is starts with "."
+    if line.slice(0, 1) == "." then
+      puts "Line is: " + line
+      style_names << line.slice(1, line.index(' ') - 1)
+    end
+  end
+
+  mapdir sources_root, lambda {  |f| f.include? ".java" or f.include? ".html" or f.include? ".js" }, 
+    lambda do |f|
+      contents = IO.read(f)
+      style_names.each do |style|
+       if contents.include? '"' + style + '"' then
+         style_names = style_names - [style]
+       end
+      end
+    end
+
+  puts "#{style_names.size} unused styles : "
+  puts style_names
+end
+
+process "/Users/michaelneale/project/jboss-rules/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css", "/Users/michaelneale/project/jboss-rules/drools-jbrms/src/main/java/org/drools/brms"


Property changes on: labs/jbossrules/trunk/lib/utility-scripts/style_usage.rb
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list