Introducing the RowX gem

# gem pushed via rvm ruby-1.9.2-180

require 'rowx'

txt =<<EOF
testing 123
path: 1
type: date only
desc:

input:
  date: 22-Apr-2011 12:34
  entry: * * * * *

output:
  date: 2011-04-22 12:34

------------------------------

path: 2
type: date only
desc:

input:
  date: 22-Apr-2011 12:34
  entry: * * * * *

output:
  date: 2011-04-22 12:34

------------------------------
EOF

rowx = RowX.new(txt)
xml = rowx.to_xml
puts xml

#=>
<?xml version='1.0' encoding='UTF-8'?>
<root>
  <summary>
    <description>testing 123</description>
  </summary>
  <item>
    <path>1</path>
    <type>date only</type>
    <desc></desc>
    <input>
      <item>
        <date>22-Apr-2011 12:34</date>
        <entry>* * * * *</entry>
      </item>
    </input>
    <output>
      <item>
        <date>2011-04-22 12:34<item>

...

The RowX gem makes it more convenient to generate XML with minimal syntax. In the above code a heredoc contains a couple of records which is then passed to the RowX Object to be converted to XML.

Notes:

Resources: - jrobertson/rowx [github.com]

Tags:
Source:
2015hrs.txt
Published:
13-12-2011 20:15