Introducing the xml-registry gem

The xml-registry gem is designed for use with Sinatra-Rscript however it can be used with any project.

Installation

sudo gem1.9.1 install xml-registry

Example

require 'xml-registry' 

s =<<REG
[app/app1]
"admin"="jrobertson"
"pin-no"="1234"

[app/app2]
"admin"="dsmith"
"pin-no"="4321"
REG

reg = XMLRegistry.new 
reg.set_key 'app/whiteboard/colour', 'red' 
reg.to_xml 
#=> "red" 

reg.import s 
reg.to_xml

output:

<root>
<system/>
  <app>
    <whiteboard>
      <colour>red</colour>
    </whiteboard>
    <app1>
      <admin>jrobertson</admin>
      <pin-no>1234</pin-no>
    </app1>
    <app2>
      <admin>dsmith</admin>
      <pin-no>4321</pin-no>
    </app2>
  </app>
  <user/>
  <ip_address/>
</root>

puts reg.export 

output:

[app/whiteboard]
"colour"="red"

[app/app1]
"admin"="jrobertson"
"pin-no"="1234"

[app/app2]
"admin"="dsmith"
"pin-no"="4321"
Tags:
Source:
1357hrs.txt
Published:
18-01-2012 13:58