Permalink
Browse files

vimux

  • Loading branch information...
1 parent cd1829d commit da42605b1295eec88d843bc2493f47dde956e038 @elight committed Jun 19, 2012
View
@@ -1,8 +1,6 @@
let g:netrw_dirhistmax =10
-let g:netrw_dirhist_cnt =6
-let g:netrw_dirhist_1='/Users/evan/.rvm/gems/ruby-1.9.2-p290@top_kycks/gems/redis-2.2.2'
-let g:netrw_dirhist_2='/Users/evan/.rvm/gems/ruby-1.9.2-p290@KYCK/gems/inherited_resources-1.3.0'
-let g:netrw_dirhist_3='/Users/evan/.rvm/gems/ruby-1.9.2-p290@top_kycks/gems/redis-2.2.2'
-let g:netrw_dirhist_4='/Users/evan/.rvm/gems/ruby-1.9.2-p290@KYCK/gems/activesupport-3.1.3'
-let g:netrw_dirhist_5='/Users/evan/.rvm/gems/ruby-1.9.3-p125@coursesharing/gems/cells-3.8.3'
-let g:netrw_dirhist_6='/Users/light/.vim/bundle/vim-coffee-script'
+let g:netrw_dirhist_cnt =4
+let g:netrw_dirhist_1='/Users/evan/.ssh'
+let g:netrw_dirhist_2='/Users/evan/.rvm/gems/ruby-1.9.2-p290@clearfit-for-rails31/gems/stripe-1.6.3'
+let g:netrw_dirhist_3='/Users/evan/.rvm/gems/ruby-1.9.2-p290@clearfit-for-rails31/gems/oink-0.9.3'
+let g:netrw_dirhist_4='/Users/evan/.vim'
View
@@ -0,0 +1,38 @@
+vroom.vim
+=========
+
+Run your Ruby tests! Supports RSpec, Test::Unit/MiniTest, and Cucumber. For more
+information, check out the
+[documentation](http://vim-doc.heroku.com/view?https://raw.github.com/skalnik/vim-vroom/master/doc/vroom.txt)
+(available in Vim after installation `:help vroom`)
+
+Installation
+------------
+
+Check out [vundle](https://github.com/gmarik/vundle) or
+[pathogen.vim](https://github.com/tpope/vim-pathogen) and then install:
+
+### vundle
+
+Add the following to your `.vimrc` after vundle setup:
+
+ Bundle 'skalnik/vim-vroom'
+
+and remember to run `:BundleInstall`.
+
+### pathogen
+
+Copy and paste:
+
+ $ cd ~/.vim/bundle
+ $ git clone 'git://github.com/skalnik/vim-vroom.git'
+
+
+Credit
+------
+
+I first stumbled upon this snippet of code in [Gary Bernhardt's
+.vimrc](https://github.com/garybernhardt/dotfiles/blob/master/.vimrc), and have
+modified it, turned it into a plugin and begun improving it. [Steven
+Harman](http://github.com/stevenharman) also provided inspiration in the
+creation of the plugin, cucumber support, and Gemfile detection.
@@ -0,0 +1,196 @@
+" Init
+if exists("g:loaded_vroom") || &cp
+ finish
+endif
+let g:loaded_vroom = 1
+
+if !exists("g:vroom_use_colors")
+ let g:vroom_use_colors = !has('gui_running')
+endif
+
+if !exists("g:vroom_clear_screen")
+ let g:vroom_clear_screen = 1
+endif
+
+if !exists("g:vroom_write_all")
+ let g:vroom_write_all = 0
+endif
+
+if !exists("g:vroom_cucumber_path")
+ let g:vroom_cucumber_path = './script/cucumber '
+endif
+
+if !exists("g:vroom_detect_spec_helper")
+ let g:vroom_detect_spec_helper = 0
+endif
+
+if !exists("g:vroom_use_vimux")
+ let g:vroom_use_vimux = 0
+endif
+
+if !exists("g:vroom_use_bundle_exec")
+ let g:vroom_use_bundle_exec = 1
+endif
+
+" If we are using binstubs, we usually don't want to bundle exec. Note that
+" this has to come before the g:vroom_use_binstubs variable is set below.
+if exists("g:vroom_use_binstubs")
+ let g:vroom_use_bundle_exec = 0
+endif
+
+" Binstubs aren't used by default
+if !exists("g:vroom_use_binstubs")
+ let g:vroom_use_binstubs = 0
+endif
+
+if !exists("g:vroom_binstubs_path")
+ let g:vroom_binstubs_path = './bin'
+endif
+
+" Public: Run current test file, or last test run
+function vroom#RunTestFile()
+ call s:RunTestFile()
+endfunction
+
+" Public: Run the nearest test in the current test file
+" Assumes your test framework supports filename:line# format
+function vroom#RunNearestTest()
+ call s:RunNearestTest()
+endfunction
+
+" Internal: Runs the current file as a test. Also saves the current file, so
+" next time the function is called in a non-test file, it runs the last test
+"
+" suffix - An optional command suffix
+function s:RunTestFile(...)
+ if a:0
+ let command_suffix = a:1
+ else
+ let command_suffix = ""
+ endif
+
+ " Run the tests for the previously-marked file.
+ let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1
+
+ if in_test_file
+ call s:SetTestFile()
+ elseif !exists("t:vroom_test_file")
+ return
+ end
+ call s:RunTests(t:vroom_test_file . command_suffix)
+endfunction
+
+" Internal: Runs the current or last test with the currently selected line
+" number
+function s:RunNearestTest()
+ let spec_line_number = line('.')
+ call s:RunTestFile(":" . spec_line_number)
+endfunction
+
+" Internal: Runs the test for a given filename
+function s:RunTests(filename)
+ if ! g:vroom_use_vimux
+ call s:ClearScreen()
+ end
+
+ call s:WriteOrWriteAll()
+ call s:SetTestRunnerPrefix()
+ call s:SetColorFlag()
+ " Run the right test for the given file
+ if match(a:filename, '_spec.rb') != -1
+ call s:Run(s:test_runner_prefix ."rspec " . a:filename . s:color_flag)
+ elseif match(a:filename, '\.feature') != -1
+ call s:Run(s:test_runner_prefix .g:vroom_cucumber_path . a:filename . s:color_flag)
+ elseif match(a:filename, "_test.rb") != -1
+ call s:Run(s:test_runner_prefix ."ruby -Itest " . a:filename)
+ end
+endfunction
+
+" Internal: Runs a command though vim or vmux
+function s:Run(cmd)
+ if g:vroom_use_vimux
+ call RunVimTmuxCommand(a:cmd)
+ else
+ exec ":!" . a:cmd
+ end
+endfunction
+
+" Internal: Clear the screen prior to running specs
+function s:ClearScreen()
+ if g:vroom_clear_screen
+ :silent !clear
+ endif
+endfunction
+
+" Internal: Write or write all files
+function s:WriteOrWriteAll()
+ if g:vroom_write_all
+ :wall
+ else
+ :w
+ endif
+endfunction
+
+" Internal: Set s:test_runner_prefix variable
+function s:SetTestRunnerPrefix()
+ let s:test_runner_prefix = ''
+ call s:IsUsingBundleExec()
+ call s:IsUsingBinstubs()
+endfunction
+
+" Internal: Check for a Gemfile if we are using `bundle exec`
+function s:IsUsingBundleExec()
+ if g:vroom_use_bundle_exec
+ call s:CheckForGemfile()
+ endif
+endfunction
+
+" Internal: Set s:test_runner_prefix variable if using binstubs
+function s:IsUsingBinstubs()
+ if g:vroom_use_binstubs
+ let s:test_runner_prefix = g:vroom_binstubs_path . '/'
+ endif
+endfunction
+
+" Internal: Checks for Gemfile, and sets s:test_runner_prefix as necessary
+function s:CheckForGemfile()
+ if s:GemfileExists()
+ let s:test_runner_prefix = "bundle exec "
+ endif
+endfunction
+
+" Internal: Checks for 'spec_helper' in file and Gemfile existance, and sets
+" s:test_runner_prefixs as necessary
+function s:CheckForSpecHelper(filename)
+ if g:vroom_detect_spec_helper &&
+ \match(readfile(a:filename, '', 1)[0], 'spec_helper') != -1 &&
+ \s:GemfileExists()
+ let s:test_runner_prefix = "bundle exec "
+ else
+ let s:test_runner_prefix = ""
+ endif
+endfunction
+
+" Internal: Check if there is a Gemfile in the current working directory
+function s:GemfileExists()
+ if filereadable("Gemfile")
+ return 1
+ else
+ return 0
+ endif
+endfunction
+
+" Internal: Sets t:vroom_test_file to current file
+function s:SetTestFile()
+ " Set the test file that tests will be run for.
+ let t:vroom_test_file=@%
+endfunction
+
+" Internal: Sets s:color_flag to the correct color flag as configured
+function s:SetColorFlag()
+ if g:vroom_use_colors
+ let s:color_flag = " --color"
+ else
+ let s:color_flag = " --no-color"
+ endif
+endfunction
@@ -0,0 +1,149 @@
+*vroom.txt* Helps you run your Ruby tests
+Author: Mike Skalnik <http://mikeskalnik.com>
+Version: 1.0.2
+
+===============================================================================
+CONTENTS *vroom-contents*
+
+ Intro ..................................... |vroom-introduction|
+ Interface ................................. |vroom-interface|
+ Commands ................................ |vroom-commands|
+ Key Mappings ............................ |vroom-key-mappings|
+ Customization ............................. |vroom-customization|
+ License ................................... |vroom-license|
+ Changelog ................................. |vroom-changelog|
+
+
+===============================================================================
+INTRO *vroom-introduction*
+
+Vroom is a plugin for running your Ruby tests, specs, and features. It allows
+you to speed up your development since you don't have to jump around to
+different windows or tabs.
+
+If you're hacking away on your awesome Ruby app, and you open your spec, you
+can easily run the whole file by hitting <Leader>r, or nearest test with
+<Leader>R. This is then remembered, so if you switch back to your code, you
+can then hit <Leader>r again and that last test will be run.
+
+===============================================================================
+INTERFACE *vroom-interface*
+
+-------------------------------------------------------------------------------
+COMMANDS *vroom-commands*
+
+:VroomRunTestFile *VroomRunTestFile*
+ Runs the current file if it is a test. Otherwise, run
+ the last test file that was run.
+
+:VroomRunNearestTest *VroomRunNearestTest*
+
+ Runs the nearest test in the current file if it's a
+ test. Otherwise, runs the last test that was run.
+
+-------------------------------------------------------------------------------
+KEY MAPPINGS *vroom-key-mappings*
+
+By default vroom maps <Leader>r to |VroomRunTestFile| and <Leader>R to
+|VroomRunNearestTest|. This can be turned off by simply putting `let
+g:vroom_map_keys = 0` in your vimrc.
+
+===============================================================================
+CUSTOMIZATION *vroom-customization*
+
+g:vroom_use_colors *vroom_use_colors*
+ Run tests with or without colors
+ Default: 0 if GUI is running, 1 otherwise
+
+g:vroom_map_keys *vroom_map_keys*
+ Map default keys to run tests
+ Default: 1
+
+g:vroom_clear_screen *vroom_clear_screen*
+ Clear the screen before running tests
+ Default: 1
+
+g:vroom_write_all *vroom_write_all*
+ Write all file before running tests
+ Default: 0 (write the current file)
+
+g:vroom_cucumber_path *vroom_cucumber_path*
+ If set, the path for the executable
+ used for *.feature files.
+ Default: './script/cucumber '
+
+g:vroom_detect_spec_helper *vroom_detect_spec_helper*
+ Only run `bundle exec` if first line of the spec file
+ requires 'spec_helper'
+ Default: 0
+
+g:vroom_use_vimux *vroom_use_vimux*
+ Run tests using the vimux plugin
+
+g:vroom_use_bundle_exec *vroom_use_bundle_exec*
+ When appropriate (see |vroom_detect_spec_helper|) use
+ `bundle exec` before test runner command. If set to
+ 1, `bundle exec` is never used.
+ Default: 0
+
+g:vroom_use_binstubs *vroom_use_binstubs*
+ If set to 1, lets Vroom know you are using binstubs.
+ This means (a) the call to your test runner will be
+ prefixed with your binstubs directory (see
+ |vroom_binstubs_path|), and (b) `bundle exec` will
+ never be called (see |vroom_use_bundle_exec|).
+ Default: 0
+
+g:vroom_binstubs_path *vroom_binstubs_path*
+ If using binstubs, the directory where your binstubs
+ are installed. The forward slash gets added
+ automatically and should not be included.
+ Default: './bin'
+
+===============================================================================
+LICENSE *vroom-license*
+
+Copyright (c) 2012 Mike Skalnik
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+===============================================================================
+CHANGELOG *vroom-changelog*
+
+1.0.3 *vroom-changelog-1.0.3*
+ * Support for vimux (run tests in tmux shell)
+
+1.0.2 *vroom-changelog-1.0.2*
+ * Support configuration of cucumber runner
+ * Can skip `bundle exec` if not requiring 'spec_helper'
+
+1.0.1 *vroom-changelog-1.0.1*
+ * Support for writing all files before running tests (off by default)
+ * Clears screen before running tests (on by default)
+ * Scopes test remembered to the current tab, instead of that instance of
+ Vim
+ * Colors now default to on in terminal, off in gvim
+ * Suppress error if existing maps exist
+ * Fix test unit bug with colors
+
+1.0.0 *vroom-changelog-1.0.0*
+ * Initial Release
+
+==============================================================================
+vim:tw=79:ft=help:norl:fen:fdl=0:fdm=marker:
Oops, something went wrong.

0 comments on commit da42605

Please sign in to comment.