Add rails-stats command line executable#49
Merged
Conversation
Add a standalone `rails-stats` executable so the tool can be run against a directory without setting up a Rakefile. It accepts both absolute and relative paths, defaults to the current directory when none is given, and optionally takes a `json` second argument for JSON output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
etagwerker
force-pushed
the
add-rails-stats-executable
branch
from
July 12, 2026 14:07
d90b473 to
c63c5ba
Compare
Set spec.bindir/spec.executables explicitly in the gemspec per the RubyGems specification reference, and update the README so the primary usage examples call the rails-stats executable instead of rake stats[...]. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a standalone rails-stats command-line executable so RailsStats can be run against any directory without needing a local Rakefile, and updates documentation/changelog accordingly.
Changes:
- Add
bin/rails-statsCLI entrypoint that resolves a target directory and runsRailsStats::CodeStatisticsdirectly. - Update README usage examples to document the CLI and replace some
rake stats[...]examples withrails-stats .... - Update gemspec executable metadata and add a changelog entry linking to this PR.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| README.md | Documents the new CLI usage and updates examples to prefer rails-stats. |
| rails_stats.gemspec | Updates gem metadata and sets executable/bindir configuration for the new CLI. |
| CHANGELOG.md | Adds an unreleased feature entry linking to PR #49. |
| bin/rails-stats | New standalone CLI wrapper around RailsStats::CodeStatistics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ```bash | ||
| $ for dir in /path/to/many/engines/*/; do bundle exec rake stats[$dir]; done | ||
| $ for dir in /path/to/many/engines/*/; do rails-stats "$dir"; done |
Comment on lines
+17
to
+18
| spec.bindir = "bin" | ||
| spec.executables = ["rails-stats"] |
Move all rake invocation instructions (Rakefile-in-any-directory and replacing the built-in rake stats inside a Rails app) into a single "Calling it through rake" subsection, and switch every other example to the rails-stats executable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
etagwerker
marked this pull request as ready for review
July 12, 2026 14:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
CHANGELOG.mdthat links to this PR under the "main (unreleased)" heading.Description:
This adds a standalone
rails-statsexecutable so the tool can be run against a directory without having to set up aRakefilefirst.Before, running against an arbitrary directory required a
Rakefileand therake stats[/path/to/app/]invocation. Now you can just call:The executable resolves the path with
File.absolute_path, so both absolute and relative paths work, prints the resolved directory, and exits with a friendly error (exit code 1) when the directory does not exist. It callsRailsStats::CodeStatisticsdirectly instead of going through Rake.The gemspec already ships anything under
bin/as an executable (spec.executables = spec.files.grep(%r{^bin/})), so no gemspec change was needed.README gains a "Run it as a command line tool" section documenting the usage.
I will abide by the code of conduct.
🤖 Generated with Claude Code