Wednesday, September 16, 2009

Enabling 'choice_node' in XMLMapping gem

XML-Mapping is a great ruby gem. It lets you make ruby objects from XML and vice versa. It is a very useful gem but it seems that it is not maintained from it's project page. The last release was done on December 2005. Looks like it is no longer being maintained by it's author.

I am using XML-Mapping and Cucumber to test a rails application which generates XML feeds. Recently I had a need to use 'choice_node' method. But it gave me a 'undefined method choice_node' every time I tried to use it. The funny part is the method is very well documented like any other methods.

I had installed it from the source as a gem at my local machine. When searched the code for definition on ChoiceNode class I got nothing. It means the code which I downloaded did not have any choice_node method in it so how come I was going to get it in my application.

However following fixed the problem.

First remove or better rename the old gem.

gem_install_directory$ mv xml-mapping-0.8.1 xml-mapping-0.8.1-old

Then checkout the latest source of the gem from it's CVS repository.

gem_install_directory$ cvs -d login
gem_install_directory$ cvs -d checkout .

Now you can use the XML-Mapping gem with it's full power.

No comments: