0
@@ -58,7 +58,7 @@ module GemManagement
0
installer = Gem::DependencyInstaller.new(options.merge(:user_install => false))
0
# Force-refresh certain gems by excluding them from the current index
0
- if
refresh.respond_to?(:include?) && !refresh.empty?
0
+ if
!options[:ignore_dependencies] && refresh.respond_to?(:include?) && !refresh.empty?
0
source_index = installer.instance_variable_get(:@source_index)
0
source_index.gems.each do |name, spec|
0
source_index.gems.delete(name) if refresh.include?(spec.name)
0
@@ -81,7 +81,7 @@ module GemManagement
0
if installer.installed_gems.empty? && exception
0
- error "Failed to install gem '#{gem} (#{version
})' (#{exception.message})"
0
+ error "Failed to install gem '#{gem} (#{version
|| 'any version'})' (#{exception.message})"
0
installer.installed_gems.each do |spec|
0
success "Successfully installed #{spec.full_name}"
0
@@ -122,11 +122,13 @@ module GemManagement
0
# install_gem_from_source(source_dir, gem_name)
0
# install_gem_from_source(source_dir, :skip => [...])
0
def install_gem_from_source(source_dir, *args)
0
Dir.chdir(source_dir) do
0
- options = args.last.is_a?(Hash) ? args.pop : {}
0
- gem_name = args[0] || File.basename(source_dir)
0
- gem_pkg_dir = File.join(source_dir, 'pkg')
0
- skip_gems = options.delete(:skip) || []
0
+ opts = args.last.is_a?(Hash) ? args.pop : {}
0
+ gem_name = args[0] || File.basename(source_dir)
0
+ gem_pkg_dir = File.join(source_dir, 'pkg')
0
+ gem_pkg_glob = File.join(gem_pkg_dir, "#{gem_name}-*.gem")
0
+ skip_gems = opts.delete(:skip) || []
0
# Cleanup what's already there
0
@@ -138,7 +140,7 @@ module GemManagement
0
if packages.length == 1
0
# The are no subpackages for the main package
0
-
options[:refresh] = [gem_name]
0
# Gather all packages into the top-level pkg directory
0
@@ -149,24 +151,38 @@ module GemManagement
0
package(source_dir, false)
0
# Gather subgems to refresh during installation of the main gem
0
-
options[:refresh] = packages.map do |pkg|
0
+
refresh = packages.map do |pkg|
0
File.basename(pkg, '.gem')[/^(.*?)-([\d\.]+)$/, 1] rescue nil
0
- gem_pkg = Dir[File.join(gem_pkg_dir, "#{gem_name}-*.gem")][0]
0
- if gem_pkg && File.exists?(gem_pkg)
0
- # Needs to be executed from the directory that contains all packages
0
- Dir.chdir(File.dirname(gem_pkg)) do
0
- install_gem(gem_pkg, options)
0
+ # Install subgems explicitly even if ignore_dependencies is set
0
+ if opts[:ignore_dependencies]
0
+ refresh.each do |name|
0
+ gem_pkg = Dir[File.join(gem_pkg_dir, "#{name}-*.gem")][0]
0
+ install_pkg(gem_pkg, opts)
0
+ # Finally install the main gem
0
+ if install_pkg(Dir[gem_pkg_glob][0], opts.merge(:refresh => refresh))
0
+ installed_gems = refresh
0
+ def install_pkg(gem_pkg, opts = {})
0
+ if (gem_pkg && File.exists?(gem_pkg))
0
+ # Needs to be executed from the directory that contains all packages
0
+ Dir.chdir(File.dirname(gem_pkg)) { install_gem(gem_pkg, opts) }
0
def uninstall_gem(gem, options = {})
0
if options[:version] && !options[:version].is_a?(Gem::Requirement)
0
@@ -178,17 +194,17 @@ module GemManagement
0
def clobber(source_dir)
0
Dir.chdir(source_dir) do
0
- system "#{Gem.ruby} -S rake -s clobber"
if File.exists?('Rakefile')
0
+ system "#{Gem.ruby} -S rake -s clobber"
unless File.exists?('Thorfile')
0
def package(source_dir, clobber = true)
0
Dir.chdir(source_dir) do
0
- if File.exists?('Rakefile')
0
+ if File.exists?('Thorfile')
0
+ elsif File.exists?('Rakefile')
0
rake "clobber" if clobber
0
Dir[File.join(source_dir, 'pkg/*.gem')]
0
@@ -230,12 +246,12 @@ module GemManagement
0
::Gem.clear_paths; ::Gem.path.unshift(gem_dir)
0
::Gem.source_index.refresh!
0
dependencies.each do |dep|
0
- if gemspec = ::Gem.source_index.search(dep).last
0
- if gemspec.loaded_from.index(gem_dir) == 0
0
- local_specs << gemspec
0
- system_specs << gemspec
0
+ gemspecs = ::Gem.source_index.search(dep)
0
+ local = gemspecs.reverse.find { |s| s.loaded_from.index(gem_dir) == 0 }
0
+ system_specs << gemspecs.last
0
@@ -313,4 +329,4 @@ TEXT
0
Gem.source_index.load_gems_in(File.join(dir, 'specifications'))
0
\ No newline at end of file