Skip to content

Resolve post-0.8.0 issue queue and add coverage tooling#97

Merged
ikraamg merged 9 commits into
mainfrom
0.8.1
May 18, 2026
Merged

Resolve post-0.8.0 issue queue and add coverage tooling#97
ikraamg merged 9 commits into
mainfrom
0.8.1

Conversation

@ikraamg

@ikraamg ikraamg commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Six independent pieces of work from the post-0.8.0 backlog, one commit each, plus
two follow-up commits. Every change ships with specs; the full suite is green and
RuboCop is clean.

Change Resolves
trmnlp init no longer creates read-only project files #83
Payload-size badge is colour-coded by size #67
Non-JSON poll responses are exposed as {{ data }} #81
trmnlp build --png renders a PNG per view #92
CLI output is TTY-aware coloured #33
SimpleCov coverage tracking + lint-check specs

Details

Fixed init creating read-only files — #83

init copied templates with a bare FileUtils.cp, which preserves the source file
mode. On read-only gem installs — NixOS stores gems under /nix/store at 0444
the generated project was not editable. The copy now adds owner-write while keeping
any executable bit, so bin/trmnlp stays runnable.

Payload-size colour coding — #67

The merge-variable payload size was shown as plain text. The badge now turns yellow
from 75 KB and red from 100 KB, so an oversized payload is obvious before the plugin
misbehaves in production.

Non-JSON polling key — #81

A text/html or text/plain poll response that is not secretly JSON was exposed to
the template as {{ text }}, while the hosted service uses {{ data }}. They now
match, so a plugin previews locally the same way it runs in production.

trmnlp build --png#92

build only wrote HTML. build --png now screenshots each view through the existing
quantization pipeline and writes a PNG alongside. --width, --height, and
--color-depth flags override the defaults for parity with the serve PNG route. The
headless-Firefox factory moved out of serve into a shared FirefoxDriver module,
since build is its second consumer.

TTY-aware coloured output — #33

Reporter hand-rolled ANSI escape codes and emitted them unconditionally, so colour
leaked into piped output as unreadable sequences. Colour is now suppressed off a
terminal and extended to warnings and the fatal-error message. (A colour gem was
trialed, then dropped in favour of a four-line hand-rolled colorizer to avoid three
transitive dependencies — see the commit history.)

Coverage tracking + lint specs

SimpleCov now runs from spec_helper; CI gates on a 90% line-coverage floor
(currently 92.5%). The 11 lint checks that had no dedicated spec — previously
exercised only incidentally through the lint command — each gained a focused
pass/fail spec.

Closes

Closes #33
Closes #67
Closes #81
Closes #83
Closes #92

Test plan

  • bundle exec rspec — 268 examples, 0 failures
  • bundle exec rubocop — 111 files, no offenses
  • SimpleCov floor enforced in CI — CI=true bundle exec rspec exits 0 at 92.5%
  • trmnlp build --png against examples/hn-stories — four 800×480 PNGs, real render
  • trmnlp lint piped — no ANSI codes; in a terminal — coloured

ikraamg added 9 commits May 18, 2026 17:21
FileUtils.cp preserves the source file mode. When trmnlp is installed
into a read-only location — NixOS stores gems under /nix/store with
0444 permissions — init produced project files the author could not
edit. The copy now adds owner-write while keeping any executable bit,
so a freshly initialised plugin is always editable.
The preview already displayed the merge-variable payload size, but as
plain text — an author had no at-a-glance signal that a payload was
approaching the size the hosted service starts rejecting. The badge
now turns yellow from 75 KB and red from 100 KB, so an oversized
payload is obvious before the plugin misbehaves in production.
A text/html or text/plain polling response that is not secretly JSON
was exposed to the template as {{ text }}. The hosted service exposes
the same body as {{ data }}. A plugin author writing Liquid against
production and previewing locally would find their template empty
with no error to explain it. The poller now uses {{ data }} to match.
trmnlp build only produced HTML, so seeing a plugin as it renders on
e-ink meant booting the serve command. build --png now screenshots
each view through the existing quantization pipeline and writes a
1-bit PNG alongside the HTML.

The headless Firefox factory that powers the screenshots was private
to the serve command. With build as a second consumer it moves to a
shared FirefoxDriver module rather than being duplicated.
The Reporter hand-rolled ANSI escape codes and emitted them
unconditionally, so colour leaked into piped or redirected output as
unreadable escape sequences. Colour was also limited to the lint
summary.

Output now routes through the tone gem, which suppresses ANSI when
the stream is not a terminal. Colour extends to the warnings the
poller and form-field validation emit, and to the error the
executable prints on a fatal failure.
Nothing measured test coverage, so a drop in coverage could land
unnoticed. SimpleCov now runs from spec_helper and CI gates on a 90%
floor — set just below the current 92.5% so a real regression fails
the build while normal variance does not.

Only 2 of the 13 lint checks had a dedicated spec; the other 11 were
exercised only incidentally through the lint command against the
fixture plugin. Each check now has a focused spec covering a passing
and a failing input.
The Reporter used exactly two things from tone: a colour helper and
terminal detection. Earning those pulled tone, zeitwerk, and
refinements into the dependency tree of a gem users install.

A four-line hand-rolled colorizer covers both — the same ANSI codes,
suppressed off a terminal. The Reporter specs pass unchanged because
they assert on output, not on the colour library, so the swap carries
no behaviour change.
build --png always rendered at 800x480 with the bit depth sniffed
from the markup, with no way to override either. The serve command's
PNG route already accepts width, height, and color_depth as params.

build now takes --width, --height, and --color-depth, threading them
through the same ScreenGenerator the route uses. --color-depth
overrides the screen--Nbit markup sniff; an omitted flag leaves the
existing default in place.
Necessary to ready the 0.8.1 release. The changelog records the new
build --png command, the payload-size colour coding, the coloured
CLI output, and the init and polling fixes. The README documents how
to drive the build command and notes the SimpleCov coverage report.
@ikraamg ikraamg marked this pull request as ready for review May 18, 2026 21:45
@ikraamg ikraamg merged commit 0b0d400 into main May 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant