[katello-devel] katello install discovering rails engines

Tom McKay thomasmckay at redhat.com
Wed Apr 10 15:29:25 UTC 2013


Ivan,

Have you done anything in foreman along the lines of loading additional rails engines after rpm-install of foreman?

What I wrote today [1] is to have katello perform two additional steps at startup:
1) Load Engines.in, a file equivalent to Gemfile.in, where engine gems would be listed for loading by bundler_ext
2) Load engine_routes.rb from routes.rb to mount the engines (eg. mount SomeEngine::Engine => '/mypath')

Has foreman already done something similar?

Thanks!
Tom



[1] https://github.com/thomasmckay/katello/compare/engine-load

diff --git a/src/config/application.rb b/src/config/application.rb
index c9db60f..db157d5 100644
--- a/src/config/application.rb
+++ b/src/config/application.rb
@@ -22,6 +22,10 @@
   require 'bundler_ext'
   BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :all)
 
+  if File.exist?(File.expand_path('../../Engines.in', __FILE__))
+    BundlerExt.system_require(File.expand_path('../../Engines.in', __FILE__), :all)
+  end
+
   # Webmock rubygem have very strong default setting - it blocks all HTTP connections
   # after it is required. Therefore we want to turn off this behavior for all environments
   # except test since with bundler_ext we load ALL groups by default.
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 2784db6..fb923c7 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -820,6 +820,9 @@ def matches?(request)
 
   match 'about', :to => "application_info#about", :as => "about"
 
+  # Load engines
+  require File.expand_path('../engine_routes.rb', __FILE__) if File.exist?(File.expand_path('../engine_routes.rb', __FILE__))
+
   #Last route in routes.rb - throws routing error for everything not handled
   match '*a', :to => 'errors#routing'




More information about the katello-devel mailing list