There's a dozen ways to spread the butter on the bread here. Here is my
humble take:

You can use the union construct: |

package(:war).libs |= [LIB_A, LIB_B]

If you have arrays of arrays, you can flatten:

package(:war).libs |= [LIB_A, LIB_B, [LIB_C, LIB_D]].flatten

To remove stuff selectively, use the delete method ?

package(:war).libs.delete(LIB_C)

The array class in Ruby is very interesting. I recommend keeping this page
around:
http://www.ruby-doc.org/core/classes/Array.html

Arrays are Enumerable (think java.util.Collection) so this is a good read
too:
http://www.ruby-doc.org/core/classes/Enumerable.html

On Thu, Jul 21, 2011 at 23:51, Christopher Tiwald <[email protected]>wrote:

> This thing's driving me nuts, so I'm hoping for a little group wisdom. I'm
> trying to package a WAR with some run-time libraries (i.e. unused in
> compilation), but without other libraries (that throw tomcat errors because
> tomcat already has them).
>
> i.e. I'm trying to do the following simultaneously:
>
> package(:war).libs += (LIBRARY_A, LIBRARY_B)
> package(:war).libs -= (LIBRARY_C)
>
> The easiest way, of course, would be to just be write an array
> (PACKAGE_THESE_LIBRARIES) that comprises all the correct libraries, and then
> use the 'with' method. On the other hand I've got something like 100
> libraries and this doesn't strike me as terribly elegant. I'm trying to
> maximize understandability, readability, and repeatability, because our
> maven pom.xml's had none of those qualities.
>
> Is there an obvious way to do this I'm missing here?
>
> --
> Christopher
>

Reply via email to