From transfire at gmail.com Tue Oct 2 15:48:34 2007 From: transfire at gmail.com (Trans) Date: Tue, 02 Oct 2007 19:48:34 -0000 Subject: [Facets] ANN: Facets 2.0.0 Message-ID: <1191354514.949636.162970@g4g2000hsf.googlegroups.com> Today I have officially released Facet 2.0.0. gem install facets Facets 2.0.0 represent the project's official push into "production ready" status --a major departure from the 1.x series which was focused on acquiring functionality. For more information about this release see the README below. I expect (as with any zero-point release) there will be some minor releases to quickly follow. Please, let me know if you encounter any problems so I can get them fixed right away. Special thanks to everyone that helped me get this release together! T. = Ruby Facets http://facets.rubyforge.com "ALL YOUR BASE ARE BELONG TO RUBY" == Introduction Ruby Facets is the single largest collection of general purpose method extensions and system additions for the Ruby programming language. The core extensions is a large collection of methods which extend the core capabilities of Ruby's built-in classes and modules. This collection of extension methods are unique by virtue of their atomicity. The methods are stored in relatively small groups of tightly coupled methods so that each can be required independently. This gives developers the potential for much finer control over which extra methods to bring into their code. The "more" additions are a collection of classes, modules and light meta-systems which constitutes an ever improving source of reusable components. Some very nice additions are provided, from the simple Functor class to a full-blown annotations system. == Installation You can install either via RubyGems or manually: % gem install facets or % tar -xzf facets-2.x.x.tar.gz % cd facets-2.x.x % sudo task/install IMPORTANT! Note that setup.rb is no longer used due to Facets new special layout. == Compatibility with 1.x series. Prior to 2.0, Facets was divided between CORE and MORE --standalone extensions vs. classes and modules, respectively. With 2.0, the idea of CORE has take only a slightly new meaning. Instead CORE now represents the libraries that are considered essential and as such are loaded automatically when using ++require "facets"++. While still primarily made up of extension methods a few classes now belong to core as well. In conjunction with this the extension methods are no longer stored on a per-method basis, but rather in tight knit packs. While dividing the extension methods up on a per- method basis had certain advantages, not the least of which was a simple organization, it proved too granular --rather than "atomic" it was "subatomic". With 2.0 we have address this issue. All the extension methods have now been organized into small tightly related groups. However, being able to require on the basis of a method is still a useful approach, so a compatibility layer for the 1.x series has been created. It makes it possible to load Facets libraries on a per method basis, just as before, via require redirection. For example: require 'facets/core/string/underscore' Will redirect according to the content of the underscore.rb file: require 'facets/string/stylize' So the underscore method will be loaded just as before. But a few other *stylization* methods will be loaded as well. This actually proves a more useful approach b/c often one will want to use one of the related methods as well. == Mission Facets holds to the notion that the more we can reasonably integrate into a common foundation directed toward general needs, the better that foundation will be able to serve everyone. There are a number of advantages here: * Better Code-reuse * Collaborative Improvements * Greater Name Consistency * One-stop Shop and Installation == Status The current status is quite good. While some parts are still considered beta, everything is relatively usable. == Installation The easiest way to install is via RubyGems. On the command line enter: > gem install facets To manually install, unpack the .tar.bz2 package and use the included setup.rb script. For example: > tar -xvzf facets-x.x.x.tar.gz > cd facets-x.x.x > sudo util/setup On Window the last step will be: > ruby util/setup == Usage For detailed usage of any given method or module please refer to the API RDocs. Most are well documented. Assistance in improving documentation though is always appreciated. If you plan to use more then a few of Facets core method it is recommended that you require require the main facility. require 'facets' This loads all the CORE functionality at once. Of course you can use the CORE library piecemeal if you prefer. The general require statement for a core extensions library is: require 'facets//' For example: require 'facets/time/stamp' Most "atoms" contain only a few methods, sometimes only one, but a few excpetions provide quite a few method, such as ++string/indexable.rb++. You can load per-class or per-module groups of core methods by requiring the class or module by name. For example" require 'facets/time' Will require all the Time method extensions. Note that some methods that were part of CORE in 1.8 and earlier are now part of MORE libraries. A good example is 'random.rb'. There were separated b/c they had more specialized usecases, where as CORE extensions are intended as general purpose. Using a Facets/MORE library of modules, classes or microframeworks is essentially the same. For example: require 'facets/basicobject' Again, for details pertaining to the functionality of each feature, please see the API Docs. == Method File Names Operator method redirect files are stored using english names. For instance for Proc#* is 'proc/op_mul'. For reference, here is the chart. +@ => op_plus_self -@ => op_minus_self + => op_plus - => op_minus ** => op_pow * => op_mul / => op_div % => op_mod ~ => op_tilde <=> => op_cmp << => op_lshift >> => op_rshift < => op_lt > => op_gt === => op_case_eq == => op_equal =~ => op_apply <= => op_lt_eq >= => op_gt_eq | => op_or & => op_and ^ => op_xor []= => op_store [] => op_fetch Facets simply takes the '*' and translates it into a string acceptable to all file systems. Also, if a method ends in '=', '?' or '!' it is simply removed. == Contribute This project thrives on contribution. If you have any extension methods, classes, modules or small frameworks that you think have general applicability and would like to see them included in this project, don't hesitate to submit. There's a very good chance it will be included. Also, if you have better versions of any thing already included or simply have a patch, they too are more than welcome. We want Ruby Facets to be of the highest quality. == Authors This collection was put together by, and largely written by Thomas Sawyer (aka Trans). He can be reached via email at transfire at gmail.com. Some parts of this collection were written and/or inspired by other persons. Fortunately nearly all were copyrighted under the same open license, the Ruby License. In the few exceptions I have included the copyright notice with the source code. Any code file not specifically labeled shall fall under the Ruby License. In all cases, I have made every effort to give credit where credit is due. You will find these copyrights, thanks and acknowledgements embedded in the source code, and an unobtrusive "Author(s)" section is given in the RDocs. Also see the AUTHORS file for a list of all contributing Rubyists. If anyone is missing from the list, please let me know and I will correct right away. Thanks. == License The collection PER COLLECTION is licensed as follows: Ruby Facets Copyright (c) 2004-2006 Thomas Sawyer Distributed under the terms of the Ruby license. The Ruby license is a dual license that also provides for use of the GPL. Complete texts of both licenses accompany this document (see doc/ COPYING). This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Acknowledgments and Copyrights for particular snippets of borrowed code are given in their respective source. All licenses are either compatible with the Ruby license (namely the GPL) or the original author has given permission for inclusion of their code under such license. From o.renaud at laposte.net Tue Oct 2 16:43:50 2007 From: o.renaud at laposte.net (Olivier Renaud) Date: Tue, 2 Oct 2007 22:43:50 +0200 Subject: [Facets] ANN: Facets 2.0.0 In-Reply-To: <1191354514.949636.162970@g4g2000hsf.googlegroups.com> References: <1191354514.949636.162970@g4g2000hsf.googlegroups.com> Message-ID: <200710022243.50197.o.renaud@laposte.net> Le mardi 02 octobre 2007 21:48, Trans a ?crit?: > Today I have officially released Facet 2.0.0. > Congratulations, thanks for the good work ! -- Olivier Renaud From transfire at gmail.com Wed Oct 3 14:47:32 2007 From: transfire at gmail.com (Trans) Date: Wed, 03 Oct 2007 18:47:32 -0000 Subject: [Facets] ANN: Facets 2.0.0 In-Reply-To: <200710022243.50197.o.renaud@laposte.net> References: <1191354514.949636.162970@g4g2000hsf.googlegroups.com> <200710022243.50197.o.renaud@laposte.net> Message-ID: <1191437252.216392.320580@g4g2000hsf.googlegroups.com> On Oct 2, 1:43 pm, Olivier Renaud wrote: > Le mardi 02 octobre 2007 21:48, Trans a ?crit : > > > Today I have officially released Facet 2.0.0. > > Congratulations, thanks for the good work ! Thanks Oliver! I'll be making a general announcement to the Ruby community tomorrow. By the way has anyone seen the latest docs page? It's shaping up pretty nicely, I think. http://facets.rubyforge.org/learn.html T. From jronallo at gmail.com Fri Oct 5 14:46:41 2007 From: jronallo at gmail.com (Jason Ronallo) Date: Fri, 5 Oct 2007 14:46:41 -0400 Subject: [Facets] String.interpolate Message-ID: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> I have facets-2.0.0 and I'm trying to get String.interpolate to work. I've taken this from the test at the end of the interpolate.rb file. $ irb1.8 irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'facets/string/interpolate' => true irb(main):003:0> a = 1 => 1 irb(main):004:0> String.interpolate{'this is #{a}'} NoMethodError: undefined method `interpolate' for String:Class from (irb):4 Any ideas why this doesn't work for me? --Jason From o.renaud at laposte.net Fri Oct 5 15:09:34 2007 From: o.renaud at laposte.net (Olivier Renaud) Date: Fri, 5 Oct 2007 21:09:34 +0200 Subject: [Facets] ANN: Facets 2.0.0 In-Reply-To: <1191437252.216392.320580@g4g2000hsf.googlegroups.com> References: <1191354514.949636.162970@g4g2000hsf.googlegroups.com> <200710022243.50197.o.renaud@laposte.net> <1191437252.216392.320580@g4g2000hsf.googlegroups.com> Message-ID: <200710052109.34722.o.renaud@laposte.net> Le mercredi 03 octobre 2007 20:47, Trans a ?crit?: > On Oct 2, 1:43 pm, Olivier Renaud wrote: > > Le mardi 02 octobre 2007 21:48, Trans a ?crit : > > > Today I have officially released Facet 2.0.0. > > > > Congratulations, thanks for the good work ! > > Thanks Oliver! I'll be making a general announcement to the Ruby > community tomorrow. > > By the way has anyone seen the latest docs page? It's shaping up > pretty nicely, I think. > > http://facets.rubyforge.org/learn.html > > T. Oh yes, I noticed the doc page, that's pretty cool. I like the direct access to classes. And the image for "quick API", too :) -- Olivier Renaud From transfire at gmail.com Fri Oct 5 15:23:00 2007 From: transfire at gmail.com (TRANS) Date: Fri, 5 Oct 2007 12:23:00 -0700 Subject: [Facets] String.interpolate In-Reply-To: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> Message-ID: <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> On 10/5/07, Jason Ronallo wrote: > I have facets-2.0.0 and I'm trying to get String.interpolate to work. > I've taken this from the test at the end of the interpolate.rb file. > > $ irb1.8 > irb(main):001:0> require 'rubygems' > => true > irb(main):002:0> require 'facets/string/interpolate' > => true > irb(main):003:0> a = 1 > => 1 > irb(main):004:0> String.interpolate{'this is #{a}'} > NoMethodError: undefined method `interpolate' for String:Class > from (irb):4 > > Any ideas why this doesn't work for me? Not sure. It works for me, and I just did a reinstall from gem and checked the gem repo to make sure everything installed right. I didn't see anything out of place. Do you by chance have 1.8.54 installed manually (ie. not via RubyGems?) Also what OS are you on? T. From jronallo at gmail.com Fri Oct 5 15:57:41 2007 From: jronallo at gmail.com (Jason Ronallo) Date: Fri, 5 Oct 2007 15:57:41 -0400 Subject: [Facets] String.interpolate In-Reply-To: <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> Message-ID: <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> On 10/5/07, TRANS wrote: > On 10/5/07, Jason Ronallo wrote: > > I have facets-2.0.0 and I'm trying to get String.interpolate to work. > > I've taken this from the test at the end of the interpolate.rb file. > > > > $ irb1.8 > > irb(main):001:0> require 'rubygems' > > => true > > irb(main):002:0> require 'facets/string/interpolate' > > => true > > irb(main):003:0> a = 1 > > => 1 > > irb(main):004:0> String.interpolate{'this is #{a}'} > > NoMethodError: undefined method `interpolate' for String:Class > > from (irb):4 > > > > Any ideas why this doesn't work for me? > > Not sure. It works for me, and I just did a reinstall from gem and > checked the gem repo to make sure everything installed right. I didn't > see anything out of place. > > Do you by chance have 1.8.54 installed manually (ie. not via RubyGems?) > > Also what OS are you on? I uninstalled the 1.8.54 gem and get the same results. facets-2.0.0 via rubygems is the only version installed. I'm on Debian Etch. --Jason From transfire at gmail.com Fri Oct 5 16:08:35 2007 From: transfire at gmail.com (TRANS) Date: Fri, 5 Oct 2007 13:08:35 -0700 Subject: [Facets] String.interpolate In-Reply-To: <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> Message-ID: <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> On 10/5/07, Jason Ronallo wrote: > > I uninstalled the 1.8.54 gem and get the same results. facets-2.0.0 > via rubygems is the only version installed. I'm on Debian Etch. Okay. Actually it's not the gem I was worried about, but a _manual_ install (in site_ruby). But I assume from what you told me that's not the case either. Hmm... let me see if I can find some one else to test it out and get back to you. I'm not sure what could be amiss at the moment. However, can you look at '/usr/lib/ruby/gems/1.8/gems/specifications/facets-2.0.0.gemspec'. And make sure this is in there: s.require_paths = ["lib/core", "lib/more", "lib/methods"] T. From transfire at gmail.com Fri Oct 5 16:14:33 2007 From: transfire at gmail.com (Trans) Date: Fri, 05 Oct 2007 20:14:33 -0000 Subject: [Facets] String.interpolate In-Reply-To: <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> Message-ID: <1191615273.702827.80570@o80g2000hse.googlegroups.com> On Oct 5, 12:57 pm, "Jason Ronallo" wrote: > I uninstalled the 1.8.54 gem and get the same results. facets-2.0.0 > via rubygems is the only version installed. I'm on Debian Etch. Oh, also see if anything else if failing. Try some of the other string extensions for example. Maybe that will give us a better idea of what's happening. Thanks, T. From jronallo at gmail.com Fri Oct 5 16:25:03 2007 From: jronallo at gmail.com (Jason Ronallo) Date: Fri, 5 Oct 2007 16:25:03 -0400 Subject: [Facets] String.interpolate In-Reply-To: <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> Message-ID: <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> On 10/5/07, TRANS wrote: > On 10/5/07, Jason Ronallo wrote: > > > > I uninstalled the 1.8.54 gem and get the same results. facets-2.0.0 > > via rubygems is the only version installed. I'm on Debian Etch. > > Okay. Actually it's not the gem I was worried about, but a _manual_ > install (in site_ruby). But I assume from what you told me that's not > the case either. > > Hmm... let me see if I can find some one else to test it out and get > back to you. I'm not sure what could be amiss at the moment. However, > can you look at > '/usr/lib/ruby/gems/1.8/gems/specifications/facets-2.0.0.gemspec'. And > make sure this is in there: > > s.require_paths = ["lib/core", "lib/more", "lib/methods"] It's /var/lib/gems/1.8/specifications/facets-2.0.0.gemspec for me, and that line is in there. Strange. align_center and downcase? work, but blank? and bracket throw a NoMethodError. This is with require 'rubygems'; require 'facets/string' --Jason From transfire at gmail.com Fri Oct 5 17:57:57 2007 From: transfire at gmail.com (Trans) Date: Fri, 05 Oct 2007 21:57:57 -0000 Subject: [Facets] String.interpolate In-Reply-To: <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> Message-ID: <1191621477.819504.192570@r29g2000hsg.googlegroups.com> On Oct 5, 1:25 pm, "Jason Ronallo" wrote: > On 10/5/07, TRANS wrote: > > > > > On 10/5/07, Jason Ronallo wrote: > > > > I uninstalled the 1.8.54 gem and get the same results. facets-2.0.0 > > > via rubygems is the only version installed. I'm on Debian Etch. > > > Okay. Actually it's not the gem I was worried about, but a _manual_ > > install (in site_ruby). But I assume from what you told me that's not > > the case either. > > > Hmm... let me see if I can find some one else to test it out and get > > back to you. I'm not sure what could be amiss at the moment. However, > > can you look at > > '/usr/lib/ruby/gems/1.8/gems/specifications/facets-2.0.0.gemspec'. And > > make sure this is in there: > > > s.require_paths = ["lib/core", "lib/more", "lib/methods"] > > It's /var/lib/gems/1.8/specifications/facets-2.0.0.gemspec for me, and > that line is in there. > > Strange. align_center and downcase? work, but blank? and bracket throw > a NoMethodError. This is with require 'rubygems'; require > 'facets/string' Very strange indeed. I'm going to have to let this rumble around my head for a bit and see if anything comes to mind. T. From jronallo at gmail.com Fri Oct 5 19:17:18 2007 From: jronallo at gmail.com (Jason Ronallo) Date: Fri, 5 Oct 2007 19:17:18 -0400 Subject: [Facets] String.interpolate In-Reply-To: <1191621477.819504.192570@r29g2000hsg.googlegroups.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> <1191621477.819504.192570@r29g2000hsg.googlegroups.com> Message-ID: <763570460710051617y22ac8b78qd164848f401986a2@mail.gmail.com> > > Strange. align_center and downcase? work, but blank? and bracket throw > > a NoMethodError. This is with require 'rubygems'; require > > 'facets/string' > > Very strange indeed. I'm going to have to let this rumble around my > head for a bit and see if anything comes to mind. No problem; no rush. Let me know if there's any other information I can provide to help out. I just tried this on another machine with a very similar Debian Etch setup and got the same results. --Jason From transfire at gmail.com Sat Oct 6 06:48:27 2007 From: transfire at gmail.com (Trans) Date: Sat, 06 Oct 2007 10:48:27 -0000 Subject: [Facets] String.interpolate In-Reply-To: <763570460710051617y22ac8b78qd164848f401986a2@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> <1191621477.819504.192570@r29g2000hsg.googlegroups.com> <763570460710051617y22ac8b78qd164848f401986a2@mail.gmail.com> Message-ID: <1191667707.239302.241860@o80g2000hse.googlegroups.com> On Oct 5, 7:17 pm, "Jason Ronallo" wrote: > > > Strange. align_center and downcase? work, but blank? and bracket throw > > > a NoMethodError. This is with require 'rubygems'; require > > > 'facets/string' > > > Very strange indeed. I'm going to have to let this rumble around my > > head for a bit and see if anything comes to mind. > > No problem; no rush. Let me know if there's any other information I > can provide to help out. > > I just tried this on another machine with a very similar Debian Etch > setup and got the same results. Thankfully I was able to reproduce tyhe problem today on my Gmom's Windows machine. Turns out the RubyGems adds the specification require_paths to Ruby's LOAD_PATH in reverse order. I'm a bit surprised at that and will bring it up with the RubyGems teams -- they've probably never even considered that the order is significant. I'll put out a new version (2.0.1) later today. In the mean time you can fix the problem by hand editing the facets-2.0.0.gemspec. Change the line: s.require_paths = ["lib/core", "lib/more", "lib/methods"] to s.require_paths = ["lib/methods", "lib/more", "lib/core"] T. From jronallo at gmail.com Sat Oct 6 12:56:31 2007 From: jronallo at gmail.com (Jason Ronallo) Date: Sat, 6 Oct 2007 12:56:31 -0400 Subject: [Facets] String.interpolate In-Reply-To: <1191667707.239302.241860@o80g2000hse.googlegroups.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> <1191621477.819504.192570@r29g2000hsg.googlegroups.com> <763570460710051617y22ac8b78qd164848f401986a2@mail.gmail.com> <1191667707.239302.241860@o80g2000hse.googlegroups.com> Message-ID: <763570460710060956m2722603apea7c58c33062eb70@mail.gmail.com> > Thankfully I was able to reproduce tyhe problem today on my Gmom's > Windows machine. Turns out the RubyGems adds the specification > require_paths to Ruby's LOAD_PATH in reverse order. I'm a bit > surprised at that and will bring it up with the RubyGems teams -- > they've probably never even considered that the order is significant. > I'll put out a new version (2.0.1) later today. In the mean time you > can fix the problem by hand editing the facets-2.0.0.gemspec. Change > the line: > > s.require_paths = ["lib/core", "lib/more", "lib/methods"] > > to > > s.require_paths = ["lib/methods", "lib/more", "lib/core"] Yes, making this change String.interpolate and bracket now work as advertised. I'll be interested to hear what the rubygems folks say about this. --Jason From transfire at gmail.com Sun Oct 7 10:10:43 2007 From: transfire at gmail.com (Trans) Date: Sun, 07 Oct 2007 14:10:43 -0000 Subject: [Facets] String.interpolate In-Reply-To: <763570460710060956m2722603apea7c58c33062eb70@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> <1191621477.819504.192570@r29g2000hsg.googlegroups.com> <763570460710051617y22ac8b78qd164848f401986a2@mail.gmail.com> <1191667707.239302.241860@o80g2000hse.googlegroups.com> <763570460710060956m2722603apea7c58c33062eb70@mail.gmail.com> Message-ID: <1191766243.316006.267990@g4g2000hsf.googlegroups.com> On Oct 6, 9:56 am, "Jason Ronallo" wrote: > > Thankfully I was able to reproduce tyhe problem today on my Gmom's > > Windows machine. Turns out the RubyGems adds the specification > > require_paths to Ruby's LOAD_PATH in reverse order. I'm a bit > > surprised at that and will bring it up with the RubyGems teams -- > > they've probably never even considered that the order is significant. > > I'll put out a new version (2.0.1) later today. In the mean time you > > can fix the problem by hand editing the facets-2.0.0.gemspec. Change > > the line: > > > s.require_paths = ["lib/core", "lib/more", "lib/methods"] > > > to > > > s.require_paths = ["lib/methods", "lib/more", "lib/core"] > > Yes, making this change String.interpolate and bracket now work as advertised. > I'll be interested to hear what the rubygems folks say about this. Just discovered something really nasty. Looks like the require_paths are searched front-to-back on Unix systems and back-to-front on windows systems. Can you believe that? I can hardly believe it myself but that's what the evidence suggests. My Windows system now works with the 2.0.1 gem, but my Linux system doesn't. Ugh. T. From transfire at gmail.com Sun Oct 7 17:05:09 2007 From: transfire at gmail.com (Trans) Date: Sun, 07 Oct 2007 21:05:09 -0000 Subject: [Facets] SHOW STOPPER Message-ID: <1191791109.024036.203850@22g2000hsm.googlegroups.com> Please note there is a problem with the current release of Facets (both 2.0.0 and 2.0.1). There appears to be a bug in RubyGems, such that it does not always scan gemspecs require_paths in the same order. That's a big problem for Facets because the core libs needs to have precedence over the method redirects. Let you all know what the RubyGems team has to say --hopefully tomorrow. T. From transfire at gmail.com Mon Oct 8 10:23:03 2007 From: transfire at gmail.com (Trans) Date: Mon, 08 Oct 2007 14:23:03 -0000 Subject: [Facets] SHOW STOPPER - RESOVLED In-Reply-To: <1191791109.024036.203850@22g2000hsm.googlegroups.com> References: <1191791109.024036.203850@22g2000hsm.googlegroups.com> Message-ID: <1191853383.122050.268920@y42g2000hsy.googlegroups.com> On Oct 7, 2:05 pm, Trans wrote: > Please note there is a problem with the current release of Facets > (both 2.0.0 and 2.0.1). There appears to be a bug in RubyGems, such > that it does not always scan gemspecs require_paths in the same order. > That's a big problem for Facets because the core libs needs to have > precedence over the method redirects. > > Let you all know what the RubyGems team has to say --hopefully > tomorrow. Ok. I've managed a work around. When generating the lib/methods/facets/ * redirects, I check to see if the method file has the same name as the core file it came from, if so I don't create it --hence eliminating file name overlap. Pretty simple. Wish I had thought of it before, but then, I didn't think RubyGems would cause a problem, and it was kind of nice to look in lib/method/facets/ and see a list of all methods defined in core. Oh well. Can't have everything. 2.0.2 is up on the gem server. Please have at it and let me know if it's working for you. Thanks, T. From transfire at gmail.com Mon Oct 8 10:23:44 2007 From: transfire at gmail.com (Trans) Date: Mon, 08 Oct 2007 14:23:44 -0000 Subject: [Facets] SHOW STOPPER - RESOLVED In-Reply-To: <1191791109.024036.203850@22g2000hsm.googlegroups.com> References: <1191791109.024036.203850@22g2000hsm.googlegroups.com> Message-ID: <1191853424.382612.209910@v3g2000hsg.googlegroups.com> Err... RESOLVED From transfire at gmail.com Mon Oct 8 10:37:42 2007 From: transfire at gmail.com (Trans) Date: Mon, 08 Oct 2007 14:37:42 -0000 Subject: [Facets] SHOW STOPPER - RESOLVED In-Reply-To: <1191853383.122050.268920@y42g2000hsy.googlegroups.com> References: <1191791109.024036.203850@22g2000hsm.googlegroups.com> <1191853383.122050.268920@y42g2000hsy.googlegroups.com> Message-ID: <1191854262.943087.281170@v3g2000hsg.googlegroups.com> RESOLVED. From jronallo at gmail.com Wed Oct 10 09:39:19 2007 From: jronallo at gmail.com (Jason Ronallo) Date: Wed, 10 Oct 2007 09:39:19 -0400 Subject: [Facets] String.interpolate In-Reply-To: <1191766243.316006.267990@g4g2000hsf.googlegroups.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <4b6f054f0710051223t598a0379ubb062d7c99519619@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> <1191621477.819504.192570@r29g2000hsg.googlegroups.com> <763570460710051617y22ac8b78qd164848f401986a2@mail.gmail.com> <1191667707.239302.241860@o80g2000hse.googlegroups.com> <763570460710060956m2722603apea7c58c33062eb70@mail.gmail.com> <1191766243.316006.267990@g4g2000hsf.googlegroups.com> Message-ID: <763570460710100639ja6f1702j35bf53d766d51a2a@mail.gmail.com> Just reporting back that Facets now works for me with the 2.0.2 release. This is on the same Debian Linux system that had the initial problem. Thanks for getting this fixed. --Jason From transfire at gmail.com Wed Oct 10 09:47:49 2007 From: transfire at gmail.com (TRANS) Date: Wed, 10 Oct 2007 06:47:49 -0700 Subject: [Facets] String.interpolate In-Reply-To: <763570460710100639ja6f1702j35bf53d766d51a2a@mail.gmail.com> References: <763570460710051146t44fe44b7l7895e1091f37cb23@mail.gmail.com> <763570460710051257g1b7db890m492e72aa04cb6b9f@mail.gmail.com> <4b6f054f0710051308s1d1c3cfbl3177af246d3b31c4@mail.gmail.com> <763570460710051325j23f8674ci8ac6dc8425df654f@mail.gmail.com> <1191621477.819504.192570@r29g2000hsg.googlegroups.com> <763570460710051617y22ac8b78qd164848f401986a2@mail.gmail.com> <1191667707.239302.241860@o80g2000hse.googlegroups.com> <763570460710060956m2722603apea7c58c33062eb70@mail.gmail.com> <1191766243.316006.267990@g4g2000hsf.googlegroups.com> <763570460710100639ja6f1702j35bf53d766d51a2a@mail.gmail.com> Message-ID: <4b6f054f0710100647u2f720749l81b6856453eaec4d@mail.gmail.com> On 10/10/07, Jason Ronallo wrote: > Just reporting back that Facets now works for me with the 2.0.2 > release. This is on the same Debian Linux system that had the initial > problem. Thanks for getting this fixed. Thank you!!! T. From o.renaud at laposte.net Thu Oct 18 09:52:07 2007 From: o.renaud at laposte.net (Olivier Renaud) Date: Thu, 18 Oct 2007 15:52:07 +0200 Subject: [Facets] SHOW STOPPER In-Reply-To: <1191791109.024036.203850@22g2000hsm.googlegroups.com> References: <1191791109.024036.203850@22g2000hsm.googlegroups.com> Message-ID: <200710181552.07760.o.renaud@laposte.net> This is just a test : I tried to start a new topic on this list, but my mails are never received. So, I try to reply to an existing topic, to see if that works. -- Olivier Renaud From transfire at gmail.com Thu Oct 18 10:55:48 2007 From: transfire at gmail.com (TRANS) Date: Thu, 18 Oct 2007 10:55:48 -0400 Subject: [Facets] module/traits.rb Message-ID: <4b6f054f0710180755k60a2f2d4lb85f5b28f64e6448@mail.gmail.com> Want to thank Robert Dober for his help in improving Facets traits library. Robert recetly release RubyTraits 0.1. This was his initial attempt to create a formal implementation of Traits (I believe according to Squeak's specifications). His next version will borrow heavily from Facets. In turn his work encouraged me to improve Facets' own lib. Facets' lib is not a formal implementation, but my attempt to give you the power of triats but within the context of Ruby's own reuse system --modules. I think the new lib is really nice. I encourge you to try it out. With it you can do module ("traits") composition like it were simple math: New module composed of M and N: L = M + N New module composed of M with method :x undefined: L = M - :x New module with method x renamed to y: L = M * { :x => :y } Probably the most signifficant difference between Facets' implementation and formal spec is the question of raising a conflict error it there are method name clashes. For example: module M def x; "Mx"; end end module N def x; "Nx"; end end M + N #=> ConflictError To circumvent you'd have to do something like: M - :x + N But I don't see how this is reasonable b/c what about #super? (which Traits spec does specifiy, btw). module M def x; "Mx"; end end module N def x; "N" + super; end end In this case N is meant to be composed with another trait/module in order to function. But to do so would cause the conflict error, and I see no resaonble way to denote cricumvention of it. (Does anyone else?) So instead of raising a conflict error I just offered a #conflict? method that you can use to make the check yourself, if you want. raise if M.conflict?(N) Hope you like the new lib. Its available in the SVN repo and will be in the next release probably in a month or so. On a slightly off note, does it seem odd to anyone else that a module's private methods participate in the inheritance chain? T. From o.renaud at laposte.net Thu Oct 18 11:25:08 2007 From: o.renaud at laposte.net (o.renaud at laposte.net) Date: Thu, 18 Oct 2007 17:25:08 +0200 (CEST) Subject: [Facets] Thread-safe PQueue Message-ID: <22736728.3970611192721108378.JavaMail.www@wwinf8402> Hi, I already worked a little on the PQueue class, an implementation of a Priority Queue (aka Heap). On Ruby-talk, someone asked for a thread-safe Priority Queue, which is a fairly reasonnable demand since a PQueue is very useful as an alternative to the Queue from the 'thread' stdlib. So, I tried to make the Facet's PQueue class thread-safe, using MonitorMixin from the 'monitor' stdlib. Synchronization seems ok, but the problem is that the synchronized version is twice as slow than the non-synchronized one (at least for the "push" method). My question is : is it worth it ? Should I directly use Thread.critical instead of MonitorMixin (not sure how to use it, by the way) ? Or maybe should we provide two different classes, thread-safe (maybe a simplified one) and non-thread-safe ? -- Olivier Renaud Cr?ez votre adresse ?lectronique pr?nom.nom at laposte.net 1 Go d'espace de stockage, anti-spam et anti-virus int?gr?s. From transfire at gmail.com Fri Oct 19 01:18:28 2007 From: transfire at gmail.com (TRANS) Date: Fri, 19 Oct 2007 01:18:28 -0400 Subject: [Facets] SHOW STOPPER In-Reply-To: <200710181552.07760.o.renaud@laposte.net> References: <1191791109.024036.203850@22g2000hsm.googlegroups.com> <200710181552.07760.o.renaud@laposte.net> Message-ID: <4b6f054f0710182218r7f11f3e3pf448784a2eccf3@mail.gmail.com> On 10/18/07, Olivier Renaud wrote: > This is just a test : I tried to start a new topic on this list, but my mails > are never received. So, I try to reply to an existing topic, to see if that > works. It works. The mailing-lists filters might be blocking you for some reason, but I would expect to get a bounce message about that, so I'm not sure. I will look at the settings. T. From transfire at gmail.com Fri Oct 19 01:26:30 2007 From: transfire at gmail.com (TRANS) Date: Fri, 19 Oct 2007 01:26:30 -0400 Subject: [Facets] SHOW STOPPER In-Reply-To: <4b6f054f0710182218r7f11f3e3pf448784a2eccf3@mail.gmail.com> References: <1191791109.024036.203850@22g2000hsm.googlegroups.com> <200710181552.07760.o.renaud@laposte.net> <4b6f054f0710182218r7f11f3e3pf448784a2eccf3@mail.gmail.com> Message-ID: <4b6f054f0710182226w32e64180g5c1eaed5e284d273@mail.gmail.com> On 10/19/07, TRANS wrote: > On 10/18/07, Olivier Renaud wrote: > > This is just a test : I tried to start a new topic on this list, but my mails > > are never received. So, I try to reply to an existing topic, to see if that > > works. > > It works. The mailing-lists filters might be blocking you for some > reason, but I would expect to get a bounce message about that, so I'm > not sure. I will look at the settings. Cannot find anything unusual. Well, if worse comes to worse you can try the google group archive: http://groups.google.com/group/facets-universal?hl=en T. From transfire at gmail.com Fri Oct 19 01:43:07 2007 From: transfire at gmail.com (Trans) Date: Fri, 19 Oct 2007 05:43:07 -0000 Subject: [Facets] Thread-safe PQueue In-Reply-To: <22736728.3970611192721108378.JavaMail.www@wwinf8402> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> Message-ID: <1192772587.472298.290490@v29g2000prd.googlegroups.com> On Oct 18, 11:25 am, "o.ren... at laposte.net" wrote: > Hi, > > I already worked a little on the PQueue class, an implementation of a Priority > Queue (aka Heap). On Ruby-talk, someone asked for a thread-safe Priority > Queue, which is a fairly reasonnable demand since a PQueue is very useful as > an alternative to the Queue from the 'thread' stdlib. So, I tried to make the > Facet's PQueue class thread-safe, using MonitorMixin from the 'monitor' > stdlib. > > Synchronization seems ok, but the problem is that the synchronized version is > twice as slow than the non-synchronized one (at least for the "push" method). > > My question is : is it worth it ? Should I directly use Thread.critical > instead of MonitorMixin (not sure how to use it, by the way) ? Or maybe > should we provide two different classes, thread-safe (maybe a simplified one) > and non-thread-safe ? Unfortunately this is an area in which I am of little brain. While I understand the basic issues of Threading, I've never understood all the various "syntax" that are strewn throughout code to fix it. I don't know, I just always get the feeling that the code could be rewritten in a different, thread-safe manner instead. But as I said, I don't really know enough to say. But if it's possible... In other words, is it possible to rewrite PQueue it in such a way that it would be thread safe, but *without* resorting to MonitorMixin or Thread.critical? T. From arne at arnebrasseur.net Fri Oct 19 02:33:06 2007 From: arne at arnebrasseur.net (Arne Brasseur) Date: Fri, 19 Oct 2007 14:33:06 +0800 Subject: [Facets] Thread-safe PQueue In-Reply-To: <1192772587.472298.290490@v29g2000prd.googlegroups.com> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> <1192772587.472298.290490@v29g2000prd.googlegroups.com> Message-ID: <47184FA2.9070507@arnebrasseur.net> Trans schreef: > On Oct 18, 11:25 am, "o.ren... at laposte.net" > wrote: > >> ... >> My question is : is it worth it ? Should I directly use Thread.critical >> instead of MonitorMixin (not sure how to use it, by the way) ? Or maybe >> should we provide two different classes, thread-safe (maybe a simplified one) >> and non-thread-safe ? >> > ... > In other words, is it possible to rewrite PQueue it in such a way that > it would be thread safe, but *without* resorting to MonitorMixin or > Thread.critical? > As far as I know there are no free meals here. You need some form of synchronization to make a data structure thread-safe. Be it high-level (MonitorMixin) or low-level (Thread.critical or Thread.exclusive). Or are you hinting at another sync' mechanism? Would it be much overhead to make thread-safety a setting that can be turned on or off for every instance? (ab) -- Arne Brasseur http://www.arnebrasseur.net http://www.zhongwiki.com http://www.bankske.org arne at arnebrasseur.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facets-universal/attachments/20071019/827cb70e/attachment-0001.html From transfire at gmail.com Fri Oct 19 02:53:28 2007 From: transfire at gmail.com (TRANS) Date: Fri, 19 Oct 2007 02:53:28 -0400 Subject: [Facets] Thread-safe PQueue In-Reply-To: <47184FA2.9070507@arnebrasseur.net> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> <1192772587.472298.290490@v29g2000prd.googlegroups.com> <47184FA2.9070507@arnebrasseur.net> Message-ID: <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> On 10/19/07, Arne Brasseur wrote: > > Trans schreef: > > On Oct 18, 11:25 am, "o.ren... at laposte.net" > wrote: > > > ... > My question is : is it worth it ? Should I directly use Thread.critical > instead of MonitorMixin (not sure how to use it, by the way) ? Or maybe > should we provide two different classes, thread-safe (maybe a simplified > one) > and non-thread-safe ? > > ... > In other words, is it possible to rewrite PQueue it in such a way that > it would be thread safe, but *without* resorting to MonitorMixin or > Thread.critical? > > As far as I know there are no free meals here. You need some form of > synchronization to make a data structure thread-safe. Be it high-level > (MonitorMixin) or low-level (Thread.critical or Thread.exclusive). Or are > you hinting at another sync' mechanism? Hmm... yes, I guess that makes sense. I suppose I was just thinking that we should be sure that we *have* to share the vars in question (ie. would a duplicate suffice?). Presuming we do, however, then there is no way around it. But why doesn't Ruby have something simple like: attr_thread_safe :x or am I over-simplifying what's possible? > Would it be much overhead to make thread-safety a setting that can be > turned on or off for every instance? The general Facets approach is to have the non-thread safe version "X" and then a thread-safe version "SyncX", which is a subclass (if possible). T. From arne at arnebrasseur.net Fri Oct 19 04:26:53 2007 From: arne at arnebrasseur.net (Arne Brasseur) Date: Fri, 19 Oct 2007 16:26:53 +0800 Subject: [Facets] Thread-safe PQueue In-Reply-To: <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> <1192772587.472298.290490@v29g2000prd.googlegroups.com> <47184FA2.9070507@arnebrasseur.net> <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> Message-ID: <47186A4D.6000008@arnebrasseur.net> TRANS schreef: > Hmm... yes, I guess that makes sense. I suppose I was just thinking > that we should be sure that we *have* to share the vars in question > (ie. would a duplicate suffice?). Presuming we do, however, then there > is no way around it. But why doesn't Ruby have something simple like: > > attr_thread_safe :x > > or am I over-simplifying what's possible? > Making the getting/setting of individual attributes thread safe wouldn't be all that useful. It probably already is since it's just updating a single object reference. The trouble usually comes in when there are multiple instance variables that in combination need to be in a consistent state. All operations that change one or more of these instance variables must be atomic. I think Ruby comes a long way in providing handy mechanisms for thread safety. The only language that is IMO more advanced in this respect is Ada. (Which is in a pain in many other respects). (ab) -- Arne Brasseur http://www.arnebrasseur.net http://www.zhongwiki.com http://www.bankske.org arne at arnebrasseur.net From o.renaud at laposte.net Fri Oct 19 07:17:06 2007 From: o.renaud at laposte.net (Olivier Renaud) Date: Fri, 19 Oct 2007 13:17:06 +0200 Subject: [Facets] Thread-safe PQueue In-Reply-To: <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> <47184FA2.9070507@arnebrasseur.net> <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> Message-ID: <200710191317.06644.o.renaud@laposte.net> Le vendredi 19 octobre 2007 08:53, TRANS a ?crit?: > On 10/19/07, Arne Brasseur wrote: > > Trans schreef: > > > > On Oct 18, 11:25 am, "o.ren... at laposte.net" > > wrote: > > > > > > ... > > My question is : is it worth it ? Should I directly use Thread.critical > > instead of MonitorMixin (not sure how to use it, by the way) ? Or maybe > > should we provide two different classes, thread-safe (maybe a simplified > > one) > > and non-thread-safe ? > > > > ... > > In other words, is it possible to rewrite PQueue it in such a way that > > it would be thread safe, but *without* resorting to MonitorMixin or > > Thread.critical? > > > > As far as I know there are no free meals here. You need some form of > > synchronization to make a data structure thread-safe. Be it high-level > > (MonitorMixin) or low-level (Thread.critical or Thread.exclusive). Or are > > you hinting at another sync' mechanism? > > Hmm... yes, I guess that makes sense. I suppose I was just thinking > that we should be sure that we *have* to share the vars in question > (ie. would a duplicate suffice?). Presuming we do, however, then there > is no way around it. But why doesn't Ruby have something simple like: > > attr_thread_safe :x > > or am I over-simplifying what's possible? > > > Would it be much overhead to make thread-safety a setting that can be > > turned on or off for every instance? > > The general Facets approach is to have the non-thread safe version "X" > and then a thread-safe version "SyncX", which is a subclass (if > possible). > > T. > _______________________________________________ > facets-universal mailing list > facets-universal at rubyforge.org > http://rubyforge.org/mailman/listinfo/facets-universal I'll try to write a Sync version on the top of the non-sync version, and see what happens. -- Olivier Renaud From transfire at gmail.com Fri Oct 19 08:52:59 2007 From: transfire at gmail.com (Trans) Date: Fri, 19 Oct 2007 08:52:59 -0400 Subject: [Facets] Thread-safe PQueue In-Reply-To: <47186A4D.6000008@arnebrasseur.net> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> <1192772587.472298.290490@v29g2000prd.googlegroups.com> <47184FA2.9070507@arnebrasseur.net> <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> <47186A4D.6000008@arnebrasseur.net> Message-ID: <4b6f054f0710190552v33dca7a6p76cf2253963075a2@mail.gmail.com> On 10/19/07, Arne Brasseur wrote: > TRANS schreef: > > Hmm... yes, I guess that makes sense. I suppose I was just thinking > > that we should be sure that we *have* to share the vars in question > > (ie. would a duplicate suffice?). Presuming we do, however, then there > > is no way around it. But why doesn't Ruby have something simple like: > > > > attr_thread_safe :x > > > > or am I over-simplifying what's possible? > > > Making the getting/setting of individual attributes thread safe wouldn't > be all that useful. It probably already is since it's just updating a > single object reference. > > The trouble usually comes in when there are multiple instance variables > that in combination need to be in a consistent state. All operations > that change one or more of these instance variables must be atomic. Oh. Most examples I see, that try to explain these things, focus on a single variable, so I thought... But Ok. Would a good approach then be to encapsulate the set of vars in special class? @safe_vars = SyncStruct.new(:x,:y,:z) > I think Ruby comes a long way in providing handy mechanisms for thread > safety. The only language that is IMO more advanced in this respect is > Ada. (Which is in a pain in many other respects). I see. Yes, that' good. I'm just struck that there's not a more transparent way to do it; one in which it would be hard to even know that threading was being used unless one sawcertain declarative statement(s) earlier in the code. But I guess that's what things like SyncHeap are for ;) Bare with me, I'm learning here. Thanks, T. From transfire at gmail.com Fri Oct 19 09:04:36 2007 From: transfire at gmail.com (Trans) Date: Fri, 19 Oct 2007 13:04:36 -0000 Subject: [Facets] Thread-safe PQueue In-Reply-To: <4b6f054f0710190552v33dca7a6p76cf2253963075a2@mail.gmail.com> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> <1192772587.472298.290490@v29g2000prd.googlegroups.com> <47184FA2.9070507@arnebrasseur.net> <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> <47186A4D.6000008@arnebrasseur.net> <4b6f054f0710190552v33dca7a6p76cf2253963075a2@mail.gmail.com> Message-ID: <1192799076.726399.16200@e9g2000prf.googlegroups.com> On Oct 19, 8:52 am, Trans wrote: > I see. Yes, that' good. I'm just struck that there's not a more > transparent way to do it; one in which it would be hard to even know > that threading was being used unless one sawcertain declarative ^^^^^^^^^ > statement(s) earlier in the code. To be more precise "threading" should read "thread synchronizing". T. From arne at arnebrasseur.net Fri Oct 19 10:07:58 2007 From: arne at arnebrasseur.net (Arne Brasseur) Date: Fri, 19 Oct 2007 22:07:58 +0800 Subject: [Facets] Thread-safe PQueue In-Reply-To: <4b6f054f0710190552v33dca7a6p76cf2253963075a2@mail.gmail.com> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> <1192772587.472298.290490@v29g2000prd.googlegroups.com> <47184FA2.9070507@arnebrasseur.net> <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> <47186A4D.6000008@arnebrasseur.net> <4b6f054f0710190552v33dca7a6p76cf2253963075a2@mail.gmail.com> Message-ID: <4718BA3E.60101@arnebrasseur.net> Trans schreef: > I see. Yes, that' good. I'm just struck that there's not a more > transparent way to do it; one in which it would be hard to even know > that threading was being used unless one sawcertain declarative > statement(s) earlier in the code. > > That would be nice, but I think it would only be that easy in trivial situations. You could for instance use some meta-programming to turn an existing class into a monitor. In a monitor only one single thread can be active inside one of the class's methods at one time. So every method is effectively atomic. But say for instance some methods are read-only, they don't have to be monitor methods, so it would unnecessarily hurt performance. But that's not the worst part. Thread synchronization does two things, it protects shared resources and it acts as a communication mechanism between threads. Take a simple Queue. When a thread tries to get an element while the Queue is empty, most implementations will make it wait until another thread adds an element. That sort of logic has to be programmed in. You can't just add that with a 'include ThreadSafe'. On the other hand, if your shared data structures are properly thread-safe then you usually for the rest don't have to think too much about these things. But you still should be aware of possible deadlocks. Conclusion : only do multi-threaded programming when you're well rested! :) (ab) > But I guess that's what things like SyncHeap are for ;) > > Bare with me, I'm learning here. > > Thanks, > T. > -- Arne Brasseur http://www.arnebrasseur.net http://www.zhongwiki.com http://www.bankske.org arne at arnebrasseur.net From transfire at gmail.com Fri Oct 19 12:54:00 2007 From: transfire at gmail.com (Trans) Date: Fri, 19 Oct 2007 16:54:00 -0000 Subject: [Facets] Thread-safe PQueue In-Reply-To: <200710191317.06644.o.renaud@laposte.net> References: <22736728.3970611192721108378.JavaMail.www@wwinf8402> <47184FA2.9070507@arnebrasseur.net> <4b6f054f0710182353w6cd92abcr5be09edc26ae33f8@mail.gmail.com> <200710191317.06644.o.renaud@laposte.net> Message-ID: <1192812840.256518.179210@e9g2000prf.googlegroups.com> On Oct 19, 7:17 am, Olivier Renaud wrote: > I'll try to write a Sync version on the top of the non-sync version, and see > what happens. Cool. T. From noreply at rubyforge.org Sun Oct 21 14:16:49 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Sun, 21 Oct 2007 14:16:49 -0400 (EDT) Subject: [Facets] [ facets-Bugs-14924 ] Conflict between require 'facets' and open-uri Message-ID: <20071021181649.CEABC18585E4@rubyforge.org> Bugs item #14924, was opened at 21/10/2007 18:16 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=14924&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Guillaume Laville (guiguilinux) Assigned to: Nobody (None) Summary: Conflict between require 'facets' and open-uri Initial Comment: Once a "require 'facets'" is done in a Ruby script, utilisation of open-uri (and facets/downloader, who depends on) raise the following NoMethodError : /usr/lib/ruby/1.8/open-uri.rb:268:in `open_http': undefined method `status=' for # (NoMethodError) from /usr/lib/ruby/1.8/open-uri.rb:617:in `buffer_open' from /usr/lib/ruby/1.8/open-uri.rb:164:in `open_loop' from /usr/lib/ruby/1.8/open-uri.rb:162:in `catch' from /usr/lib/ruby/1.8/open-uri.rb:162:in `open_loop' from /usr/lib/ruby/1.8/open-uri.rb:132:in `open_uri' from /usr/lib/ruby/1.8/open-uri.rb:519:in `open' from /usr/lib/ruby/1.8/open-uri.rb:30:in `open' from test.rb:8 I am using Ruby 1.8.6-p111 without any addition except Facets 2.0.2, which was installed using the tar.gz archive and task/install without any changes. Sample script to reproduce this behaviour : --- # We only require open-uri to test it require 'open-uri' # OK open "http://www.google.com" # Now, the famous "require 'facets'" require 'facets' require 'facets/downloader' # Fails open "http://www.google.com" # Fails with the same error, due to internal depend on open-uri Downloader.new(".").download("http://www.google.com", "index.html") --- (Sorry for my poor english of non-native speaker, and thanks for this usefull library ;)) ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=14924&group_id=804 From transfire at gmail.com Mon Oct 22 06:45:46 2007 From: transfire at gmail.com (Trans) Date: Mon, 22 Oct 2007 10:45:46 -0000 Subject: [Facets] [ facets-Bugs-14924 ] Conflict between require 'facets' and open-uri In-Reply-To: <20071021181649.CEABC18585E4@rubyforge.org> References: <20071021181649.CEABC18585E4@rubyforge.org> Message-ID: <1193049946.350736.134390@k35g2000prh.googlegroups.com> On Oct 21, 2:16 pm, wrote: [snip] > (Sorry for my poor english of non-native speaker, and thanks for this usefull library ;)) Don't fret it. My English is probably worse. I'm an American ;) Thanks for reporting this, btw. So I tracked the problem down to the definition of #meta. Facets defines this in Kernel, and open-uri defines it in OpenURI::Meta, which is uses to extend StringIO object's (via singleton). Now that in itself isn't a problem, what is though is that open-uri checks to see if the StringIO object has been extended with the OpenURI::Meta module with 'io.respond_to? :meta' (on lines 314 and 321). Interesting problem. I've occasionally used the respond_to? technique myself, thinking it was oh so duck-typee. It never really occurred to me that this kind of problem might arise -- yes, extending Kernel is one of the more challenging parts of extending Ruby ;) I'm going to bring this topic up on ruby-talk. Should be interesting. In the mean time, put the following in your code after require 'open- uri', and it should fix it: module OpenURI class Buffer # :nodoc: def <<(str) @io << str @size += str.length if StringIO === @io && StringMax < @size require 'tempfile' io = Tempfile.new('open-uri') io.binmode Meta.init io, @io if @io.is_a?(OpenURI::Meta) # <<< HERE io << @io.string @io = io end end def io Meta.init @io unless @io.is_a?(OpenURI::Meta) # <<< HERE @io end end end T. From noreply at rubyforge.org Fri Oct 26 19:11:54 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 26 Oct 2007 19:11:54 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15091 ] Dictionary with block that assigns values doesn't add key to @order Message-ID: <20071026231154.12F4C18585CD@rubyforge.org> Bugs item #15091, was opened at 2007-10-26 16:11 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Dictionary with block that assigns values doesn't add key to @order Initial Comment: Take this code: ## require 'rubygems' require 'facets/dictionary' d = Dictionary.new{ |hash,key| hash[key] = 0 } d[:a] d[:b] += 1 ## The expected result is {:a => 0, :b => 1} with an order of [:a,:b]. However, the result is {} with an order of [] Accessing d[:a] *does* result in 0 and d[:b] results in 1. It's only that the key isn't added to the @order instance variable. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 From noreply at rubyforge.org Fri Oct 26 19:20:20 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 26 Oct 2007 19:20:20 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15091 ] Dictionary with block that assigns values doesn't add key to @order Message-ID: <20071026232020.D039A18585F5@rubyforge.org> Bugs item #15091, was opened at 2007-10-26 16:11 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Dictionary with block that assigns values doesn't add key to @order Initial Comment: Take this code: ## require 'rubygems' require 'facets/dictionary' d = Dictionary.new{ |hash,key| hash[key] = 0 } d[:a] d[:b] += 1 ## The expected result is {:a => 0, :b => 1} with an order of [:a,:b]. However, the result is {} with an order of [] Accessing d[:a] *does* result in 0 and d[:b] results in 1. It's only that the key isn't added to the @order instance variable. ---------------------------------------------------------------------- >Comment By: Dave Myron (orangechicken) Date: 2007-10-26 16:20 Message: This also effects Dictionary.auto. For example: # require 'rubygems' require 'facets/dictionary' d = Dictionary.auto d[:a][:b][:c] = 1 puts d # => {} expected: {:a=>{:b=>{:c=>1}}} puts d[:a] # => {} expected: {:b=>{:c=>1}} puts d[:a][:b] # => {:c=>1} as expected # ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 From noreply at rubyforge.org Fri Oct 26 19:31:06 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 26 Oct 2007 19:31:06 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15092 ] Time.to_date needs to explicitly be made public because Ruby 1.8.6 has it as a private method Message-ID: <20071026233106.B9DB618585EF@rubyforge.org> Bugs item #15092, was opened at 2007-10-26 16:31 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15092&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Time.to_date needs to explicitly be made public because Ruby 1.8.6 has it as a private method Initial Comment: Given Ruby 1.8.6 and the following code: # require 'rubygems' require 'facets/time' Time.now.to_date # Expected: # Actual: NoMethodError: private method `to_date' called for Fri Oct 26 16:30:28 -0700 2007:Time If you open up Time and add public_method :to_date (I believe) that should fix it. Rails had the same problem. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15092&group_id=804 From noreply at rubyforge.org Fri Oct 26 19:33:10 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 26 Oct 2007 19:33:10 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15092 ] Time.to_date needs to explicitly be made public because Ruby 1.8.6 has it as a private method Message-ID: <20071026233310.89CEA18585EF@rubyforge.org> Bugs item #15092, was opened at 2007-10-26 16:31 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15092&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Time.to_date needs to explicitly be made public because Ruby 1.8.6 has it as a private method Initial Comment: Given Ruby 1.8.6 and the following code: # require 'rubygems' require 'facets/time' Time.now.to_date # Expected: # Actual: NoMethodError: private method `to_date' called for Fri Oct 26 16:30:28 -0700 2007:Time If you open up Time and add public_method :to_date (I believe) that should fix it. Rails had the same problem. ---------------------------------------------------------------------- >Comment By: Dave Myron (orangechicken) Date: 2007-10-26 16:33 Message: Whoops, no such thing as public_method method. :) Do this instead: class Time %w(to_date to_datetime).each do |method| public method if private_instance_methods.include?(method) end end ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15092&group_id=804 From noreply at rubyforge.org Fri Oct 26 20:54:31 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 26 Oct 2007 20:54:31 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15092 ] Time.to_date needs to explicitly be made public because Ruby 1.8.6 has it as a private method Message-ID: <20071027005432.0A39218585C3@rubyforge.org> Bugs item #15092, was opened at 2007-10-26 18:31 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15092&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Time.to_date needs to explicitly be made public because Ruby 1.8.6 has it as a private method Initial Comment: Given Ruby 1.8.6 and the following code: # require 'rubygems' require 'facets/time' Time.now.to_date # Expected: # Actual: NoMethodError: private method `to_date' called for Fri Oct 26 16:30:28 -0700 2007:Time If you open up Time and add public_method :to_date (I believe) that should fix it. Rails had the same problem. ---------------------------------------------------------------------- >Comment By: 7rans (transami) Date: 2007-10-26 19:54 Message: Isn't this a bug in Ruby itself? ---------------------------------------------------------------------- Comment By: Dave Myron (orangechicken) Date: 2007-10-26 18:33 Message: Whoops, no such thing as public_method method. :) Do this instead: class Time %w(to_date to_datetime).each do |method| public method if private_instance_methods.include?(method) end end ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15092&group_id=804 From noreply at rubyforge.org Fri Oct 26 20:58:30 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 26 Oct 2007 20:58:30 -0400 (EDT) Subject: [Facets] [ facets-Bugs-13421 ] range/umberella incorrectly uses .last for ... (3 dots) ranges Message-ID: <20071027005830.5949A18585C3@rubyforge.org> Bugs item #13421, was opened at 2007-08-27 09:50 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=13421&group_id=804 Category: None Group: None >Status: Closed Resolution: None Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: range/umberella incorrectly uses .last for ... (3 dots) ranges Initial Comment: When a user specifies a range as incl_lower...excl_upper, the .last and .max methods of a range are different. Umberella always uses .last, when .max would be more accurate. 33 e = r.last <=> self.last ---------------------------------------------------------------------- >Comment By: 7rans (transami) Date: 2007-10-26 19:58 Message: I assume the changes I made on this are satisfactory, and I will close the ticket. ---------------------------------------------------------------------- Comment By: Chris Kappler (chrisk2) Date: 2007-08-28 10:23 Message: The utility of the function is great. I ended up using it as part of Range.within? ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-08-28 09:50 Message: Good catch. I'm looking at fixing it with something like: def umbrella(r) s = first <=> r.first e = r.last <=> last if exclude_end? unless r.exclude_end? e = 1 if e == 0 end elsif r.exclude_end? e = -1 if e == 0 end return s,e end However, in looking over this code, I'm wondering if I've defined it inverse of what would be best. Eg. (1..4).umbrella(2..3) #=> [1,1] rather than [-1,-1] Any thoughts on the on the utility of this function and the best definition to serve it's intended purpose? T. ---------------------------------------------------------------------- Comment By: Chris Kappler (chrisk2) Date: 2007-08-27 10:31 Message: Actually, the range.max method is expensive for large ranges. The code below gives a more reliable perforrmance. 31 def umbrella(r) 32 s = self.first <=> r.first 33 r_last = r.last - ((r.exclude_end?) ? 1 : 0) 34 s_last = self.last - ((self.exclude_end?) ? 1 : 0) 35 e = r_last <=> s_last 36 return s,e 37 end ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=13421&group_id=804 From transfire at gmail.com Sat Oct 27 06:13:29 2007 From: transfire at gmail.com (Trans) Date: Sat, 27 Oct 2007 10:13:29 -0000 Subject: [Facets] [ facets-Bugs-15092 ] Time.to_date needs to explicitly be made public because Ruby 1.8.6 has it as a private method In-Reply-To: <20071026233106.B9DB618585EF@rubyforge.org> References: <20071026233106.B9DB618585EF@rubyforge.org> Message-ID: <1193480009.887666.289000@57g2000hsv.googlegroups.com> > Summary: Time.to_date needs to explicitly be made public because Ruby 1.8.6 has it as a private method Isn't this a bug in Ruby itself? T. From noreply at rubyforge.org Wed Oct 31 17:07:38 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:07:38 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15091 ] Dictionary with block that assigns values doesn't add key to @order Message-ID: <20071031210738.D2D4218585C9@rubyforge.org> Bugs item #15091, was opened at 2007-10-26 18:11 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Dictionary with block that assigns values doesn't add key to @order Initial Comment: Take this code: ## require 'rubygems' require 'facets/dictionary' d = Dictionary.new{ |hash,key| hash[key] = 0 } d[:a] d[:b] += 1 ## The expected result is {:a => 0, :b => 1} with an order of [:a,:b]. However, the result is {} with an order of [] Accessing d[:a] *does* result in 0 and d[:b] results in 1. It's only that the key isn't added to the @order instance variable. ---------------------------------------------------------------------- >Comment By: 7rans (transami) Date: 2007-10-31 16:07 Message: def initialize(*args, &blk) @order = [] @order_by = nil dict = self # This ensure autmatic key entry effect the oblk = lambda{ |hsh, key| blk[dict,key] } # dictionary rather then just the interal hash. @hash = Hash.new(*args, &oblk) end ---------------------------------------------------------------------- Comment By: Dave Myron (orangechicken) Date: 2007-10-26 18:20 Message: This also effects Dictionary.auto. For example: # require 'rubygems' require 'facets/dictionary' d = Dictionary.auto d[:a][:b][:c] = 1 puts d # => {} expected: {:a=>{:b=>{:c=>1}}} puts d[:a] # => {} expected: {:b=>{:c=>1}} puts d[:a][:b] # => {:c=>1} as expected # ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:08:36 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:08:36 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15091 ] Dictionary with block that assigns values doesn't add key to @order Message-ID: <20071031210837.0564418585EF@rubyforge.org> Bugs item #15091, was opened at 2007-10-26 18:11 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Dictionary with block that assigns values doesn't add key to @order Initial Comment: Take this code: ## require 'rubygems' require 'facets/dictionary' d = Dictionary.new{ |hash,key| hash[key] = 0 } d[:a] d[:b] += 1 ## The expected result is {:a => 0, :b => 1} with an order of [:a,:b]. However, the result is {} with an order of [] Accessing d[:a] *does* result in 0 and d[:b] results in 1. It's only that the key isn't added to the @order instance variable. ---------------------------------------------------------------------- >Comment By: 7rans (transami) Date: 2007-10-31 16:08 Message: Try that again. Fixed with: def initialize(*args, &blk) @order = [] @order_by = nil dict = self oblk = lambda{ |hsh, key| blk[dict,key] } @hash = Hash.new(*args, &oblk) end ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:07 Message: def initialize(*args, &blk) @order = [] @order_by = nil dict = self # This ensure autmatic key entry effect the oblk = lambda{ |hsh, key| blk[dict,key] } # dictionary rather then just the interal hash. @hash = Hash.new(*args, &oblk) end ---------------------------------------------------------------------- Comment By: Dave Myron (orangechicken) Date: 2007-10-26 18:20 Message: This also effects Dictionary.auto. For example: # require 'rubygems' require 'facets/dictionary' d = Dictionary.auto d[:a][:b][:c] = 1 puts d # => {} expected: {:a=>{:b=>{:c=>1}}} puts d[:a] # => {} expected: {:b=>{:c=>1}} puts d[:a][:b] # => {:c=>1} as expected # ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:14:29 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:14:29 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15091 ] Dictionary with block that assigns values doesn't add key to @order Message-ID: <20071031211429.9155D18585EF@rubyforge.org> Bugs item #15091, was opened at 2007-10-26 18:11 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Dictionary with block that assigns values doesn't add key to @order Initial Comment: Take this code: ## require 'rubygems' require 'facets/dictionary' d = Dictionary.new{ |hash,key| hash[key] = 0 } d[:a] d[:b] += 1 ## The expected result is {:a => 0, :b => 1} with an order of [:a,:b]. However, the result is {} with an order of [] Accessing d[:a] *does* result in 0 and d[:b] results in 1. It's only that the key isn't added to the @order instance variable. ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:08 Message: Try that again. Fixed with: def initialize(*args, &blk) @order = [] @order_by = nil dict = self oblk = lambda{ |hsh, key| blk[dict,key] } @hash = Hash.new(*args, &oblk) end ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:07 Message: def initialize(*args, &blk) @order = [] @order_by = nil dict = self # This ensure autmatic key entry effect the oblk = lambda{ |hsh, key| blk[dict,key] } # dictionary rather then just the interal hash. @hash = Hash.new(*args, &oblk) end ---------------------------------------------------------------------- Comment By: Dave Myron (orangechicken) Date: 2007-10-26 18:20 Message: This also effects Dictionary.auto. For example: # require 'rubygems' require 'facets/dictionary' d = Dictionary.auto d[:a][:b][:c] = 1 puts d # => {} expected: {:a=>{:b=>{:c=>1}}} puts d[:a] # => {} expected: {:b=>{:c=>1}} puts d[:a][:b] # => {:c=>1} as expected # ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:26:43 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:26:43 -0400 (EDT) Subject: [Facets] [ facets-Bugs-14924 ] Conflict between require 'facets' and open-uri Message-ID: <20071031212643.1BB5B18585BC@rubyforge.org> Bugs item #14924, was opened at 2007-10-21 13:16 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=14924&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Guillaume Laville (guiguilinux) Assigned to: Nobody (None) Summary: Conflict between require 'facets' and open-uri Initial Comment: Once a "require 'facets'" is done in a Ruby script, utilisation of open-uri (and facets/downloader, who depends on) raise the following NoMethodError : /usr/lib/ruby/1.8/open-uri.rb:268:in `open_http': undefined method `status=' for # (NoMethodError) from /usr/lib/ruby/1.8/open-uri.rb:617:in `buffer_open' from /usr/lib/ruby/1.8/open-uri.rb:164:in `open_loop' from /usr/lib/ruby/1.8/open-uri.rb:162:in `catch' from /usr/lib/ruby/1.8/open-uri.rb:162:in `open_loop' from /usr/lib/ruby/1.8/open-uri.rb:132:in `open_uri' from /usr/lib/ruby/1.8/open-uri.rb:519:in `open' from /usr/lib/ruby/1.8/open-uri.rb:30:in `open' from test.rb:8 I am using Ruby 1.8.6-p111 without any addition except Facets 2.0.2, which was installed using the tar.gz archive and task/install without any changes. Sample script to reproduce this behaviour : --- # We only require open-uri to test it require 'open-uri' # OK open "http://www.google.com" # Now, the famous "require 'facets'" require 'facets' require 'facets/downloader' # Fails open "http://www.google.com" # Fails with the same error, due to internal depend on open-uri Downloader.new(".").download("http://www.google.com", "index.html") --- (Sorry for my poor english of non-native speaker, and thanks for this usefull library ;)) ---------------------------------------------------------------------- >Comment By: 7rans (transami) Date: 2007-10-31 16:26 Message: This is a problem with open-uri. I've requeted that it be fixed in the next release cycle of Ruby. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=14924&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:26:54 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:26:54 -0400 (EDT) Subject: [Facets] [ facets-Bugs-14924 ] Conflict between require 'facets' and open-uri Message-ID: <20071031212654.CA1C618585BC@rubyforge.org> Bugs item #14924, was opened at 2007-10-21 13:16 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=14924&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Guillaume Laville (guiguilinux) Assigned to: Nobody (None) Summary: Conflict between require 'facets' and open-uri Initial Comment: Once a "require 'facets'" is done in a Ruby script, utilisation of open-uri (and facets/downloader, who depends on) raise the following NoMethodError : /usr/lib/ruby/1.8/open-uri.rb:268:in `open_http': undefined method `status=' for # (NoMethodError) from /usr/lib/ruby/1.8/open-uri.rb:617:in `buffer_open' from /usr/lib/ruby/1.8/open-uri.rb:164:in `open_loop' from /usr/lib/ruby/1.8/open-uri.rb:162:in `catch' from /usr/lib/ruby/1.8/open-uri.rb:162:in `open_loop' from /usr/lib/ruby/1.8/open-uri.rb:132:in `open_uri' from /usr/lib/ruby/1.8/open-uri.rb:519:in `open' from /usr/lib/ruby/1.8/open-uri.rb:30:in `open' from test.rb:8 I am using Ruby 1.8.6-p111 without any addition except Facets 2.0.2, which was installed using the tar.gz archive and task/install without any changes. Sample script to reproduce this behaviour : --- # We only require open-uri to test it require 'open-uri' # OK open "http://www.google.com" # Now, the famous "require 'facets'" require 'facets' require 'facets/downloader' # Fails open "http://www.google.com" # Fails with the same error, due to internal depend on open-uri Downloader.new(".").download("http://www.google.com", "index.html") --- (Sorry for my poor english of non-native speaker, and thanks for this usefull library ;)) ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:26 Message: This is a problem with open-uri. I've requeted that it be fixed in the next release cycle of Ruby. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=14924&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:33:38 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:33:38 -0400 (EDT) Subject: [Facets] [ facets-Bugs-12736 ] Dictionary#dup does not work correctly Message-ID: <20071031213338.8FF1C18585BC@rubyforge.org> Bugs item #12736, was opened at 2007-08-01 03:41 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=12736&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Thomas Leitner (gettalong) Assigned to: Nobody (None) Summary: Dictionary#dup does not work correctly Initial Comment: See following irb session: irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'facets/more/dictionary' => true irb(main):003:0> a = Dictionary.new => {} irb(main):004:0> a.dup => {} irb(main):005:0> a['hallo']=['t',5] => ["t", 5] irb(main):006:0> a.dup ArgumentError: odd number of elements for Hash from /opt/local/lib/ruby/gems/1.8/gems/facets-1.8.54/lib/facets/more/dictionary.rb:86:in `[]' from /opt/local/lib/ruby/gems/1.8/gems/facets-1.8.54/lib/facets/more/dictionary.rb:356:in `dup' from (irb):6 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:7 The problems stems from .flatten in dup: 355 def dup 356 self.class[*to_a.flatten] 357 end But I don't have time currently to make a patch. ---------------------------------------------------------------------- >Comment By: 7rans (transami) Date: 2007-10-31 16:33 Message: Fixed with: def dup a = [] each{ |k,v| a << k; a << v } self.class[*a] end ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=12736&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:34:02 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:34:02 -0400 (EDT) Subject: [Facets] [ facets-Bugs-12736 ] Dictionary#dup does not work correctly Message-ID: <20071031213402.64E2718585D5@rubyforge.org> Bugs item #12736, was opened at 2007-08-01 03:41 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=12736&group_id=804 >Category: Code Group: None >Status: Closed >Resolution: Accepted Priority: 3 Submitted By: Thomas Leitner (gettalong) Assigned to: Nobody (None) Summary: Dictionary#dup does not work correctly Initial Comment: See following irb session: irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'facets/more/dictionary' => true irb(main):003:0> a = Dictionary.new => {} irb(main):004:0> a.dup => {} irb(main):005:0> a['hallo']=['t',5] => ["t", 5] irb(main):006:0> a.dup ArgumentError: odd number of elements for Hash from /opt/local/lib/ruby/gems/1.8/gems/facets-1.8.54/lib/facets/more/dictionary.rb:86:in `[]' from /opt/local/lib/ruby/gems/1.8/gems/facets-1.8.54/lib/facets/more/dictionary.rb:356:in `dup' from (irb):6 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:7 The problems stems from .flatten in dup: 355 def dup 356 self.class[*to_a.flatten] 357 end But I don't have time currently to make a patch. ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:33 Message: Fixed with: def dup a = [] each{ |k,v| a << k; a << v } self.class[*a] end ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=12736&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:35:18 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:35:18 -0400 (EDT) Subject: [Facets] [ facets-Bugs-9988 ] Singular function fails many tests Message-ID: <20071031213518.3B81118585D5@rubyforge.org> Bugs item #9988, was opened at 2007-04-09 08:19 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9988&group_id=804 Category: None Group: None Status: Open Resolution: Postponed Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: Singular function fails many tests Initial Comment: I ran some additional tests on the Singular function and it failed 10 out of the following 68 tests: tests["Americans"] = "American" tests["analyses"] = "analysis" tests["bays"] = "bay" tests["bureaus"] = "bureau" tests["businesses"] = "business" tests["cacti"] = "cactus" tests["cactuses"] = "cactus" tests["calves"] = "calf" tests["carpets"] = "carpet" tests["chiefs"] = "chief" tests["choruses"] = "chorus" tests["churches"] = "church" tests["companies"] = "company" tests["courses"] = "course" tests["cows"] = "cow" tests["crashes"] = "crash" tests["criteria"] = "criterion" tests["discos"] = "disco" tests["doors"] = "door" tests["factories"] = "factory" tests["farms"] = "farm" tests["farmers"] = "farmer" tests["faxes"] = "fax" tests["firemen"] = "fireman" tests["fish"] = "fish" tests["flowers"] = "flower" tests["forks"] = "fork" tests["foxes"] = "fox" tests["friends"] = "friend" tests["garages"] = "garage" tests["gardens"] = "garden" tests["geese"] = "goose" tests["grown-ups"] = "grown-up" tests["heroes"] = "hero" tests["highways"] = "highway" tests["horses"] = "horse" tests["hovercraft"] = "hovercraft" tests["indexes"] = "index" tests["indices"] = "index" tests["kisses"] = "kiss" tests["lives"] = "life" tests["lights"] = "light" tests["loaves"] = "loaf" tests["memos"] = "memo" tests["mountains"] = "mountain" tests["mice"] = "mouse" tests["ovens"] = "oven" tests["parties"] = "party" tests["pens"] = "pen" tests["pennies"] = "penny" tests["potatoes"] = "potato" tests["prizes"] = "prize" tests["proofs"] = "proof" tests["scarves"] = "scarf" tests["series"] = "series" tests["staples"] = "staple" tests["statuses"] = "status" tests["stores"] = "store" tests["Swiss"] = "Swiss" tests["tables"] = "table" tests["take-offs"] = "take-off" tests["teachers"] = "teacher" tests["theses"] = "thesis" tests["thieves"] = "thief" tests["tomatoes"] = "tomato" tests["torpedoes"] = "torpedo" tests["videos"] = "video" tests["watches"] = "watch" ---------------------------------------------------------------------- >Comment By: 7rans (transami) Date: 2007-10-31 16:35 Message: All of these now work. You will find the new inflect.rb in the the latest English release. ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-07-26 08:21 Message: Nice work! Thanks, for catching these. We'll work on this soon. But BIG NEWS here too. inflect.rb is one of libraries being spun-off from Facets. It will now be found in the English project. (http://english.rubyforge.org). The intent is that we can better develop a solid, strong english grammer and general "writ-processing" library by having it separate. I'll keep the community posted when this get's it's first release. If anyone is interested in becoming a main developer on that project, please let me know. --trans ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9988&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:35:49 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:35:49 -0400 (EDT) Subject: [Facets] [ facets-Bugs-9988 ] Singular function fails many tests Message-ID: <20071031213549.A1C4618585BC@rubyforge.org> Bugs item #9988, was opened at 2007-04-09 08:19 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9988&group_id=804 Category: None Group: None Status: Open Resolution: Postponed Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: Singular function fails many tests Initial Comment: I ran some additional tests on the Singular function and it failed 10 out of the following 68 tests: tests["Americans"] = "American" tests["analyses"] = "analysis" tests["bays"] = "bay" tests["bureaus"] = "bureau" tests["businesses"] = "business" tests["cacti"] = "cactus" tests["cactuses"] = "cactus" tests["calves"] = "calf" tests["carpets"] = "carpet" tests["chiefs"] = "chief" tests["choruses"] = "chorus" tests["churches"] = "church" tests["companies"] = "company" tests["courses"] = "course" tests["cows"] = "cow" tests["crashes"] = "crash" tests["criteria"] = "criterion" tests["discos"] = "disco" tests["doors"] = "door" tests["factories"] = "factory" tests["farms"] = "farm" tests["farmers"] = "farmer" tests["faxes"] = "fax" tests["firemen"] = "fireman" tests["fish"] = "fish" tests["flowers"] = "flower" tests["forks"] = "fork" tests["foxes"] = "fox" tests["friends"] = "friend" tests["garages"] = "garage" tests["gardens"] = "garden" tests["geese"] = "goose" tests["grown-ups"] = "grown-up" tests["heroes"] = "hero" tests["highways"] = "highway" tests["horses"] = "horse" tests["hovercraft"] = "hovercraft" tests["indexes"] = "index" tests["indices"] = "index" tests["kisses"] = "kiss" tests["lives"] = "life" tests["lights"] = "light" tests["loaves"] = "loaf" tests["memos"] = "memo" tests["mountains"] = "mountain" tests["mice"] = "mouse" tests["ovens"] = "oven" tests["parties"] = "party" tests["pens"] = "pen" tests["pennies"] = "penny" tests["potatoes"] = "potato" tests["prizes"] = "prize" tests["proofs"] = "proof" tests["scarves"] = "scarf" tests["series"] = "series" tests["staples"] = "staple" tests["statuses"] = "status" tests["stores"] = "store" tests["Swiss"] = "Swiss" tests["tables"] = "table" tests["take-offs"] = "take-off" tests["teachers"] = "teacher" tests["theses"] = "thesis" tests["thieves"] = "thief" tests["tomatoes"] = "tomato" tests["torpedoes"] = "torpedo" tests["videos"] = "video" tests["watches"] = "watch" ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:35 Message: All of these now work. You will find the new inflect.rb in the the latest English release. ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-07-26 08:21 Message: Nice work! Thanks, for catching these. We'll work on this soon. But BIG NEWS here too. inflect.rb is one of libraries being spun-off from Facets. It will now be found in the English project. (http://english.rubyforge.org). The intent is that we can better develop a solid, strong english grammer and general "writ-processing" library by having it separate. I'll keep the community posted when this get's it's first release. If anyone is interested in becoming a main developer on that project, please let me know. --trans ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9988&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:36:55 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:36:55 -0400 (EDT) Subject: [Facets] [ facets-Bugs-13114 ] Typo in rdoc documentation for Proc.compose Message-ID: <20071031213656.118BE18585BC@rubyforge.org> Bugs item #13114, was opened at 2007-08-15 18:50 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=13114&group_id=804 >Category: Documentation >Group: 1.0 - 2.0 Status: Closed Resolution: Accepted Priority: 1 Submitted By: Bill McNeill (billmcn) Assigned to: Nobody (None) Summary: Typo in rdoc documentation for Proc.compose Initial Comment: The rdoc documentation for Proc.compose has a typo in it. The sample code reads in part a.compose(b).call(4) #=> 6 b.compase(a).call(4) #=> 4 The second call is misspelled--should be "compose", not "compase". I noticed this while browsing http://facets.rubyforge.org/rdoc/core/index.html. Presumably it is wrong in the source. ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-08-27 12:37 Message: Fixed. Thanks. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=13114&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:38:02 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:38:02 -0400 (EDT) Subject: [Facets] [ facets-Bugs-9988 ] Singular function fails many tests Message-ID: <20071031213802.1D20218585BC@rubyforge.org> Bugs item #9988, was opened at 2007-04-09 08:19 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9988&group_id=804 >Category: Code >Group: 1.0 - 2.0 >Status: Closed >Resolution: Accepted Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: Singular function fails many tests Initial Comment: I ran some additional tests on the Singular function and it failed 10 out of the following 68 tests: tests["Americans"] = "American" tests["analyses"] = "analysis" tests["bays"] = "bay" tests["bureaus"] = "bureau" tests["businesses"] = "business" tests["cacti"] = "cactus" tests["cactuses"] = "cactus" tests["calves"] = "calf" tests["carpets"] = "carpet" tests["chiefs"] = "chief" tests["choruses"] = "chorus" tests["churches"] = "church" tests["companies"] = "company" tests["courses"] = "course" tests["cows"] = "cow" tests["crashes"] = "crash" tests["criteria"] = "criterion" tests["discos"] = "disco" tests["doors"] = "door" tests["factories"] = "factory" tests["farms"] = "farm" tests["farmers"] = "farmer" tests["faxes"] = "fax" tests["firemen"] = "fireman" tests["fish"] = "fish" tests["flowers"] = "flower" tests["forks"] = "fork" tests["foxes"] = "fox" tests["friends"] = "friend" tests["garages"] = "garage" tests["gardens"] = "garden" tests["geese"] = "goose" tests["grown-ups"] = "grown-up" tests["heroes"] = "hero" tests["highways"] = "highway" tests["horses"] = "horse" tests["hovercraft"] = "hovercraft" tests["indexes"] = "index" tests["indices"] = "index" tests["kisses"] = "kiss" tests["lives"] = "life" tests["lights"] = "light" tests["loaves"] = "loaf" tests["memos"] = "memo" tests["mountains"] = "mountain" tests["mice"] = "mouse" tests["ovens"] = "oven" tests["parties"] = "party" tests["pens"] = "pen" tests["pennies"] = "penny" tests["potatoes"] = "potato" tests["prizes"] = "prize" tests["proofs"] = "proof" tests["scarves"] = "scarf" tests["series"] = "series" tests["staples"] = "staple" tests["statuses"] = "status" tests["stores"] = "store" tests["Swiss"] = "Swiss" tests["tables"] = "table" tests["take-offs"] = "take-off" tests["teachers"] = "teacher" tests["theses"] = "thesis" tests["thieves"] = "thief" tests["tomatoes"] = "tomato" tests["torpedoes"] = "torpedo" tests["videos"] = "video" tests["watches"] = "watch" ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:35 Message: All of these now work. You will find the new inflect.rb in the the latest English release. ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-07-26 08:21 Message: Nice work! Thanks, for catching these. We'll work on this soon. But BIG NEWS here too. inflect.rb is one of libraries being spun-off from Facets. It will now be found in the English project. (http://english.rubyforge.org). The intent is that we can better develop a solid, strong english grammer and general "writ-processing" library by having it separate. I'll keep the community posted when this get's it's first release. If anyone is interested in becoming a main developer on that project, please let me know. --trans ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9988&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:48:00 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:48:00 -0400 (EDT) Subject: [Facets] [ facets-Bugs-9791 ] alias_method_chain incompatible with rails Message-ID: <20071031214800.51AF718585C9@rubyforge.org> Bugs item #9791, was opened at 2007-04-03 13:48 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9791&group_id=804 >Category: Code >Group: 2.0 + >Status: Closed >Resolution: Accepted >Priority: 4 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: alias_method_chain incompatible with rails Initial Comment: ActiveSupport's alias_method_chain method accepts and yields to a block. This behavior is necessary for the operation of deprecation_associations.rb in ActiveRecord. The alias_method_chain supplied by Facets overwrites the one provided by Rails and breaks stuff (stuff is a technical term). Versions: Facets 1.8.54 Rails 1.2.3 ---------------------------------------------------------------------- >Comment By: 7rans (transami) Date: 2007-10-31 16:48 Message: Fixed. Facets now supports Rails/ActiveSupport's version of this method verbatim. ---------------------------------------------------------------------- Comment By: Tyler Rick (tylerrick) Date: 2007-04-17 12:51 Message: I'm having this problem too. Some of the plugins and gems that my Rails app depends on are requiring the Facets version ... which is fine, except that it's incompatible with the Rails one, so if it gets included *last*, it will break stuff in Rails. Possible solution: have Facets (in general) refuse to define methods if they already exist -- i.e., don't overwrite them. Workaround for the time being: config/environment.rb # Make sure this gets added to $LOADED_FEATURES now so that it won't get loaded again. require 'facets/core/module/alias_method_chain' # Override alias_method_chain (again!) with the Rails version, which is compatible with the version expected by plugins and gems that explicitly tried to require 'facets/core/module/alias_method_chain' load 'active_support/core_ext/module/aliasing.rb' ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9791&group_id=804 From noreply at rubyforge.org Wed Oct 31 17:54:12 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 31 Oct 2007 17:54:12 -0400 (EDT) Subject: [Facets] [ facets-Bugs-15091 ] Dictionary with block that assigns values doesn't add key to @order Message-ID: <20071031215412.4D0BB18585C9@rubyforge.org> Bugs item #15091, was opened at 2007-10-26 18:11 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804 >Category: Code >Group: 2.0 + >Status: Closed >Resolution: Accepted Priority: 3 Submitted By: Dave Myron (orangechicken) Assigned to: Nobody (None) Summary: Dictionary with block that assigns values doesn't add key to @order Initial Comment: Take this code: ## require 'rubygems' require 'facets/dictionary' d = Dictionary.new{ |hash,key| hash[key] = 0 } d[:a] d[:b] += 1 ## The expected result is {:a => 0, :b => 1} with an order of [:a,:b]. However, the result is {} with an order of [] Accessing d[:a] *does* result in 0 and d[:b] results in 1. It's only that the key isn't added to the @order instance variable. ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:08 Message: Try that again. Fixed with: def initialize(*args, &blk) @order = [] @order_by = nil dict = self oblk = lambda{ |hsh, key| blk[dict,key] } @hash = Hash.new(*args, &oblk) end ---------------------------------------------------------------------- Comment By: 7rans (transami) Date: 2007-10-31 16:07 Message: def initialize(*args, &blk) @order = [] @order_by = nil dict = self # This ensure autmatic key entry effect the oblk = lambda{ |hsh, key| blk[dict,key] } # dictionary rather then just the interal hash. @hash = Hash.new(*args, &oblk) end ---------------------------------------------------------------------- Comment By: Dave Myron (orangechicken) Date: 2007-10-26 18:20 Message: This also effects Dictionary.auto. For example: # require 'rubygems' require 'facets/dictionary' d = Dictionary.auto d[:a][:b][:c] = 1 puts d # => {} expected: {:a=>{:b=>{:c=>1}}} puts d[:a] # => {} expected: {:b=>{:c=>1}} puts d[:a][:b] # => {:c=>1} as expected # ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=15091&group_id=804