Refactor domain model: Ball, Border, Cursor, Destination#4
Merged
Conversation
Remove .freeze from Zeitwerk::Loader assignment that prevented setup and eager_load from working. Disable Style/MutableConstant cop to avoid this class of issue. Add rdoc comments to satisfy Style/Documentation.
Fill in 82 integration spec bodies across 5 files that were previously skeletons with skip placeholders. Add ANSI color matcher from lot project and fix spec helper issues (EXE path resolution, pack_bundle absolute paths, aggregate_failures).
Refactor bundle.rb parser into small focused methods, extract regex constants, decompose command methods in unpack/diff/list, rename ExtractionResult#size to #line_count to avoid Struct override, extract CommandKit extensions to separate files, split minitest methods exceeding assertion limits, and fix misc style offenses in gemspec, spec helpers, and rake tasks.
New entities created alongside existing Bundle for incremental migration. Ball is the aggregate root (replaces Bundle), Border is fixed domain knowledge, Cursor replaces primitive line/index parsing, Destination handles filesystem writes.
Ball#serialize now passes Border::SEPARATOR to Entry#serialize to avoid ArgumentError. Cursor extracts previous_line and peek_line methods to eliminate raw lines[idx] access from public and private methods.
75 unit specs covering all public interfaces. Fix content fidelity bug in Cursor: collect content lines during walk instead of reconstructing from index arithmetic afterward.
Move raw_line below private keyword since it's only used internally by read_content_until_end. Add position guard to previous_line to prevent silent wrap-around on lines[-1]. DRY binary_entry let in ball_spec.
Parse warnings are advisory (partial success), not errors. Destination now accumulates results internally, yields per-write via block, and provides summary(malformed:) instead of requiring callers to collect results manually.
Pack, unpack, list, and diff commands now use Ball as the aggregate root and Destination for filesystem writes. Removes --border, --border-width, --show-border options. Eliminates Config dependency. Unpack uses pattern matching destructure for options.
Replace options destructure with direct hash access to prevent NoMatchingPatternKeyError when --dry-run is absent. Add exit 1 to Diff#read_input on empty input. Normalize Destination#dry_run? to boolean. Add ExtractionSummary#dry_run? to eliminate LoD violation in Unpack#print_summary.
When file content doesn't end with \n, the border is glued to the last content line. Cursor must strip the border suffix from collected content, same as the old Bundle parser did.
Entry#serialize uses Border::SEPARATOR directly (no parameter). Entry#write_to and Entry#safe_for? removed (Destination owns filesystem writes). Delete Bundle, Config, MalformedBundleError. Remove redundant minitest files (covered by rspec unit specs). Update integration specs for removed --border/--show-border options.
Ball specs test iteration filtering, not mime detection. Stubbing Entry#text? isolates the test from libmagic version differences across platforms.
Update production code comments and error messages to use codeball instead of bundle. Fix spec context descriptions to say parse warnings instead of parse errors.
Owner
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
Move hand-crafted codeball text builder from unpack_spec to CLIHelper so diff_spec can reuse it. Use literal border string since integration specs don't load Codeball in-process.
Cursor is now a pure lexer producing typed tokens (Header, Body, Footer, EOF). Stream is an Enumerable assembler that pulls tokens from Cursor, feeds them to Entry via write-once setters, and emits when Entry reports valid or errored. Entry is a state machine that enforces its own invariants through Design by Contract. Ball uses the snowball model -- starts empty, grows via add_entry. New classes: Header, Body, Footer (SimpleDelegator string wrappers), Stream (assembler), Cursor::EOF (sentinel). Entry rewritten with write-once setters and two construction paths (from_file for packing, token-by-token for parsing). Ball simplified to thin parse factory with no private class methods. Renames: parse_warnings -> warnings, each_parse_warning -> each_warning, parse_warning_count -> warning_count.
Owner
Author
Code reviewFound 1 issue:
codeball/lib/codeball/cursor.rb Lines 84 to 88 in dd9d1d3 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Bare END lines in content no longer terminate body collection. An END marker is only recognized when preceded by a border line (border_before_end?) or when it follows a border suffix on the previous content line (inline_end_marker?). This prevents file content containing END "path" from being silently truncated. Fix false-pass in round-trip spec: unpack to separate output directory so the assertion reads the unpacked file, not the pre-existing original from create_file.
Remove unused found_end(match) from Cursor. Add nil guards to Entry#line_count and Entry#text? for incomplete entries. Update gemspec summary and description to use codeball terminology.
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
--border,--border-width,--show-borderCLI optionsTest plan
bundle exec rakepasses (minitest + rspec + rubocop)codeball pack lib/*.rb | codeball unpack -o /tmp/testround-trips files correctlycodeball pack lib/*.rb | codeball listshows file tablecodeball unpack --dry-runprints preview without writingcodeball unpack -o outdircreates output directory and writes files