Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 5ccf337

Browse files
committed
Add ability to customize additional arguments passed to Ruby
1 parent 7bbd68b commit 5ccf337

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Your Config in Atom menu):
2121
# ruby path. run `which ruby` to find the path.
2222
'rubyExecutablePath': null
2323

24+
# additional arguments arguments passed to ruby.
25+
# default: -c -w --external-encoding=utf-8 --internal-encoding=utf-8
26+
# add -Ku if you experience problems with utf-8 encoding on macOS.
27+
'rubyAdditionalArgs': '-Ku'
28+
2429
# ignored extensions, ERB and markdown files by default.
2530
'ignoredExtensions': 'erb, md'
2631
```

lib/main.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export default {
1414
atom.config.observe('linter-ruby.rubyExecutablePath', (value) => {
1515
this.executablePath = value;
1616
}),
17+
atom.config.observe('linter-ruby.rubyAdditionalArgs', (value) => {
18+
this.additionalArgs = value;
19+
}),
1720
atom.config.observe('linter-ruby.ignoredExtensions', (value) => {
1821
this.ignoredExtensions = value;
1922
}),
@@ -44,13 +47,16 @@ export default {
4447
return [];
4548
}
4649

47-
const execArgs = [
50+
const defaultExecArgs = [
4851
'-c', // Check syntax only, no execution
4952
'-w', // Turns on warnings
5053
// Set the encoding to UTF-8
5154
'--external-encoding=utf-8',
5255
'--internal-encoding=utf-8',
5356
];
57+
const additionalArgs = this.additionalArgs.split(/\s+/);
58+
59+
const execArgs = defaultExecArgs.concat(additionalArgs);
5460
const execOpts = {
5561
stdin: fileText,
5662
stream: 'stderr',

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
"type": "string",
1818
"default": "ruby"
1919
},
20+
"rubyAdditionalArgs": {
21+
"title": "Additional arguments passed to Ruby",
22+
"description": "Default arguments: `-c -w --external-encoding=utf-8 --internal-encoding=utf-8`",
23+
"type": "string",
24+
"default": ""
25+
},
2026
"ignoredExtensions": {
2127
"type": "array",
2228
"default": [

0 commit comments

Comments
 (0)