Ⅰ. 插件描述
Run ruby tests asynchronously with named pipesⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'stefanoverna/vim-plumber'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'stefanoverna/vim-plumber'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'stefanoverna/vim-plumber'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/stefanoverna/vim-plumber
Ⅳ. 文档说明
# Vim Plumber - Run ruby tests asynchronously with named pipes
Plumber is designed to speed up your TDD cycle by using a single key
mapping to run the most relevant test based on the current file in vim.
It uses unix named pipes to send the commands to a secondary session. This
implies the presence of a named pipe called .plumber in the current directory
and a script that continuously reads the content of pipe, executing the
commands it receives:
#!/bin/bash
DEFAULT_PIPE_NAME=".plumber"
PIPE_NAME="${1:-$DEFAULT_PIPE_NAME}"
if [ ! -p $PIPE_NAME ]; then
echo "Created pipe ${PIPE_NAME}..."
mkfifo $PIPE_NAME
fi
echo "Waiting for commands!"
while true; do
COMMAND=$(cat $PIPE_NAME)
echo Running ${COMMAND}...
sh -c "$COMMAND"
doneThe default mapping for invoking the plugin is <leader>t. In a spec
file, this will run rspec <filename>. In a test-unit file, this will
run ruby -Itest <filename>. In a cucumber feature file, this will runcucumber <filename>.
Repeating
If you invoke the plugin (by default, with <leader>t), and neither the
current file nor the alternate is a test, spec or feature, plumber will
simply send the most recent command instead. This can be quite helpful
in situations where you are editing a related file, or in the case of
cucumber, step definitions or a view.
The |plumber| and |plumber-focused| invocations each store their own
command, so you can use the focused one elsewhere in a test suite while
still setting the normal one, or vice-versa.
Focused
Plumber also comes with bindings to run focused tests. This is
accomplished by appending the current line number to the test command.
In cucumber, this runs the scenario under the cursor. In rspec, this
runs only the example or group under the cursor.
The default mapping for focused test output is <leader>T.
Send anything you want!
You can use the "Plumber" function to send arbitrary commands to
the pipe, i.e.:
:nmap ,x :call Plumber("echo %")<CR>Mappings
The following are available:
<leader>t: Normal invocation<leader>T: Focused test (appends line number)