<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>BlackBox : Tag yaml</title>
    <link>http://www.warneronstine.com/blog/articles/tag/yaml</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Where technology and art disappear</description>
    <item>
      <title>Yaml with JYaml</title>
      <description>&lt;p&gt;So, I decided to use &lt;a href="http://yaml.org"&gt;Yaml&lt;/a&gt; for all of my configuration needs, in order to use this I needed a library to interface with it, I found &lt;a href="http://jyaml.sf.net"&gt;JYaml&lt;/a&gt; which seems to fit the bill nicely. Here&amp;#8217;s a short example of what I&amp;#8217;ve used it for in &lt;a href="http://www.warneronstine.com/cgi-bin/trac.cgi"&gt;Chama&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;--- !org.chama.db.DBConfiguration
dev: !org.chama.db.DBConnection
  dbName: chama_dev
  driver: org.hsqldb.jdbcDriver
  url: "jdbc:hsqldb:mem:"
  username: sa
production: !org.chama.db.DBConnection
  dbName: chama_production
  driver: org.hsqldb.jdbcDriver
  url: "jdbc:hsqldb:mem:"
  username: sa
test: !org.chama.db.DBConnection
  dbName: chama_test
  driver: org.hsqldb.jdbcDriver
  url: "jdbc:hsqldb:mem:"
  username: sa

DBConfigurationTest.groovy
class DBConfigurationTest extends GroovyTestCase {

    void testReadConfigFile() {
        DBConfiguration config = Yaml.load(new File("src/test/conf/db.yml"))
            assert config.test.dbName == "chama_test"
            assert config.dev.dbName == "chama_dev"
            assert config.production.dbName = "chama_production"
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I also found another package when I was having some difficulty with JYaml called &lt;a href="https://jvyaml.dev.java.net/"&gt;JvYaml&lt;/a&gt;, but when I tried to save my configuration class it gave me a nested object exception telling me that I couldn&amp;#8217;t save nested objects into my Yaml file. That seemed kinda stupid to me so perhaps I was doing something wrong, but I didn&amp;#8217;t have time to try and figure out what it was and went back to JYaml.&lt;/p&gt;</description>
      <pubDate>Mon, 18 Dec 2006 21:25:41 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:ebaf88e7-c490-4ae1-9a2e-9d9689a1aa72</guid>
      <author>Warner Onstine</author>
      <link>http://www.warneronstine.com/blog/articles/2006/12/18/yaml-with-jyaml</link>
      <category>programming</category>
      <category>groovy</category>
      <category>yaml</category>
      <trackback:ping>http://www.warneronstine.com/blog/articles/trackback/224</trackback:ping>
    </item>
  </channel>
</rss>
