22from SublimeLinter .lint import Linter
33
44
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 ):
626 defaults = {
727 'selector' : 'source.ruby - text.html - text.haml'
828 }
@@ -15,17 +35,7 @@ class Rubocop(Linter):
1535 def cmd (self ):
1636 """Build command, using STDIN if a file path can be determined."""
1737
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' ]
2939
3040 path = self .filename
3141 if not path :
@@ -54,5 +64,8 @@ def cmd(self):
5464 command += ['--force-exclusion' , '--stdin' , path ]
5565 # Ensure the files contents are passed in via STDIN:
5666 self .tempfile_suffix = None
67+ else :
68+ self .tempfile_suffix = 'rb'
69+ command += ['${temp_file}' ]
5770
5871 return command
0 commit comments