diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 864c618d63..5a80e21446 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Don't require rails/gem_builder during rails initialization, it's only needed for the gems:build task. [rick] + * script/performance/profiler compatibility with the ruby-prof >= 0.5.0. Closes #9176. [Catfish] * Flesh out rake gems:unpack to unpack all gems, and add rake gems:build for native extensions. #11513 [ddollar] diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 61fcddc5f0..8a5ca6f91b 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -7,7 +7,6 @@ require 'railties_path' require 'rails/version' require 'rails/plugin/locator' require 'rails/plugin/loader' -require 'rails/gem_builder' require 'rails/gem_dependency' diff --git a/railties/lib/rails/gem_builder.rb b/railties/lib/rails/gem_builder.rb index 629726a5c6..e7e06d0008 100644 --- a/railties/lib/rails/gem_builder.rb +++ b/railties/lib/rails/gem_builder.rb @@ -1,3 +1,4 @@ +require 'rubygems' require 'rubygems/installer' module Rails diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index 8d6a748e4c..0b2e6eb93d 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -14,8 +14,7 @@ module Rails end @lib = options[:lib] @source = options[:source] - @loaded = false - @load_paths_added = false + @loaded = @frozen = @load_paths_added = false @unpack_directory = nil end @@ -28,6 +27,7 @@ module Rails gem *args else $LOAD_PATH << File.join(unpacked_paths.first, 'lib') + @frozen = true end @load_paths_added = true rescue Gem::LoadError @@ -47,6 +47,10 @@ module Rails $!.backtrace.each { |b| puts b } end + def frozen? + @frozen + end + def loaded? @loaded end diff --git a/railties/lib/tasks/gems.rake b/railties/lib/tasks/gems.rake index 8f3fc51635..c8d5167be6 100644 --- a/railties/lib/tasks/gems.rake +++ b/railties/lib/tasks/gems.rake @@ -1,13 +1,18 @@ desc "List the gems that this rails application depends on" task :gems => :environment do Rails.configuration.gems.each do |gem| - puts "[#{gem.loaded? ? '*' : ' '}] #{gem.name} #{gem.requirement.to_s}" + code = gem.loaded? ? (gem.frozen? ? "F" : "I") : " " + puts "[#{code}] #{gem.name} #{gem.requirement.to_s}" end + puts + puts "I = Installed" + puts "F = Frozen" end namespace :gems do desc "Build any native extensions for unpacked gems" task :build do + require 'rails/gem_builder' Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*')].each do |gem_dir| spec_file = File.join(gem_dir, '.specification') next unless File.exists?(spec_file) @@ -26,12 +31,11 @@ namespace :gems do end desc "Unpacks the specified gem into vendor/gems." - task :unpack do - Rake::Task["environment"].invoke + task :unpack => :environment do require 'rubygems' require 'rubygems/gem_runner' Rails.configuration.gems.each do |gem| - next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name + next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name) gem.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems')) if gem.loaded? end end