Skip to content

Lazy load package.yml and improve inspect output#25

Merged
ngan merged 3 commits intomainfrom
lazy-load-pack-yaml
Feb 4, 2026
Merged

Lazy load package.yml and improve inspect output#25
ngan merged 3 commits intomainfrom
lazy-load-pack-yaml

Conversation

@ngan
Copy link
Contributor

@ngan ngan commented Feb 4, 2026

Summary

  • Lazy loading: Pack objects no longer read package.yml on creation. The YAML file is only loaded when raw_hash or metadata is accessed, improving performance when iterating over many packs.
  • Improved inspect: #inspect now only shows @name instead of all instance variables, using Ruby 4's instance_variables_to_inspect with a fallback for Ruby 3.
  • Developer experience: Switched from pry to debug gem and added bin/console for interactive development.
  • CI improvements: Updated CI to test Ruby 3.2-4.0 matrix with static type checking and Slack notifications.

Changes

Packs::Pack

  • Converted from T::Struct to regular class to support lazy initialization
  • name, path, relative_path are set immediately from the file path
  • raw_hash is lazily loaded on first access via ||=
  • Added instance_variables_to_inspect (Ruby 4 feature) returning [:@name]
  • Added fallback inspect method for Ruby < 4

Development

  • Replaced pry with debug gem
  • Added bin/console executable for IRB sessions
  • Updated required_ruby_version to >= 3.1
  • Fixed Ruby 3.3+ stdlib requires (fileutils, tmpdir)

CI

  • Replaced shared config with inline workflow
  • Test matrix: Ruby 3.2, 3.3, 3.4, 4.0
  • Added static type checking with Sorbet (srb tc)
  • Added Slack notification on failure for main branch

Test plan

  • All existing tests pass (22 examples)
  • Added tests for lazy loading behavior (3 examples)
  • Added tests for inspect output (2 examples)
  • Added Ruby 4-specific test for instance_variables_to_inspect (1 example)

🤖 Generated with Claude Code

ngan and others added 3 commits February 3, 2026 19:34
- Convert Pack from T::Struct to regular class for lazy loading support
- Defer YAML file reading until raw_hash or metadata is accessed
- Add instance_variables_to_inspect for Ruby 4 native inspect support
- Add fallback inspect method for Ruby 3 compatibility
- Switch from pry to debug gem
- Add bin/console for development
- Update required Ruby version to 3.1+
- Fix Ruby 3.3+ stdlib requires (fileutils, tmpdir)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace shared config with inline workflow for more control
- Test against Ruby 3.2, 3.3, 3.4, and 4.0
- Add static type checking with Sorbet
- Add Slack notification on failure for main branch

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ngan ngan merged commit 19a51b3 into main Feb 4, 2026
6 checks passed
@ngan ngan deleted the lazy-load-pack-yaml branch February 4, 2026 03:40
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