Skip to content

Commit bfd2d85

Browse files
committed
Add RVM Capabilities
Enable specifying Ruby version with rvm so that you can use this with multiple rubies without issue.
1 parent f361dbe commit bfd2d85

File tree

4 files changed

+44
-32
lines changed

4 files changed

+44
-32
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Version 1.3
2+
* Enable using `rvm-exec` with rubocop.
3+
14
## Version 1.2
25
* Enable using `bundle exec` with rubocop.
36
* Bug: fix error if there are no fixes from Rubocop.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11

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

4-
<!--
5-
🎈 It can also be helpful to include a screenshot or GIF showing your extension in action:
6-
-->
7-
84
![](https://www.zagaja.com/images/rubocop-extension-screenshot.png)
95

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

23+
- RVM users can now prepend their rubocop command with `rvm .ruby-version do` to surmount
24+
configuration issues with rvm. It will automatically use the `.ruby-version` file in your project
25+
root if you enable this option.
26+
2727
### Troubleshooting
2828
If you have a .rubocop.yml with `inherit_gem` and use `rvm` you will need to make sure your gems are
29-
all available in the default gemset. The easiest way to do this is to avoid using app specific
29+
all available in the default gemset with rvm. The easiest way to do this is to avoid using app specific
3030
gemsets. Otherwise try:
3131

3232
```sh

Scripts/main.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ class IssuesProvider {
1818
if(nova.config.get("Rubocop.bundle-exec", "boolean")) {
1919
options.args.unshift("bundle", "exec")
2020
}
21-
// console.log('Config: ' + nova.config.get("Rubocop.bundle-exec", "boolean"))
22-
// console.log("Options: " + options.args)
21+
if (nova.config.get("Rubocop.rvm-exec", "boolean")) {
22+
const rubyVersionFile = nova.fs.open(
23+
`${nova.workspace.path}/.ruby-version`
24+
);
25+
const rubyVersion = rubyVersionFile.readline().replace(/(\r\n|\n|\r)/gm, "");
26+
options.args.unshift("rvm", rubyVersion, "--summary", "do");
27+
}
2328
let rubocop = new Process("/usr/bin/env", options);
2429
let rawIssues = []
2530
let issues = [];

extension.json

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
{
2-
"identifier": "zagaja.Rubocop",
3-
"name": "RuboCop",
4-
"organization": "Matt Zagaja",
5-
"description": "Rubocop extension.",
6-
"version": "1.2",
7-
"categories": [
8-
"issues"
9-
],
10-
"repository": "https://github.com/mzagaja/Rubocop.novaextension",
11-
"bugs": "https://github.com/mzagaja/Rubocop.novaextension/issues",
12-
"main": "main.js",
13-
"activationEvents": [
14-
"onLanguage:ruby"
15-
],
16-
"entitlements": {
17-
"process": true
2+
"identifier": "zagaja.Rubocop",
3+
"name": "RuboCop",
4+
"organization": "Matt Zagaja",
5+
"description": "Rubocop extension.",
6+
"version": "1.3",
7+
"categories": ["issues"],
8+
"repository": "https://github.com/mzagaja/Rubocop.novaextension",
9+
"bugs": "https://github.com/mzagaja/Rubocop.novaextension/issues",
10+
"main": "main.js",
11+
"activationEvents": ["onLanguage:ruby"],
12+
"entitlements": {
13+
"process": true,
14+
"filesystem": "readonly"
15+
},
16+
"config": [
17+
{
18+
"key": "Rubocop.bundle-exec",
19+
"title": "Prepend rubocop with bundle exec",
20+
"description": "Use this to prepend rubocop with bundle exec.",
21+
"type": "boolean",
22+
"default": false
1823
},
19-
"config": [
20-
{
21-
"key": "Rubocop.bundle-exec",
22-
"title": "Prepend rubocop with bundle exec",
23-
"description": "Use this to prepend rubocop with bundle exec.",
24-
"type": "boolean",
25-
"default": false
26-
}
27-
]
24+
{
25+
"key": "Rubocop.rvm-exec",
26+
"title": "Prepend rubocop with rvm-exec",
27+
"description": "Use this to prepend rubocop with rvm-exec .ruby-version",
28+
"type": "boolean",
29+
"default": false
30+
}
31+
]
2832
}

0 commit comments

Comments
 (0)