From noreply at rubyforge.org Thu Apr 3 15:42:16 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Thu, 3 Apr 2008 15:42:16 -0400 (EDT) Subject: [Facets] [ facets-Bugs-19291 ] hence(3, :months) is incorrectly adjusting the year Message-ID: <20080403194216.21F5218585F5@rubyforge.org> Bugs item #19291, was opened at 2008-04-03 14:42 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=19291&group_id=804 Category: Code Group: None Status: Open Resolution: None Priority: 3 Submitted By: Andy Freeman (awf) Assigned to: Nobody (None) Summary: hence(3, :months) is incorrectly adjusting the year Initial Comment: >> t = Time.now => Thu Apr 03 15:36:02 -0400 2008 >> t.hence(3, :months) => Tue Jul 03 15:36:02 -0400 2012 Notice that the years are being incorrectly adjusted. when :months years = (month + number / 12).to_i set(:year=>(year + years), :month=>(month + number) % 12) The years assignment needs an extra set of parens. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=19291&group_id=804 From transfire at gmail.com Thu Apr 3 20:54:23 2008 From: transfire at gmail.com (Trans) Date: Thu, 3 Apr 2008 20:54:23 -0400 Subject: [Facets] [ facets-Bugs-19291 ] hence(3, :months) is incorrectly adjusting the year In-Reply-To: <20080403194216.21F5218585F5@rubyforge.org> References: <20080403194216.21F5218585F5@rubyforge.org> Message-ID: <4b6f054f0804031754r765ea15ch28d6d9841c6e7804@mail.gmail.com> On Thu, Apr 3, 2008 at 3:42 PM, wrote: > Bugs item #19291, was opened at 2008-04-03 14:42 > You can respond by visiting: > http://rubyforge.org/tracker/?func=detail&atid=3169&aid=19291&group_id=804 > > Category: Code > Group: None > Status: Open > Resolution: None > Priority: 3 > Submitted By: Andy Freeman (awf) > Assigned to: Nobody (None) > Summary: hence(3, :months) is incorrectly adjusting the year > > Initial Comment: > >> t = Time.now > => Thu Apr 03 15:36:02 -0400 2008 > >> t.hence(3, :months) > => Tue Jul 03 15:36:02 -0400 2012 > > Notice that the years are being incorrectly adjusted. > > > when :months > years = (month + number / 12).to_i > set(:year=>(year + years), :month=>(month + number) % 12) > > The years assignment needs an extra set of parens. Thanks. T. From transfire at gmail.com Sat Apr 5 13:01:29 2008 From: transfire at gmail.com (Trans) Date: Sat, 5 Apr 2008 10:01:29 -0700 (PDT) Subject: [Facets] Paramix Message-ID: <4febbe74-88d0-43a1-8fed-44cea91c669e@59g2000hsb.googlegroups.com> I've just finished restoring paramix.rb to Facets library. You can expect it in 2.4.2 which I will release soon. (Note that the version included in 2.4.1 is a work in progress and should not be used). Just to let people know how it works now, as opposed to the old version which overrode #include itself, the new version uses a delegating module. So it is much more robust. Here is a simple example: require 'facets/paramix' module MyMixin include Paramix def hello puts "Hello from #{mixin_params[MyMixin][:name]}!" end end class MyClass include Mixin[:name => 'Ruby'] end m = MyClass.new m.hello -> 'Hello from Ruby!' Notice the use of #[]. Capitalized methods have namespace issues, so the #[] method was used instead. T. From noreply at rubyforge.org Wed Apr 9 12:51:16 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 9 Apr 2008 12:51:16 -0400 (EDT) Subject: [Facets] [ facets-Feature Requests-19398 ] Object#delegate, for delegating methods to private variables Message-ID: <20080409165116.665D5185867C@rubyforge.org> Feature Requests item #19398, was opened at 2008-04-09 12:51 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3172&aid=19398&group_id=804 Category: None Group: None Status: Open Priority: 3 Submitted By: Dan Bernier (danbernier) Assigned to: Nobody (None) Summary: Object#delegate, for delegating methods to private variables Initial Comment: When an object has a reference to another object, and wants to set up delegation calls to it, you have two options: manually write all the methods, or implement method_missing, and pass the calls through. Doing it manually is tedious and not DRY; using method_missing isn't bad, but you might want to delegate only some methods, and you might want to delegate them to different variables. We want something like this: class HomeOwner def initialize @landscaper = Landscaper.new @plumber = Plumber.new end delegate :cut_grass, :plant, :to => :landscaper delegate :fix_toilet, :to => :plumber end See the attachment for a working sample implementation and usage examples. Sort of inspired by http://weblog.raganwald.com/2008/04/is-strictly-equivalent-to.html, this is something I've thought of doing a few times before. I was surprised to see it's not already there. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3172&aid=19398&group_id=804 From noreply at rubyforge.org Mon Apr 14 13:32:24 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 14 Apr 2008 13:32:24 -0400 (EDT) Subject: [Facets] [ facets-Patches-19520 ] Dictionary first and last methods might as well take argument like array does.. Message-ID: <20080414173224.D53E41858595@rubyforge.org> Patches item #19520, was opened at 2008-04-14 17:32 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3171&aid=19520&group_id=804 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Christian Theil Have (aquila78) Assigned to: Nobody (None) Summary: Dictionary first and last methods might as well take argument like array does.. Initial Comment: The Dictionary class provides the methods first and last which returns the first and last element of the dictionary. However, Array has similar methods but they take an argument like this: [ :a, :b, :c ].first(2) => [ :a, :b ] I suggest that the dictionary adopts this behaviour, which would IMHO be the least surprising behavior. A patch which changes Dictionary, so that an argument may be given is attached. Note, this doesn't break anything. Calling .first or .last without an argument will work exactly as before. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3171&aid=19520&group_id=804 From noreply at rubyforge.org Wed Apr 30 13:37:18 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 30 Apr 2008 13:37:18 -0400 (EDT) Subject: [Facets] [ facets-Bugs-19865 ] Bug in Hash.recursively Message-ID: <20080430173718.47A7A1858647@rubyforge.org> Bugs item #19865, was opened at 2008-04-30 17:37 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=19865&group_id=804 Category: Code Group: 2.0 + Status: Open Resolution: None Priority: 3 Submitted By: Tomasz Muras (zabuch) Assigned to: Nobody (None) Summary: Bug in Hash.recursively Initial Comment: File: facets/trunk/lib/facets/hash/merge.rb def recursively(&block) yeild inject({}) do |hash, (key, value)| if value.is_a?(Hash) hash[key] = value.recursively(&block) else hash[key] = value end hash end end 1. There is a typo there - should be 'yield' instead of 'yeild'. 2. Function doesn't work on my ruby (ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux]) because of precedence in this line: yeild inject({}) do |hash, (key, value)| changing do-end block to {-} could fix it 3. What is the idea behind this function anyway? Adding some documentation and example could help. Thanks and thanks for a good work on ruby facets! ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3169&aid=19865&group_id=804