[Ruby] Weird Rails Class Inheritance Bug
Ryan Davis
ryand-ruby at zenspider.com
Tue Jul 18 00:32:13 PDT 2006
On Jul 17, 2006, at 3:55 PM, Geoffrey Grosenbach wrote:
> http://pastie.caboo.se/4990
In the following:
# Ignore directories and files that end with a digit
# Capture the name of the fixture file
if FileTest.file?(path) && /\D\.yml$/.match(path) && %r%/([^./]
+)\.yml$%.match(path)
@@fixture_files << $1
end
I wonder about the last 2 conditions. Why two conditions and why
ignore files that end in a digit? I assume the second is really just
for the capture, but that will break on legacy DBs that have '.' in
their table name (the last oracle db I worked on used them all over
for namespacing, and yes it was a rails app I was writing). How about:
# Ignore directories and files that end with a digit
if FileTest.file?(path) && /\D\.yml$/ =~ path then
@@fixture_files << File.basename(path, '.yml')
end
or something similar?
Also, as an aside, //.match(s) or s.match(//) are both a fair bit
slower than // =~ s or s =~ //. Doesn't matter in your current
example, but in a tight loop it'll add up quickly.
More information about the Ruby
mailing list