Skip to content

Commit

Permalink
Merge pull request #67 from SublimeLinter/enable-rvm
Browse files Browse the repository at this point in the history
Use rvm if available
  • Loading branch information
kaste authored Aug 26, 2019
2 parents 621d9fa + 875623d commit 9bf25c7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 120
ignore=
D,
W503
37 changes: 25 additions & 12 deletions linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,27 @@
from SublimeLinter.lint import Linter


class Rubocop(Linter):
class RubyLinter(Linter):
def context_sensitive_executable_path(self, cmd):
# The default implementation will look for a user defined `executable`
# setting.
success, executable = super().context_sensitive_executable_path(cmd)
if success:
return True, executable

gem_name = cmd[0] if isinstance(cmd, list) else cmd

if self.settings.get('use_bundle_exec', False):
return True, ['bundle', 'exec', gem_name]

rvm = self.which('rvm-auto-ruby')
if rvm:
return True, [rvm, '-S', gem_name]

return False, None


class Rubocop(RubyLinter):
defaults = {
'selector': 'source.ruby - text.html - text.haml'
}
Expand All @@ -15,17 +35,7 @@ class Rubocop(Linter):
def cmd(self):
"""Build command, using STDIN if a file path can be determined."""

settings = self.get_view_settings()

command = []

if settings.get('use_bundle_exec', False):
command.extend(['bundle', 'exec'])

command.extend(['rubocop', '--format', 'emacs'])

# Set tempfile_suffix so by default a tempfile is passed onto rubocop:
self.tempfile_suffix = 'rb'
command = ['rubocop', '--format', 'emacs']

path = self.filename
if not path:
Expand Down Expand Up @@ -54,5 +64,8 @@ def cmd(self):
command += ['--force-exclusion', '--stdin', path]
# Ensure the files contents are passed in via STDIN:
self.tempfile_suffix = None
else:
self.tempfile_suffix = 'rb'
command += ['${temp_file}']

return command

0 comments on commit 9bf25c7

Please sign in to comment.