feat(ruby): add Ruby on Rails command support#643
Open
Maimer wants to merge 5 commits intortk-ai:developfrom
Open
feat(ruby): add Ruby on Rails command support#643Maimer wants to merge 5 commits intortk-ai:developfrom
Maimer wants to merge 5 commits intortk-ai:developfrom
Conversation
Port upstream PR rtk-ai#292 (rtk-ai/rtk feat/ruby-rails-support): - rspec_cmd.rs: RSpec JSON filter with text fallback (~1000 lines, 97 tests) - rubocop_cmd.rs: RuboCop JSON filter grouped by cop/severity (~660 lines) - utils.rs: ruby_exec(), fallback_tail(), exit_code_from_output(), count_tokens() ruby_exec() uses bundle exec whenever Gemfile exists (transitive deps like rake aren't declared in Gemfile but still need bundler) - E2E smoke test script (scripts/test-ruby.sh) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Nicholas Lee <nicholas.lee@appfolio.com>
State machine parser for Minitest output (rake test / rails test): - Parses both standard Minitest and minitest-reporters formats - Handles "# Running:" and "Started with run options" headers - Summary matches both "N runs" and "N tests" keywords - All-pass: "ok rake test: N runs, 0 failures" - Failures: summary + numbered failure details (limit 10, truncated) - Handles ANSI codes, skipped tests, errors - 80%+ token savings on typical test runs (11 tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Nicholas Lee <nicholas.lee@appfolio.com>
src/main.rs: - Add mod rake_cmd, rspec_cmd, rubocop_cmd - Add Commands::Rake, Rspec, Rubocop variants with trailing_var_arg - Route to respective run() functions - Add to is_operational_command list src/discover/rules.rs: - bundle install/update pattern + rule (TOML, 70% savings) - rake/rails test pattern + rule (85% savings, handles bin/rails) - rspec pattern + rule (65% savings, handles bundle exec) - rubocop pattern + rule (65% savings, handles bundle exec) Rewrite examples: rake test -> rtk rake test bundle exec rake test -> rtk rake test WITH_COVERAGE=true bundle exec rake test -> WITH_COVERAGE=true rtk rake test bundle exec rspec -> rtk rspec bundle exec rubocop -> rtk rubocop bundle install -> rtk bundle install Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Nicholas Lee <nicholas.lee@appfolio.com>
- bundle-install.toml: strips 'Using' lines, gem metadata, blank lines - Short-circuits to "ok bundle: complete/updated" on success - 4 inline tests: all-cached, mixed install, update, empty - Update builtin filter count (47 -> 48) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Nicholas Lee <nicholas.lee@appfolio.com>
- Add rake_cmd.rs, rspec_cmd.rs, rubocop_cmd.rs to module responsibilities - Add ruby_exec to utils.rs description - Add Ruby on Rails Support section to fork-specific features Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Nicholas Lee <nicholas.lee@appfolio.com>
48cb4e5 to
0991f09
Compare
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.
feat(ruby): add Ruby on Rails command support
Summary
Add comprehensive Ruby on Rails support to rtk with 3 new command modules, 1 TOML filter, shared utilities, and automatic discover/rewrite rules.
New Commands
rtk rake testrake_cmd.rsrtk rspecrspec_cmd.rsrtk rubocoprubocop_cmd.rsrtk bundle installbundle-install.tomlDiscover/Rewrite Rules
All common Ruby invocation patterns are automatically rewritten by the Claude Code hook:
ENV_PREFIX auto-strips
RAILS_ENV,WITH_COVERAGE,BUNDLE_GEMFILEand re-prepends to the rewritten command (e.g.WITH_COVERAGE=true bundle exec rake test→WITH_COVERAGE=true rtk rake test).Shared Infrastructure
ruby_exec(tool)inutils.rs: Auto-detectsbundle execwhenGemfileexists in working directory. Handles transitive dependencies correctly (e.g.rakepulled in viarailsnot listed directly in Gemfile).fallback_tail(output, n): Returns last N lines on parse failure (graceful degradation).exit_code_from_output(output): Unix signal handling for child process exit codes.count_tokens(text): Test utility for token savings verification.Minitest Parser Details (
rake_cmd.rs)State machine with 4 states:
Header → Running → Failures → Summary# Running:,N runs) and minitest-reporters format (Started with run options,N tests)"ok rake test: 8 runs, 0 failures"Testing
cargo test)Documentation
Commits
feat(ruby): add RSpec and RuboCop filters with shared Ruby utilities— rspec_cmd.rs, rubocop_cmd.rs, utils.rs additions, test-ruby.shfeat(ruby): add minitest filter for rake/rails test— rake_cmd.rs with state machine parserfeat(ruby): register rake/rspec/rubocop commands and rewrite rules— main.rs routing, discover/rules.rs patternsfeat(ruby): add TOML filter for bundle install/update— bundle-install.toml, filter count updatedocs(ruby): update documentation— README, CHANGELOG, ARCHITECTURE, CLAUDE.mdTest Plan
cargo fmt --all --checkpasses (our files)cargo clippy --all-targetspasses (no new warnings)cargo test— 989 tests pass, 3 ignoredbin/railsand env var prefixes🤖 Generated with Claude Code