aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/tasks/gems.rake
blob: 198f6050c3f2e280793a114c4def95d2b92f7c0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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}"
  end
end

namespace :gems do
  desc "Installs all required gems for this application."
  task :install => :environment do
    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."
  task :unpack do
    raise "Specify name of gem in the config.gems array with GEM=" if ENV['GEM'].blank?
    Rake::Task["environment"].invoke
    require 'rubygems'
    require 'rubygems/gem_runner'
    unless Rails.configuration.gems.select do |gem|
      if gem.loaded? && gem.name == ENV['GEM']
        gem.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems'))
        true
      end
    end.any?
      puts "No gem named #{ENV['GEM'].inspect} found."
    end
  end
end