2008-05-18 06:22:34 +02:00
|
|
|
desc "List the gems that this rails application depends on"
|
2008-06-02 08:35:38 +02:00
|
|
|
task :gems => 'gems:base' do
|
2008-05-18 06:22:34 +02:00
|
|
|
Rails.configuration.gems.each do |gem|
|
2008-10-27 07:47:01 +01:00
|
|
|
print_gem_status(gem)
|
2008-05-18 06:22:34 +02:00
|
|
|
end
|
|
|
|
puts
|
|
|
|
puts "I = Installed"
|
|
|
|
puts "F = Frozen"
|
2008-11-24 22:53:39 +01:00
|
|
|
puts "R = Framework (loaded before rails starts)"
|
2008-05-18 06:22:34 +02:00
|
|
|
end
|
|
|
|
|
2008-10-27 07:47:01 +01:00
|
|
|
def print_gem_status(gem, indent=1)
|
2008-11-24 22:53:39 +01:00
|
|
|
code = gem.loaded? ? (gem.frozen? ? (gem.framework_gem? ? "R" : "F") : "I") : " "
|
2008-10-27 07:47:01 +01:00
|
|
|
puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
|
|
|
|
gem.dependencies.each { |g| print_gem_status(g, indent+1)} if gem.loaded?
|
|
|
|
end
|
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
namespace :gems do
|
2008-06-02 08:35:38 +02:00
|
|
|
task :base do
|
|
|
|
$rails_gem_installer = true
|
|
|
|
Rake::Task[:environment].invoke
|
|
|
|
end
|
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
desc "Build any native extensions for unpacked gems"
|
|
|
|
task :build do
|
2008-06-02 08:35:38 +02:00
|
|
|
$rails_gem_installer = true
|
2008-05-18 06:22:34 +02:00
|
|
|
require 'rails/gem_builder'
|
2008-10-27 07:47:01 +01:00
|
|
|
Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |gem_dir|
|
2008-05-18 06:22:34 +02:00
|
|
|
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
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
desc "Installs all required gems for this application."
|
2008-06-02 08:35:38 +02:00
|
|
|
task :install => :base do
|
2008-05-18 06:22:34 +02:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/gem_runner'
|
|
|
|
Rails.configuration.gems.each { |gem| gem.install unless gem.loaded? }
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Unpacks the specified gem into vendor/gems."
|
2008-06-02 08:35:38 +02:00
|
|
|
task :unpack => :base do
|
2008-05-18 06:22:34 +02:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/gem_runner'
|
|
|
|
Rails.configuration.gems.each do |gem|
|
|
|
|
next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
|
2008-10-27 07:47:01 +01:00
|
|
|
gem.unpack_to(Rails::GemDependency.unpacked_path) if gem.loaded?
|
2008-05-18 06:22:34 +02:00
|
|
|
end
|
|
|
|
end
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
namespace :unpack do
|
|
|
|
desc "Unpacks the specified gems and its dependencies into vendor/gems"
|
|
|
|
task :dependencies => :unpack do
|
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/gem_runner'
|
|
|
|
Rails.configuration.gems.each do |gem|
|
|
|
|
next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
|
|
|
|
gem.dependencies.each do |dependency|
|
|
|
|
next if dependency.frozen?
|
2008-10-27 07:47:01 +01:00
|
|
|
dependency.unpack_to(Rails::GemDependency.unpacked_path)
|
2008-05-18 06:22:34 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2008-10-27 07:47:01 +01:00
|
|
|
|
|
|
|
desc "Regenerate gem specifications in correct format."
|
|
|
|
task :refresh_specs => :base do
|
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/gem_runner'
|
|
|
|
Rails::VendorGemSourceIndex.silence_spec_warnings = true
|
|
|
|
Rails.configuration.gems.each do |gem|
|
|
|
|
next unless gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
|
|
|
|
gem.refresh_spec(Rails::GemDependency.unpacked_path) if gem.loaded?
|
|
|
|
end
|
|
|
|
end
|
2008-05-18 06:22:34 +02:00
|
|
|
end
|