rubocop: add shim and command.

Add a shim and a command that can be used to easily add a single
directory to your `PATH` (`Library/Homebrew/shims/gems`) and have it
automatically install, configure and run `rubocop` so you can use it
for in-editor integrations.
This commit is contained in:
Mike McQuaid 2021-01-06 15:21:09 +00:00
parent a65ba2fbfe
commit dc072afdb1
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
5 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,25 @@
#: * `rubocop`
#:
#: Installs, configures and runs Homebrew's `rubocop`.
homebrew-rubocop() {
# Don't need shellcheck to follow this `source`.
# shellcheck disable=SC1090
source "$HOMEBREW_LIBRARY/Homebrew/utils/ruby.sh"
setup-ruby-path
GEM_VERSION="$("$HOMEBREW_RUBY_PATH" "$RUBY_DISABLE_OPTIONS" -rrbconfig -e 'puts RbConfig::CONFIG["ruby_version"]')"
GEM_HOME="$HOMEBREW_LIBRARY/Homebrew/vendor/bundle/ruby/$GEM_VERSION"
if ! [[ -f "$GEM_HOME/bin/rubocop" ]]; then
"$HOMEBREW_BREW_FILE" install-bundler-gems
fi
export GEM_HOME
export PATH="$GEM_HOME/bin:$PATH"
# Unconditional -W0 to avoid printing e.g.:
# warning: parser/current is loading parser/ruby26, which recognizes
# warning: 2.6.6-compliant syntax, but you are running 2.6.3.
exec "$HOMEBREW_RUBY_PATH" "$RUBY_DISABLE_OPTIONS" -W0 -S rubocop "$@"
}

View File

@ -0,0 +1,2 @@
#!/bin/bash
exec brew rubocop "$@"

View File

@ -74,6 +74,7 @@ reinstall
release-notes
remove
rm
rubocop
ruby
search
sh

View File

@ -1206,6 +1206,10 @@ a warning will be shown if the latest minor release was less than one month ago.
* `--markdown`:
Print as a Markdown list.
### `rubocop`
Installs, configures and runs Homebrew's `rubocop`.
### `ruby` (`-e` *`text`*|*`file`*)
Run a Ruby instance with Homebrew's libraries loaded, e.g.

View File

@ -1683,6 +1683,9 @@ If \fB\-\-markdown\fR and a \fIprevious_tag\fR are passed, an extra line contain
\fB\-\-markdown\fR
Print as a Markdown list\.
.
.SS "\fBrubocop\fR"
Installs, configures and runs Homebrew\'s \fBrubocop\fR\.
.
.SS "\fBruby\fR (\fB\-e\fR \fItext\fR|\fIfile\fR)"
Run a Ruby instance with Homebrew\'s libraries loaded, e\.g\. \fBbrew ruby \-e "puts :gcc\.f\.deps"\fR or \fBbrew ruby script\.rb\fR\.
.