In Files

  • rubygems/bundler_version_finder.rb

Class/Module Index [+]

Quicksearch

Gem::BundlerVersionFinder

Public Class Methods

bundler_version() click to toggle source
 
               # File rubygems/bundler_version_finder.rb, line 11
def self.bundler_version
  version, _ = bundler_version_with_reason

  return unless version

  Gem::Version.new(version)
end
            
bundler_version_with_reason() click to toggle source
 
               # File rubygems/bundler_version_finder.rb, line 19
def self.bundler_version_with_reason
  return if @without_filtering

  if v = ENV["BUNDLER_VERSION"]
    return [v, "`$BUNDLER_VERSION`"]
  end
  if v = bundle_update_bundler_version
    return if v == true
    return [v, "`bundle update --bundler`"]
  end
  v, lockfile = lockfile_version
  if v
    return [v, "your #{lockfile}"]
  end
end
            
compatible?(spec) click to toggle source
 
               # File rubygems/bundler_version_finder.rb, line 44
def self.compatible?(spec)
  return true unless spec.name == "bundler".freeze
  return true unless bundler_version = self.bundler_version
  if bundler_version.segments.first >= 2
    spec.version == bundler_version
  else # 1.x
    spec.version.segments.first < 2
  end
end
            
filter!(specs) click to toggle source
 
               # File rubygems/bundler_version_finder.rb, line 54
def self.filter!(specs)
  return unless bundler_version = self.bundler_version
  if bundler_version.segments.first >= 2
    specs.reject! { |spec| spec.version != bundler_version }
  else # 1.x
    specs.reject! { |spec| spec.version.segments.first >= 2}
  end
end
            
missing_version_message() click to toggle source
 
               # File rubygems/bundler_version_finder.rb, line 35
  def self.missing_version_message
    return unless vr = bundler_version_with_reason
    <<-EOS
Could not find 'bundler' (#{vr.first}) required by #{vr.last}.
To update to the lastest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:#{vr.first}`
    EOS
  end
            
without_filtering() click to toggle source
 
               # File rubygems/bundler_version_finder.rb, line 4
def self.without_filtering
  without_filtering, @without_filtering = true, @without_filtering
  yield
ensure
  @without_filtering = without_filtering
end