Krikri::PluginHelpers::CronVar
CronVar - pure logic for managing a named environment-variable assignment (NAME=value line) inside crontab-style text, mirroring ansible.builtin.cronvar's parse/update semantics. Entirely without I/O so it's unit-testable with plain strings, same shape as CronTable for the cron module.
Detection mirrors real cronvar.py's shlex-based parse_for_var: a
line is a variable assignment iff its first whitespace-delimited
token (quotes group, '#' starts a comment, '=' is its own token)
is followed by a bare "=" token - so MAILTO=root and
MAILTO = root both match, but FOOBAR=baz does not match
name FOO (exact token match, case-sensitive), and crontab
schedule lines never parse as assignments (their second token is
a schedule field, never "=").
Class methods
The value of the first assignment named name, or nil.
Parses one line as a variable assignment. Returns {name, value}
or nil when the line isn't one (comment, schedule line, blank).
Unquoted spaces inside the value are swallowed exactly like real
cronvar.py's "".join(lexer) does ("bar baz" reads back as
"barbaz"); quoted spaces survive.
Finds/replaces/removes the assignment named name inside text.
Pass new_value: nil to remove (state: absent). Returns
{new_text, changed}, with changed decided exactly like real
cronvar.py's main(): added (was absent), updated (value differs),
or removed (was present) - and NO change when it already matches.
Known real-module quirk reproduced deliberately: inserting a NEW variable with insertbefore/insertafter naming a variable that doesn't exist silently drops the line (nothing is inserted) but still reports changed: true - every subsequent run reports changed again, forever, identically to real cronvar.