Class: Bundler::Resolver::SpecGroup
- Inherits:
-
Object
- Object
- Bundler::Resolver::SpecGroup
- Defined in:
- lib/bundler/resolver/spec_group.rb
Instance Attribute Summary collapse
-
#activated_platforms ⇒ Object
Returns the value of attribute activated_platforms.
-
#name ⇒ Object
Returns the value of attribute name.
-
#source ⇒ Object
Returns the value of attribute source.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #dependencies_for_activated_platforms ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(exemplary_spec, specs, relevant_platforms) ⇒ SpecGroup
constructor
A new instance of SpecGroup.
- #to_s ⇒ Object
- #to_specs ⇒ Object
Constructor Details
#initialize(exemplary_spec, specs, relevant_platforms) ⇒ SpecGroup
Returns a new instance of SpecGroup.
18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |
Instance Attribute Details
#activated_platforms ⇒ Object
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 |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/bundler/resolver/spec_group.rb', line 6 def name @name end |
#source ⇒ Object
Returns the value of attribute source.
6 7 8 |
# File 'lib/bundler/resolver/spec_group.rb', line 6 def source @source end |
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/bundler/resolver/spec_group.rb', line 6 def version @version end |
Class Method Details
.create_for(specs, all_platforms, specific_platform) ⇒ Object
9 10 11 12 13 14 15 16 |
# 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 Method Details
#==(other) ⇒ Object
53 54 55 56 57 58 59 |
# 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_for_activated_platforms ⇒ Object
49 50 51 |
# File 'lib/bundler/resolver/spec_group.rb', line 49 def dependencies_for_activated_platforms @dependencies[activated_platforms] end |
#eql?(other) ⇒ Boolean
61 62 63 64 65 66 67 |
# 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 ⇒ Object
69 70 71 |
# File 'lib/bundler/resolver/spec_group.rb', line 69 def hash name.hash ^ version.hash ^ sorted_activated_platforms.hash ^ source.hash end |
#to_s ⇒ Object
44 45 46 47 |
# 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 ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |