Sha256: e758cf5c55b2b882df57bdc87a3de8222981ae2624d13896a5e4107767882db0

Contents?: true

Size: 1.32 KB

Versions: 170

Compression:

Stored size: 1.32 KB

Contents

module Bundler::PubGrub
  module RubyGems
    extend self

    def requirement_to_range(requirement)
      ranges = requirement.requirements.map do |(op, ver)|
        case op
        when "~>"
          name = "~> #{ver}"
          bump = ver.class.new(ver.bump.to_s + ".A")
          VersionRange.new(name: name, min: ver, max: bump, include_min: true)
        when ">"
          VersionRange.new(min: ver)
        when ">="
          VersionRange.new(min: ver, include_min: true)
        when "<"
          VersionRange.new(max: ver)
        when "<="
          VersionRange.new(max: ver, include_max: true)
        when "="
          VersionRange.new(min: ver, max: ver, include_min: true, include_max: true)
        when "!="
          VersionRange.new(min: ver, max: ver, include_min: true, include_max: true).invert
        else
          raise "bad version specifier: #{op}"
        end
      end

      ranges.inject(&:intersect)
    end

    def requirement_to_constraint(package, requirement)
      Bundler::PubGrub::VersionConstraint.new(package, range: requirement_to_range(requirement))
    end

    def parse_range(dep)
      requirement_to_range(Gem::Requirement.new(dep))
    end

    def parse_constraint(package, dep)
      range = parse_range(dep)
      Bundler::PubGrub::VersionConstraint.new(package, range: range)
    end
  end
end

Version data entries

170 entries across 170 versions & 4 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.23 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
bundler-2.5.23 lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.22 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
bundler-2.5.22 lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.21 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
bundler-2.5.21 lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.20 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
bundler-2.5.20 lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.19 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
bundler-2.5.19 lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.18 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
bundler-2.5.18 lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.17 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
bundler-2.5.17 lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.16 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
bundler-2.5.16 lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
rubygems-update-3.5.15 bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb