boot.rb - environment_without_comments

Whilst looking into some of the initialization code, I came across this at line 20 in rails-1.1.6/environments/boot.rb

   environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join

This, it seems, is intended to pull non commented lines out of environment.rb.

Although a trivial point, this regexp misses indented # and so still includes most of the commented lines.

Would this be better as?

.......reject { |l| l =~ /^\s*#/ }.join

Also in the subsequent line, [^#] would seem to serve no purpose since a line starting with # would have been rejected..

Tonypm

Tonypm - good catch. Perhaps you should submit this as a tiny patch to the Rails trac with some unit tests.

Cheers Luke

As far as I recall, the only point of reading the environment via IO is to read the gem version if it’s not commented out. This “hack” is not supposed to do anything with the rest of the file, so I don’t think it really matters. The “RAILS_GEM_VERSION” line is not indented by default.