erb, erubis: Redirect file into first command.

The previous version relied on a zsh-specific behavior where
`<filename` after a pipe could redirect to the first command. This
is the standard way to do it.
This commit is contained in:
Eddie Lebow 2017-11-16 23:02:30 -05:00
parent 1f4f19cbd4
commit b390c69642
4 changed files with 4 additions and 4 deletions

View File

@ -11,7 +11,7 @@ function! ale_linters#eruby#erb#GetCommand(buffer) abort
" Rails-flavored eRuby does not comply with the standard as understood by " Rails-flavored eRuby does not comply with the standard as understood by
" ERB, so we'll have to do some substitution. This does not reduce the " ERB, so we'll have to do some substitution. This does not reduce the
" effectiveness of the linter—the translated code is still evaluated. " effectiveness of the linter—the translated code is still evaluated.
return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . ' | ruby -c' return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
endfunction endfunction
call ale#linter#Define('eruby', { call ale#linter#Define('eruby', {

View File

@ -11,7 +11,7 @@ function! ale_linters#eruby#erubis#GetCommand(buffer) abort
" Rails-flavored eRuby does not comply with the standard as understood by " 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 " Erubis, so we'll have to do some substitution. This does not reduce the
" effectiveness of the linter—the translated code is still evaluated. " effectiveness of the linter—the translated code is still evaluated.
return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . ' | ruby -c' return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c'
endfunction endfunction
call ale#linter#Define('eruby', { call ale#linter#Define('eruby', {

View File

@ -17,5 +17,5 @@ Execute(Executable should filter invalid eRuby when inside a Rails project):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb')
AssertEqual AssertEqual
\ 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . ' | ruby -c', \ 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c',
\ ale_linters#eruby#erb#GetCommand(bufnr('')) \ ale_linters#eruby#erb#GetCommand(bufnr(''))

View File

@ -17,5 +17,5 @@ Execute(Executable should filter invalid eRuby when inside a Rails project):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb')
AssertEqual AssertEqual
\ 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . ' | ruby -c', \ 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c',
\ ale_linters#eruby#erubis#GetCommand(bufnr('')) \ ale_linters#eruby#erubis#GetCommand(bufnr(''))