[ANN] Ruby/Extensions v0.6.0

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

Gavin Sinclair wrote:

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.

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.
  .
  This project contains several extensions to the Ruby standard classes. Many
  are sourced from the Ruby Wiki.
  .
  Criteria for inclusion of a method are:
  - the method serves a general purpose
  - it is reasonably clear from the method name what its behaviour is
  - it would not generally be out of place in the language itself
  .
  Apart from convenience, the benefit of this package is to provide a
  reference.
  You can use this package for your convenience, and deploy your code with a
  clear dependency on it, since anyone can download it. That is better than
  releasing your package with a few ad hoc standard class modifications, and
  hoping that they don't conflict with any code your users have written.
  .
  Long story short: it's useful that Ruby allows you to add methods to existing
  classes, even built-ins like String and Array. Some people rightfully are
  uneasy about actually doing so, because of possible conflicts. This project
  offers a standard set of extensions in order to mitigate that uneasiness by
  making them publicly available, and well documented.

···

On Wed, Dec 08, 2004 at 11:12:29PM +0900, Gavin Sinclair wrote:

--
Hassle-free packages for Ruby?
RPA is available from http://www.rubyarchive.org/

Gavin Sinclair wrote:

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.

A change log is included in the rubyforge release:

···

On Thursday, December 9, 2004, 1:22:29 AM, Florian wrote:

2004-12-09 Gavin Sinclair <gsinclair@soyabean.com.au>

        * 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

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

:slight_smile:

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.

Thanks, I'll try to fix that.

Gavin

···

On Thursday, December 9, 2004, 2:16:10 AM, Mauricio wrote:

On Wed, Dec 08, 2004 at 11:12:29PM +0900, Gavin Sinclair wrote:

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!

···

On Thu, 9 Dec 2004 00:39:40 +0900, Gavin Sinclair <gsinclair@soyabean.com.au> wrote:

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

Gavin Sinclair wrote:

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.

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 :slight_smile:

Cheers,
Gavin

···

On Thursday, December 9, 2004, 6:57:28 AM, Florian wrote:

Gavin Sinclair wrote:

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

Oh, that's quite a nifty feature. Well done!

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.

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 :slight_smile:

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.

···

On Thursday, December 9, 2004, 6:57:28 AM, Florian wrote:

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.

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

···

On Thursday, December 9, 2004, 11:32:31 AM, Florian wrote: