https://gist.github.com/2984118
require 'thor'
class VimInstaller < Thor::Group
include Thor::Actions
def self.source_root
'/tmp'
end
def clean_up
vimify :clean, 'Cleaning previous installations' do
run 'rm -fr vim'
end
end
def set_up
say_status :setup, 'Setup system ruby', :white
run 'rbenv global system'
end
def download_vim
vimify :download, 'Downloading VIM' do
run 'hg clone https://vim.googlecode.com/hg/ vim'
end
end
def configure_vim
vimify :configure, 'Configuring VIM', 'vim' do
options = ['--with-features=huge',
'--enable-cscope',
'--enable-pythoninterp',
'--enable-rubyinterp',
'--enable-perlinterp',
'--enable-multibyte',
'--enable-clipboard=yes',
'--enable-xterm_clipboard=yes']
run "./configure #{options.join(' ')}"
end
end
def set_arch_vim
vimify :arch, 'Setting VIM arch', 'vim' do
arch = "-arch x86_64"
gsub_file 'src/auto/config.mk', /.*LDFLAGS.*/, "LDFLAGS = -L. #{arch} -L/usr/local/lib"
end
end
def make_vim
vimify :make, 'Making VIM', 'vim' do
run_with_gcc 'make'
end
end
def verify_vim
vimify :verify, 'Verifying VIM', 'vim/src' do
run './vim --version'
end
end
def install_vim
vimify :install, 'Installing VIM', 'vim' do
if yes?('Install VIM in /usr/bin [yes/no]? ')
run_with_gcc 'sudo make install'
say_status :install, "old vim symlink moved to /usr/bin/vim.old", :white
run "sudo mv /usr/bin/vim /usr/bin/vim.old"
run "sudo ln -s /usr/local/bin/vim /usr/bin/vim"
else
say 'Skipping'
end
end
end
def tear_down
say_status :setup, 'Setup 1.9.3-p194 ruby', :white
run 'rbenv global 1.9.3-p194'
end
private
def vimify(status, message, dir = nil, &block)
say_status status, message, :white
if dir
inside dir, &block
else
in_root &block
end
end
def run_with_gcc(cmd)
# resolve some weird problems with XCode 4.3 and rbenv
run "env CC=/usr/bin/gcc #{cmd}"
end
end