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

Commit

Permalink
Merge pull request #37 from goddamnhippie/ignore_extensions
Browse files Browse the repository at this point in the history
Ignore extensions
  • Loading branch information
steelbrain committed Sep 5, 2015
2 parents 5dc2f2e + c36c2e8 commit 5719572
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ You can configure linter-ruby by editing ~/.atom/config.cson (choose Open Your C
```
'linter-ruby':
'rubyExecutablePath': null #ruby path. run 'which ruby' to find the path.
'ignoredExtensions': 'erb, md' #ignored extensions, ERB and markdown files by default.
```

## Contributing
Expand Down
15 changes: 15 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ export default {
rubyExecutablePath: {
type: "string",
default: "ruby"
},
ignoredExtensions: {
type: 'array',
default: ['erb', 'md'],
items: {
type: 'string'
}
}
},

Expand All @@ -31,14 +38,22 @@ export default {

provideLinter: () => {
const helpers = require("atom-linter");
const Path = require("path");
const regex = /.+:(\d+):\s*(.+?):\s(.+)/;
return {
grammarScopes: ["source.ruby", "source.ruby.rails", "source.ruby.rspec"],
scope: "file",
lintOnFly: true,
lint: (activeEditor) => {
const command = atom.config.get("linter-ruby.rubyExecutablePath");
const ignored = atom.config.get("linter-ruby.ignoredExtensions");
const filePath = activeEditor.getPath();
const fileExtension = Path.extname(filePath).substr(1);

for (let extension of ignored) {
if (fileExtension === extension) return [];
}

return helpers.exec(command, ['-wc'], {stdin: activeEditor.getText(), stream: 'stderr'}).then(output => {
var toReturn = [];
output.split(/\r?\n/).forEach(function (line) {
Expand Down

0 comments on commit 5719572

Please sign in to comment.