summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-28 09:47:04 +0000
committerw0rp <devw0rp@gmail.com>2017-11-28 09:48:35 +0000
commit4e821e64c7292ba635e55c409a015023d7549374 (patch)
tree3fb657e555ce622d41bfd1e111af60e624b2103e
parentbba6b4c23ccf556656aac6d12c25c21713179209 (diff)
downloadale-4e821e64c7292ba635e55c409a015023d7549374.zip
Fix #1168 - Make the ruby linter executable configurable
-rw-r--r--ale_linters/ruby/ruby.vim16
-rw-r--r--doc/ale-ruby.txt17
-rw-r--r--doc/ale.txt1
-rw-r--r--test/command_callback/test_ruby_command_callback.vader25
4 files changed, 54 insertions, 5 deletions
diff --git a/ale_linters/ruby/ruby.vim b/ale_linters/ruby/ruby.vim
index a9f7b51b..1aa88851 100644
--- a/ale_linters/ruby/ruby.vim
+++ b/ale_linters/ruby/ruby.vim
@@ -1,10 +1,22 @@
" Author: Brandon Roehl - https://github.com/BrandonRoehl
" Description: Ruby MRI for Ruby files
+call ale#Set('ruby_ruby_executable', 'ruby')
+
+function! ale_linters#ruby#ruby#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'ruby_ruby_executable')
+endfunction
+
+function! ale_linters#ruby#ruby#GetCommand(buffer) abort
+ let l:executable = ale_linters#ruby#ruby#GetExecutable(a:buffer)
+
+ return ale#Escape(l:executable) . ' -w -c -T1 %t'
+endfunction
+
call ale#linter#Define('ruby', {
\ 'name': 'ruby',
-\ 'executable': 'ruby',
+\ 'executable_callback': 'ale_linters#ruby#ruby#GetExecutable',
+\ 'command_callback': 'ale_linters#ruby#ruby#GetCommand',
\ 'output_stream': 'stderr',
-\ 'command': 'ruby -w -c -T1 %t',
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})
diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt
index c710a26e..94181ed4 100644
--- a/doc/ale-ruby.txt
+++ b/doc/ale-ruby.txt
@@ -58,10 +58,10 @@ g:ale_ruby_reek_show_wiki_link *g:ale_ruby_reek_show_wiki_link*
===============================================================================
rubocop *ale-ruby-rubocop*
-g:ale_ruby_rubocop_executable g:ale_ruby_rubocop_executable
- b:ale_ruby_rubocop_executable
+g:ale_ruby_rubocop_executable *g:ale_ruby_rubocop_executable*
+ *b:ale_ruby_rubocop_executable*
Type: String
- Default: 'rubocop'
+ Default: `'rubocop'`
Override the invoked rubocop binary. This is useful for running rubocop
from binstubs or a bundle.
@@ -76,4 +76,15 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options*
===============================================================================
+ruby *ale-ruby-ruby*
+
+g:ale_ruby_ruby_executable *g:ale_ruby_ruby_executable*
+ *b:ale_ruby_ruby_executable*
+ Type: String
+ Default: `'ruby'`
+
+ This variable can be changed to use a different executable for ruby.
+
+
+===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index d1afb423..7d870774 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -170,6 +170,7 @@ CONTENTS *ale-contents*
rails_best_practices................|ale-ruby-rails_best_practices|
reek................................|ale-ruby-reek|
rubocop.............................|ale-ruby-rubocop|
+ ruby................................|ale-ruby-ruby|
rust..................................|ale-rust-options|
cargo...............................|ale-rust-cargo|
rls.................................|ale-rust-rls|
diff --git a/test/command_callback/test_ruby_command_callback.vader b/test/command_callback/test_ruby_command_callback.vader
new file mode 100644
index 00000000..3813d56b
--- /dev/null
+++ b/test/command_callback/test_ruby_command_callback.vader
@@ -0,0 +1,25 @@
+Before:
+ Save g:ale_ruby_ruby_executable
+
+ unlet! g:ale_ruby_ruby_executable
+
+ runtime ale_linters/ruby/ruby.vim
+
+After:
+ Restore
+
+ call ale#linter#Reset()
+
+Execute(The default command should be correct):
+ AssertEqual 'ruby', ale_linters#ruby#ruby#GetExecutable(bufnr(''))
+ AssertEqual
+ \ ale#Escape('ruby') . ' -w -c -T1 %t',
+ \ ale_linters#ruby#ruby#GetCommand(bufnr(''))
+
+Execute(The executable should be configurable):
+ let g:ale_ruby_ruby_executable = 'foobar'
+
+ AssertEqual 'foobar', ale_linters#ruby#ruby#GetExecutable(bufnr(''))
+ AssertEqual
+ \ ale#Escape('foobar') . ' -w -c -T1 %t',
+ \ ale_linters#ruby#ruby#GetCommand(bufnr(''))