[PATCH conductor 2/2] Redmine #3242: Set up conductor to use new Bundler extension point.

Jason Guiditta jguiditt at redhat.com
Wed May 9 17:40:28 UTC 2012


https://www.aeolusproject.org/redmine/issues/3242

This is not currently 100% for upstream (ruby-only) dev, but gets us much closer.
We should now be updating only Gemfile.in, no more duplication in application.rb.

For the time being, you should be able to install everything via rpm, have the app
load from Gemfile.in (and not generate a lock file).  You should be able to start the
app, run specs and cukes, all using Gemfile.in (with no extra steps needed).  Note that
if you keep a copy of Gemfile in your src/, you will experience issues, as rails, rspec,
and cucumber look for that file to determine if they use bundler (even if we say we want to
load the deps ourselves).

The idea is that you, as a ruby developer, simply copy over the Gemfile.in to Gemfile,
and run 'bundle install'.  We still have a 'USE_BUNDLER' env var which is set to nil,
meaning for upstream you have to explicitly set it to 'yes'.  Once upstream is working
properly, we can default this to that setting, and set it to no/nil in our initscript.

If you add a dependency, once you have the gem/rpm installed, simply put it in Gemfile.in,
and bundle install using that file with:

bundle install [--gemfile=GEMFILE]
---
 aeolus-conductor.spec.in    |    8 ++++++--
 src/.gitignore              |    1 +
 src/{Gemfile => Gemfile.in} |   17 +++++------------
 src/Gemfile.lock            |   31 ++++++++++++++++---------------
 src/config/application.rb   |   36 +++---------------------------------
 src/config/boot.rb          |    8 +++-----
 6 files changed, 34 insertions(+), 67 deletions(-)
 rename src/{Gemfile => Gemfile.in} (69%)

diff --git a/aeolus-conductor.spec.in b/aeolus-conductor.spec.in
index 123040a..8004781 100644
--- a/aeolus-conductor.spec.in
+++ b/aeolus-conductor.spec.in
@@ -213,8 +213,8 @@ rake="lib/tasks"
 rb="app/models app/controllers app/controllers/api app/helpers app/services app/util \
     config config/initializers config/environments db db/migrate \
     features/support features/step_definitions lib spec spec/controllers \
-    spec/factories spec/helpers spec/models spec/services spec/controllers/api lib/aeolus \
-    lib/aeolus/event"
+    spec/factories spec/helpers spec/models spec/services spec/controllers/api \
+    spec/aeolus/event spec/aeolus/ext lib/aeolus lib/aeolus/event lib/aeolus/ext"
 rhtml="app/views/layouts"
 svg="public/images public/images/icons public/javascripts/jquery-svg public/fonts"
 ttf="public/fonts"
@@ -247,6 +247,8 @@ done
 # misc files
 %{__cp} src/Rakefile %{buildroot}%{app_root}
 %{__cp} src/config.ru %{buildroot}%{app_root}
+%{__cp} src/Gemfile.in %{buildroot}%{app_root}
+%{__cp} src/spec/fixtures/Gemfile.in %{buildroot}%{app_root}/spec/fixtures
 %{__cp} src/lib/aeolus/debug/aeolus-debug %{buildroot}%{_bindir}
 
 %{__mkdir} -p %{buildroot}%{app_root}/config
@@ -378,6 +380,8 @@ fi
 %{app_root}/log
 %{app_root}/public
 %{app_root}/Rakefile
+%{app_root}/Gemfile.in
+%{app_root}/spec/fixtures/Gemfile.in
 %config %{_sysconfdir}/%{name}
 %doc AUTHORS COPYING
 
diff --git a/src/.gitignore b/src/.gitignore
index 283be2f..2d77f59 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -3,3 +3,4 @@ db/*.sqlite3
 log/*.log
 tmp/**/*
 config/oauth.json
+Gemfile
diff --git a/src/Gemfile b/src/Gemfile.in
similarity index 69%
rename from src/Gemfile
rename to src/Gemfile.in
index 387c13b..2264cd3 100644
--- a/src/Gemfile
+++ b/src/Gemfile.in
@@ -1,8 +1,6 @@
-#source 'http://rubygems.org'
+source :rubygems
 
-gem 'rails', ' >= 3.0.7'
-
-gem 'sqlite3', :require => 'sqlite3'
+gem 'rails', '>= 3.0.7'
 
 gem 'deltacloud-client', :require => 'deltacloud'
 gem 'sass'
@@ -17,26 +15,21 @@ gem 'uuidtools'
 gem 'pg'
 gem 'thin'
 gem 'json'
-gem 'railties'
 gem 'rails_warden'
-gem 'ruby-net-ldap'
-gem 'aeolus-image'
+gem 'ruby-net-ldap', :require => 'ldap'
+gem 'aeolus-image', :require => 'aeolus_image'
 gem 'oauth'
 gem 'delayed_job'
 platforms :ruby_18 do
   gem 'fastercsv'
 end
-
 group :development, :test do
   gem 'rspec-rails'
-  gem 'rspec-core'
-  gem 'rspec-mocks'
-  gem 'rspec-expectations'
   gem 'factory_girl_rails'
   gem 'timecop'
   gem 'capybara'
   gem 'cucumber'
-  gem 'cucumber-rails'
+  gem 'cucumber-rails', :require => false
   gem 'database_cleaner'
   gem 'vcr'
   gem 'webmock'
diff --git a/src/Gemfile.lock b/src/Gemfile.lock
index 496e210..132f5b5 100644
--- a/src/Gemfile.lock
+++ b/src/Gemfile.lock
@@ -1,4 +1,5 @@
 GEM
+  remote: http://rubygems.org/
   specs:
     abstract (1.0.0)
     actionmailer (3.0.10)
@@ -29,7 +30,9 @@ GEM
     activesupport (3.0.10)
     addressable (2.2.6)
     aeolus-image (0.4.0)
+      activeresource (~> 3.0.10)
       nokogiri (>= 0.4.0)
+      oauth
       rest-client
     arel (2.0.9)
     builder (2.1.2)
@@ -56,7 +59,9 @@ GEM
     daemons (1.0.10)
     database_cleaner (0.6.6)
     delayed_job (2.1.4)
-    deltacloud-client (0.4.0)
+      activesupport (~> 3.0)
+      daemons
+    deltacloud-client (0.5.0)
       nokogiri (>= 1.4.3)
       rest-client (>= 1.6.1)
     diff-lcs (1.1.2)
@@ -64,6 +69,7 @@ GEM
       abstract (>= 1.0.0)
     eventmachine (0.12.10)
     factory_girl (2.3.2)
+      activesupport
     factory_girl_rails (1.4.0)
       factory_girl (~> 2.3.0)
       railties (>= 3.0.0)
@@ -74,7 +80,7 @@ GEM
     haml (3.1.2)
     i18n (0.5.0)
     json (1.4.6)
-    json_pure (1.4.6)
+    json_pure (1.5.1)
     launchy (2.0.5)
       addressable (~> 2.2.6)
     mail (2.3.0)
@@ -83,7 +89,7 @@ GEM
       treetop (~> 1.4.8)
     mime-types (1.16)
     mustache (0.99.4)
-    nokogiri (1.5.0.beta.4)
+    nokogiri (1.5.2)
     oauth (0.4.4)
     pg (0.11.0)
     polyglot (0.3.1)
@@ -129,7 +135,7 @@ GEM
       rspec-mocks (~> 2.6.0)
     ruby-net-ldap (0.0.4)
     rubyzip (0.9.4)
-    sass (3.1.4)
+    sass (3.1.7)
     selenium-webdriver (2.3.2)
       childprocess (>= 0.1.9)
       ffi (>= 1.0.7)
@@ -137,7 +143,6 @@ GEM
       rubyzip
     simple-navigation (3.0.0)
       activesupport (>= 2.3.2)
-    sqlite3 (1.3.3)
     term-ansicolor (1.0.7)
     thin (1.2.11)
       daemons (>= 1.0.9)
@@ -145,14 +150,15 @@ GEM
       rack (>= 1.0.0)
     thor (0.14.6)
     timecop (0.3.5)
-    treetop (1.4.9)
-      polyglot (>= 0.2.5)
+    treetop (1.4.10)
+      polyglot
+      polyglot (>= 0.3.1)
     tzinfo (0.3.26)
     uuidtools (2.1.1)
     vcr (1.10.0)
-    warden (1.0.3)
-      rack (>= 1.0.0)
-    webmock (1.6.4)
+    warden (1.0.5)
+      rack (>= 1.0)
+    webmock (1.7.6)
       addressable (~> 2.2, > 2.2.5)
       crack (>= 0.1.7)
     will_paginate (3.0.pre2)
@@ -182,16 +188,11 @@ DEPENDENCIES
   rack-restful_submit
   rails (>= 3.0.7)
   rails_warden
-  railties
   rest-client
-  rspec-core
-  rspec-expectations
-  rspec-mocks
   rspec-rails
   ruby-net-ldap
   sass
   simple-navigation
-  sqlite3
   thin
   timecop
   uuidtools
diff --git a/src/config/application.rb b/src/config/application.rb
index 2dbe959..f1abc78 100644
--- a/src/config/application.rb
+++ b/src/config/application.rb
@@ -18,44 +18,14 @@ require File.expand_path('../boot', __FILE__)
 
 require 'rails/all'
 
-# If you have a Gemfile, require the gems listed there, including any gems
-# you've limited to :test, :development, or :production.
+require File.join(File.dirname(__FILE__), '..', 'lib', 'aeolus', 'ext')
 if ENV['USE_BUNDLER'] == 'yes'
+  ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', __FILE__)
   puts "===== application.rb will try and use bundler ========="
   Bundler.require(:default, Rails.env) if defined?(Bundler)
 else
   puts 'Using gem require instead of bundler'
-  require 'rails_warden'
-  require 'net/ldap'
-  require 'deltacloud'
-  require 'sass'
-  require 'haml'
-  require 'mustache'
-  require 'will_paginate'
-  require 'nokogiri'
-  require 'simple-navigation'
-  require 'rest-client'
-  require 'rack-restful_submit'
-  require 'uuidtools'
-  require 'pg'
-  require 'thin'
-  require 'json'
-  require 'fastercsv' if RUBY_VERSION =~ /1\.8\..*/  # no longer needed in ruby 1.9+
-  require 'nokogiri'
-  #require 'railties'
-
-  unless (ENV["RAILS_ENV"] == "production")
-    puts "========= cucumber/test env deps loaded... =========="
-    require 'rspec-rails'
-    require 'factory_girl_rails'
-    require 'timecop'
-    require 'capybara'
-    require 'cucumber'
-    require 'database_cleaner'
-    require 'vcr'
-    require 'webmock'
-    require 'launchy'
-  end
+  Aeolus::Ext::BundlerExt.system_require('Gemfile.in',:default, Rails.env)
 end
 
 $: << File.join(File.dirname(__FILE__), "../app")
diff --git a/src/config/boot.rb b/src/config/boot.rb
index 8bf8ce5..571315e 100644
--- a/src/config/boot.rb
+++ b/src/config/boot.rb
@@ -18,15 +18,13 @@ require 'rubygems'
 
 if ENV['USE_BUNDLER'] == 'yes'
   puts "===== boot.rb will try and use bundler ========="
-  # Set up gems listed in the Gemfile.
-  gemfile = File.expand_path('../../Gemfile', __FILE__)
+  ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', __FILE__)
   begin
-    ENV['BUNDLE_GEMFILE'] = gemfile
-    require 'bundler'
+    require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
     Bundler.setup
   rescue Bundler::GemNotFound => e
     STDERR.puts e.message
     STDERR.puts "Try running `bundle install`."
     exit!
-  end if File.exist?(gemfile)
+  end # if File.exist?(gemfile)
 end
-- 
1.7.7.6




More information about the aeolus-devel mailing list