feat: 0.2.0 — CLI, per-category operator specs, round-trip property - #2
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/postscriptCLI:parse INPUT,serialize INPUT [OUTPUT],tokenize INPUT,version.Bugs found by the property spec (all fixed):
showpageeven if the body already contained one — accumulated duplicates on each round-trip.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.%%HiResBoundingBoxeven when the header had it.Other:
consumes/producesdeclarations to all Boolean ops andTransformations::Matrix.# frozen_string_literal: trueon every.rbfile.CHANGELOG.md,LICENSE,.gitignore,.rubocop.yml..github/workflows/{rake,release}.yml— CI + trusted-publishing release.Test plan
bundle exec rspec— 149 examples, 0 failuresbundle exec ruby exe/postscript version→postscript 0.1.0bundle exec rake buildproducespkg/postscript-0.1.0.gemnext_version=minorafter merge; expect tagv0.2.0+postscript-0.2.0.gemon RubyGemsAfter merge
RubyGems trusted publisher must be configured at https://rubygems.org/gems/postscript/trusted_publishers with:
claricle/postscriptrubygems-release.ymlmetanormaci