Class: Bundler::Resolver::SpecGroup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(specs, relevant_platforms) ⇒ SpecGroup

Returns a new instance of SpecGroup.



9
10
11
12
13
14
15
16
17
# File 'lib/bundler/resolver/spec_group.rb', line 9

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

  @activated_platforms = relevant_platforms
  @specs = specs
end

Instance Attribute Details

#activated_platformsObject

Returns the value of attribute activated_platforms.



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

def activated_platforms
  @activated_platforms
end

#force_ruby_platformObject

Returns the value of attribute force_ruby_platform.



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

def force_ruby_platform
  @force_ruby_platform
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#==(other) ⇒ Object



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

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_for_activated_platformsObject



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

def dependencies_for_activated_platforms
  @dependencies_for_activated_platforms ||= @specs.map do |spec|
    __dependencies(spec) + (spec)
  end.flatten.uniq
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#hashObject



55
56
57
# File 'lib/bundler/resolver/spec_group.rb', line 55

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

#to_sObject



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

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

#to_specsObject



19
20
21
22
23
24
25
26
# File 'lib/bundler/resolver/spec_group.rb', line 19

def to_specs
  @specs.map do |s|
    lazy_spec = LazySpecification.new(name, version, s.platform, source)
    lazy_spec.force_ruby_platform = force_ruby_platform
    lazy_spec.dependencies.replace s.dependencies
    lazy_spec
  end
end