[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

RProperties 0.0.1 Released

Tiago Nogueira

2/4/2009 1:43:00 AM

Hello everybody!
The first release of RProperties is on the RubyForge now on
http://rubyforge.org/projects/rp... !
RProperties is a simple (very simple) implementation of the Java
Properties feature.
In this first release i just put the VERY basic functionality but i´m
working to do more things on it.

Just to exemplify a use of RProperties :
1. Imagine that you have a .properties file containing :
site_name = My Crazy Blog About Ruby
site_author = Barack Obama
author_email = barack@whitehouse.org

2. Using RProperties :

require 'r_properties'
rp = RProperties.new("my_file.properties");
rp.load_p;
puts "The name of my site is #{rp.get_p("site_name")}"

That´s All! I know that i have too much work to do and i hope that
everybody help on it.
- tiago


4 Answers

Peter Szinek

2/4/2009 12:21:00 PM

0

> Hello everybody!
> The first release of RProperties is on the RubyForge now on
> http://rubyforge.org/projects/rp... !

Great! But I don't really get the advantage of RProperties over built in
yaml+hash for example (or yaml+struct, or... whatever):

store:

props = {:site_name => "My Crazy Blog About Ruby",
:site_author => "Barack Obama",
:author_email => "barack@whitehouse.org"}
open('my_props.yml','w') {|f| f.write props.to_yaml}

load:

rp = YAML::load(open('my_props.yml'))
puts rp[:site_name]
puts rp[:site_author]
etc.

the yaml file almost looks like the java properties file:

---
:site_name: " My Crazy Blog About Ruby"
:site_author: Barack Obama
:author_email: barack@whitehouse.org

Peter
___
http://www.rubyra...
http://s...



Tiago Nogueira

2/4/2009 12:42:00 PM

0

You are completly right Peter!

But my intention to make rproperties is to mantain the java way and , with
this, convence more java users
here in brazil to migrate to ruby, and migrating , they will be completly
free to use the ruby ways and discover this wonderfull language , that i
prefer too! Peter , here in Brazil i am finding a hard resistence with the
java users to migrate to Ruby. I guess that in a group of 100 developers
here , 10 are tendencious to migrate to ruby,15 says that will take a look
but always says : tomorrow , tomorrow i'll see some and 75 just will change
when ruby pays more that java.

- tiago



On Wed, 4 Feb 2009 21:21:15 +0900, peter@rubyrailways.com wrote:
>> Hello everybody!
>> The first release of RProperties is on the RubyForge now on
>> http://rubyforge.org/projects/rp... !
>
> Great! But I don't really get the advantage of RProperties over built in
> yaml+hash for example (or yaml+struct, or... whatever):
>
> store:
>
> props = {:site_name => "My Crazy Blog About Ruby",
> :site_author => "Barack Obama",
> :author_email => "barack@whitehouse.org"}
> open('my_props.yml','w') {|f| f.write props.to_yaml}
>
> load:
>
> rp = YAML::load(open('my_props.yml'))
> puts rp[:site_name]
> puts rp[:site_author]
> etc.
>
> the yaml file almost looks like the java properties file:
>
> ---
> :site_name: " My Crazy Blog About Ruby"
> :site_author: Barack Obama
> :author_email: barack@whitehouse.org
>
> Peter
> ___
> http://www.rubyra...
> http://s...


Tiago Nogueira

2/4/2009 3:38:00 PM

0

Dominik,
I just put the ideas on the air and i'm open to sugestions etc...
This is the first release and i know that i have too much work to do and if
somebody
have other ideas please , lets talk!
- tiago

On Wed, 4 Feb 2009 23:33:21 +0900, Dominik Honnef <dominikho@gmx.net>
wrote:
>> But my intention to make rproperties is to mantain the java way and ,
> with
>> this, convence more java users
>> here in brazil to migrate to ruby, and migrating , they will be
> completly
>> free to use the ruby ways and discover this wonderfull language , that i
>> prefer too!
>
> I doubt that people coming from Java will discover the beauty of Ruby
> if they are able to use things like RProperties. And in my opinion,
> something like #get_p(...) is not Ruby-like at all.
>
> The proper way would be to actually show them how it is done in Ruby's
> way.
>
>> site_name = My Crazy Blog About Ruby
>> site_author = Barack Obama
>> author_email = barack@whitehouse.org
>
> By simply adding "" around the values, you could even use this kind of
> format with, e.g., instance_eval and provide an interface like the
> following:
>
> Properties.site_name
>
> to get the value of site_name, which is way nicer than get_p('site_name')
>


Tiago Nogueira

2/4/2009 3:44:00 PM

0

Dominik, you said:
"...
By simply adding "" around the values, you could even use this kind of
format with, e.g., instance_eval and provide an interface like the
following: Properties.site_name to get the value of site_name, which is way
nicer than get_p('site_name')
..."

And i was think thats can be a good way.
- tiago



On Thu, 5 Feb 2009 00:38:25 +0900, <tjnogueira@oomaster.com> wrote:
> Dominik,
> I just put the ideas on the air and i'm open to sugestions etc...
> This is the first release and i know that i have too much work to do and
> if
> somebody
> have other ideas please , lets talk!
> - tiago
>
> On Wed, 4 Feb 2009 23:33:21 +0900, Dominik Honnef <dominikho@gmx.net>
> wrote:
>>> But my intention to make rproperties is to mantain the java way and ,
>> with
>>> this, convence more java users
>>> here in brazil to migrate to ruby, and migrating , they will be
>> completly
>>> free to use the ruby ways and discover this wonderfull language , that
> i
>>> prefer too!
>>
>> I doubt that people coming from Java will discover the beauty of Ruby
>> if they are able to use things like RProperties. And in my opinion,
>> something like #get_p(...) is not Ruby-like at all.
>>
>> The proper way would be to actually show them how it is done in Ruby's
>> way.
>>
>>> site_name = My Crazy Blog About Ruby
>>> site_author = Barack Obama
>>> author_email = barack@whitehouse.org
>>
>> By simply adding "" around the values, you could even use this kind of
>> format with, e.g., instance_eval and provide an interface like the
>> following:
>>
>> Properties.site_name
>>
>> to get the value of site_name, which is way nicer than
> get_p('site_name')
>>