Tuesday, April 24, 2007

Ruby for text processing

In context of ETL project, I has ported a large Java class from old API to new API. I actually has done it twice to try two different implementation options. Since ported API had a very regular structure, I decided to try Ruby for this task. It worked pretty well. Ruby has a great text processing library. The method gsub!() that invokes a closure to perform text substitution when using regular expression has saved me a lot of efforts. This allows quite complex transformations just in the place where it is needed.

I'm not sure whether I saved efforts or I would have faster done it manually. I do not know Ruby very well after all. But surely, the process was more enjoyable.

No comments: