|
1 |
| -desc "Copy the vim/doc files into ~/.vim" |
2 |
| -task :deploy_local do |
3 |
| - run "cp plugin/NERD_commenter.vim ~/.vim/plugin" |
4 |
| - run "cp doc/NERD_commenter.txt ~/.vim/doc" |
5 |
| -end |
| 1 | +# written by travis jeffery <[email protected]> |
| 2 | +# contributions by scrooloose <github:scrooloose> |
| 3 | + |
| 4 | +require 'rake' |
| 5 | +require 'find' |
| 6 | +require 'pathname' |
6 | 7 |
|
| 8 | +IGNORE = [/\.gitignore$/, /Rakefile$/] |
7 | 9 |
|
8 |
| -desc "Create a zip archive for release to vim.org" |
| 10 | +files = `git ls-files`.split("\n") |
| 11 | +files.reject! { |f| IGNORE.any? { |re| f.match(re) } } |
| 12 | + |
| 13 | +desc 'Zip up the project files' |
9 | 14 | task :zip do
|
10 |
| - abort "NERD_commenter.zip already exists, aborting" if File.exist?("NERD_commenter.zip") |
11 |
| - run "zip NERD_commenter.zip plugin/NERD_commenter.vim doc/NERD_commenter.txt" |
| 15 | + zip_name = File.basename(File.dirname(__FILE__)) |
| 16 | + zip_name.gsub!(/ /, '_') |
| 17 | + zip_name = "#{zip_name}.zip" |
| 18 | + |
| 19 | + if File.exist?(zip_name) |
| 20 | + abort("Zip file #{zip_name} already exists. Remove it first.") |
| 21 | + end |
| 22 | + |
| 23 | + puts "Creating zip file: #{zip_name}" |
| 24 | + system("zip #{zip_name} #{files.join(" ")}") |
| 25 | +end |
| 26 | + |
| 27 | +desc 'Install plugin and documentation' |
| 28 | +task :install do |
| 29 | + vimfiles = if ENV['VIMFILES'] |
| 30 | + ENV['VIMFILES'] |
| 31 | + elsif RUBY_PLATFORM =~ /(win|w)32$/ |
| 32 | + File.expand_path("~/vimfiles") |
| 33 | + else |
| 34 | + File.expand_path("~/.vim") |
| 35 | + end |
| 36 | + files.each do |file| |
| 37 | + target_file = File.join(vimfiles, file) |
| 38 | + FileUtils.mkdir_p File.dirname(target_file) |
| 39 | + FileUtils.cp file, target_file |
| 40 | + |
| 41 | + puts "Installed #{file} to #{target_file}" |
| 42 | + end |
| 43 | + |
| 44 | +end |
| 45 | + |
| 46 | +desc 'Pulls from origin' |
| 47 | +task :pull do |
| 48 | + puts "Updating local repo..." |
| 49 | + system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull") |
| 50 | +end |
| 51 | + |
| 52 | +desc 'Calls pull task and then install task' |
| 53 | +task :update => ['pull', 'install'] do |
| 54 | + puts "Update of vim script complete." |
12 | 55 | end
|
13 | 56 |
|
14 |
| -def run(cmd) |
15 |
| - puts "Executing: #{cmd}" |
16 |
| - system cmd |
| 57 | +desc 'Uninstall plugin and documentation' |
| 58 | +task :uninstall do |
| 59 | + vimfiles = if ENV['VIMFILES'] |
| 60 | + ENV['VIMFILES'] |
| 61 | + elsif RUBY_PLATFORM =~ /(win|w)32$/ |
| 62 | + File.expand_path("~/vimfiles") |
| 63 | + else |
| 64 | + File.expand_path("~/.vim") |
| 65 | + end |
| 66 | + files.each do |file| |
| 67 | + target_file = File.join(vimfiles, file) |
| 68 | + FileUtils.rm target_file |
| 69 | + |
| 70 | + puts "Uninstalled #{target_file}" |
| 71 | + end |
| 72 | + |
17 | 73 | end
|
18 | 74 |
|
| 75 | +task :default => ['update'] |
| 76 | + |
0 commit comments