Friday, March 27, 2009

Onion

I have created a small RubyGem for Ruby's Array class in order to circumvent the complexity of nested arrays when gathering information from a specific format to another. This is used in a real project, namely L10nTool.

Onions have layers. Ogres have layers.

Onion, or Array Onion, allows peeling an array like an onion. It shreds one layer after another, from the outer inwards the inner nested array, according to the given depth. Infinite depth (or greater than current nested array depth) is equivalent to Array#flatten.

This is not the most stunning code one would have written but it fully passes its Unit Tests. Though some more tests have to be written. Also, it is an insignificant part of L10nTool. The export feature creates references for the import feature. These references are telling the import feature the location (id, accessors, etc.) and which database each translated text should be replaced at. Constructing cross references among multiple targets and databases, while abiding to the desired format, became easier with Onion.

That would perhaps be interesting for Hashes as well.
Difficult to say considering that it would be of no use for myself.

? ...why are you crying

Many reasons brought me to create a RubyGem and publish it in the open source community. Firstly, I would like to be more familiar with the process in general. Secondly, it's great to improve a piece of work to have peer reviews. Finally, hopefully, it will be helpful to others and give back to the community.

The project page is located at http://rubyforge.org/projects/onion/. It should be available on standard RubyGems server shortly.

All right, throw me stones little monkeys!

No comments:

Post a Comment