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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Tonypm - good catch. Perhaps you should submit this as a tiny patch to the Rails trac with some unit tests. Cheers Luke On 30 Dec 2006, at 16:32, tonypm wrote:> > 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 > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 12/30/06, tonypm <tonypmartin@hotmail.com> wrote:> > 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.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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---