[ANN] Ruby/Extensions v0.6.0

G

Gavin Sinclair

I am pleased to announce the release of v0.6.0 of Ruby/Extensions
('extensions').

== What Is It?

A set of methods added to Ruby's standard classes. A few examples,
taken from the methods added in this release:

arr = [1, 3, 5]
arr.rand # -> 1, 3, or 5
arr.none? { |n| n.even? } # -> true
arr.one? { |n| n > 4 } # -> true

Class.by_name "Process::Sys" # -> Process::Sys
Process::Sys.basename # -> "Sys"

'extensions' now contains 52 methods spread around 12 of Ruby's
classes, all well tested and documented.

== Links

http://extensions.rubyforge.org/ (read about it)
http://rubyforge.org/frs/?group_id=89 (download it)

== Installation

gem install extensions

(RPA support usually lags only 1 day.)

Or grab the tarball.

Cheers,
Gavin
 
F

Florian Gross

Gavin said:
I am pleased to announce the release of v0.6.0 of Ruby/Extensions
('extensions').

Same question as with RubyScript2Exe here: What was added and changed?
Is a change log available? Thank you.
 
G

Gavin Sinclair

Gavin Sinclair wrote:
Same question as with RubyScript2Exe here: What was added and changed?
Is a change log available? Thank you.

A change log is included in the rubyforge release:

2004-12-09 Gavin Sinclair <[email protected]>

* RELEASE: 0.6.0 ===================================================
* lib/extensions/array.rb: Implemented Array#only and #rand.
* test/tc_array.rb: Test Array#only and #rand.
* lib/extensions/module.rb: [NEW] Implemented Module.by_name,
Module#basename, and Module#deep_const_get.
* test/tc_module.rb: [NEW] Test the aforementioned Module methods.
* lib/extensions/enumerable.rb: Implemented Enumerable#none? and #one?
* test/tc_enumerable.rb: Test aforementioned Enumerable methods.
* lib/extensions/kernel.rb: Implemented Kernel#relative_require.
* test/tc_kernel.rb: Test Kernel#relative_require.
* lib/extensions/numeric.rb: Added comment for possible future method.
* lib/extensions/all.rb: Included new files module.rb and kernel.rb.
* test/data/kernel_test/global_var_1.rb: [NEW] test data file.
* test/data/kernel_test/global_var_2.rb: [NEW] test data file.
* README: Updated to describe release of 0.6.

The methods added since 0.5 are summarised on the website:

+ Array#only
+ Array#rand
+ Enumerable#none?
+ Enumerable#one?
+ Kernel#require_relative
+ Module.by_name
+ Module#basename
+ Module#deep_const_get

In future releases, I'll change the ChangeLog to an RDoc-friendly
format and publish it on the website.

Cheers,
Gavin
 
M

Mauricio Fernández

I am pleased to announce the release of v0.6.0 of Ruby/Extensions
('extensions'). [...]
(RPA support usually lags only 1 day.)

Not always: in some cases the packaging task is pretty involved and can
take longer (when there are complex dependencies, lots of glitches in
the upstream release to be fixed, etc). In this case it was easy, and we
have to thank you for following (maybe unknowingly) most of the practices
explained at
http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices

Also, http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodAPIDesign might
interest you.
Or grab the tarball.

I noticed that the permissions in the tarball seem wrong (too many files
are 755), maybe that can be addressed in the next release.


Port: extensions
Classification: Top.Library.Development
Available-Version: 0.6.0-1
RPA-Version: 0.0
Updated: Wed, 08 Dec 2004 15:52:53 +0100
Source-URL: http://rpa-base.rubyforge.org/ports/extensions_0.6.0-1.rps
Description:
Extensions to the Ruby standard classes.
 
G

Gavin Sinclair

I am pleased to announce the release of v0.6.0 of Ruby/Extensions
('extensions'). [...]
(RPA support usually lags only 1 day.)
Not always: in some cases the packaging task is pretty involved and can
take longer (when there are complex dependencies, lots of glitches in
the upstream release to be fixed, etc). In this case it was easy, and we
have to thank you for following (maybe unknowingly) most of the practices
explained at
http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices

I meant that RPA support for 'extensions' usually lags only one day,
precisely because I try to follow most of the practices explained at

http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices

:)
I noticed that the permissions in the tarball seem wrong (too many files
are 755), maybe that can be addressed in the next release.

Thanks, I'll try to fix that.

Gavin
 
A

Aredridel

I meant that RPA support for 'extensions' usually lags only one day,
precisely because I try to follow most of the practices explained at

http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices

And thank you for that. It took me eight minutes to package up the new
version for PLD's repository, and seven and a half minutes of that
were me figuring out that I used the wrong download URL and got bit by
GForge's bug that lets you download an old file with a new name
instead of getting a 404.

A quality release!
 
F

Florian Gross

Gavin said:
The methods added since 0.5 are summarised on the website:

+ Array#only
+ Array#rand
+ Enumerable#none?
+ Enumerable#one?
+ Kernel#require_relative
+ Module.by_name
+ Module#basename
+ Module#deep_const_get

Thanks, I was fearing that there would be name clashes with the
Ruby-Junction library which defines Enumerable#none, #any, #all,
#with_count and #exactly.

Array#rand sounds interesting, but I wonder if it does not lead to
trouble when using rand() from a custom overloaded Array or Enumerable
method.
 
G

Gavin Sinclair

The methods added since 0.5 are summarised on the website:
[...]
Thanks, I was fearing that there would be name clashes with the
Ruby-Junction library which defines Enumerable#none, #any, #all,
#with_count and #exactly.

You might be interested to know that 'extensions' is careful about
adding methods. If, for example, you did this:

class Array; def rand; ...; end; end

require 'extensions/array'

then you'd get a warning on STDERR, something like

WARNING: Array#rand exists, not overwriting

But obviously method clashes are better discovered by human
communication than by code. I'll have to check out the Ruby-Junction
library.
Array#rand sounds interesting, but I wonder if it does not lead to
trouble when using rand() from a custom overloaded Array or Enumerable
method.

What might an example of this trouble be? For a start, it's only
defined on Array, not Enumerable. And its definition is very simple:

def rand
idx = Kernel.rand(self.size)
at(idx)
end

So any array that properly implements size and at should do the trick.

BTW Florian, while I've got you on this subject, I must apologise for
an incorrect attribution in extensions: Florian Frank appears in there
on one occasion instead of you. FINR :)

Cheers,
Gavin
 
F

Florian Gross

Gavin said:
You might be interested to know that 'extensions' is careful about
adding methods. If, for example, you did this:

class Array; def rand; ...; end; end

require 'extensions/array'

then you'd get a warning on STDERR, something like

WARNING: Array#rand exists, not overwriting

Oh, that's quite a nifty feature. Well done!
What might an example of this trouble be? For a start, it's only
defined on Array, not Enumerable. And its definition is very simple:

def rand
idx = Kernel.rand(self.size)
at(idx)
end

So any array that properly implements size and at should do the trick.

I'm thinking about something like this: (Made-up sample, does not make
much sense in isolation -- but it could also happen in real code.)

class Enumerable
def find_some(chance = 0.5)
find_all { rand < chance }
end
end

I think using the Array#rand extension would lead to trouble in this case:

[1, 2, 3].find_some

Because Enumerable#find_some expects to call Kernel#rand.

I'm not sure if it is necessary to rename it (Array#pick_rand seems to
be a common candidate), but a note in the documentation might be a good
thing.
BTW Florian, while I've got you on this subject, I must apologise for
an incorrect attribution in extensions: Florian Frank appears in there
on one occasion instead of you. FINR :)

Oh, no problem there -- we tend to get confused a lot. I guess one could
refer to me as 'flgr' instead in case it would help.
 
G

Gavin Sinclair

I'm thinking about something like this: (Made-up sample, does not make
much sense in isolation -- but it could also happen in real code.)
class Enumerable
def find_some(chance = 0.5)
find_all { rand < chance }
end
end
I think using the Array#rand extension would lead to trouble in this case:
[1, 2, 3].find_some
Because Enumerable#find_some expects to call Kernel#rand.

OIC. Yes, when dabbling in these waters I tend to be explicit, so I
would use Kernel.rand instead.
I'm not sure if it is necessary to rename it (Array#pick_rand seems to
be a common candidate), but a note in the documentation might be a good
thing.

Yes. I'll put something in.

Gavin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,316
Latest member
naturesElixirCBDGummies

Latest Threads

Top