require "bundler/lockfile_parser"

class LockfileSpecs
  def initialize(lockfile)
    if File.exist?(lockfile)
      @contents = File.read(lockfile)
    else
      @contents = ""
    end
  end

  def include?(name)
    @lockfile ||= Bundler::LockfileParser.new(@contents)
    @lockfile.specs.any? { |spec| spec.name == name }
  rescue Bundler::LockfileError
    false
  end
end

require "bundler"

class LockfileSpecs
  def initialize(lockfile)
    if File.exist?(lockfile)
      @contents = File.read(lockfile)
    else
      @contents = ""
    end
  end

  def include?(name)
    @lockfile ||= Bundler::LockfileParser.new(@contents)
    @lockfile.specs.any? { |spec| spec.name == name }
  rescue Bundler::LockfileError
    false
  end
end

Add bundler to Gemfile and require for LockfileParser dependencies
Add bundler to Gemfile and require for LockfileParser dependencies

Without this, the LockfileParser runs into undefined errors when
referencing other Bundler classes.
