Using Ruby to read .properties file

Hi

I am working on a project in which I need to read and write the
.properties files. Is there a way to do this in Ruby ... other than
writing code from scratch.
Thanks in advance.

regards
Sanchit

What is a .properties file? After some googling it looks like it's a Java thing. Here's a project: http://raa.ruby-lang.org/project/propertyfile/

(Two hints, 1) it's easier to help when your question is specific and gives all the details and 2) Google is your friend (http://www.google.com/search?hl=en&lr=&q=parse+java+.properties+file+in+ruby&btnG=Search)
)

···

On Jun 6, 2006, at 9:51 AM, Sanchit.Misra@trilogy.com wrote:

Hi

I am working on a project in which I need to read and write the
.properties files. Is there a way to do this in Ruby ... other than
writing code from scratch.
Thanks in advance.

regards
Sanchit

unknown wrote:

I am working on a project in which I need to read and write the
.properties files. Is there a way to do this in Ruby ... other than
writing code from scratch.

Have a look at yaml, It allows you to easily save objects in files and
read them. You can have an optionshash and just
File.open(propertiesfile, "w+") { |f| f.puts( optionshash.to_yaml ) }

hash = YAML.load( propertiesfile )

http://yaml4r.sourceforge.net/

Edwin

···

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

Thanks for the help and hints :slight_smile:

sanchit

Logan Capaldo <logancapaldo@gmail.com>
06/06/2006 07:39 PM
Please respond to
ruby-talk@ruby-lang.org

To
ruby-talk@ruby-lang.org (ruby-talk ML)
cc

Subject
Re: Using Ruby to read .properties file

Hi

I am working on a project in which I need to read and write the
.properties files. Is there a way to do this in Ruby ... other than
writing code from scratch.
Thanks in advance.

regards
Sanchit

What is a .properties file? After some googling it looks like it's a
Java thing. Here's a project: http://raa.ruby-lang.org/project/
propertyfile/

(Two hints, 1) it's easier to help when your question is specific and
gives all the details and 2) Google is your friend (http://
www.google.com/search?hl=en&lr=&q=parse+java+.properties+file+in
+ruby&btnG=Search)
)

···

On Jun 6, 2006, at 9:51 AM, Sanchit.Misra@trilogy.com wrote: