Method: Bundler::GemVersionPromoter#filter_versions
- Defined in:
- lib/bundler/gem_version_promoter.rb
#filter_versions(package, specs) ⇒ Specification
Given a Resolver::Package and an Array of Specifications of available versions for a gem, this method will truncate the Array if strict is true. That means filtering out downgrades from the version currently locked, and filtering out upgrades that go past the selected level (major, minor, or patch).
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/bundler/gem_version_promoter.rb', line 105 def filter_versions(package, specs) return specs unless strict locked_version = package.locked_version return specs if locked_version.nil? || major? specs.select do |spec| gsv = spec.version must_match = minor? ? [0] : [0, 1] all_match = must_match.all? {|idx| gsv.segments[idx] == locked_version.segments[idx] } all_match && gsv >= locked_version end end |