PHP 8.2.31
Preview: request_set.rb Size: 3.67 KB
/proc/thread-self/root/opt/alt/ruby20/lib64/ruby/2.0.0/rubygems/request_set.rb

require 'rubygems'
require 'rubygems/dependency'
require 'rubygems/dependency_resolver'
require 'rubygems/dependency_list'
require 'rubygems/installer'
require 'tsort'

module Gem
  class RequestSet

    include TSort

    def initialize(*deps)
      @dependencies = deps

      yield self if block_given?
    end

    attr_reader :dependencies

    # Declare that a gem of name +name+ with +reqs+ requirements
    # is needed.
    #
    def gem(name, *reqs)
      @dependencies << Gem::Dependency.new(name, reqs)
    end

    # Add +deps+ Gem::Depedency objects to the set.
    #
    def import(deps)
      @dependencies += deps
    end

    # Resolve the requested dependencies and return an Array of
    # Specification objects to be activated.
    #
    def resolve(set=nil)
      r = Gem::DependencyResolver.new(@dependencies, set)
      @requests = r.resolve
    end

    # Resolve the requested dependencies against the gems
    # available via Gem.path and return an Array of Specification
    # objects to be activated.
    #
    def resolve_current
      resolve DependencyResolver::CurrentSet.new
    end

    # Load a dependency management file.
    #
    def load_gemdeps(path)
      gf = GemDepedencyAPI.new(self, path)
      gf.load
    end

    def specs
      @specs ||= @requests.map { |r| r.full_spec }
    end

    def tsort_each_node(&block)
      @requests.each(&block)
    end

    def tsort_each_child(node)
      node.spec.dependencies.each do |dep|
        next if dep.type == :development

        match = @requests.find { |r| dep.match? r.spec.name, r.spec.version }
        if match
          begin
            yield match
          rescue TSort::Cyclic
          end
        else
          raise Gem::DependencyError, "Unresolved depedency found during sorting - #{dep}"
        end
      end
    end

    def sorted_requests
      @sorted ||= strongly_connected_components.flatten
    end

    def specs_in(dir)
      Dir["#{dir}/specifications/*.gemspec"].map do |g|
        Gem::Specification.load g
      end
    end

    def install_into(dir, force=true, &b)
      existing = force ? [] : specs_in(dir)

      dir = File.expand_path dir

      installed = []

      sorted_requests.each do |req|
        if existing.find { |s| s.full_name == req.spec.full_name }
          b.call req, nil if b
          next
        end

        path = req.download(dir)

        inst = Gem::Installer.new path, :install_dir => dir,
                                        :only_install_dir => true

        b.call req, inst if b

        inst.install

        installed << req
      end

      installed
    end

    def install(options, &b)
      if dir = options[:install_dir]
        return install_into(dir, false, &b)
      end

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

      specs = []

      sorted_requests.each do |req|
        if req.installed?
          b.call req, nil if b
          next
        end

        path = req.download cache_dir

        inst = Gem::Installer.new path, options

        b.call req, inst if b

        specs << inst.install
      end

      specs
    end

    # A semi-compatible DSL for Bundler's Gemfile format
    #
    class GemDepedencyAPI
      def initialize(set, path)
        @set = set
        @path = path
      end

      def load
        instance_eval File.read(@path).untaint, @path, 1
      end

      # DSL

      def source(url)
      end

      def gem(name, *reqs)
        # Ignore the opts for now.
        reqs.pop if reqs.last.kind_of?(Hash)

        @set.gem name, *reqs
      end

      def platform(what)
        if what == :ruby
          yield
        end
      end

      alias_method :platforms, :platform

      def group(*what)
      end
    end
  end
end

Directory Contents

Dirs: 6 × Files: 53

Name Size Perms Modified Actions
commands DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
core_ext DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
ext DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
package DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
security DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
ssl_certs DIR
- drwxr-xr-x 2024-03-03 22:43:42
Edit Download
1.56 KB lrw-r--r-- 2013-03-17 14:51:53
Edit Download
13.43 KB lrw-r--r-- 2012-11-30 16:27:52
Edit Download
5.27 KB lrw-r--r-- 2012-12-06 05:26:46
Edit Download
1.58 KB lrw-r--r-- 2013-02-05 21:06:14
Edit Download
11.82 KB lrw-r--r-- 2023-07-26 14:06:15
Edit Download
2.76 KB lrw-r--r-- 2013-07-22 16:33:18
Edit Download
7.74 KB lrw-r--r-- 2012-12-23 00:35:09
Edit Download
12.36 KB lrw-r--r-- 2013-11-13 02:59:08
Edit Download
5.53 KB lrw-r--r-- 2013-03-17 14:51:53
Edit Download
14.97 KB lrw-r--r-- 2013-07-22 16:33:18
Edit Download
1.73 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
2.86 KB lrw-r--r-- 2013-01-04 07:31:57
Edit Download
2.14 KB lrw-r--r-- 2013-07-22 16:33:18
Edit Download
2.70 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
416 B lrw-r--r-- 2012-12-10 00:40:39
Edit Download
2.84 KB lrw-r--r-- 2013-09-15 14:23:26
Edit Download
1.98 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
12.89 KB lrw-r--r-- 2012-12-06 05:26:46
Edit Download
22.19 KB lrw-r--r-- 2013-08-16 15:35:06
Edit Download
4.28 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
281 B lrw-r--r-- 2012-11-29 06:52:18
Edit Download
5.09 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
3.36 KB lrw-r--r-- 2011-07-27 01:40:07
Edit Download
1.35 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
1.96 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
13.22 KB lrw-r--r-- 2023-07-26 14:06:15
Edit Download
3.77 KB lrw-r--r-- 2013-08-16 15:35:06
Edit Download
1.58 KB lrw-r--r-- 2012-11-30 00:23:15
Edit Download
5.63 KB lrw-r--r-- 2013-07-22 16:33:18
Edit Download
249 B lrw-r--r-- 2013-07-25 15:42:22
Edit Download
763 B lrw-r--r-- 2013-07-22 16:33:18
Edit Download
7.75 KB lrw-r--r-- 2013-03-17 14:51:53
Edit Download
15.99 KB lrw-r--r-- 2015-08-18 13:01:02
Edit Download
3.67 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
6.02 KB lrw-r--r-- 2012-11-30 16:27:52
Edit Download
1.11 KB lrw-r--r-- 2023-07-26 14:06:15
Edit Download
20.56 KB lrw-r--r-- 2013-03-17 15:01:47
Edit Download
21.69 KB lrw-r--r-- 2013-10-26 17:44:33
Edit Download
3.12 KB lrw-r--r-- 2013-10-26 17:44:33
Edit Download
1.22 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
1.88 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
552 B lrw-r--r-- 2012-11-29 06:52:18
Edit Download
66.90 KB lrw-r--r-- 2023-07-26 14:06:15
Edit Download
5.17 KB lrw-r--r-- 2013-10-26 17:44:33
Edit Download
2.07 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
28.09 KB lrw-r--r-- 2013-07-25 15:42:22
Edit Download
4.03 KB lrw-r--r-- 2013-03-17 15:07:00
Edit Download
1.23 KB lrw-r--r-- 2011-07-27 01:40:07
Edit Download
8.29 KB lrw-r--r-- 2012-12-19 07:19:10
Edit Download
11.44 KB lrw-r--r-- 2012-11-29 06:52:18
Edit Download
4.08 KB lrw-r--r-- 2012-12-23 00:35:09
Edit Download
10.50 KB lrw-r--r-- 2013-10-26 17:44:33
Edit Download
1.59 KB lrw-r--r-- 2011-07-27 01:40:07
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).