Programmatically testing the version of ruby-gnome2?

Hi,

If I’m correct, there’s no way to programmatically say what version of
ruby-gnome2 an application is running with?

If it’s the case, wouldn’t it be helpful to add it? My intent is to
avoid random crashes in my application when I detect known bad version
combinations (currently I want to do it for rg2 0.15.0, and rg2 <
0.17.0 + ruby >= 1.8.7).

Thanks,


Guillaume C. - http://zarb.org/~gc/

Hi,

2008/7/2 Guillaume C. [email protected]:

If I’m correct, there’s no way to programmatically say what version of
ruby-gnome2 an application is running with?

Gtk::BINDING_VERSION?
Some bindings have *::BINDING_VERSION but not all…

Thanks,

kou

Guillaume C. wrote:

Hi,

If I’m correct, there’s no way to programmatically say what version of
ruby-gnome2 an application is running with?

If it’s the case, wouldn’t it be helpful to add it? My intent is to
avoid random crashes in my application when I detect known bad version
combinations (currently I want to do it for rg2 0.15.0, and rg2 <
0.17.0 + ruby >= 1.8.7).

I used to have this in my code:

major, minor, micro = Gtk::BINDING_VERSION
if major == 0 and minor < 16
msg = "Error: Your ruby-gnome2 binding version is too old and WILL
cause crashes. Please use 0.16.0 at least. "
d = Gtk::MessageDialog.new(nil, Gtk::Dialog::MODAL,
Gtk::MessageDialog::ERROR , Gtk::MessageDialog::BUTTONS_OK,msg )
d.run
exit!
end

Of course, you may encounter some “random” crashes in 0.16 too because
of some GC-bugs, which are solved in 0.17.

For Ruby version you can read the constant RUBY_VERSION .

On Wed, Jul 2, 2008 at 12:47 PM, Joachim G.
[email protected] wrote:

Of course, you may encounter some “random” crashes in 0.16 too because
of some GC-bugs, which are solved in 0.17.

In my experience 0.16 is almost stable as long as ruby <= 1.8.6 is
used. But no way when using ruby 1.8.7.

For Ruby version you can read the constant RUBY_VERSION .

Yes. Here’s what I’ve actually added (too bad RUBY_VERSION is a
string, though there’s probably a more elegant way to use it).

binding_version = Gtk::BINDING_VERSION
if binding_version == [ 0, 15, 0 ]
puts “It seems that we’re running ruby-gtk2 0.15.0; this version
is known to crash; please upgrade or downgrade.”
puts str
exit
end
ruby_version = RUBY_VERSION.split(‘.’).collect { |v| v.to_i }
if binding_version[0] <= 0 && binding_version[1] <= 16 &&
ruby_version[0] >= 1 && ruby_version[1] >= 8 && ruby_version[2] >= 7
puts “It seems that we’re running ruby-gtk2 <= 0.16.0 with ruby >=
1.8.7; this combination is known to crash; please upgrade or downgrade
some.”
puts str
exit
end


Guillaume C. - Guillaume Cottenceau

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] programmatically testing the version of
ruby-gnome2?” on Wed, 2 Jul 2008 14:14:40 +0200,
“Guillaume C.” [email protected] wrote:

exit

end
ruby_version = RUBY_VERSION.split(‘.’).collect { |v| v.to_i }
if binding_version[0] <= 0 && binding_version[1] <= 16 &&
ruby_version[0] >= 1 && ruby_version[1] >= 8 && ruby_version[2] >= 7
puts “It seems that we’re running ruby-gtk2 <= 0.16.0 with ruby >=
1.8.7; this combination is known to crash; please upgrade or downgrade
some.”
puts str
exit
end

if (Gtk::BINDING_VERSION <=> [0, 17, 0]) < 0 and
(RUBY_VERSION.split(‘.’).collect {|v| v.to_i} <=> [1, 8, 7]) >= 0
puts “ruby-gtk2 < 0.17.0 and ruby >= 1.8.7”
end

Thanks,

kou