lib/maven/model/utils.rb in maven-tools-0.31.0 vs lib/maven/model/utils.rb in maven-tools-0.32.0
- old
+ new
@@ -112,10 +112,33 @@
end
self
end
end
+ class ResourceArray < Array
+
+ def initialize( name = 'resources', child = Resource, &block )
+ @_child = child
+ #super( name, &block )
+ if block
+ block.call self
+ end
+ self
+ end
+
+ alias :do_add :<<
+
+ def add( &block )
+ r = @_child.new
+ block.call( r )
+ do_add r
+ r
+ end
+ alias :<< :add
+
+ end
+
class ModelHash < Hash
def initialize(clazz)
@clazz = clazz
end
@@ -324,10 +347,17 @@
buf << "#{indent} </#{k}>\n"
when Array
buf << "#{indent} <#{k}>\n"
singular = k.to_s.sub(/s$/, '')
v.each do |i|
- buf << "#{indent} <#{singular}>#{i}</#{singular}>\n"
+ case i
+ when Hash
+ buf << "#{indent} <#{singular}>\n"
+ map_to_xml(buf, indent + " ", i)
+ buf << "#{indent} </#{singular}>\n"
+ else
+ buf << "#{indent} <#{singular}>#{i}</#{singular}>\n"
+ end
end
buf << "#{indent} </#{k}>\n"
when /\n$/
buf << "#{indent} <#{k}>#{v}"
buf << "#{indent} </#{k}>\n"