[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby equivalent for property or config.xml ?

Rebhan, Gilbert

2/23/2007 12:12:00 PM


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

4 Answers

Farrel Lifson

2/23/2007 12:15:00 PM

0

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

Alex Young

2/23/2007 1:05:00 PM

0

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

Richard Conroy

2/23/2007 1:22:00 PM

0

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 ?

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

Even in java, XML files for configuration are overkill.

Dov Murik

3/3/2007 9:02:00 AM

0

> 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/PropertiesConfigur...

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/PropertiesConfigurationL...


Best,
Dov.

--
Posted via http://www.ruby-....