Adding #environment to the new rails templates

Hey All

As I started to use the new Rails Template Runner functionality (thanks to lifo + jeremymcanally - it's really awesome) I realized some small missing methods that could make the template a lot more powerful. One in particular was really already there - just embedded within another method.

I just submitted a patch: http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1613-adding-environment-to-new-template_runner That extracts the functionality for adding 'config.gem' to the Rails::Initializer block to its own method #environment.

The strongest use-case for this is adding or configuring load paths - e.g.

  environment "config.load_paths += %w[\#{Rails.root}/app/mailers \# {Rails.root}/app/observers]"

It could also be used for adding observers:

  environment "config.active_record.observers = :user_observer"

Or setting any arbitrary config method.

Heres the patch for easy viewing on github: http://github.com/quirkey/rails/commit/6947592c772c67d4fdbaf397c6736eaa3be69363

Thanks! --AQ

Since this email, Lifo urged me to write tests for the Template Runner (which has 0 tests in master currently). I've submitted another patch: http://rails.lighthouseapp.com/projects/8994/tickets/1618-test-coverage-and-refactor-of-template-runner#ticket-1618-1

Which refactors a bunch of the template runner (DRY) uses the logger instead of just 'puts' and now has very good test coverage. Please test it out and let me know if I need to make more changes. I think this will let us progress the template runner in the light of the BIG NEWS.

--AQ

Since this email, Lifo urged me to write tests for the Template Runner (which has 0 tests in master currently). I've submitted another patch: http://rails.lighthouseapp.com/projects/8994/tickets/1618-test-coverage-and-refactor-of-template-runner#ticket-1618-1

Which refactors a bunch of the template runner (DRY) uses the logger instead of just 'puts' and now has very good test coverage. Please test it out and let me know if I need to make more changes. I think this will let us progress the template runner in the light of the BIG NEWS.

--AQ

Looks awesome. Thanks for doing that; you did all the refactorings I didn't have time to get to! :slight_smile:

--Jeremy