In Files

  • bundler/resolver/spec_group.rb

Class/Module Index [+]

Quicksearch

Bundler::Resolver::SpecGroup

Attributes

activated_platforms[RW]
name[RW]
source[RW]
version[RW]

Public Class Methods

create_for(specs, all_platforms, specific_platform) click to toggle source
 
               # File 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
            
new(exemplary_spec, specs, relevant_platforms) click to toggle source
 
               # File 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

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

Public Instance Methods

==(other) click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 69
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
            
activate_all_platforms!() click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 52
def activate_all_platforms!
  self.activated_platforms = @all_platforms
end
            
activate_platform!(platform) click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 48
def activate_platform!(platform)
  self.activated_platforms = [platform]
end
            
dependencies_for_activated_platforms() click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 61
def dependencies_for_activated_platforms
  @dependencies[activated_platforms]
end
            
eql?(other) click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 77
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() click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 85
def hash
  name.hash ^ version.hash ^ sorted_activated_platforms.hash ^ source.hash
end
            
partitioned_dependency_names_for_activated_platforms() click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 65
def partitioned_dependency_names_for_activated_platforms
  @partitioned_dependency_names[activated_platforms]
end
            
to_s() click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 56
def to_s
  activated_platforms_string = sorted_activated_platforms.join(", ")
  "#{name} (#{version}) (#{activated_platforms_string})"
end
            
to_specs() click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 35
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
            

Protected Instance Methods

sorted_activated_platforms() click to toggle source
 
               # File bundler/resolver/spec_group.rb, line 91
def sorted_activated_platforms
  activated_platforms.sort_by(&:to_s)
end