You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2019/08/16 16:49:10 UTC
svn commit: r1865325 - /commons/scripts/pomskel.rb
Author: sebb
Date: Fri Aug 16 16:49:10 2019
New Revision: 1865325
URL: http://svn.apache.org/viewvc?rev=1865325&view=rev
Log:
Add depth --one option
Modified:
commons/scripts/pomskel.rb
Modified: commons/scripts/pomskel.rb
URL: http://svn.apache.org/viewvc/commons/scripts/pomskel.rb?rev=1865325&r1=1865324&r2=1865325&view=diff
==============================================================================
--- commons/scripts/pomskel.rb (original)
+++ commons/scripts/pomskel.rb Fri Aug 16 16:49:10 2019
@@ -29,13 +29,16 @@ PRUNE=%w(
testResources
)
+INDENT=' '
+
def textonly?(node)
return node.children.count == 1 && node.children.first.name == 'text'
end
-def show(node, depth)
+def show(node, depth, maxdepth)
name = node.name
- if textonly? node # empty
+ return if IGNORE.include? name
+ if textonly? node or depth == maxdepth # empty
puts "#{depth}<#{name}/>"
return
end
@@ -43,17 +46,19 @@ def show(node, depth)
puts "#{depth}<#{name}>...</#{name}>"
return
end
- return if IGNORE.include? name
puts "#{depth}<#{name}>"
node.children.each do |child|
- show(child,depth+' ')
+ show(child,depth+INDENT, maxdepth)
end
puts "#{depth}</#{name}>"
end
+maxdepth = nil
+maxdepth = INDENT if ARGV.delete '--one'
+
doc = Nokogiri::XML(ARGF) do |config|
config.options = Nokogiri::XML::ParseOptions::NOBLANKS
end
-show(doc.root,'')
+show(doc.root,'',maxdepth)