How to get homedir?

Hello,

I’m writing an app in ruby/glade and I want to save the configuration and
some data in the directory of the user.
There is the function g_get_home_dir() in the GLib, but I can’t find the
way to call it from ruby :frowning:
Also I need it to function on GNU/Linux, Windows, and hopefully MacOS X.

So, can anybody help me ?

···


Florent “flure” C.
Décrypter l’@ pour répondre
Coders don’t die, they just JMP without RET !

Version 0.0.4 of Kansas has been released. This one fixes a few bugs,
including one that caused problems with DBD::Pg. It also now uses
forwardable to support DBI::StatementHandle method calls via it’s internal
database handle. This makes it easy to step out of Kansas in order to use
the database handle directly if you are doing something that is outside of
what Kansas supports.

Kansas can be found at RubyForge: http://rubyforge.org/projects/kansas
There is documentation in progress at http://enigo.com/projects/kansas

If you don’t know what Kansas is:

···

Kansas is a simple Object-Relational mapping layer for Ruby. It takes
a relational schema, accessible via Ruby’s DBI layer, and converts it
in to a set of Ruby classes, one per table. Each class contains a set
of accessors corresponding to the columns in the table. So, given a
table:

 create table CoursesTaken (
         name            char(30) not null,
         student_number  int(8)   not null,
         primary key (name, student_number)
 );

Kansas would create a class ‘CoursesTaken’, containing read and write
attributes called ‘name’ and ‘student_number’.

Kansas also let’s you define the joins between tables (which can be
one-to-one or one-to-many). If you access a join in a table, Kansas
automatically loads the row in the referenced table, returning the
appropriate object.

If you assign to a row attribute, Kansas updates the corresponding
field in the database. In the default mode, this update is
immediate. Setting autocommit off makes Kansas keep all changes
pending until a commit is issued. When autocommit is off, changes
can also be rolled back, preventing them from being written to the
database.

As always, I appreciate comments, especially if you are going to use it
with a database other than MySQL. In theory it should work with any
database that DBI works with, but that theory is far from tested.

Thanks,

Kirk Haines

well, ENV[‘HOME’] works fine on my windows box and linux one

···

il Thu, 29 Apr 2004 11:38:55 +0200, “Florent ‘flure’ C.” flurePASDESPAM@freePASDESPAM.fr ha scritto::

Hello,

I’m writing an app in ruby/glade and I want to save the configuration and
some data in the directory of the user.
There is the function g_get_home_dir() in the GLib, but I can’t find the
way to call it from ruby :frowning:
Also I need it to function on GNU/Linux, Windows, and hopefully MacOS X.

If the Glade g_get_home_dir() call works on both Linux, Windows, and MacOS
X, then you could use Ruby/DL to do that.

ENV[‘HOME’] does NOT work on Windows, by default. This is something that was
discussed not too long ago; I was having problems getting to
www.ruby-talk.org yesterday, but I recommend searching for this on the list
– there is a Win32 API that you can call to get this information.

-austin

···

On Thu, 29 Apr 2004 19:14:03 +0900, gabriele renzi wrote:

il Thu, 29 Apr 2004 11:38:55 +0200, “Florent ‘flure’ C.” > flurePASDESPAM@freePASDESPAM.fr ha scritto::

I’m writing an app in ruby/glade and I want to save the configuration
and some data in the directory of the user.
There is the function g_get_home_dir() in the GLib, but I can’t find
the way to call it from ruby :frowning:
Also I need it to function on GNU/Linux, Windows, and hopefully MacOS X.
well, ENV[‘HOME’] works fine on my windows box and linux one


austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2004.04.29
* 07.32.12

We had similar questions before, e. g. the thread
“Profile-independent directory specification for NT?”
might be interesting in this context.

Cheers
Sascha

···

gabriele renzi surrender_it@remove.yahoo.it wrote:

There is the function g_get_home_dir() in the GLib, but I can’t find the
way to call it from ruby :frowning:
Also I need it to function on GNU/Linux, Windows, and hopefully MacOS X.

well, ENV[‘HOME’] works fine on my windows box and linux one