2017-11-11 21:59:18 -05:00
|
|
|
" Author: Jake Zimmerman <jake@zimmerman.io>, Eddie Lebow https://github.com/elebow
|
2017-08-21 16:34:42 -04:00
|
|
|
" Description: eruby checker using `erubis`, instead of `erb`
|
|
|
|
|
2017-11-11 21:59:18 -05:00
|
|
|
function! ale_linters#eruby#erubis#GetCommand(buffer) abort
|
|
|
|
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
|
|
|
|
|
|
|
if empty(l:rails_root)
|
|
|
|
return 'erubis -x %t | ruby -c'
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Rails-flavored eRuby does not comply with the standard as understood by
|
|
|
|
" Erubis, so we'll have to do some substitution. This does not reduce the
|
2017-11-21 11:39:05 -05:00
|
|
|
" effectiveness of the linter - the translated code is still evaluated.
|
2017-11-16 23:02:30 -05:00
|
|
|
return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c'
|
2017-11-11 21:59:18 -05:00
|
|
|
endfunction
|
|
|
|
|
2017-08-21 16:34:42 -04:00
|
|
|
call ale#linter#Define('eruby', {
|
|
|
|
\ 'name': 'erubis',
|
|
|
|
\ 'executable': 'erubis',
|
|
|
|
\ 'output_stream': 'stderr',
|
2019-02-22 13:05:04 -05:00
|
|
|
\ 'command': function('ale_linters#eruby#erubis#GetCommand'),
|
2017-08-21 16:34:42 -04:00
|
|
|
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
|
|
|
\})
|