123456789_123456789_123456789_123456789_123456789_

Class: Bundler::Resolver::SpecGroup

Relationships & Source Files
Inherits: Object
Defined in: lib/bundler/resolver/spec_group.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(exemplary_spec, specs, relevant_platforms) ⇒ SpecGroup

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 18

def initialize(exemplary_spec, specs, relevant_platforms)
  @exemplary_spec = exemplary_spec
  @name = exemplary_spec.name
  @version = exemplary_spec.version
  @source = exemplary_spec.source

  @activated_platforms = relevant_platforms
  @dependencies = Hash.new do |dependencies, platforms|
    dependencies[platforms] = dependencies_for(platforms)
  end
  @specs = specs
end

Class Method Details

.create_for(specs, all_platforms, specific_platform)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 9

def self.create_for(specs, all_platforms, specific_platform)
  specific_platform_specs = specs[specific_platform]
  return unless specific_platform_specs.any?

  platforms = all_platforms.select {|p| specs[p].any? }

  new(specific_platform_specs.first, specs, platforms)
end

Instance Attribute Details

#activated_platforms (rw)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 7

attr_accessor :activated_platforms

#name (rw)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 6

attr_accessor :name, :version, :source

#source (rw)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 6

attr_accessor :name, :version, :source

#version (rw)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 6

attr_accessor :name, :version, :source

Instance Method Details

#==(other)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 53

def ==(other)
  return unless other.is_a?(SpecGroup)
  name == other.name &&
    version == other.version &&
    sorted_activated_platforms == other.sorted_activated_platforms &&
    source == other.source
end

#__dependencies(platform) (private)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 87

def __dependencies(platform)
  dependencies = []
  @specs[platform].first.dependencies.each do |dep|
    next if dep.type == :development
    dependencies << DepProxy.get_proxy(dep, platform)
  end
  dependencies
end

#dependencies_for(platforms) (private)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 81

def dependencies_for(platforms)
  platforms.map do |platform|
    __dependencies(platform) + (platform)
  end.flatten
end

#dependencies_for_activated_platforms

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 49

def dependencies_for_activated_platforms
  @dependencies[activated_platforms]
end

#eql?(other) ⇒ Boolean

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 61

def eql?(other)
  return unless other.is_a?(SpecGroup)
  name.eql?(other.name) &&
    version.eql?(other.version) &&
    sorted_activated_platforms.eql?(other.sorted_activated_platforms) &&
    source.eql?(other.source)
end

#hash

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 69

def hash
  name.hash ^ version.hash ^ sorted_activated_platforms.hash ^ source.hash
end

#metadata_dependencies(platform) (private)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 96

def (platform)
  spec = @specs[platform].first
  return [] unless spec.is_a?(Gem::Specification)
  dependencies = []
  if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
    dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
  end
  if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none?
    dependencies << DepProxy.get_proxy(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
  end
  dependencies
end

#sorted_activated_platforms (protected)

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 75

def sorted_activated_platforms
  activated_platforms.sort_by(&:to_s)
end

#to_s

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 44

def to_s
  activated_platforms_string = sorted_activated_platforms.join(", ")
  "#{name} (#{version}) (#{activated_platforms_string})"
end

#to_specs

[ GitHub ]

  
# File 'lib/bundler/resolver/spec_group.rb', line 31

def to_specs
  activated_platforms.map do |p|
    specs = @specs[p]
    next unless specs.any?

    specs.map do |s|
      lazy_spec = LazySpecification.new(name, version, s.platform, source)
      lazy_spec.dependencies.replace s.dependencies
      lazy_spec
    end
  end.flatten.compact.uniq
end