From 329ede9094e92684ffe56f3504a78ff1a28f143e Mon Sep 17 00:00:00 2001 From: Dmitry Matveyev Date: Sat, 25 May 2019 12:39:52 +0300 Subject: [PATCH 2/2] Add test/ ruby-alternative-file implementation --- rc/filetype/ruby.kak | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index 7996b089..7bac8dba 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -104,17 +104,22 @@ define-command ruby-alternative-file -docstring 'Jump to the alternate file (imp altfile=$(eval echo $(echo $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) [ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit ;; + *test/*_test.rb) + altfile=$(eval echo $(echo $kak_buffile | sed s+test/+'*'/+';'s/_test//)) + [ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit + ;; *.rb) path=$kak_buffile dirs=$(while [ $path ]; do echo $path; path=${path%/*}; done | tail -n +2) for dir in $dirs; do - altdir=$dir/spec + altdir=$dir/spec && suffix=spec + [ ! -d $altdir ] && altdir=$dir/test && suffix=test if [ -d $altdir ]; then - altfile=$altdir/$(realpath $kak_buffile --relative-to $dir | sed s+[^/]'*'/++';'s/.rb$/_spec.rb/) + altfile=$altdir/$(realpath $kak_buffile --relative-to $dir | sed s+[^/]'*'/++';'s/.rb$/_${suffix}.rb/) break fi done - [ ! -d $altdir ] && echo "echo -markup '{Error}spec/ not found'" && exit + [ ! -d $altdir ] && echo "echo -markup '{Error}spec/ and test/ not found'" && exit ;; *) echo "echo -markup '{Error}alternative file not found'" && exit