22
33import * as helpers from 'atom-linter' ;
44import { extname } from 'path' ;
5+ // eslint-disable-next-line import/extensions, import/no-extraneous-dependencies
6+ import { CompositeDisposable } from 'atom' ;
57
68export default {
7- activate : ( ) => {
9+ activate ( ) {
810 require ( 'atom-package-deps' ) . install ( 'linter-ruby' ) ;
11+
12+ this . subscriptions = new CompositeDisposable ( ) ;
13+ this . subscriptions . add ( atom . config . observe ( 'linter-ruby.rubyExecutablePath' ,
14+ ( value ) => { this . executablePath = value ; } ) ) ;
15+ this . subscriptions . add ( atom . config . observe ( 'linter-ruby.ignoredExtensions' ,
16+ ( value ) => { this . ignoredExtensions = value ; } ) ) ;
17+ } ,
18+
19+ deactivate ( ) {
20+ this . subscriptions . dispose ( ) ;
921 } ,
1022
11- provideLinter : ( ) => {
23+ provideLinter ( ) {
1224 const regex = / .+ : ( \d + ) : \s * ( .+ ?) [ , : ] \s ( .+ ) / ;
1325 return {
1426 name : 'Ruby' ,
1527 grammarScopes : [ 'source.ruby' , 'source.ruby.rails' , 'source.ruby.rspec' ] ,
1628 scope : 'file' ,
1729 lintOnFly : true ,
1830 lint : async ( activeEditor ) => {
19- const command = atom . config . get ( 'linter-ruby.rubyExecutablePath' ) ;
20- const ignored = atom . config . get ( 'linter-ruby.ignoredExtensions' ) ;
2131 const filePath = activeEditor . getPath ( ) ;
2232 const fileExtension = extname ( filePath ) . substr ( 1 ) ;
2333
24- if ( ignored . includes ( fileExtension ) ) {
34+ if ( this . ignoredExtensions . includes ( fileExtension ) ) {
2535 return [ ] ;
2636 }
2737
@@ -30,7 +40,7 @@ export default {
3040 stdin : activeEditor . getText ( ) ,
3141 stream : 'stderr' ,
3242 } ;
33- const output = await helpers . exec ( command , execArgs , execOpts ) ;
43+ const output = await helpers . exec ( this . executablePath , execArgs , execOpts ) ;
3444 const toReturn = [ ] ;
3545 output . split ( / \r ? \n / ) . forEach ( ( line ) => {
3646 const matches = regex . exec ( line ) ;
0 commit comments