Class: Rails::Generator::Commands::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/instance/instance_generator.rb

Overview

Small addition to enable the enqueing of “bundle install”

Instance Method Summary collapse

Instance Method Details

#run_bundler(destination_root) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/instance/instance_generator.rb', line 5

def run_bundler(destination_root)
  # thanks to http://spectator.in/2011/01/28/bundler-in-subshells/
  bundler_vars = %w(BUNDLE_GEMFILE RUBYOPT )
  command = %{"#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" install --gemfile="#{File.join(File.expand_path(destination_root), 'Gemfile')}"}
  begin
    bundled_env = ENV.to_hash
    bundler_vars.each{ |var| ENV.delete(var) }
    print `#{command}`
  ensure
    ENV.replace(bundled_env)
  end
end