# Bundler

`cooldown` gates Ruby projects through `--tool bundler` (aliases `bundle`, `ruby`, `gem`,
`rubygems`).

## What it reads

A Bundler project is a `Gemfile` with its `Gemfile.lock`. `cooldown` reads each gem's `Gemfile`
requirement from the lock's `DEPENDENCIES` section:

- **An exact `= 1.2.3` pin:** holds the gem as `pinned`.
- **A `~>`, `<` or `<=` bound:** keeps its target inside the bound.

## Registry

Publish times come from rubygems.org. `cooldown` plans only gems Bundler fetches from rubygems.org
itself, so none from a private, Git or path source.

## How it is driven

`upgrade`, `fix` and `check` run `ruby`, or the program `COOLDOWN_RUBY` names, which loads Bundler.
`--build` runs `bundle lock`, with `bundle` or the program `COOLDOWN_BUNDLE` names.

`upgrade` and `fix` use Bundler to lock each gem at exactly its planned version. They need a
Bundler `>= 2.7.2, < 5`, and refuse while a mirror is configured for rubygems.org. The relock never
edits the `Gemfile`.

`check` proves `Gemfile.lock` current with the comparison a frozen `bundle install` starts with. It
runs in place under the Bundler release the lock's `BUNDLED WITH` names, so it installs and writes
nothing. A lock that comparison refuses is stale, which `--allow-stale-lock` waives.

## Edge cases

The lock is `lock_unknown` when:

- it has a `GIT`, `PATH` or `PLUGIN SOURCE` section;
- it has no `BUNDLED WITH` release, or that release is outside `>= 2.4, < 5`;
- that Bundler release is not installed, or another one is configured;
- the `Gemfile` names another lock;
- the lock does not fit this host's Ruby or platform;
- the temporary directory lies inside the project.

## Fixing what goes wrong

- **A requirement you edited is not picked up:** run `bundle lock`, since `cooldown` reads the
  requirement from the lock.
- **A gem held by a pin or a bound:** the relock never edits the `Gemfile`, so neither `--rewrite`
  nor `--downgrade-pinned` lifts it. Loosen the requirement yourself.
