Hi, 

<snip>

> >>
> >> Gem::location_of_caller is insufficient for windows paths :/
> >
> > How does this look?
> >
> > C:\>diff -u rubygems.orig rubygems.rb
> > --- rubygems.orig       Mon Sep 29 08:01:06 2008
> > +++ rubygems.rb Tue Oct 21 14:29:27 2008
> > @@ -479,8 +479,9 @@
> >   # The file name and line number of the caller of the 
> caller of this 
> > method.
> >
> >   def self.location_of_caller
> > -    file, lineno = caller[1].split(':')
> > -    lineno = lineno.to_i
> > +    caller[1] =~ /(.*?)\:(\d+)$/i
> > +    file = $1
> > +    lineno = $2.to_i
> >     [file, lineno]
> >   end
> >
> > Regards,
> >
> 
> Bummer, you beat me, hate bad internet wireless connections...
> 
> I did something similar but one liner for Thor:
> 
> http://github.com/luislavena/thor/commit/e66b67a684200ccd915d5
> 808cb415ea6e5fe08c6
> 
> And of course, for the ones didn't noticed it, I suck at regexp :-P

Mine is more verbose but less greedy. This better?

def self.location_of_caller
   caller[1] =~ /(.*?)\:(\d+)$/i
   [$1, $2.to_i] # file, lineno
end

Regards,

Dan


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.
_______________________________________________
Rubygems-developers mailing list
Rubygems-developers@rubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-developers

Reply via email to