public this repo is viewable by everyone
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
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
ddollar (author)
about 1 month ago
commit  4364c361b599f99bc2345ce4eb2d145b07ed8a0f
tree    1fb87b58438790cda9308ee3cba05427b577b334
parent  e89093aeb4b1f544cb54caf54a0374075250cc59
...
8
9
10
11
12
 
 
 
 
13
14
 
 
15
 
 
 
16
17
18
...
35
36
37
 
 
 
 
 
 
 
 
38
39
40
...
64
65
66
67
68
69
70
71
72
73
...
83
84
85
 
 
 
 
 
 
 
 
 
 
86
87
88
...
8
9
10
 
 
11
12
13
14
15
 
16
17
18
19
20
21
22
23
24
...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
...
78
79
80
 
 
 
 
81
82
83
...
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
0
@@ -8,11 +8,17 @@ module Rails
0
 
0
     def initialize(name, options = {})
0
       require 'rubygems' unless Object.const_defined?(:Gem)
0
- @name = name.to_s
0
- if options[:version]
0
+
0
+ if options[:requirement]
0
+ @requirement = options[:requirement]
0
+ elsif options[:version]
0
         @requirement = Gem::Requirement.create(options[:version])
0
- @version = @requirement.instance_variable_get("@requirements").first.last
0
+ else
0
+ raise ArgumentError.new('Must pass either :version or :requirement')
0
       end
0
+
0
+ @version = @requirement.instance_variable_get("@requirements").first.last if @requirement
0
+ @name = name.to_s
0
       @lib = options[:lib]
0
       @source = options[:source]
0
       @loaded = @frozen = @load_paths_added = false
0
@@ -35,6 +41,14 @@ module Rails
0
       puts $!.to_s
0
     end
0
     
0
+ def dependencies
0
+ all_dependencies = specification.dependencies.map do |dependency|
0
+ GemDependency.new(dependency.name, :requirement => dependency.version_requirements)
0
+ end
0
+ all_dependencies += all_dependencies.map(&:dependencies).flatten
0
+ all_dependencies.uniq
0
+ end
0
+
0
     def gem_dir(base_directory)
0
       File.join(base_directory, specification.full_name)
0
     end
0
@@ -64,10 +78,6 @@ module Rails
0
       Gem::GemRunner.new.run(install_command)
0
     end
0
     
0
- def specification
0
- @spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last
0
- end
0
-
0
     def unpack_to(directory)
0
       FileUtils.mkdir_p directory
0
       Dir.chdir directory do
0
@@ -83,6 +93,16 @@ module Rails
0
       end
0
     end
0
 
0
+ def ==(other)
0
+ self.name == other.name && self.requirement == other.requirement
0
+ end
0
+
0
+private ###################################################################
0
+
0
+ def specification
0
+ @spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last
0
+ end
0
+
0
     def install_command
0
       cmd = %w(install) << @name
0
       cmd << "--version" << "#{@requirement.to_s}" if @requirement
...
39
40
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43
...
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
0
@@ -39,4 +39,20 @@ namespace :gems do
0
       gem.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems')) if gem.loaded?
0
     end
0
   end
0
+
0
+ namespace :unpack do
0
+ desc "Unpacks the specified gems and its dependencies into vendor/gems"
0
+ task :dependencies => :unpack do
0
+ require 'rubygems'
0
+ require 'rubygems/gem_runner'
0
+ Rails.configuration.gems.each do |gem|
0
+ next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
0
+ gem.dependencies.each do |dependency|
0
+ dependency.add_load_paths # double check that we have not already unpacked
0
+ next if dependency.frozen?
0
+ dependency.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems'))
0
+ end
0
+ end
0
+ end
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.