Skip to content

Commit

Permalink
Add RVM Capabilities
Browse files Browse the repository at this point in the history
Enable specifying Ruby version with rvm so that you can use this with multiple rubies without issue.
  • Loading branch information
mzagaja committed Oct 28, 2022
1 parent f361dbe commit bfd2d85
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 32 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Version 1.3
* Enable using `rvm-exec` with rubocop.

## Version 1.2
* Enable using `bundle exec` with rubocop.
* Bug: fix error if there are no fixes from Rubocop.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@

**Rubocop** automatically lints all open files, then reports errors and warnings in Nova's **Issues** sidebar and the editor gutter:

<!--
🎈 It can also be helpful to include a screenshot or GIF showing your extension in action:
-->

![](https://www.zagaja.com/images/rubocop-extension-screenshot.png)

## Requirements
Expand All @@ -24,9 +20,13 @@ gem install rubocop rubocop-rails rubocop-rspec rubocop-md
* We now let you choose whether to prepend your rubocop with `bundle exec`. If you do not it will
use `rubocop` from your default/global gemset.

- RVM users can now prepend their rubocop command with `rvm .ruby-version do` to surmount
configuration issues with rvm. It will automatically use the `.ruby-version` file in your project
root if you enable this option.

### Troubleshooting
If you have a .rubocop.yml with `inherit_gem` and use `rvm` you will need to make sure your gems are
all available in the default gemset. The easiest way to do this is to avoid using app specific
all available in the default gemset with rvm. The easiest way to do this is to avoid using app specific
gemsets. Otherwise try:

```sh
Expand Down
9 changes: 7 additions & 2 deletions Scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ class IssuesProvider {
if(nova.config.get("Rubocop.bundle-exec", "boolean")) {
options.args.unshift("bundle", "exec")
}
// console.log('Config: ' + nova.config.get("Rubocop.bundle-exec", "boolean"))
// console.log("Options: " + options.args)
if (nova.config.get("Rubocop.rvm-exec", "boolean")) {
const rubyVersionFile = nova.fs.open(
`${nova.workspace.path}/.ruby-version`
);
const rubyVersion = rubyVersionFile.readline().replace(/(\r\n|\n|\r)/gm, "");
options.args.unshift("rvm", rubyVersion, "--summary", "do");
}
let rubocop = new Process("/usr/bin/env", options);
let rawIssues = []
let issues = [];
Expand Down
54 changes: 29 additions & 25 deletions extension.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
{
"identifier": "zagaja.Rubocop",
"name": "RuboCop",
"organization": "Matt Zagaja",
"description": "Rubocop extension.",
"version": "1.2",
"categories": [
"issues"
],
"repository": "https://github.com/mzagaja/Rubocop.novaextension",
"bugs": "https://github.com/mzagaja/Rubocop.novaextension/issues",
"main": "main.js",
"activationEvents": [
"onLanguage:ruby"
],
"entitlements": {
"process": true
"identifier": "zagaja.Rubocop",
"name": "RuboCop",
"organization": "Matt Zagaja",
"description": "Rubocop extension.",
"version": "1.3",
"categories": ["issues"],
"repository": "https://github.com/mzagaja/Rubocop.novaextension",
"bugs": "https://github.com/mzagaja/Rubocop.novaextension/issues",
"main": "main.js",
"activationEvents": ["onLanguage:ruby"],
"entitlements": {
"process": true,
"filesystem": "readonly"
},
"config": [
{
"key": "Rubocop.bundle-exec",
"title": "Prepend rubocop with bundle exec",
"description": "Use this to prepend rubocop with bundle exec.",
"type": "boolean",
"default": false
},
"config": [
{
"key": "Rubocop.bundle-exec",
"title": "Prepend rubocop with bundle exec",
"description": "Use this to prepend rubocop with bundle exec.",
"type": "boolean",
"default": false
}
]
{
"key": "Rubocop.rvm-exec",
"title": "Prepend rubocop with rvm-exec",
"description": "Use this to prepend rubocop with rvm-exec .ruby-version",
"type": "boolean",
"default": false
}
]
}

0 comments on commit bfd2d85

Please sign in to comment.