From: "Shot (Piotr Szotkowski)" Date: 2008-05-19T05:17:43+09:00 Subject: Re: How to wrap either forkoff or map depending on a config variable? --6Mt39TZj+HFMr11E Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Shot (Piotr Szotkowski): > Shot (Piotr Szotkowski): >> I=E2=80=99m trying to write an Enumerable#parallel method that, dependin= g on >> a config option (retrieved inside it) would end up being an alias for >> either Enumerable#map or Enumerable#forkoff. > FWIW, the spec to pass is > describe Enumerable do > it 'should be able to process in parallel, depending on config option' = do > ArtDecomp::Config.processes =3D 1 > pid1, pid2 =3D [1,2].parallel { Process.pid } > pid1.should =3D=3D pid2 > ArtDecomp::Config.processes =3D 2 > pid1, pid2 =3D [1,2].parallel { Process.pid } > pid1.should_not =3D=3D pid2 > end > end Ok, a patch to make it actually test the implementation: describe Enumerable do it 'should be able to process in parallel, depending on config option' do ArtDecomp::Config.processes =3D 1 pid1, pid2 =3D [1,2].parallel { Process.pid } - pid1.should =3D=3D pid2 + pid1.should =3D=3D Process.pid ArtDecomp::Config.processes =3D 2 pid1, pid2 =3D [1,2].parallel { Process.pid } pid1.should_not =3D=3D pid2 end end -- Shot (aware that the above spec in not really in true BDD spirit) --=20 When C++ is your hammer, everything looks like a thumb. -- Steven M. Hafl= ich --6Mt39TZj+HFMr11E Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFIMJBxi/mCfdEo8UoRAqO7AKCUtWG5E4AM11QfqDA8bs82+5AfwACfd6hI DwGm14pgC+IrpKxawp1c4r4= =tzJB -----END PGP SIGNATURE----- --6Mt39TZj+HFMr11E--