Ruby equivalent for property or config.xml?

Hi,

i have a ruby script that should be controlled via
configfile, similar as a propertyfile or config.xml in java.

What's the ruby equivalent for that ?

Gilbert

Your best bet is probably YAML which is part of the standard library.

Farrel

···

On 23/02/07, Rebhan, Gilbert <Gilbert.Rebhan@huk-coburg.de> wrote:

Hi,

i have a ruby script that should be controlled via
configfile, similar as a propertyfile or config.xml in java.

What's the ruby equivalent for that ?

Gilbert

YAML is what you want, though parsing properties files into ruby
hashes is straightforward.

Even in java, XML files for configuration are overkill.

···

On 2/23/07, Rebhan, Gilbert <Gilbert.Rebhan@huk-coburg.de> wrote:

i have a ruby script that should be controlled via
configfile, similar as a propertyfile or config.xml in java.

What's the ruby equivalent for that ?

Farrel Lifson wrote:

···

On 23/02/07, Rebhan, Gilbert <Gilbert.Rebhan@huk-coburg.de> wrote:

Hi,

i have a ruby script that should be controlled via
configfile, similar as a propertyfile or config.xml in java.

What's the ruby equivalent for that ?

Gilbert

Your best bet is probably YAML which is part of the standard library.

Farrel

Or just a ruby file...

module Config
   DATABASE = {:adapter => 'foo' ...}
   FROBNICATOR = :fozzbangle
   LOCATION = :coozbain
end

--
Alex

YAML is what you want, though parsing properties files into ruby
hashes is straightforward.

I wondered whether some features of Apache Jakarta Commons Configuration
format are available with YAML (or another Ruby gismo):

http://jakarta.apache.org/commons/configuration/apidocs/org/apache/commons/configuration/PropertiesConfiguration.html

Two interesting features:

1. Variable expansion:

  user.name = miles
  first_file = /home/${user.name}/first
  app_title = ${user.name}'s homepage

I think variable expansion is done on reference ("lazy"). YAML has
aliases, but can't concatenate strings (which is OK, because YAML is for
object (de)serialization...).

2. Layout preservation: The 'load' methods saves the layout of the
properties file, including comments, line order, indentation. The 'save'
method tries to preserve as much of it as possible. See:

http://jakarta.apache.org/commons/configuration/apidocs/org/apache/commons/configuration/PropertiesConfigurationLayout.html

Best,
Dov.

···

--
Posted via http://www.ruby-forum.com/\.