@@ -1623,9 +1623,9 @@ endfunction
16231623" Script Wrappers {{{1
16241624
16251625function ! s: BufScriptWrappers ()
1626- command ! - buffer - bang - bar -nargs =* -complete =customlist ,s: Complete_script Rscript :execute empty (<q-args> ) ? rails#app (). script_command ( <bang> 0 , ' console' ) : rails#app (). script_command ( <bang> 0 , <f -args>)
1626+ command ! - buffer - bang - bar -nargs =? -complete =customlist ,s: Complete_script Rscript :execute ' Rails<bang> ' empty (<q-args> ) ? ' console' : <q -args>
16271627 command ! - buffer - bang - bar -nargs =* -complete =customlist ,s: Complete_environments Console :Rails<bang> console <args>
1628- command ! - buffer - bang - bar -nargs =* - complete =customlist ,s: Complete_script Rails : execute rails#app (). script_command ( <bang> 0 , <f -args> )
1628+ command ! - buffer - bang - bar -nargs =? - count - complete =customlist ,s: Complete_script Rails : execute s: Rails ( <bang> 0 , ! <count> && <line1> ? -1 : <count> , <q -args> )
16291629 command ! - buffer - bang - bar -nargs =* -complete =customlist ,s: Complete_generate Rgenerate :execute rails#app ().generator_command (<bang> 0 ,' generate' ,<f-args> )
16301630 command ! - buffer - bang - bar -nargs =* -complete =customlist ,s: Complete_generate Generate :execute rails#app ().generator_command (<bang> 0 ,' generate' ,<f-args> )
16311631 command ! - buffer - bar -nargs =* -complete =customlist ,s: Complete_destroy Rdestroy :execute rails#app ().generator_command (1 ,' destroy' ,<f-args> )
@@ -1660,16 +1660,35 @@ function! s:app_generators() dict abort
16601660 return self .cache.get (' generators' )
16611661endfunction
16621662
1663- function ! s: app_script_command (bang ,... ) dict
1664- let str = join (map (copy (a: 000 ), ' s:rquote(v:val)' ), ' ' )
1663+ function ! s: Rails (bang , count , arg) abort
1664+ if ! empty (a: arg )
1665+ let str = a: arg
1666+ elseif rails#buffer ().type_name (' spec' , ' cucumber' )
1667+ return rails#buffer ().runner_command (a: bang , a: count , ' ' )
1668+ elseif rails#buffer ().type_name (' test' ) && ! rails#app ().has (' rails5' )
1669+ return rails#buffer ().runner_command (a: bang , a: count , ' ' )
1670+ elseif rails#buffer ().name () = ~# ' ^\%(app\|config\|db\|lib\|log\|README\|Rakefile\|test\|spec\|features\)'
1671+ let str = rails#buffer ().default_rake_task (a: count )
1672+ if str == # ' --tasks'
1673+ let str = ' '
1674+ else
1675+ let rake = 1
1676+ endif
1677+ else
1678+ let str = ' '
1679+ endif
16651680 if str = ~# ' ^\%(c\|console\|db\|dbconsole\|s\|server\)\S\@!' && str !~# ' -d\| --daemon\| --help'
1666- return self .start_rails_command (str, a: bang )
1681+ return rails#app () .start_rails_command (str, a: bang )
16671682 else
16681683 let [mp , efm , cc ] = [&l: mp , &l: efm , get (b: , ' current_compiler' , ' ' )]
16691684 try
16701685 compiler rails
1671- let &l: makeprg = self .prepare_rails_command (' $*' )
1672- let &l: errorformat .= ' ,chdir ' .escape (self .path (), ' ,' )
1686+ if exists (' rake' ) && ! rails#app ().has (' rails5' )
1687+ let &l: makeprg = rails#app ().rake_command ()
1688+ else
1689+ let &l: makeprg = rails#app ().prepare_rails_command (' $*' )
1690+ endif
1691+ let &l: errorformat .= ' ,chdir ' .escape (rails#app ().path (), ' ,' )
16731692 call s: make (a: bang , str)
16741693 finally
16751694 let [&l: mp , &l: efm , b: current_compiler ] = [mp , efm , cc ]
@@ -1874,7 +1893,7 @@ function! s:app_generator_command(bang,...) dict
18741893 endif
18751894endfunction
18761895
1877- call s: add_methods (' app' , [' generators' ,' script_command ' , ' output_command' ,' server_command' ,' generator_command' ])
1896+ call s: add_methods (' app' , [' generators' ,' output_command' ,' server_command' ,' generator_command' ])
18781897
18791898function ! s: Complete_script (ArgLead, CmdLine, P ) abort
18801899 return rails#complete_rails (a: ArgLead , a: CmdLine , a: P , rails#app ())
@@ -5029,11 +5048,13 @@ function! rails#buffer_setup() abort
50295048 call self .setvar (' dispatch' , dir . dispatch[0 ])
50305049 elseif self .name () = ~# ' ^public'
50315050 call self .setvar (' dispatch' , ' :Preview' )
5032- elseif self .type_name (' test' , ' spec' , ' cucumber' )
5051+ elseif self .type_name (' spec' , ' cucumber' )
5052+ call self .setvar (' dispatch' , ' :Runner' )
5053+ elseif self .type_name (' test' ) && ! self .app ().has (' rails5' )
50335054 call self .setvar (' dispatch' , ' :Runner' )
5034- elseif self .name () = ~# ' ^\%(app\|config\|db\|lib\|log\|README\|Rakefile\)'
5055+ elseif self .name () = ~# ' ^\%(app\|config\|db\|lib\|log\|README\|Rakefile\|test\|spec\|features\ )'
50355056 if ! exists (' dir' )
5036- call self .setvar (' dispatch' , ' :Rake ' )
5057+ call self .setvar (' dispatch' , ' :Rails ' )
50375058 elseif self .app ().has (' rails5' )
50385059 call self .setvar (' dispatch' ,
50395060 \ dir .
0 commit comments