vim-bundler 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +105 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/bin/vbundle +5 -0
- data/lib/vim-bundler/actions.rb +27 -0
- data/lib/vim-bundler/cli.rb +66 -0
- data/lib/vim-bundler/dsl.rb +52 -0
- data/lib/vim-bundler/git.rb +83 -0
- data/lib/vim-bundler/installer.rb +40 -0
- data/lib/vim-bundler/ui.rb +22 -0
- data/lib/vim-bundler/vim_org.rb +49 -0
- data/lib/vim-bundler.rb +17 -0
- data/test/helper.rb +18 -0
- data/test/test_vim-bundler.rb +7 -0
- data/vim-bundler.gemspec +70 -0
- metadata +123 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.0"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.6.2)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rake (0.9.2)
|
10
|
+
rcov (0.9.9)
|
11
|
+
shoulda (2.11.3)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.0.0)
|
18
|
+
jeweler (~> 1.6.0)
|
19
|
+
rcov
|
20
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Pavel Tatarsky
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
= vim-bundler
|
2
|
+
|
3
|
+
This gem provides a simple way to manage your vim bundles (aka plugins).
|
4
|
+
If you are familiar with ruby gem bundler - you are familar with vim-bundler.
|
5
|
+
|
6
|
+
== Requirements
|
7
|
+
|
8
|
+
git
|
9
|
+
|
10
|
+
== Quick start
|
11
|
+
|
12
|
+
Switch to your vimfiles directory (e.g +~/.vim+)
|
13
|
+
Initialize +vim_bundles+ config file
|
14
|
+
|
15
|
+
vbundle init
|
16
|
+
|
17
|
+
Put some lines in your +vim_bundles+ config file. For example:
|
18
|
+
|
19
|
+
bundle 'snipmate', :git => 'git://github.com/msanders/snipmate.vim.git'
|
20
|
+
bundle 'nerdtree', :git => 'git://github.com/scrooloose/nerdtree.git'
|
21
|
+
|
22
|
+
Perform install action
|
23
|
+
|
24
|
+
vbundle install
|
25
|
+
|
26
|
+
All you bundles will appear in +bundle+ dir.
|
27
|
+
|
28
|
+
After that you can clean your vimfiles directory from stale plugins
|
29
|
+
|
30
|
+
== Using different bundle sources
|
31
|
+
|
32
|
+
You can use use git sources as shown above and also it is possible to load scripts from www.vim.org
|
33
|
+
It can be done as following:
|
34
|
+
|
35
|
+
bundle 'indexed-search', :vim_script_id => 7062
|
36
|
+
|
37
|
+
value of +vim_script_id+ can be found in download link. You also need to point location if
|
38
|
+
the script originally requires another location than +plugin+
|
39
|
+
|
40
|
+
== Updating bundles
|
41
|
+
|
42
|
+
It is quite easy
|
43
|
+
|
44
|
+
vbundle update
|
45
|
+
|
46
|
+
Also you can update a specific plugin
|
47
|
+
|
48
|
+
vbundle update snipmate
|
49
|
+
|
50
|
+
== Cleaning bundles
|
51
|
+
|
52
|
+
It is also easy enough
|
53
|
+
|
54
|
+
vbundle clean
|
55
|
+
|
56
|
+
So you can clean a specific plugin
|
57
|
+
|
58
|
+
vbundle clean snipmate
|
59
|
+
|
60
|
+
As you can see, every command might be proceeded for specific plugin (except +init+)
|
61
|
+
|
62
|
+
== Managing bundles using git modules
|
63
|
+
|
64
|
+
It might be useful to attach plugins as git modules (for example if you keep your vimfiles at github.com), to do so put this line in your +vim_bundles+
|
65
|
+
|
66
|
+
use_git_submodules true
|
67
|
+
|
68
|
+
== Defining post actions
|
69
|
+
|
70
|
+
Sometimes it is usefull to do some actions after bundle installing or updating
|
71
|
+
|
72
|
+
bundle 'command-t', :git => 'git://github.com/vim-scripts/Command-T' do
|
73
|
+
`rvm use system && cd ruby/command-t && /usr/bin/ruby extconf.rb && make clean && make && cd - && rvm use default`
|
74
|
+
end
|
75
|
+
|
76
|
+
== Configuration options
|
77
|
+
|
78
|
+
There are some options that you can define in +vim_bundles+ file
|
79
|
+
|
80
|
+
use_git_submodules (default: false)
|
81
|
+
git_bin (default: 'git')
|
82
|
+
vimrc_file (default: 'vimrc')
|
83
|
+
vim_bin_path (default: '/usr/bin/vim')
|
84
|
+
bundles_dir (default: 'bundle')
|
85
|
+
|
86
|
+
== Example
|
87
|
+
|
88
|
+
My +vim_bundles+ located here
|
89
|
+
https://github.com/vintikzzz/my-vim-files/blob/master/vim_bundles
|
90
|
+
|
91
|
+
== Contributing to vim-bundler
|
92
|
+
|
93
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
94
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
95
|
+
* Fork the project
|
96
|
+
* Start a feature/bugfix branch
|
97
|
+
* Commit and push until you are happy with your contribution
|
98
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
99
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
100
|
+
|
101
|
+
== Copyright
|
102
|
+
|
103
|
+
Copyright (c) 2011 Pavel Tatarsky. See LICENSE.txt for
|
104
|
+
further details.
|
105
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "vim-bundler"
|
18
|
+
gem.homepage = "http://github.com/vintikzzz/vim-bundler"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Bundler for vim}
|
21
|
+
gem.description = %Q{This gem provides a simple way to manage your vim bundles (aka plugins).
|
22
|
+
If you are familiar with ruby gem bundler - you are familar with vim-bundler.}
|
23
|
+
gem.email = "fazzzenda@mail.ru"
|
24
|
+
gem.authors = ["Pavel Tatarsky"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rcov/rcovtask'
|
37
|
+
Rcov::RcovTask.new do |test|
|
38
|
+
test.libs << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
41
|
+
test.rcov_opts << '--exclude "gems/*"'
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "vim-bundler #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/vbundle
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module VimBundler
|
2
|
+
module Actions
|
3
|
+
def clean(bundle)
|
4
|
+
dir = File.join(@opts[:bundles_dir], bundle.name)
|
5
|
+
if Dir.exists?(dir)
|
6
|
+
FileUtils.rm_rf(dir)
|
7
|
+
VimBundler.ui.info "#{bundle.name} removed"
|
8
|
+
else
|
9
|
+
VimBundler.ui.warn "#{bundle.name} not found"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
def post_action(dir, bundle)
|
13
|
+
return true if bundle.block.nil?
|
14
|
+
cur_dir = FileUtils.pwd
|
15
|
+
FileUtils.cd(dir)
|
16
|
+
begin
|
17
|
+
bundle.block.call
|
18
|
+
rescue
|
19
|
+
FileUtils.cd(cur_dir)
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
FileUtils.cd(cur_dir)
|
23
|
+
return false unless $?.to_i == 0
|
24
|
+
true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/actions'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'open-uri'
|
5
|
+
module VimBundler
|
6
|
+
class CLI < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
def initialize(*)
|
9
|
+
super
|
10
|
+
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
11
|
+
VimBundler.ui = UI.new(shell)
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'install [bundle]', 'Install vim bundles'
|
15
|
+
def install(name = nil)
|
16
|
+
VimBundler::Installer.install(definition, name)
|
17
|
+
end
|
18
|
+
desc 'update [bundle]', 'Update vim bundles'
|
19
|
+
def update(name = nil)
|
20
|
+
VimBundler::Installer.update(definition, name)
|
21
|
+
end
|
22
|
+
desc 'init', 'Initialize vim bundles'
|
23
|
+
def init
|
24
|
+
pathogen_path = 'autoload/pathogen.vim'
|
25
|
+
unless File.exists? pathogen_path
|
26
|
+
FileUtils.mkdir_p('autoload')
|
27
|
+
open(pathogen_path, 'w+').write open('https://github.com/tpope/vim-pathogen/raw/master/autoload/pathogen.vim').read
|
28
|
+
VimBundler.ui.info "pathogen loaded"
|
29
|
+
end
|
30
|
+
unless Dir.exists?(definition[:opts][:bundles_dir])
|
31
|
+
FileUtils.mkdir_p(definition[:opts][:bundles_dir])
|
32
|
+
VimBundler.ui.info "bunldes dir created"
|
33
|
+
end
|
34
|
+
vimrc_file = definition[:opts][:vimrc_file]
|
35
|
+
FileUtils.touch(vimrc_file) unless File.exists?(vimrc_file)
|
36
|
+
prepend_line(vimrc_file, "call pathogen#helptags()")
|
37
|
+
prepend_line(vimrc_file, "call pathogen#runtime_append_all_bundles()")
|
38
|
+
VimBundler.ui.info "vimrc modified"
|
39
|
+
VimBundler.ui.confirm "bundles inited"
|
40
|
+
end
|
41
|
+
desc 'clean [bundle]', 'Remove all bundles'
|
42
|
+
def clean(name = nil)
|
43
|
+
VimBundler::Installer.clean(definition, name)
|
44
|
+
end
|
45
|
+
desc 'list', 'List all installed bundles'
|
46
|
+
def list
|
47
|
+
definition[:bundles].each { |k, v| puts k }
|
48
|
+
end
|
49
|
+
private
|
50
|
+
def definition
|
51
|
+
file = File.join(FileUtils.pwd, VimBundler.default_bundles_file)
|
52
|
+
@definition ||= VimBundler::DSL.eval(file).to_definition
|
53
|
+
end
|
54
|
+
def prepend_line(file, str)
|
55
|
+
data = open(file, 'r+') do |f|
|
56
|
+
while (line = f.gets)
|
57
|
+
return if line.start_with?(str)
|
58
|
+
end
|
59
|
+
f.pos = 0
|
60
|
+
temp = "#{str}\n#{f.read}"
|
61
|
+
f.pos = 0
|
62
|
+
f.write temp
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
module VimBundler
|
3
|
+
class DSL
|
4
|
+
def self.eval(file)
|
5
|
+
builder = new
|
6
|
+
builder.instance_eval(File.open(file, "rb") { |f| f.read })
|
7
|
+
builder
|
8
|
+
end
|
9
|
+
def self.defaults
|
10
|
+
@defaults ||= {}
|
11
|
+
end
|
12
|
+
def self.handlers
|
13
|
+
@handlers ||= {}
|
14
|
+
end
|
15
|
+
def self.option(name, default = nil)
|
16
|
+
defaults[name] = default
|
17
|
+
define_method("#{name.to_s}") do |val|
|
18
|
+
opts = instance_variable_get('@opts')
|
19
|
+
opts[name] = val
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def self.handler(name, &block)
|
23
|
+
handlers[name] = block
|
24
|
+
end
|
25
|
+
option :vimrc_file, 'vimrc'
|
26
|
+
option :vim_bin_path, '/usr/bin/vim'
|
27
|
+
option :bundles_dir, 'bundle'
|
28
|
+
def initialize
|
29
|
+
@bundles = {}
|
30
|
+
@opts = {}
|
31
|
+
self.class.defaults.each { |k, v| @opts[k] = v }
|
32
|
+
end
|
33
|
+
def bundle(*args, &block)
|
34
|
+
bundle = OpenStruct.new(args[1])
|
35
|
+
bundle.name = args[0]
|
36
|
+
bundle.block = block
|
37
|
+
self.class.handlers.each do |k, v|
|
38
|
+
if v.call(bundle)
|
39
|
+
bundle.type = k
|
40
|
+
@bundles[bundle.name] = bundle
|
41
|
+
break
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
def to_definition
|
46
|
+
{
|
47
|
+
:bundles => @bundles,
|
48
|
+
:opts => @opts
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
module VimBundler
|
3
|
+
module Git
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
module Installer
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
module InstanceMethods
|
8
|
+
include VimBundler::Actions
|
9
|
+
def git_install(bundle)
|
10
|
+
dir = File.join(@opts[:bundles_dir], bundle.name)
|
11
|
+
if Dir.exists?(dir)
|
12
|
+
VimBundler.ui.info "#{bundle.name} already installed"
|
13
|
+
return
|
14
|
+
end
|
15
|
+
if @opts[:use_git_submodules]
|
16
|
+
`#{@opts[:git_bin]} submodule add #{bundle.git} #{dir} 2>&1`
|
17
|
+
else
|
18
|
+
`#{@opts[:git_bin]} clone #{bundle.git} #{dir} 2>&1`
|
19
|
+
end
|
20
|
+
if $?.to_i == 0 && post_action(dir, bundle)
|
21
|
+
VimBundler.ui.info "#{bundle.name} installed"
|
22
|
+
else
|
23
|
+
VimBundler.ui.warn "#{bundle.name} not installed"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def git_update(bundle)
|
27
|
+
dir = File.join(@opts[:bundles_dir], bundle.name)
|
28
|
+
unless Dir.exists?(dir)
|
29
|
+
VimBundler.ui.warn "#{bundle.name} not found"
|
30
|
+
return
|
31
|
+
end
|
32
|
+
`cd #{dir} && #{@opts[:git_bin]} pull #{bundle.git} 2>&1 && cd - `
|
33
|
+
if $?.to_i == 0 && post_action(dir, bundle)
|
34
|
+
VimBundler.ui.info "#{bundle.name} updated"
|
35
|
+
else
|
36
|
+
VimBundler.ui.warn "#{bundle.name} not updated"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
def git_clean(bundle)
|
40
|
+
clean(bundle)
|
41
|
+
if @opts[:use_git_submodules]
|
42
|
+
clean_config_file('.gitmodules', bundle)
|
43
|
+
clean_config_file('.git/config', bundle)
|
44
|
+
lines = File.readlines('.gitmodules')
|
45
|
+
dir = File.join(@opts[:bundles_dir], bundle.name)
|
46
|
+
`#{@opts[:git_bin]} rm --cached #{dir}`
|
47
|
+
end
|
48
|
+
end
|
49
|
+
private
|
50
|
+
def clean_config_file(path, bundle)
|
51
|
+
temp = []
|
52
|
+
delete = false
|
53
|
+
file = File.open(path, 'r') do |f|
|
54
|
+
while (line = f.gets)
|
55
|
+
delete = false if line.include?('[submodule')
|
56
|
+
delete = true if line.include?(bundle.name) && line.include?('[submodule')
|
57
|
+
temp << line unless delete
|
58
|
+
end
|
59
|
+
end
|
60
|
+
file = File.open(path, 'w') do |f|
|
61
|
+
temp.each do |line|
|
62
|
+
f.write line
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
module DSL
|
69
|
+
extend ActiveSupport::Concern
|
70
|
+
included do
|
71
|
+
handler :git do |bundle|
|
72
|
+
bundle.respond_to?(:git)
|
73
|
+
end
|
74
|
+
option :use_git_submodules, false
|
75
|
+
option :git_bin, 'git'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
included do
|
79
|
+
VimBundler::Installer.send(:include, VimBundler::Git::Installer)
|
80
|
+
VimBundler::DSL.send(:include, VimBundler::Git::DSL)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'active_support/callbacks'
|
2
|
+
module VimBundler
|
3
|
+
class Installer
|
4
|
+
include ActiveSupport::Callbacks
|
5
|
+
define_callbacks :process, :all
|
6
|
+
def self.define_actions(*args)
|
7
|
+
args.each do |a|
|
8
|
+
self.define_callbacks a
|
9
|
+
self.define_singleton_method a do |d, name|
|
10
|
+
process_all(d, a.to_s, name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
define_actions :install, :update, :clean
|
15
|
+
def initialize(opts)
|
16
|
+
@opts = opts
|
17
|
+
end
|
18
|
+
private
|
19
|
+
def self.process(installer, type, bundle)
|
20
|
+
installer.run_callbacks(type.to_sym, bundle) do
|
21
|
+
installer.run_callbacks(:process, bundle) do
|
22
|
+
installer.send("#{bundle.type.to_s}_#{type}", bundle)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def self.process_all(definitions, type, name)
|
27
|
+
installer = new(definitions[:opts])
|
28
|
+
installer.run_callbacks(:all) do
|
29
|
+
unless name.nil?
|
30
|
+
process(installer, type, definitions[:bundles][name])
|
31
|
+
else
|
32
|
+
definitions[:bundles].each do |k, v|
|
33
|
+
process(installer, type, v)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
VimBundler.ui.confirm "all bundles processed"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module VimBundler
|
2
|
+
class UI
|
3
|
+
def initialize(shell)
|
4
|
+
@shell = shell
|
5
|
+
end
|
6
|
+
def info(msg)
|
7
|
+
@shell.say(msg)
|
8
|
+
end
|
9
|
+
|
10
|
+
def confirm(msg)
|
11
|
+
@shell.say(msg, :green)
|
12
|
+
end
|
13
|
+
|
14
|
+
def warn(msg)
|
15
|
+
@shell.say(msg, :yellow)
|
16
|
+
end
|
17
|
+
|
18
|
+
def error(msg)
|
19
|
+
@shell.say(msg, :red)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require 'open-uri'
|
3
|
+
module VimBundler
|
4
|
+
module VimOrg
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
module Installer
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
module InstanceMethods
|
9
|
+
include VimBundler::Actions
|
10
|
+
def vim_org_install(bundle)
|
11
|
+
dir = File.join(@opts[:bundles_dir], bundle.name)
|
12
|
+
if Dir.exists?(dir)
|
13
|
+
VimBundler.ui.info "#{bundle.name} already installed"
|
14
|
+
return
|
15
|
+
end
|
16
|
+
FileUtils.mkdir_p(dir)
|
17
|
+
f = open("http://www.vim.org/scripts/download_script.php?src_id=#{bundle.vim_script_id}")
|
18
|
+
local_file = f.meta["content-disposition"].gsub(/attachment; filename=/,"")
|
19
|
+
if local_file.end_with? 'vim'
|
20
|
+
as = bundle.respond_to?(:as) ? bundle.as.to_s : 'plugin'
|
21
|
+
FileUtils.mkdir_p(File.join(dir, as))
|
22
|
+
data = open(File.join(dir, as, local_file), 'w')
|
23
|
+
data.write f.read
|
24
|
+
end
|
25
|
+
VimBundler.ui.info "#{bundle.name} installed"
|
26
|
+
end
|
27
|
+
def vim_org_update(bundle)
|
28
|
+
clean(bundle)
|
29
|
+
vim_org_install(bundle)
|
30
|
+
end
|
31
|
+
def vim_org_clean(bundle)
|
32
|
+
clean(bundle)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
module DSL
|
37
|
+
extend ActiveSupport::Concern
|
38
|
+
included do
|
39
|
+
handler :vim_org do |bundle|
|
40
|
+
bundle.respond_to?(:vim_script_id)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
included do
|
45
|
+
VimBundler::Installer.send(:include, VimBundler::VimOrg::Installer)
|
46
|
+
VimBundler::DSL.send(:include, VimBundler::VimOrg::DSL)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/vim-bundler.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module VimBundler
|
2
|
+
autoload :DSL, 'vim-bundler/dsl'
|
3
|
+
autoload :Installer, 'vim-bundler/installer'
|
4
|
+
autoload :Git, 'vim-bundler/git'
|
5
|
+
autoload :VimOrg, 'vim-bundler/vim_org'
|
6
|
+
autoload :UI, 'vim-bundler/ui'
|
7
|
+
autoload :Actions, 'vim-bundler/actions'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :ui
|
11
|
+
def default_bundles_file
|
12
|
+
'vim_bundles'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
include Git
|
16
|
+
include VimOrg
|
17
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'vim-bundler'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/vim-bundler.gemspec
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{vim-bundler}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Pavel Tatarsky"]
|
12
|
+
s.date = %q{2011-06-17}
|
13
|
+
s.default_executable = %q{vbundle}
|
14
|
+
s.description = %q{This gem provides a simple way to manage your vim bundles (aka plugins).
|
15
|
+
If you are familiar with ruby gem bundler - you are familar with vim-bundler.}
|
16
|
+
s.email = %q{fazzzenda@mail.ru}
|
17
|
+
s.executables = ["vbundle"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE.txt",
|
20
|
+
"README.rdoc"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".document",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"bin/vbundle",
|
31
|
+
"lib/vim-bundler.rb",
|
32
|
+
"lib/vim-bundler/actions.rb",
|
33
|
+
"lib/vim-bundler/cli.rb",
|
34
|
+
"lib/vim-bundler/dsl.rb",
|
35
|
+
"lib/vim-bundler/git.rb",
|
36
|
+
"lib/vim-bundler/installer.rb",
|
37
|
+
"lib/vim-bundler/ui.rb",
|
38
|
+
"lib/vim-bundler/vim_org.rb",
|
39
|
+
"test/helper.rb",
|
40
|
+
"test/test_vim-bundler.rb",
|
41
|
+
"vim-bundler.gemspec"
|
42
|
+
]
|
43
|
+
s.homepage = %q{http://github.com/vintikzzz/vim-bundler}
|
44
|
+
s.licenses = ["MIT"]
|
45
|
+
s.require_paths = ["lib"]
|
46
|
+
s.rubygems_version = %q{1.6.2}
|
47
|
+
s.summary = %q{Bundler for vim}
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
55
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
|
56
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
61
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
65
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
67
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vim-bundler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Pavel Tatarsky
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-17 00:00:00 +04:00
|
14
|
+
default_executable: vbundle
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: shoulda
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: jeweler
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.6.0
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rcov
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
description: |-
|
61
|
+
This gem provides a simple way to manage your vim bundles (aka plugins).
|
62
|
+
If you are familiar with ruby gem bundler - you are familar with vim-bundler.
|
63
|
+
email: fazzzenda@mail.ru
|
64
|
+
executables:
|
65
|
+
- vbundle
|
66
|
+
extensions: []
|
67
|
+
|
68
|
+
extra_rdoc_files:
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.rdoc
|
71
|
+
files:
|
72
|
+
- .document
|
73
|
+
- Gemfile
|
74
|
+
- Gemfile.lock
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.rdoc
|
77
|
+
- Rakefile
|
78
|
+
- VERSION
|
79
|
+
- bin/vbundle
|
80
|
+
- lib/vim-bundler.rb
|
81
|
+
- lib/vim-bundler/actions.rb
|
82
|
+
- lib/vim-bundler/cli.rb
|
83
|
+
- lib/vim-bundler/dsl.rb
|
84
|
+
- lib/vim-bundler/git.rb
|
85
|
+
- lib/vim-bundler/installer.rb
|
86
|
+
- lib/vim-bundler/ui.rb
|
87
|
+
- lib/vim-bundler/vim_org.rb
|
88
|
+
- test/helper.rb
|
89
|
+
- test/test_vim-bundler.rb
|
90
|
+
- vim-bundler.gemspec
|
91
|
+
has_rdoc: true
|
92
|
+
homepage: http://github.com/vintikzzz/vim-bundler
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 2339842478696687007
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: "0"
|
115
|
+
requirements: []
|
116
|
+
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.6.2
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: Bundler for vim
|
122
|
+
test_files: []
|
123
|
+
|