2
2
from SublimeLinter .lint import Linter
3
3
4
4
5
- class Rubocop (Linter ):
5
+ class RubyLinter (Linter ):
6
+ def context_sensitive_executable_path (self , cmd ):
7
+ # The default implementation will look for a user defined `executable`
8
+ # setting.
9
+ success , executable = super ().context_sensitive_executable_path (cmd )
10
+ if success :
11
+ return True , executable
12
+
13
+ gem_name = cmd [0 ] if isinstance (cmd , list ) else cmd
14
+
15
+ if self .settings .get ('use_bundle_exec' , False ):
16
+ return True , ['bundle' , 'exec' , gem_name ]
17
+
18
+ rvm = self .which ('rvm-auto-ruby' )
19
+ if rvm :
20
+ return True , [rvm , '-S' , gem_name ]
21
+
22
+ return False , None
23
+
24
+
25
+ class Rubocop (RubyLinter ):
6
26
defaults = {
7
27
'selector' : 'source.ruby - text.html - text.haml'
8
28
}
@@ -15,17 +35,7 @@ class Rubocop(Linter):
15
35
def cmd (self ):
16
36
"""Build command, using STDIN if a file path can be determined."""
17
37
18
- settings = self .get_view_settings ()
19
-
20
- command = []
21
-
22
- if settings .get ('use_bundle_exec' , False ):
23
- command .extend (['bundle' , 'exec' ])
24
-
25
- command .extend (['rubocop' , '--format' , 'emacs' ])
26
-
27
- # Set tempfile_suffix so by default a tempfile is passed onto rubocop:
28
- self .tempfile_suffix = 'rb'
38
+ command = ['rubocop' , '--format' , 'emacs' ]
29
39
30
40
path = self .filename
31
41
if not path :
@@ -54,5 +64,8 @@ def cmd(self):
54
64
command += ['--force-exclusion' , '--stdin' , path ]
55
65
# Ensure the files contents are passed in via STDIN:
56
66
self .tempfile_suffix = None
67
+ else :
68
+ self .tempfile_suffix = 'rb'
69
+ command += ['${temp_file}' ]
57
70
58
71
return command
0 commit comments