<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -8,11 +8,17 @@ module Rails
 
     def initialize(name, options = {})
       require 'rubygems' unless Object.const_defined?(:Gem)
-      @name     = name.to_s
-      if options[:version]
+
+      if options[:requirement]
+        @requirement = options[:requirement]
+      elsif options[:version]
         @requirement = Gem::Requirement.create(options[:version])
-        @version     = @requirement.instance_variable_get(&quot;@requirements&quot;).first.last
+      else
+        raise ArgumentError.new('Must pass either :version or :requirement')
       end
+
+      @version     = @requirement.instance_variable_get(&quot;@requirements&quot;).first.last if @requirement
+      @name     = name.to_s
       @lib      = options[:lib]
       @source   = options[:source]
       @loaded   = @frozen = @load_paths_added = false
@@ -35,6 +41,14 @@ module Rails
       puts $!.to_s
     end
     
+    def dependencies
+      all_dependencies = specification.dependencies.map do |dependency|
+        GemDependency.new(dependency.name, :requirement =&gt; dependency.version_requirements)
+      end
+      all_dependencies += all_dependencies.map(&amp;:dependencies).flatten
+      all_dependencies.uniq
+    end
+    
     def gem_dir(base_directory)
       File.join(base_directory, specification.full_name)
     end
@@ -64,10 +78,6 @@ module Rails
       Gem::GemRunner.new.run(install_command)
     end
     
-    def specification
-      @spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last
-    end
-
     def unpack_to(directory)
       FileUtils.mkdir_p directory
       Dir.chdir directory do
@@ -83,6 +93,16 @@ module Rails
       end
     end
 
+    def ==(other)
+      self.name == other.name &amp;&amp; self.requirement == other.requirement
+    end
+
+private ###################################################################
+
+    def specification
+      @spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last
+    end
+
     def install_command
       cmd = %w(install) &lt;&lt; @name
       cmd &lt;&lt; &quot;--version&quot; &lt;&lt; &quot;#{@requirement.to_s}&quot; if @requirement</diff>
      <filename>railties/lib/rails/gem_dependency.rb</filename>
    </modified>
    <modified>
      <diff>@@ -39,4 +39,20 @@ namespace :gems do
       gem.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems')) if gem.loaded?
     end
   end
+  
+  namespace :unpack do
+    desc &quot;Unpacks the specified gems and its dependencies into vendor/gems&quot;
+    task :dependencies =&gt; :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|
+          dependency.add_load_paths # double check that we have not already unpacked
+          next if dependency.frozen?
+          dependency.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems'))
+        end
+      end
+    end
+  end
 end
\ No newline at end of file</diff>
      <filename>railties/lib/tasks/gems.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e89093aeb4b1f544cb54caf54a0374075250cc59</id>
    </parent>
  </parents>
  <author>
    <name>David Dollar</name>
    <email>ddollar@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/4364c361b599f99bc2345ce4eb2d145b07ed8a0f</url>
  <id>4364c361b599f99bc2345ce4eb2d145b07ed8a0f</id>
  <committed-date>2008-04-11T15:25:11-07:00</committed-date>
  <authored-date>2008-04-11T15:25:11-07:00</authored-date>
  <message>Now that we have gems:unpack and gems:build allowing for integration of
100% of your gems into vendor/ it would be nice to have the ability to
automatically unpack the full dependency tree of your specified gems.

This patch adds the rake task gems:unpack:dependencies to do this.

Usage:

gems:unpack:dependencies          # unpack all dependencies
gems:unpack:dependencies GEM=foo  # unpack all dependencies for gem foo</message>
  <tree>1fb87b58438790cda9308ee3cba05427b577b334</tree>
  <committer>
    <name>David Dollar</name>
    <email>ddollar@gmail.com</email>
  </committer>
</commit>
