Class: Bundler::Override
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/bundler/override.rb |
Constant Summary
-
UPPER_BOUND_OPERATORS =
# File 'lib/bundler/override.rb', line 5["<", "<="].freeze
Class Method Summary
-
.attach(specs, overrides)
Attach the given overrides onto every
LazySpecificationinspecsso downstream consumers (LazySpecification#choose_compatible, the install- time compatibility check, etc.) can read the override list off the spec itself. - .find_for(overrides, name, field)
- .new(target, field, operation, source_location: nil) ⇒ Override constructor
Instance Attribute Summary
- #field readonly
- #operation readonly
- #source_location readonly
- #target readonly
Instance Method Summary
Constructor Details
.new(target, field, operation, source_location: nil) ⇒ Override
Class Method Details
.attach(specs, overrides)
Attach the given overrides onto every LazySpecification in specs so
downstream consumers (LazySpecification#choose_compatible, the install-
time compatibility check, etc.) can read the override list off the spec
itself. Non-LazySpec entries (StubSpecification, ::Gem::Specification, ...)
are left untouched.
# File 'lib/bundler/override.rb', line 17
def self.attach(specs, overrides) return if overrides.nil? || overrides.empty? specs.each {|s| s.overrides = overrides if s.is_a?(LazySpecification) } end
.find_for(overrides, name, field)
[ GitHub ]Instance Attribute Details
#field (readonly)
[ GitHub ]# File 'lib/bundler/override.rb', line 22
attr_reader :target, :field, :operation, :source_location
#operation (readonly)
[ GitHub ]# File 'lib/bundler/override.rb', line 22
attr_reader :target, :field, :operation, :source_location
#source_location (readonly)
[ GitHub ]#target (readonly)
[ GitHub ]# File 'lib/bundler/override.rb', line 22
attr_reader :target, :field, :operation, :source_location
Instance Method Details
#apply_to(requirement)
[ GitHub ]# File 'lib/bundler/override.rb', line 36
def apply_to(requirement) case operation when nil Gem::Requirement.default when :ignore_upper remove_upper_bounds(requirement) when String Gem::Requirement.new(operation) else raise ArgumentError, "unsupported override operation: #{operation.inspect}" end end
#remove_upper_bounds(requirement) (private)
[ GitHub ]# File 'lib/bundler/override.rb', line 51
def remove_upper_bounds(requirement) return Gem::Requirement.default if requirement.nil? || requirement.none? preserved = requirement.requirements.filter_map do |op, version| if UPPER_BOUND_OPERATORS.include?(op) nil elsif op == "~>" [">=", version] else [op, version] end end return Gem::Requirement.default if preserved.empty? Gem::Requirement.new(preserved.map {|op, v| "#{op} #{v}" }) end
#source_location_label
[ GitHub ]# File 'lib/bundler/override.rb', line 31
def source_location_label return nil unless @source_location "#{File.basename(@source_location.path)}:#{@source_location.lineno}" end