In Files

  • rubygems/request_set.rb
  • rubygems/request_set/gem_dependency_api.rb

Class/Module Index [+]

Quicksearch

Gem::RequestSet

Attributes

always_install[R]

Array of gems to install even if already installed

dependencies[R]
development[RW]
soft_missing[RW]

Treat missing dependencies as silent errors

Public Class Methods

new(*deps) click to toggle source
 
               # File rubygems/request_set.rb, line 26
def initialize *deps
  @dependencies = deps

  @always_install = []
  @development    = false
  @soft_missing   = false

  yield self if block_given?
end
            

Public Instance Methods

gem(name, *reqs) click to toggle source

Declare that a gem of name name with reqs requirements is needed.

 
               # File rubygems/request_set.rb, line 39
def gem name, *reqs
  @dependencies << Gem::Dependency.new(name, reqs)
end
            
import(deps) click to toggle source

Add deps Gem::Dependency objects to the set.

 
               # File rubygems/request_set.rb, line 46
def import deps
  @dependencies += deps
end
            
install(options, &block) click to toggle source
 
               # File rubygems/request_set.rb, line 50
def install options, &block
  if dir = options[:install_dir]
    return install_into dir, false, options, &block
  end

  cache_dir = options[:cache_dir] || Gem.dir

  specs = []

  sorted_requests.each do |req|
    if req.installed? and
       @always_install.none? { |spec| spec == req.spec.spec } then
      yield req, nil if block_given?
      next
    end

    path = req.download cache_dir

    inst = Gem::Installer.new path, options

    yield req, inst if block_given?

    specs << inst.install
  end

  specs
end
            
install_into(dir, force = true, options = {}) click to toggle source
 
               # File rubygems/request_set.rb, line 78
def install_into dir, force = true, options = {}
  existing = force ? [] : specs_in(dir)
  existing.delete_if { |s| @always_install.include? s }

  dir = File.expand_path dir

  installed = []

  sorted_requests.each do |req|
    if existing.find { |s| s.full_name == req.spec.full_name }
      yield req, nil if block_given?
      next
    end

    path = req.download(dir)

    unless path then # already installed
      yield req, nil if block_given?
      next
    end

    options[:install_dir] = dir
    options[:only_install_dir] = true

    inst = Gem::Installer.new path, options

    yield req, inst if block_given?

    inst.install

    installed << req
  end

  installed
end
            
load_gemdeps(path) click to toggle source

Load a dependency management file.

 
               # File rubygems/request_set.rb, line 117
def load_gemdeps path
  gf = Gem::RequestSet::GemDepedencyAPI.new self, path
  gf.load
end
            
resolve(set = nil) click to toggle source

Resolve the requested dependencies and return an Array of Specification objects to be activated.

 
               # File rubygems/request_set.rb, line 126
def resolve set = nil
  resolver = Gem::DependencyResolver.new @dependencies, set
  resolver.development  = @development
  resolver.soft_missing = @soft_missing

  @requests = resolver.resolve
end
            
resolve_current() click to toggle source

Resolve the requested dependencies against the gems available via Gem.path and return an Array of Specification objects to be activated.

 
               # File rubygems/request_set.rb, line 138
def resolve_current
  resolve Gem::DependencyResolver::CurrentSet.new
end
            
sorted_requests() click to toggle source
 
               # File rubygems/request_set.rb, line 142
def sorted_requests
  @sorted ||= strongly_connected_components.flatten
end
            
specs() click to toggle source
 
               # File rubygems/request_set.rb, line 146
def specs
  @specs ||= @requests.map { |r| r.full_spec }
end
            
specs_in(dir) click to toggle source
 
               # File rubygems/request_set.rb, line 150
def specs_in dir
  Dir["#{dir}/specifications/*.gemspec"].map do |g|
    Gem::Specification.load g
  end
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.

blog comments powered by Disqus