[SVN] Re: Source bundle, comment line command: Changes for Ruby 1.9

James Gray james at grayproductions.net
Thu Aug 28 20:45:37 UTC 2008


On Aug 28, 2008, at 3:38 PM, Charles Turner wrote:

> On Thu, 28 Aug 2008 14:52:55 -0500, James Gray wrote:
>> My copy of the command already has text.map().  We cannot do the
>> reverse either, switch to text.lines.map() as 1.8 doesn't have  
>> lines().
>
> OK, my embarrassment level is up pretty high. :-)

No worries.  I should have figured it out.

> This is what works for me in 1.9:
>
>  when "line"  # line by line comment
>    if text !~ /\A[\t ]+\z/ &&
>       text.lines.map { |l| !!(l =~ /\A\s*(#{com[:esc_start]}|$)/)
> }.uniq == [true]

OK, we can't go to just lines() here, since it breaks 1.8.  Can we use  
my previous trick though?

   text.send(text.respond_to?(:lines) ? :lines : :to_s)…

James Edward Gray II


More information about the textmate-dev mailing list