Flesh out rake gems:unpack to unpack all gems, and add rake gems:build for native extensions. Closes #11513 [ddollar]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9215 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
2c6f1d4396
commit
7d2316604a
@ -1,5 +1,13 @@
|
|||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Flesh out rake gems:unpack to unpack all gems, and add rake gems:build for native extensions. [ddollar]
|
||||||
|
|
||||||
|
rake gems:unpack # unpacks all gems
|
||||||
|
rake gems:unpack GEM=mygem # unpacks only the gem 'mygem'
|
||||||
|
|
||||||
|
rake gems:build # builds all unpacked gems
|
||||||
|
rake gems:build GEM=mygem # builds only the gem 'mygem'
|
||||||
|
|
||||||
* Add config.active_support for future configuration options. Also, add more new Rails 3 config settings to new_rails_defaults.rb [rick]
|
* Add config.active_support for future configuration options. Also, add more new Rails 3 config settings to new_rails_defaults.rb [rick]
|
||||||
|
|
||||||
* Add Rails.logger, Rails.root, Rails.env and Rails.cache shortcuts for RAILS_* constants [pratik]
|
* Add Rails.logger, Rails.root, Rails.env and Rails.cache shortcuts for RAILS_* constants [pratik]
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
require 'rails/version'
|
require 'rails/version'
|
||||||
require 'rails/plugin/locator'
|
require 'rails/plugin/locator'
|
||||||
require 'rails/plugin/loader'
|
require 'rails/plugin/loader'
|
||||||
|
require 'rails/gem_builder'
|
||||||
require 'rails/gem_dependency'
|
require 'rails/gem_dependency'
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,10 @@ def add_load_paths
|
|||||||
rescue Gem::LoadError
|
rescue Gem::LoadError
|
||||||
puts $!.to_s
|
puts $!.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def gem_dir(base_directory)
|
||||||
|
File.join(base_directory, specification.full_name)
|
||||||
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
return if @loaded || @load_paths_added == false
|
return if @loaded || @load_paths_added == false
|
||||||
@ -54,12 +58,24 @@ def load_paths_added?
|
|||||||
def install
|
def install
|
||||||
Gem::GemRunner.new.run(install_command)
|
Gem::GemRunner.new.run(install_command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def specification
|
||||||
|
@spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last
|
||||||
|
end
|
||||||
|
|
||||||
def unpack_to(directory)
|
def unpack_to(directory)
|
||||||
FileUtils.mkdir_p directory
|
FileUtils.mkdir_p directory
|
||||||
Dir.chdir directory do
|
Dir.chdir directory do
|
||||||
Gem::GemRunner.new.run(unpack_command)
|
Gem::GemRunner.new.run(unpack_command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# copy the gem's specification into GEMDIR/.specification so that
|
||||||
|
# we can access information about the gem on deployment systems
|
||||||
|
# without having the gem installed
|
||||||
|
spec_filename = File.join(gem_dir(directory), '.specification')
|
||||||
|
File.open(spec_filename, 'w') do |file|
|
||||||
|
file.puts specification.to_yaml
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_command
|
def install_command
|
||||||
|
@ -6,6 +6,18 @@ task :gems => :environment do
|
|||||||
end
|
end
|
||||||
|
|
||||||
namespace :gems do
|
namespace :gems do
|
||||||
|
desc "Build any native extensions for unpacked gems"
|
||||||
|
task :build do
|
||||||
|
Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*')].each do |gem_dir|
|
||||||
|
spec_file = File.join(gem_dir, '.specification')
|
||||||
|
next unless File.exists?(spec_file)
|
||||||
|
specification = YAML::load_file(spec_file)
|
||||||
|
next unless ENV['GEM'].blank? || ENV['GEM'] == specification.name
|
||||||
|
Rails::GemBuilder.new(specification, gem_dir).build_extensions
|
||||||
|
puts "Built gem: '#{gem_dir}'"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc "Installs all required gems for this application."
|
desc "Installs all required gems for this application."
|
||||||
task :install => :environment do
|
task :install => :environment do
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
@ -15,17 +27,12 @@ namespace :gems do
|
|||||||
|
|
||||||
desc "Unpacks the specified gem into vendor/gems."
|
desc "Unpacks the specified gem into vendor/gems."
|
||||||
task :unpack do
|
task :unpack do
|
||||||
raise "Specify name of gem in the config.gems array with GEM=" if ENV['GEM'].blank?
|
|
||||||
Rake::Task["environment"].invoke
|
Rake::Task["environment"].invoke
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rubygems/gem_runner'
|
require 'rubygems/gem_runner'
|
||||||
unless Rails.configuration.gems.select do |gem|
|
Rails.configuration.gems.each do |gem|
|
||||||
if gem.loaded? && gem.name == ENV['GEM']
|
next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
|
||||||
gem.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems'))
|
gem.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems')) if gem.loaded?
|
||||||
true
|
|
||||||
end
|
|
||||||
end.any?
|
|
||||||
puts "No gem named #{ENV['GEM'].inspect} found."
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user