Skip to content

Commit

Permalink
Merge pull request pitluga#2 from jdost/master
Browse files Browse the repository at this point in the history
Removed Ruby Dependency
  • Loading branch information
pitluga committed Feb 24, 2014
2 parents 772bd04 + 66e32b9 commit fae6dce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Vimux plugin for running nose test. Similar to [vimux-ruby-test](https://github.
## Requirements

- vim with ruby support (compiled +ruby)
- [vimux](https://github.com/benmills/vimux)
- [vimux](https://github.com/benmills/vimux) (0.3.0 or greater)
- optionally requires [nose-run-line-number](https://github.com/pitluga/nose-run-line-number) for focused tests.

## Installation
Expand Down
67 changes: 21 additions & 46 deletions plugin/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,32 @@ if exists("g:loaded_vimux_nose_test") || &cp
endif
let g:loaded_vimux_nose_test = 1

if !has("ruby")
finish
end

command RunAllNoseTests :call s:RunAllNoseTests()
command RunFocusedNoseTests :call s:RunFocusedNoseTests()
command RunCurrentNoseTests :call s:RunCurrentNoseTests()

function! FindVirtualEnv()
if $VIRTUAL_ENV != ''
return $VIRTUAL_ENV . "/bin/"
else
return ""
end
endfunction

function s:RunAllNoseTests()
ruby NoseTest.new.run_all
let virtualenv = FindVirtualEnv()
call VimuxRunCommand("clear && " . virtualenv . "nosetests *.py")
endfunction

function s:RunFocusedNoseTests()
ruby NoseTest.new.run_focused
function s:RunCurrentNoseTests()
let virtualenv = FindVirtualEnv()
let file_name = @%
call VimuxRunCommand("clear && " . virtualenv . "nosetests " . file_name)
endfunction

ruby << EOF
module VIM
class Buffer
def method_missing(method, *args, &block)
VIM.command "#{method} #{self.name}"
end
end
end

class NoseTest
def current_file
VIM::Buffer.current.name
end

def line_number
VIM::Buffer.current.line_number
end

def virtualenv
if Vim.evaluate('exists("g:NoseVirtualenv")') != 0
". #{Vim.evaluate('g:NoseVirtualenv')} && "
else
""
end
end

def run_all
send_to_vimux("#{virtualenv} nosetests '#{current_file}'")
end

def run_focused
send_to_vimux("#{virtualenv} noseline '#{current_file}' --line #{line_number}")
end

def send_to_vimux(test_command)
Vim.command("call RunVimTmuxCommand(\"clear && #{test_command}\")")
end
end
EOF
function s:RunFocusedNoseTests()
let virtualenv = FindVirtualEnv()
let line_number = getline('.')
let file_name = @%
call VimuxRunCommand("clear && " . virtualenv . "nosetests " . file_name . " --line " . line_number)
endfunction

0 comments on commit fae6dce

Please sign in to comment.