From noreply at rubyforge.org Tue Apr 3 14:48:11 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Tue, 3 Apr 2007 14:48:11 -0400 (EDT) Subject: [Facets] [ facets-Bugs-9791 ] alias_method_chain incompatible with rails Message-ID: <20070403184811.E88925240D01@rubyforge.org> Bugs item #9791, was opened at 2007-04-03 14:48 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9791&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 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 ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9791&group_id=804 From noreply at rubyforge.org Mon Apr 9 09:19:39 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 9 Apr 2007 09:19:39 -0400 (EDT) Subject: [Facets] [ facets-Bugs-9988 ] Singular function fails many tests Message-ID: <20070409131939.6FF1452409E6@rubyforge.org> Bugs item #9988, was opened at 2007-04-09 09: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: None 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" ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=9988&group_id=804 From noreply at rubyforge.org Mon Apr 9 15:19:40 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 9 Apr 2007 15:19:40 -0400 (EDT) Subject: [Facets] [ facets-Feature Requests-9995 ] Add reminder in File.open_as_string that you can't use = or += Message-ID: <20070409191940.CC35D52409FB@rubyforge.org> Feature Requests item #9995, was opened at 2007-04-09 12:19 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3172&aid=9995&group_id=804 Category: None Group: None Status: Open Priority: 3 Submitted By: Tyler Rick (tylerrick) Assigned to: Nobody (None) Summary: Add reminder in File.open_as_string that you can't use = or += Initial Comment: I know this is just a fact of Ruby, that = and += create new objects rather than changing an existing objects, but I think it deserves a reminder, because it's so easy to forget! Maybe something like: Remember to use str.replace "new contents" rather than str = "new contents" and str << "contents to append" rather than str += "contents to append" FileUtils.touch 'foo' => ["foo"] irb -> FileUtils.touch 'foo' => ["foo"] irb -> File.open_as_string('foo') { |s| puts s } => nil irb -> File.open_as_string('foo') { |s| s = "Initial contents\n" }; puts File.read('foo') => nil irb -> File.open_as_string('foo') { |s| s.replace "Initial contents\n" }; puts File.read('foo') Initial contents => nil irb -> File.open_as_string('foo') { |s| s += "Another line\n" }; puts File.read('foo') Initial contents => nil irb -> File.open_as_string('foo') { |s| s << "Another line\n" }; puts File.read('foo') Initial contents Another line => nil ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3172&aid=9995&group_id=804 From transfire at gmail.com Fri Apr 13 18:23:07 2007 From: transfire at gmail.com (Trans) Date: Fri, 13 Apr 2007 22:23:07 -0000 Subject: [Facets] Facets 2.0 Home Stretch Message-ID: <1176502987.748035.13280@n59g2000hsh.googlegroups.com> Hi all, Happy to report that I have the structural changes of Facets 2.0 pretty much worked out. It took quite a bit of self-debate and ultimately compromises between conflicting goals, but the outcome looks quite good. Essentially I've refined the idea of Facets as Ruby's tertiary library --the idea that Facets contains the extension methods and libraries one might half-expect Matz himself to include as a _core_ part of Ruby. Anything more extraneous than that (even if arguably a good addition to Ruby's _standard_ library) has been moved elsewhere. This refinement led to segregating Facets into three parts: the extension methods, extension groups and general additions. Basically the first is what we were calling "core" and the later "more". Groups are in between, they are extensions, but they are either convenient groupings of some methods (eg. binding.rb) or numerous extensions that just don't make sense without each other (eg. times.rb). I'm now down to the final few decisions concerning the require namespaces and the distribution of the libs. For these core "more" modules, I have given up the idea of distributing them individually. This is a bit of a disappointment to me as there were at least a few that I felt would do very well as stand-alones, such as Annotations, but it was an important compromise to make. Instead I am considering the creation the three packages, something like: facetsmethods, facetsgroups and facetsmodules (opinions on this welcome). As you might expect, the require namespaces will become facets/methods, facets/groups and facets/modules. I am still debating whether to offer the facet/ redirection directory (I would prefer not to have to mess with it), and whether to make the standard means of require to always start with require 'facets' then simply use, for example: require 'string/plural' require 'multiton' etc. My only hesitation with making this the standard usage, is the slight chance of name clash with other libs. It's probably not a problem, but I haven't been able to rule out that it could cause some sort of very bad conflict. Anyone have any thoughts on this matter? So now, for what's getting moved OUT of Facets. First I removed anything I felt wasn't really up to snuff and I wouldn't be working on anytime soon, like FloatString and StateParser, etc. Then I removed the higher level libs --too far removed from being considered "core". In particular the markup tools related to xml, html, bbcode, and so forth -- I'm making a new project for these, and also the high-level console tools which again I have created a new package for. (Note, I had consider separating the AOP related libs, but ultimately decided against it.) With these separated out, Facets is a much more refined product. Version 2.0 should be well received having less cruft and fat. I will of course be making the libs I moved out of Facets available forthwith. And now that these structural issues are nearly resolved I will be able to start focusing on fixing some recent bug reports. Yea! T. From noreply at rubyforge.org Wed Apr 25 19:34:53 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 25 Apr 2007 19:34:53 -0400 (EDT) Subject: [Facets] [ facets-Bugs-10372 ] String#index_all breaks when passed a String for a search term Message-ID: <20070425233453.AC6A95240A03@rubyforge.org> Bugs item #10372, was opened at 2007-04-25 16:34 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=10372&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Tyler Rick (tylerrick) Assigned to: Nobody (None) Summary: String#index_all breaks when passed a String for a search term Initial Comment: The existing test shows that it works for Regexp as input: def test_index_all_with_regexp assert_equal( [0,4,8], "a123a567a9".index_all(/a/) ) end but doesn't take into account the other 2 classes of search terms that a user might want to pass in (at least if you're trying to offer behavior analogous to that of String#index, http://corelib.rubyonrails.org/classes/String.html#M001505, which I hope you are)... I've added a new test case for strings: def test_index_all_with_string assert_equal( [0,4,8], "a123a567a9".index_all('a') ) end ... which fails unless the implementation is changed. NoMethodError: undefined method `length' for nil:NilClass Changing this line: i += (reuse ? 1 : $~.length ) to this seems to have fixed the problem: i += (reuse ? $~.length : 1 ) I really don't understand the reuse flag (could you add some comments explaining how it works and (to the docs) why I'd ever want to use that flag (performance boost??), but it looked like you just had the order mixed up on that one line :) Would suggest a test such as this be added that actually exercises that behavior: def test_index_all_with_regexp_reuse assert_equal( [0,4,8], "a123a567a9".index_all(/a/, true) ) end I tried to see what was going on by adding this line: puts "Incrementing by #{ (reuse ? $~.length : 1 ) }" but it printed "1" for all of 3 tests, indicating that the reuse flag didn't make one iota of difference... Question: Should it only use $~ if s is a Regexp? (Should it *automatically* use it if $~ is a Regexp?) $~ appears to not even be set if s is a string; only if it's a Regexp, so we probably shouldn't let people shoot their foot off by calling index_all('a', true)... Haven't even looked at the Fixnum===s case. class String # Like index but returns an array of all index locations. # The reuse flag allows the trailing portion of a match to be # reused for subsquent matches. # # "abcabcabc".index_all('a') #=> [0,3,6] # def index_all(s, reuse=false) ia = []; i = 0 while (i = self.index(s,i)) ia << i i += (reuse ? $~.length : 1 ) end ia end end By the way, thanks for this method. I was just about to create my own String#nth_index(s, 2) method, but then saw this and decided I could just use index_all(s)[2] instead... ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=10372&group_id=804 From noreply at rubyforge.org Fri Apr 27 20:35:56 2007 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Fri, 27 Apr 2007 20:35:56 -0400 (EDT) Subject: [Facets] [ facets-Bugs-10424 ] Module#attr_tester bugs and change requests Message-ID: <20070428003556.CBDEE5240B61@rubyforge.org> Bugs item #10424, was opened at 2007-04-27 17:35 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=10424&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Tyler Rick (tylerrick) Assigned to: Nobody (None) Summary: Module#attr_tester bugs and change requests Initial Comment: The (apparent) bug is this: Docs claim that " One is used to test the attribute and the other is used to set or toggle it." Yet when I try to *set* it to false, like this, it remains unchanged: x.a! false I assume that is not the desired behavior. Am I correct? It looks like you just copied this line from the a?-generator: @#{a} ? true_value : @#{a} In the attached file, I have included some tests that expose this bug. The other change requests are as follows: * rename attr_tester to bool_attr_accessor to be more like Ruby's core attr_accessor method, since it seems to have such a similar purpose. * move the creation of a? and a! into bool_attr_reader and bool_attr_writer methods, respectively, which can be reused by bool_attr_accessor * That also lets the user create a read-only boolean attribute -- you can have reader without having a setter. The included file has exactly the changes I just described, if you want to consider using them. Including comprehensive unit tests, of course. This change has also been included in qualitysmith_extensions version 0.0.23 at http://qualitysmithext.rubyforge.org/src/lib/qualitysmith_extensions/module/bool_attr_accessor.rb or by installing `gem qualitysmith_extensions` (0.0.24 or later). Another thing -- and this is more just a question than a request -- Why does it return make.keys ? Why does it even need to create the 'make' hash? I guess it's a more useful return value than *nil*, but I still can't think of how I'd use it. :) Thanks in advance! Tyler ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=10424&group_id=804 From transfire at gmail.com Mon Apr 30 11:14:42 2007 From: transfire at gmail.com (TRANS) Date: Mon, 30 Apr 2007 11:14:42 -0400 Subject: [Facets] [ facets-Bugs-10424 ] Module#attr_tester bugs and change requests In-Reply-To: <20070428003556.CBDEE5240B61@rubyforge.org> References: <20070428003556.CBDEE5240B61@rubyforge.org> Message-ID: <4b6f054f0704300814g77546fa2hf1bfa0d85908d66d@mail.gmail.com> On 4/27/07, noreply at rubyforge.org wrote: > Bugs item #10424, was opened at 2007-04-27 17:35 > You can respond by visiting: > http://rubyforge.org/tracker/?func=detail&atid=3169&aid=10424&group_id=804 > > Category: None > Group: None > Status: Open > Resolution: None > Priority: 3 > Submitted By: Tyler Rick (tylerrick) > Assigned to: Nobody (None) > Summary: Module#attr_tester bugs and change requests > > Initial Comment: > The (apparent) bug is this: > Docs claim that " One is used to test the attribute and the other is used to set or toggle it." > > Yet when I try to *set* it to false, like this, it remains unchanged: > x.a! false > > I assume that is not the desired behavior. Am I correct? > > It looks like you just copied this line from the a?-generator: > @#{a} ? true_value : @#{a} > > In the attached file, I have included some tests that expose this bug. > > > The other change requests are as follows: > * rename attr_tester to bool_attr_accessor to be more like Ruby's core attr_accessor method, since it seems to have such a similar purpose. > * move the creation of a? and a! into bool_attr_reader and bool_attr_writer methods, respectively, which can be reused by bool_attr_accessor > * That also lets the user create a read-only boolean attribute -- you can have reader without having a setter. > > The included file has exactly the changes I just described, if you want to consider using them. Including comprehensive unit tests, of course. > > This change has also been included in qualitysmith_extensions version 0.0.23 at > http://qualitysmithext.rubyforge.org/src/lib/qualitysmith_extensions/module/bool_attr_accessor.rb > or by installing `gem qualitysmith_extensions` (0.0.24 or later). That's a pretty good idea. Let me think on it a little. > Another thing -- and this is more just a question than a request -- Why does it return make.keys ? Why does it even need to create the 'make' hash? I guess it's a more useful return value than *nil*, but I still can't think of how I'd use it. :) Ideally all the attr methods would return the names so you could do something like: private attr_accessor :x, :y, :z For whatever reason, Matz hasn't embraced this. But when writing the Facets code I figure it couldn't hurt to offer it. I figure it's better to have a useful return value, even if limited, than none at all. Perhaps you have a better reason for not doing so? T.