Class: Bundler::Resolver::SpecGroup

Inherits:
Object
  • Object
show all
Includes:
GemHelpers
Defined in:
lib/bundler/resolver/spec_group.rb

Constant Summary

Constants included from GemHelpers

GemHelpers::GENERICS, GemHelpers::GENERIC_CACHE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GemHelpers

generic, generic_local_platform, platform_specificity_match, select_best_platform_match

Constructor Details

#initialize(all_specs) ⇒ SpecGroup

Returns a new instance of SpecGroup.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bundler/resolver/spec_group.rb', line 11

def initialize(all_specs)
  raise ArgumentError, "cannot initialize with an empty value" unless exemplary_spec = all_specs.first
  @name = exemplary_spec.name
  @version = exemplary_spec.version
  @source = exemplary_spec.source

  @activated_platforms = []
  @dependencies = nil
  @specs        = Hash.new do |specs, platform|
    specs[platform] = select_best_platform_match(all_specs, platform)
  end
  @ignores_bundler_dependencies = true
end

Instance Attribute Details

#ignores_bundler_dependenciesObject

Returns the value of attribute ignores_bundler_dependencies.



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

def ignores_bundler_dependencies
  @ignores_bundler_dependencies
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#==(other) ⇒ Object



57
58
59
60
61
62
# File 'lib/bundler/resolver/spec_group.rb', line 57

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

#activate_platform!(platform) ⇒ Object



34
35
36
37
38
# File 'lib/bundler/resolver/spec_group.rb', line 34

def activate_platform!(platform)
  return unless for?(platform)
  return if @activated_platforms.include?(platform)
  @activated_platforms << platform
end

#dependencies_for_activated_platformsObject



49
50
51
52
53
54
55
# File 'lib/bundler/resolver/spec_group.rb', line 49

def dependencies_for_activated_platforms
  dependencies = @activated_platforms.map {|p| __dependencies[p] }
   = @activated_platforms.map do |platform|
    (@specs[platform], platform)
  end
  dependencies.concat().flatten
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
67
68
69
# File 'lib/bundler/resolver/spec_group.rb', line 64

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

#for?(platform) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/bundler/resolver/spec_group.rb', line 40

def for?(platform)
  spec = @specs[platform]
  !spec.nil?
end

#hashObject



71
72
73
# File 'lib/bundler/resolver/spec_group.rb', line 71

def hash
  to_s.hash ^ source.hash
end

#to_sObject



45
46
47
# File 'lib/bundler/resolver/spec_group.rb', line 45

def to_s
  @to_s ||= "#{name} (#{version})"
end

#to_specsObject



25
26
27
28
29
30
31
32
# File 'lib/bundler/resolver/spec_group.rb', line 25

def to_specs
  @activated_platforms.map do |p|
    next unless s = @specs[p]
    lazy_spec = LazySpecification.new(name, version, s.platform, source)
    lazy_spec.dependencies.replace s.dependencies
    lazy_spec
  end.compact
end