Skip to content

feat: 0.2.0 — CLI, per-category operator specs, round-trip property - #2

Merged
ronaldtse merged 1 commit into
mainfrom
feat/cli-and-property-tests
Jul 27, 2026
Merged

feat: 0.2.0 — CLI, per-category operator specs, round-trip property#2
ronaldtse merged 1 commit into
mainfrom
feat/cli-and-property-tests

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

0.2.0 — adds a CLI, per-category operator specs, and a round-trip property spec that caught 3 real serializer bugs.

New surface:

  • Postscript.parse(source), Postscript.serialize(program, **opts), Postscript.tokenize(source) — top-level convenience API.
  • exe/postscript CLI: parse INPUT, serialize INPUT [OUTPUT], tokenize INPUT, version.
  • 13 per-category operator spec files (one per PLRM chapter).
  • Round-trip property spec covering 6 representative PS programs + BoundingBox + HiResBoundingBox.

Bugs found by the property spec (all fixed):

  1. Serializer always appended showpage even if the body already contained one — accumulated duplicates on each round-trip.
  2. Serializer had per-operator emit_<keyword> methods that inlined operands, but the parser ALSO puts operands in body as standalone literal statements → each round-trip doubled the literal count.
  3. Serializer didn't emit %%HiResBoundingBox even when the header had it.

Other:

  • Added missing consumes/produces declarations to all Boolean ops and Transformations::Matrix.
  • # frozen_string_literal: true on every .rb file.
  • Initial CHANGELOG.md, LICENSE, .gitignore, .rubocop.yml.
  • .github/workflows/{rake,release}.yml — CI + trusted-publishing release.

Test plan

  • bundle exec rspec — 149 examples, 0 failures
  • Round-trip property holds for all 6 fixtures
  • CLI works: bundle exec ruby exe/postscript versionpostscript 0.1.0
  • bundle exec rake build produces pkg/postscript-0.1.0.gem
  • Live: trigger release workflow with next_version=minor after merge; expect tag v0.2.0 + postscript-0.2.0.gem on RubyGems

After merge

gh workflow run release.yml -f next_version=minor

RubyGems trusted publisher must be configured at https://rubygems.org/gems/postscript/trusted_publishers with:

  • Repository: claricle/postscript
  • Workflow filename: rubygems-release.yml
  • Workflow repository owner: metanorma
  • Workflow repository name: ci

Add a Thor-based CLI (postscript parse/serialize/tokenize/version)
and a top-level convenience API (Postscript.parse / serialize /
tokenize) for ad-hoc PS source inspection without writing Ruby.

Add one spec file per operator category (13 files) covering
from_operands arity, stack ordering, and value semantics.

Add a round-trip property spec covering 6 representative PS
programs. The property caught two real bugs in the serializer
that are fixed in this commit:

1. Serializer always appended showpage even when the program body
   already contained one — accumulated duplicates on each round-
   trip. Now checks body_has_showpage? first.

2. Serializer had per-operator emit_keyword methods that inlined
   operands, but the parser ALSO puts operands in body as
   standalone literal statements. Each round-trip doubled the
   literal count. Removed all per-operator emitters; the generic
   emit_operator now emits just the keyword, and operands are
   emitted as their own literal statements.

3. Serializer did not emit HiResBoundingBox even when the header
   had it. Now emits both BoundingBox and HiResBoundingBox.

Also:
- Add missing consumes/produces declarations to all Boolean ops
  and Transformations::Matrix.
- Frozen-string literals on every .rb file.
- Initial CHANGELOG, LICENSE, .gitignore, .rubocop.yml.
- GitHub Actions workflows: rake.yml (CI), release.yml (trusted
  publishing via metanorma/ci).

149 specs, 0 failures. postsvg (downstream) still passes 124/124.
@ronaldtse
ronaldtse merged commit ccd7861 into main Jul 27, 2026
@ronaldtse
ronaldtse deleted the feat/cli-and-property-tests branch July 27, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant