module Dependabot::Bundler::Helpers

Constants

BUNDLER_MAJOR_VERSION_REGEX
DEFAULT

If we are updating a project with no Gemfile.lock, we default to the newest version we support

FAILOVER

If we are updating a project with a Gemfile.lock that does not specify the version it was bundled with, with failover to V1 on the assumption it was created with an old version that didn't add this information

V1
V2

Public Class Methods

bundler_version(lockfile) click to toggle source
# File lib/dependabot/bundler/helpers.rb, line 18
def self.bundler_version(lockfile)
  return DEFAULT unless lockfile

  if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX))
    matches[:version].to_i >= 2 ? V2 : V1
  else
    FAILOVER
  end
end
detected_bundler_version(lockfile) click to toggle source
# File lib/dependabot/bundler/helpers.rb, line 28
def self.detected_bundler_version(lockfile)
  return "unknown" unless lockfile

  if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX))
    matches[:version]
  else
    "1"
  end
end