Class: Bundler::Resolver::SpecGroup

Inherits:
Array
  • Object
show all
Includes:
GemHelpers
Defined in:
lib/bundler/resolver.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

Constructor Details

#initialize(a) ⇒ SpecGroup

Returns a new instance of SpecGroup.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bundler/resolver.rb', line 32

def initialize(a)
  super
  @required_by  = []
  @activated    = []
  @dependencies = nil
  @specs        = {}

  ALL.each do |p|
    @specs[p] = reverse.find { |s| s.match_platform(p) }
  end
end

Instance Attribute Details

#activatedObject (readonly)

Returns the value of attribute activated.



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

def activated
  @activated
end

#required_byObject (readonly)

Returns the value of attribute required_by.



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

def required_by
  @required_by
end

Instance Method Details

#activate_platform(platform) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/bundler/resolver.rb', line 66

def activate_platform(platform)
  unless @activated.include?(platform)
    @activated << platform
    return __dependencies[platform] || []
  end
  []
end

#for?(platform) ⇒ Boolean

Returns:

  • (Boolean)


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

def for?(platform)
  @specs[platform]
end

#initialize_copy(o) ⇒ Object



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

def initialize_copy(o)
  super
  @required_by = o.required_by.dup
  @activated   = o.activated.dup
end

#nameObject



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

def name
  @name ||= first.name
end

#sourceObject



82
83
84
# File 'lib/bundler/resolver.rb', line 82

def source
  @source ||= first.source
end

#to_sObject



90
91
92
# File 'lib/bundler/resolver.rb', line 90

def to_s
  "#{name} (#{version})"
end

#to_specsObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/bundler/resolver.rb', line 50

def to_specs
  specs = {}

  @activated.each do |p|
    if s = @specs[p]
      platform = generic(Gem::Platform.new(s.platform))
      next if specs[platform]

      lazy_spec = LazySpecification.new(name, version, platform, source)
      lazy_spec.dependencies.replace s.dependencies
      specs[platform] = lazy_spec
    end
  end
  specs.values
end

#versionObject



78
79
80
# File 'lib/bundler/resolver.rb', line 78

def version
  @version ||= first.version
end