The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
any better methods of require a specific version/set of versions?
-a
This might be a good thing to encapsulate somehow; perl has a construct
like so:
require 5;
which requires that the version of perl running the script be >= 5.
(IIRC, you can “require” arbitrary levels, like ``require 5.0.1;‘’, but
I might be mistaken on that.)
Given ruby is changing in fairly large chunks, this might be useful.
any better methods of require a specific version/set of versions?
A bit more complicated, but could be included in the std. distribution…
module Kernel
def ensure_version( ver )
if ( RUBY_VERSION.split(/./).map{|x|x.to_i} <=>
ver.split(/./).map{|x|x.to_i} ) < 0
throw “Version error: should be #{ver} but is #{RUBY_VERSION}”
end
end
end
major = Config::CONFIG[‘MAJOR’].to_i
minor = Config::CONFIG[‘MINOR’].to_i
teeny = Config::CONFIG[‘TEENY’].to_i
if major < 1 or (major == 1 and minor < 8) then
raise “wrong version”
end
Of course, this can be wrapped into a nice version class. I wrote one
of these a long time ago and never released it, but there are plenty of
others already out there.
Paul
···
On Tue, Nov 25, 2003 at 08:32:14AM +0900, Ara.T.Howard wrote:
any better methods of require a specific version/set of versions?
Date: Tue, 25 Nov 2003 08:41:34 +0900
From: Michael campbell michael_s_campbell@yahoo.com
Newsgroups: comp.lang.ruby
Subject: Re: raise unless RUBY_VERSION[%r/^\s*\d+.\d+/o].to_f >= 1.8
Ara.T.Howard wrote:
any better methods of require a specific version/set of versions?
-a
This might be a good thing to encapsulate somehow; perl has a construct
like so:
require 5;
which requires that the version of perl running the script be >= 5.
(IIRC, you can “require” arbitrary levels, like ``require 5.0.1;‘’, but
I might be mistaken on that.)
Given ruby is changing in fairly large chunks, this might be useful.
–
ATTN: please update your address books with address below!
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
Date: Thu, 27 Nov 2003 06:40:52 +0900
From: Paul Brannan pbrannan@atdesk.com
Newsgroups: comp.lang.ruby
Subject: Re: raise unless RUBY_VERSION[%r/^\s*\d+.\d+/o].to_f >= 1.8
On Tue, Nov 25, 2003 at 08:32:14AM +0900, Ara.T.Howard wrote:
any better methods of require a specific version/set of versions?
require ‘rbconfig’
major = Config::CONFIG[‘MAJOR’].to_i
minor = Config::CONFIG[‘MINOR’].to_i
teeny = Config::CONFIG[‘TEENY’].to_i
if major < 1 or (major == 1 and minor < 8) then
raise “wrong version”
end
Of course, this can be wrapped into a nice version class. I wrote one
of these a long time ago and never released it, but there are plenty of
others already out there.
Paul
–
ATTN: please update your address books with address below!
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
any better methods of require a specific version/set of versions?
What about RUBY_VERSION >= “1.8.0”?
Regards,
Florian Gross
i thought about this for a while and came up with a good reason not to
do this
but it currently eludes me!
unless someone can think of a reason not to - i’ll take it!
It does not work as a general solution, as “1.11.0” < “1.8.0”. However,
bearing in mind that Ruby so far had only 1-digit version components
and 1.9.x is going to be the last Ruby1 version (according to Matz),
this check may be OK.
Gennady
···
On Nov 24, 2003, at 20:42, Ara.T.Howard wrote:
On Tue, 25 Nov 2003, Florian Gross wrote:
-a
ATTN: please update your address books with address below!
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print
"\x3a\x2d\x29\x0a"”;done’
=======================================================================
========
any better methods of require a specific version/set of versions?
What about RUBY_VERSION >= “1.8.0”?
i thought about this for a while and came up with a good reason not to do this
but it currently eludes me!
Maybe this bothered you ?
RUBY_VERSION = “1.8.1”
p RUBY_VERSION >= “1.8” #-> true
RUBY_VERSION = “1.10.1”
p RUBY_VERSION >= “1.8” #-> false
… but MINOR 10 would upset RUBY_VERSION_CODE (in version.h)
which, incidentally, would be a useful global (eventually).
It might take the pressure off Matz if 1.9 didn’t have to be
followed by 2.0 tho’
unless someone can think of a reason not to - i’ll take it!
Um, because it’s crufty (looks like we can’t tell the difference
between Numeric and String sorting sequence - even though I’ve
seen it used a lot in Ruby).
not knocking paul’s solution or anything, but you prefer this to using a
tuple?
···
On Thursday 27 November 2003 12:12 am, Ara.T.Howard wrote:
On Thu, 27 Nov 2003, Paul Brannan wrote:
Date: Thu, 27 Nov 2003 06:40:52 +0900
From: Paul Brannan pbrannan@atdesk.com
Newsgroups: comp.lang.ruby
Subject: Re: raise unless RUBY_VERSION[%r/^\s*\d+.\d+/o].to_f >= 1.8
On Tue, Nov 25, 2003 at 08:32:14AM +0900, Ara.T.Howard wrote:
any better methods of require a specific version/set of versions?
require ‘rbconfig’
major = Config::CONFIG[‘MAJOR’].to_i
minor = Config::CONFIG[‘MINOR’].to_i
teeny = Config::CONFIG[‘TEENY’].to_i
if major < 1 or (major == 1 and minor < 8) then
raise “wrong version”
end
Of course, this can be wrapped into a nice version class. I wrote one
of these a long time ago and never released it, but there are plenty of
others already out there.
RUBY_VERSION = “1.8.1”
p RUBY_VERSION >= “1.8” #-> true
RUBY_VERSION = “1.10.1”
p RUBY_VERSION >= “1.8” #-> false
… but MINOR 10 would upset RUBY_VERSION_CODE (in version.h)
which, incidentally, would be a useful global (eventually).
It might take the pressure off Matz if 1.9 didn’t have to be
followed by 2.0 tho’
unless someone can think of a reason not to - i’ll take it!
Um, because it’s crufty (looks like we can’t tell the difference
between Numeric and String sorting sequence - even though I’ve
seen it used a lot in Ruby).
ah yes - did think of that at one point. must have drank more coffee that
day. thatnks for the heads up. definitely best to stick with a ‘to_f’ type
impl for now.
it would be really good if there was a ‘standard’ way to do this.
at one point, i created a Version class which used the rules that ‘ld’
follows:
interface.age.revision
etc. etc.
does anyone know what the meaning of ruby’s tripplet?
any better methods of require a specific version/set of versions?
What about RUBY_VERSION >= “1.8.0”?
Regards,
Florian Gross
i thought about this for a while and came up with a good reason not to
do this
but it currently eludes me!
unless someone can think of a reason not to - i’ll take it!
It does not work as a general solution, as “1.11.0” < “1.8.0”. However,
bearing in mind that Ruby so far had only 1-digit version components
and 1.9.x is going to be the last Ruby1 version (according to Matz),
this check may be OK.
–
ATTN: please update your address books with address below!
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
yes. one thing i had not yet mentioned is that i also may want to incorporate
the semantics of version. for instance, with libtool type versioning, the
following are compatible versions:
7.6.10
2.0.7
this is because, with libtool, the revision’s meaning is
revision.age.impl
(see the libtool docs for more)
because revision 7 spans 6 ages, it is compatible with all versions 1 - 7.
i don’t know what ruby’s major, minor, teeny numbers mean but would like to do
something similar if possible. and using them in paul’s way would make the
intent very clear.
-a
···
On Thu, 27 Nov 2003, T. Onoma wrote:
Date: Thu, 27 Nov 2003 14:59:58 +0900
From: T. Onoma transami@runbox.com
Newsgroups: comp.lang.ruby
Subject: Re: raise unless RUBY_VERSION[%r/^\s*\d+.\d+/o].to_f >= 1.8
On Thursday 27 November 2003 12:12 am, Ara.T.Howard wrote:
On Thu, 27 Nov 2003, Paul Brannan wrote:
Date: Thu, 27 Nov 2003 06:40:52 +0900
From: Paul Brannan pbrannan@atdesk.com
Newsgroups: comp.lang.ruby
Subject: Re: raise unless RUBY_VERSION[%r/^\s*\d+.\d+/o].to_f >= 1.8
On Tue, Nov 25, 2003 at 08:32:14AM +0900, Ara.T.Howard wrote:
any better methods of require a specific version/set of versions?
require ‘rbconfig’
major = Config::CONFIG[‘MAJOR’].to_i
minor = Config::CONFIG[‘MINOR’].to_i
teeny = Config::CONFIG[‘TEENY’].to_i
if major < 1 or (major == 1 and minor < 8) then
raise “wrong version”
end
Of course, this can be wrapped into a nice version class. I wrote one
of these a long time ago and never released it, but there are plenty of
others already out there.
Paul
nice! you win paul!
not knocking paul’s solution or anything, but you prefer this to using a
tuple?
–
ATTN: please update your address books with address below!
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
RUBY_VERSION = “1.8.1”
p RUBY_VERSION >= “1.8” #-> true
RUBY_VERSION = “1.10.1”
p RUBY_VERSION >= “1.8” #-> false
… but MINOR 10 would upset RUBY_VERSION_CODE (in version.h)
which, incidentally, would be a useful global (eventually).
It might take the pressure off Matz if 1.9 didn’t have to be
followed by 2.0 tho’
unless someone can think of a reason not to - i’ll take it!
Um, because it’s crufty (looks like we can’t tell the difference
between Numeric and String sorting sequence - even though I’ve
seen it used a lot in Ruby).
It does not work as a general solution, as “1.11.0” < “1.8.0”.
ah yes - did think of that at one point. must have drank more coffee that
day. thatnks for the heads up. definitely best to stick with a ‘to_f’ type
impl for now.
RUBY_VERSION = “1.8.1”
p RUBY_VERSION >= “1.8” #-> true
RUBY_VERSION = “1.10.1”
p RUBY_VERSION >= “1.8” #-> false
… but MINOR 10 would upset RUBY_VERSION_CODE (in version.h)
which, incidentally, would be a useful global (eventually).
It might take the pressure off Matz if 1.9 didn’t have to be
followed by 2.0 tho’
unless someone can think of a reason not to - i’ll take it!
Um, because it’s crufty (looks like we can’t tell the difference
between Numeric and String sorting sequence - even though I’ve
seen it used a lot in Ruby).