Skip to content

Commit

Permalink
Don't require rails/gem_builder during rails initialization, it's onl…
Browse files Browse the repository at this point in the history
…y needed for the gems:build task. [rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9240 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
technoweenie committed Apr 8, 2008
1 parent 7e94cf7 commit 0bea3f8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions 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]
Expand Down
1 change: 0 additions & 1 deletion railties/lib/initializer.rb
Expand Up @@ -7,7 +7,6 @@
require 'rails/version'
require 'rails/plugin/locator'
require 'rails/plugin/loader'
require 'rails/gem_builder'
require 'rails/gem_dependency'


Expand Down
1 change: 1 addition & 0 deletions railties/lib/rails/gem_builder.rb
@@ -1,3 +1,4 @@
require 'rubygems'
require 'rubygems/installer'

module Rails
Expand Down
8 changes: 6 additions & 2 deletions railties/lib/rails/gem_dependency.rb
Expand Up @@ -14,8 +14,7 @@ def initialize(name, options = {})
end
@lib = options[:lib]
@source = options[:source]
@loaded = false
@load_paths_added = false
@loaded = @frozen = @load_paths_added = false
@unpack_directory = nil
end

Expand All @@ -28,6 +27,7 @@ def add_load_paths
gem *args
else
$LOAD_PATH << File.join(unpacked_paths.first, 'lib')
@frozen = true
end
@load_paths_added = true
rescue Gem::LoadError
Expand All @@ -47,6 +47,10 @@ def load
$!.backtrace.each { |b| puts b }
end

def frozen?
@frozen
end

def loaded?
@loaded
end
Expand Down
12 changes: 8 additions & 4 deletions 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)
Expand All @@ -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
Expand Down

0 comments on commit 0bea3f8

Please sign in to comment.