public
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-more.git
Freezer now looks locally, remotely and in gems cache to install from 
rubygems
fabien (author)
Wed May 28 12:42:06 -0700 2008
commit  5364f80683ddb902fd004a55f9914f3c9e0b167a
tree    48df36ef665874846f1d7d120133655e75cdfb35
parent  c1c8cc3915fcb170ca8c9ac32434cd4b241214ee
...
1
2
 
 
 
3
4
5
...
49
50
51
52
53
54
55
56
 
57
58
59
60
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
63
64
...
1
 
2
3
4
5
6
7
...
51
52
53
 
54
55
 
 
56
57
58
 
 
 
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
0
@@ -1,5 +1,7 @@
0
 require 'find'
0
-#require 'merb-core/tasks/merb_rake_helper'
0
+require 'rubygems'
0
+require 'rubygems/dependency_installer'
0
+
0
 module FreezerMode
0
   
0
   def sudo
0
@@ -49,16 +51,39 @@ module FreezerMode
0
   end
0
 
0
   # Uses rubygems to freeze the components locally
0
- #
0
   def rubygems_freeze
0
     create_freezer_dir(freezer_dir)
0
- action = update ? 'update' : 'install'
0
- puts "#{action} #{@component} and dependencies from rubygems"
0
+ puts "Install #{@component} and dependencies from rubygems"
0
     if File.exist?(freezer_dir) && !File.writable?("#{freezer_dir}/cache")
0
       puts "you might want to CHOWN the gems folder so it's not owned by root: sudo chown -R #{`whoami`} #{freezer_dir}"
0
- `#{sudo} gem #{action} #{@component} --no-rdoc --no-ri -i #{freezer_dir}`
0
- else
0
- `gem #{action} #{@component} --no-rdoc --no-ri -i #{freezer_dir}`
0
+ end
0
+ install_rubygem @component
0
+ end
0
+
0
+ # Install a gem - looks remotely and locally
0
+ # won't process rdoc or ri options.
0
+ def install_rubygem(gem, version = nil)
0
+ Gem.configuration.update_sources = false
0
+ Gem.clear_paths
0
+ installer = Gem::DependencyInstaller.new(:install_dir => freezer_dir)
0
+ exception = nil
0
+ begin
0
+ installer.install gem, version
0
+ rescue Gem::InstallError => e
0
+ exception = e
0
+ rescue Gem::GemNotFoundException => e
0
+ puts "Locating #{gem} in local gem path cache..."
0
+ spec = version ? Gem.cache.find_name(gem, "= #{version}").first : Gem.cache.find_name(gem).sort_by { |g| g.version }.last
0
+ if spec && File.exists?(gem_file = spec.installation_path / 'cache' / "#{spec.full_name}.gem")
0
+ installer.install gem_file
0
+ end
0
+ exception = e
0
+ end
0
+ if installer.installed_gems.empty? && e
0
+ puts "Failed to install gem '#{gem}' (#{e.message})"
0
+ end
0
+ installer.installed_gems.each do |spec|
0
+ puts "Successfully installed #{spec.full_name}"
0
     end
0
   end
0
 
...
32
33
34
35
 
36
37
38
...
32
33
34
 
35
36
37
38
0
@@ -32,7 +32,7 @@ end
0
 
0
 desc "Install Merb-Slices as a gem"
0
 task :install => [:package] do
0
- sh %{#{sudo} gem install pkg/#{NAME}-#{GEM_VERSION} --no-update-sources}
0
+ sh %{#{sudo} gem install #{install_home} pkg/#{NAME}-#{GEM_VERSION} --no-update-sources}
0
 end
0
 
0
 namespace :jruby do

Comments

    No one has commented yet.