vvm-rb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +4 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +36 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/vvm-rb +8 -0
- data/etc/login +14 -0
- data/lib/vvm-rb.rb +6 -0
- data/lib/vvm-rb/cli.rb +41 -0
- data/lib/vvm-rb/constants.rb +6 -0
- data/lib/vvm-rb/installer.rb +112 -0
- data/lib/vvm-rb/switcher.rb +31 -0
- data/lib/vvm-rb/uninstaller.rb +39 -0
- data/lib/vvm-rb/validator.rb +27 -0
- data/spec/cli_spec.rb +43 -0
- data/spec/installer_spec.rb +77 -0
- data/spec/spec_helper.rb +71 -0
- data/spec/switcher_spec.rb +43 -0
- data/spec/uninstaller_spec.rb +32 -0
- data/spec/vvm-rb_spec.rb +4 -0
- data/vvm-rb.gemspec +94 -0
- metadata +223 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1146a78b2527ca5cad66aa93ec0b3637fd73228d
|
4
|
+
data.tar.gz: b72b7e360f843ec3c482bd59e27c057fe744c23f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61550cfcd07aa5ffdcae7a68e9eca6c373dfb4f0c83a8586e130f75ae7ea317190d46eac6917ce1eb73bbae4057417a8e08af7f6bf2befa52e6b92ef054d2aa6
|
7
|
+
data.tar.gz: 741e36421f5e2c08c237e38b2bdfe002fd380f6fdec073917f5850f5bb182d04d57a68daf4d86cdb7223a4cefd03eaf3c49422a293e8153e0e984890070dd865
|
data/.document
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Yuu Shigetani
|
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,36 @@
|
|
1
|
+
= vvm-rb
|
2
|
+
|
3
|
+
vim version manager : fork from https://github.com/kana/vim-version-manager
|
4
|
+
|
5
|
+
== Install
|
6
|
+
|
7
|
+
$ rake build
|
8
|
+
$ rake install
|
9
|
+
|
10
|
+
== Usage
|
11
|
+
please add the following line into your ~/.bash_login etc:
|
12
|
+
|
13
|
+
test -f ~/.vvm-rb/etc/login && source ~/.vvm-rb/etc/login
|
14
|
+
|
15
|
+
$ vvm-rb install v7-4
|
16
|
+
$ vvm-rb install v7-4-035
|
17
|
+
$ vvm-rb reinstall v7-4
|
18
|
+
$ vvm-rb rebuild v7-4 --enable-rubyinterp --enable-pythoninterp
|
19
|
+
$ vvm-rb use v7-4
|
20
|
+
$ vvm-rb uninstall v7-4-035
|
21
|
+
|
22
|
+
== Contributing to vvm-rb
|
23
|
+
|
24
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
25
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
26
|
+
* Fork the project.
|
27
|
+
* Start a feature/bugfix branch.
|
28
|
+
* Commit and push until you are happy with your contribution.
|
29
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
30
|
+
* 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.
|
31
|
+
|
32
|
+
== Copyright
|
33
|
+
|
34
|
+
Copyright (c) 2013 Yuu Shigetani. See LICENSE.txt for
|
35
|
+
further details.
|
36
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
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 = "vvm-rb"
|
18
|
+
gem.homepage = "http://github.com/calorie/vvm-rb"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{vim version manager}
|
21
|
+
gem.description = %Q{vvm-rb can manage multiple vim's versions & switch each other.}
|
22
|
+
gem.email = "s2g4t1n2@gmail.com"
|
23
|
+
gem.authors = ["Yuu Shigetani"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "vvm-rb #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/vvm-rb
ADDED
data/etc/login
ADDED
data/lib/vvm-rb.rb
ADDED
data/lib/vvm-rb/cli.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'vvm-rb/validator'
|
3
|
+
require 'vvm-rb/installer'
|
4
|
+
require 'vvm-rb/uninstaller'
|
5
|
+
require 'vvm-rb/switcher'
|
6
|
+
|
7
|
+
class Cli < Thor
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
desc 'install [TAG] [options]', 'Install a specific version of Vim'
|
11
|
+
def install(version, *conf)
|
12
|
+
installer = Installer.new(version, conf)
|
13
|
+
installer.install
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'reinstall [TAG] [options]', 'Reinstall a specific version of Vim'
|
17
|
+
def reinstall(version, *conf)
|
18
|
+
uninstaller = Uninstaller.new(version)
|
19
|
+
uninstaller.uninstall
|
20
|
+
installer = Installer.new(version, conf)
|
21
|
+
installer.install
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'rebuild [TAG] [options]', 'Rebuild a specific version of Vim, then install it'
|
25
|
+
def rebuild(version, *conf)
|
26
|
+
installer = Installer.new(version, conf)
|
27
|
+
installer.rebuild
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'use [TAG]', 'Use a specific version of Vim as the default one.'
|
31
|
+
def use(version)
|
32
|
+
switcher = Switcher.new(version)
|
33
|
+
switcher.use
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'uninstall [TAG]', 'Uninstall a specific version of Vim.'
|
37
|
+
def uninstall(version)
|
38
|
+
uninstaller = Uninstaller.new(version)
|
39
|
+
uninstaller.uninstall
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class Installer
|
4
|
+
include Validator
|
5
|
+
|
6
|
+
def initialize(version, conf = nil)
|
7
|
+
@version = version
|
8
|
+
@conf = conf
|
9
|
+
end
|
10
|
+
|
11
|
+
def install
|
12
|
+
fetch
|
13
|
+
checkout
|
14
|
+
configure
|
15
|
+
make_install
|
16
|
+
cp_etc
|
17
|
+
|
18
|
+
print "\e[32m"
|
19
|
+
puts <<-EOS
|
20
|
+
|
21
|
+
Vim is successfully installed. For daily use,
|
22
|
+
please add the following line into your ~/.bash_login etc:
|
23
|
+
|
24
|
+
test -f ~/.vvm-rb/etc/login && source ~/.vvm-rb/etc/login
|
25
|
+
|
26
|
+
EOS
|
27
|
+
print "\e[0m"
|
28
|
+
end
|
29
|
+
|
30
|
+
def rebuild
|
31
|
+
make_clean
|
32
|
+
configure
|
33
|
+
make_install
|
34
|
+
|
35
|
+
print "\e[32m"
|
36
|
+
puts <<-EOS
|
37
|
+
|
38
|
+
Vim is successfully rebuilded.
|
39
|
+
EOS
|
40
|
+
print "\e[0m"
|
41
|
+
end
|
42
|
+
|
43
|
+
def fetch
|
44
|
+
FileUtils.mkdir_p(REPOS_DIR)
|
45
|
+
repos_dir = get_repos_dir
|
46
|
+
unless Dir.exists?(repos_dir)
|
47
|
+
system("hg clone #{VIM_URI} #{repos_dir}")
|
48
|
+
end
|
49
|
+
Dir.chdir(repos_dir) { system('hg pull') }
|
50
|
+
end
|
51
|
+
|
52
|
+
def checkout
|
53
|
+
FileUtils.mkdir_p(SRC_DIR)
|
54
|
+
repos_dir = get_repos_dir
|
55
|
+
src_dir = get_src_dir(@version)
|
56
|
+
unless Dir.exists?(src_dir)
|
57
|
+
system("cd #{repos_dir} && hg archive -t tar -r #{@version} -p #{@version} - | (cd #{SRC_DIR} && tar xf -)")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def configure
|
62
|
+
vims_dir = get_vims_dir(@version)
|
63
|
+
src_dir = get_src_dir(@version)
|
64
|
+
default = "--prefix=#{vims_dir}"
|
65
|
+
Dir.chdir src_dir do
|
66
|
+
system("./configure #{default} #{@conf.join(' ')}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def make_clean
|
71
|
+
src_dir = get_src_dir(@version)
|
72
|
+
Dir.chdir src_dir do
|
73
|
+
system('make clean')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def make_install
|
78
|
+
src_dir = get_src_dir(@version)
|
79
|
+
Dir.chdir src_dir do
|
80
|
+
system('make all install')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def cp_etc
|
85
|
+
unless File.exists?(get_login_file)
|
86
|
+
FileUtils.mkdir_p(ETC_DIR)
|
87
|
+
|
88
|
+
login = File.expand_path(File.dirname(__FILE__) + '/../../etc/login')
|
89
|
+
FileUtils.cp(login, ETC_DIR)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
before(:fetch, :checkout) { validations }
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def get_repos_dir
|
98
|
+
return "#{REPOS_DIR}/vimorg"
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_src_dir(version)
|
102
|
+
return "#{SRC_DIR}/#{version}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_vims_dir(version)
|
106
|
+
return "#{VIMS_DIR}/#{version}"
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_login_file
|
110
|
+
return "#{ETC_DIR}/login"
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class Switcher
|
4
|
+
def initialize(version)
|
5
|
+
@version = version
|
6
|
+
end
|
7
|
+
|
8
|
+
def use
|
9
|
+
current = get_current
|
10
|
+
if Dir.exists?(current)
|
11
|
+
FileUtils.rm(current)
|
12
|
+
end
|
13
|
+
unless @version == 'system'
|
14
|
+
vims_dir = get_vims_dir(@version)
|
15
|
+
unless Dir.exists?(vims_dir)
|
16
|
+
abort "#{@version} is not installed."
|
17
|
+
end
|
18
|
+
FileUtils.ln_s(vims_dir, current)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def get_current
|
25
|
+
return "#{VIMS_DIR}/current"
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_vims_dir(version)
|
29
|
+
return "#{VIMS_DIR}/#{version}"
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class Uninstaller
|
4
|
+
def initialize(version)
|
5
|
+
@version = version
|
6
|
+
end
|
7
|
+
|
8
|
+
def uninstall
|
9
|
+
current = get_current
|
10
|
+
vims_dir = get_vims_dir(@version)
|
11
|
+
src_dir = get_src_dir(@version)
|
12
|
+
if Dir.exists?(current)
|
13
|
+
target = File.readlink(current)
|
14
|
+
if target == vims_dir
|
15
|
+
abort "#{@version} can not be uninstalled; it is currently used."
|
16
|
+
end
|
17
|
+
end
|
18
|
+
if Dir.exists?(src_dir)
|
19
|
+
FileUtils.rm_rf(src_dir)
|
20
|
+
end
|
21
|
+
if Dir.exists?(vims_dir)
|
22
|
+
FileUtils.rm_rf(vims_dir)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def get_current
|
29
|
+
return "#{VIMS_DIR}/current"
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_vims_dir(version)
|
33
|
+
return "#{VIMS_DIR}/#{version}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_src_dir(version)
|
37
|
+
return "#{SRC_DIR}/#{version}"
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Validator
|
2
|
+
def self.included(base)
|
3
|
+
base.extend(ClassMethods)
|
4
|
+
end
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def before(*names)
|
8
|
+
names.each do |name|
|
9
|
+
m = instance_method(name)
|
10
|
+
define_method(name) do |*args, &block|
|
11
|
+
yield
|
12
|
+
m.bind(self).(*args, &block)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def validations
|
18
|
+
check_hg
|
19
|
+
end
|
20
|
+
|
21
|
+
def check_hg
|
22
|
+
`hg --version`
|
23
|
+
abort 'mercurial is required to install.' unless $?.success?
|
24
|
+
return true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Cli' do
|
4
|
+
describe 'install' do
|
5
|
+
let(:output) { capture(:stdout) { Cli.start('install v7-4-001'.split)} }
|
6
|
+
|
7
|
+
it 'success' do
|
8
|
+
expect(output).to match(/Vim is successfully installed/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'reinstall' do
|
13
|
+
let(:output) { capture(:stdout) { Cli.start('reinstall v7-4-001'.split)} }
|
14
|
+
|
15
|
+
it 'success' do
|
16
|
+
expect(output).to match(/Vim is successfully installed/)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'rebuild' do
|
21
|
+
let(:output) { capture(:stdout) { Cli.start('rebuild v7-4-001'.split)} }
|
22
|
+
|
23
|
+
it 'success' do
|
24
|
+
expect(output).to match(/Vim is successfully rebuilded/)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'use' do
|
29
|
+
let(:output) { capture(:stdout) { Cli.start('use v7-4'.split)} }
|
30
|
+
|
31
|
+
it 'success' do
|
32
|
+
expect(output).to eq('')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'uninstall' do
|
37
|
+
let(:output) { capture(:stdout) { Cli.start('uninstall v7-3-969'.split)} }
|
38
|
+
|
39
|
+
it 'success' do
|
40
|
+
expect(output).to eq('')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Installer' do
|
5
|
+
describe 'install' do
|
6
|
+
before :all do
|
7
|
+
Cli.start('uninstall v7-3-969'.split)
|
8
|
+
Cli.start('uninstall v7-4'.split)
|
9
|
+
FileUtils.rm_rf(REPOS_DIR)
|
10
|
+
FileUtils.rm_rf(ETC_DIR)
|
11
|
+
@version = 'v7-4'
|
12
|
+
@installer = Installer.new(@version, [])
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'fetch' do
|
16
|
+
before :all do
|
17
|
+
@installer.fetch
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'exists vimorg dir' do
|
21
|
+
expect(Dir.exists?("#{REPOS_DIR}/vimorg")).to be_true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'checkout' do
|
26
|
+
before :all do
|
27
|
+
@installer.checkout
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'exists src dir' do
|
31
|
+
expect(Dir.exists?("#{SRC_DIR}/#{@version}")).to be_true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'configure & make_install' do
|
36
|
+
before :all do
|
37
|
+
@installer.configure
|
38
|
+
@installer.make_install
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'exists vims dir' do
|
42
|
+
expect(Dir.exists?("#{VIMS_DIR}/#{@version}")).to be_true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'cp_etc' do
|
47
|
+
before :all do
|
48
|
+
@installer.cp_etc
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'exists etc dir' do
|
52
|
+
expect(Dir.exists?(ETC_DIR)).to be_true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'exists login file' do
|
56
|
+
expect(File.exists?("#{ETC_DIR}/login")).to be_true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'rebuild' do
|
62
|
+
before :all do
|
63
|
+
@version = 'v7-4'
|
64
|
+
@installer = Installer.new(@version, [])
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'make_clean' do
|
68
|
+
before :all do
|
69
|
+
@installer.make_clean
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'not exists objects dir' do
|
73
|
+
expect(Dir["#{SRC_DIR}/#{@version}/src/objects/*"].empty?).to be_true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter '/spec/'
|
4
|
+
end
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
+
require 'rspec'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'tmpdir'
|
11
|
+
require 'vvm-rb'
|
12
|
+
|
13
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.before :suite do
|
17
|
+
clear_consts
|
18
|
+
CACHE_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '.vvm_cache'))
|
19
|
+
DOT_DIR = CACHE_DIR
|
20
|
+
ETC_DIR = "#{DOT_DIR}/etc"
|
21
|
+
REPOS_DIR = "#{DOT_DIR}/repos"
|
22
|
+
SRC_DIR = "#{DOT_DIR}/src"
|
23
|
+
VIMS_DIR = "#{DOT_DIR}/vims"
|
24
|
+
VIM_URI = 'https://vim.googlecode.com/hg/'
|
25
|
+
unless Dir.exists?(CACHE_DIR)
|
26
|
+
FileUtils.mkdir_p(CACHE_DIR)
|
27
|
+
Cli.start('install v7-3-969'.split)
|
28
|
+
Cli.start('install v7-4'.split)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
config.before :all do
|
33
|
+
clear_consts
|
34
|
+
@tmp = Dir.mktmpdir
|
35
|
+
FileUtils.cp_r(CACHE_DIR, @tmp)
|
36
|
+
DOT_DIR = File.expand_path(File.join(@tmp, '.vvm_cache'))
|
37
|
+
ETC_DIR = "#{DOT_DIR}/etc"
|
38
|
+
REPOS_DIR = "#{DOT_DIR}/repos"
|
39
|
+
SRC_DIR = "#{DOT_DIR}/src"
|
40
|
+
VIMS_DIR = "#{DOT_DIR}/vims"
|
41
|
+
end
|
42
|
+
|
43
|
+
config.after :all do
|
44
|
+
FileUtils.rm_rf(@tmp)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def clear_consts
|
49
|
+
%w{
|
50
|
+
DOT_DIR
|
51
|
+
ETC_DIR
|
52
|
+
REPOS_DIR
|
53
|
+
SRC_DIR
|
54
|
+
VIMS_DIR
|
55
|
+
}.each do |c|
|
56
|
+
const = c.to_sym
|
57
|
+
Object.send(:remove_const, const) if Object.const_defined?(const)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def capture(stream)
|
62
|
+
begin
|
63
|
+
stream = stream.to_s
|
64
|
+
eval "$#{stream} = StringIO.new"
|
65
|
+
yield
|
66
|
+
result = eval("$#{stream}").string
|
67
|
+
ensure
|
68
|
+
eval("$#{stream} = #{stream.upcase}")
|
69
|
+
end
|
70
|
+
result
|
71
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Switcher' do
|
4
|
+
describe 'use' do
|
5
|
+
context 'system vim' do
|
6
|
+
before :all do
|
7
|
+
switcher = Switcher.new('system')
|
8
|
+
switcher.use
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'delete current' do
|
12
|
+
expect(Dir.exists?("#{VIMS_DIR}/current")).not_to be_true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'different version' do
|
17
|
+
before :all do
|
18
|
+
switcher = Switcher.new('v7-4')
|
19
|
+
switcher.use
|
20
|
+
@vims_dir = "#{VIMS_DIR}/v7-4"
|
21
|
+
@current = "#{VIMS_DIR}/current"
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'exist current' do
|
25
|
+
expect(Dir.exists?(@current)).to be_true
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'switch current' do
|
29
|
+
expect(File.readlink(@current)).to eq(@vims_dir)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'unknown version' do
|
34
|
+
before :all do
|
35
|
+
@switcher = Switcher.new('v7-5')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raise error' do
|
39
|
+
expect(proc { @switcher.use }).to raise_error
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Uninstaller' do
|
4
|
+
describe 'uninstall' do
|
5
|
+
context 'vim version is currently used' do
|
6
|
+
before :all do
|
7
|
+
Cli.start('use v7-4'.split)
|
8
|
+
@uninstaller = Uninstaller.new('v7-4')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'raise error' do
|
12
|
+
expect(proc { @uninstaller.uninstall }).to raise_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'can uninstall version' do
|
17
|
+
before :all do
|
18
|
+
@version = 'v7-3-969'
|
19
|
+
@uninstaller = Uninstaller.new(@version)
|
20
|
+
@uninstaller.uninstall
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'delete src dir' do
|
24
|
+
expect(Dir.exists?("#{SRC_DIR}/#{@version}")).not_to be_true
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'delete vims dir' do
|
28
|
+
expect(Dir.exists?("#{VIMS_DIR}/#{@version}")).not_to be_true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/vvm-rb_spec.rb
ADDED
data/vvm-rb.gemspec
ADDED
@@ -0,0 +1,94 @@
|
|
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
|
+
# stub: vvm-rb 0.0.1 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "vvm-rb"
|
9
|
+
s.version = "0.0.1"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Yuu Shigetani"]
|
13
|
+
s.date = "2013-09-24"
|
14
|
+
s.description = "vvm-rb can manage multiple vim's versions & switch each other."
|
15
|
+
s.email = "s2g4t1n2@gmail.com"
|
16
|
+
s.executables = ["vvm-rb"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/vvm-rb",
|
30
|
+
"etc/login",
|
31
|
+
"lib/vvm-rb.rb",
|
32
|
+
"lib/vvm-rb/cli.rb",
|
33
|
+
"lib/vvm-rb/constants.rb",
|
34
|
+
"lib/vvm-rb/installer.rb",
|
35
|
+
"lib/vvm-rb/switcher.rb",
|
36
|
+
"lib/vvm-rb/uninstaller.rb",
|
37
|
+
"lib/vvm-rb/validator.rb",
|
38
|
+
"spec/cli_spec.rb",
|
39
|
+
"spec/installer_spec.rb",
|
40
|
+
"spec/spec_helper.rb",
|
41
|
+
"spec/switcher_spec.rb",
|
42
|
+
"spec/uninstaller_spec.rb",
|
43
|
+
"spec/vvm-rb_spec.rb",
|
44
|
+
"vvm-rb.gemspec"
|
45
|
+
]
|
46
|
+
s.homepage = "http://github.com/calorie/vvm-rb"
|
47
|
+
s.licenses = ["MIT"]
|
48
|
+
s.require_paths = ["lib"]
|
49
|
+
s.rubygems_version = "2.1.3"
|
50
|
+
s.summary = "vim version manager"
|
51
|
+
|
52
|
+
if s.respond_to? :specification_version then
|
53
|
+
s.specification_version = 4
|
54
|
+
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<vvm-rb>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
60
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
63
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
65
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<vvm-rb>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
70
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
71
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
72
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
73
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
74
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
75
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
76
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
77
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
78
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
79
|
+
end
|
80
|
+
else
|
81
|
+
s.add_dependency(%q<vvm-rb>, [">= 0"])
|
82
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
83
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
84
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
85
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
86
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
87
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
88
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
89
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
90
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
91
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
metadata
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vvm-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuu Shigetani
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: vvm-rb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jeweler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rdoc
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: bundler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: jeweler
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: vvm-rb can manage multiple vim's versions & switch each other.
|
168
|
+
email: s2g4t1n2@gmail.com
|
169
|
+
executables:
|
170
|
+
- vvm-rb
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files:
|
173
|
+
- LICENSE.txt
|
174
|
+
- README.rdoc
|
175
|
+
files:
|
176
|
+
- .document
|
177
|
+
- .rspec
|
178
|
+
- Gemfile
|
179
|
+
- LICENSE.txt
|
180
|
+
- README.rdoc
|
181
|
+
- Rakefile
|
182
|
+
- VERSION
|
183
|
+
- bin/vvm-rb
|
184
|
+
- etc/login
|
185
|
+
- lib/vvm-rb.rb
|
186
|
+
- lib/vvm-rb/cli.rb
|
187
|
+
- lib/vvm-rb/constants.rb
|
188
|
+
- lib/vvm-rb/installer.rb
|
189
|
+
- lib/vvm-rb/switcher.rb
|
190
|
+
- lib/vvm-rb/uninstaller.rb
|
191
|
+
- lib/vvm-rb/validator.rb
|
192
|
+
- spec/cli_spec.rb
|
193
|
+
- spec/installer_spec.rb
|
194
|
+
- spec/spec_helper.rb
|
195
|
+
- spec/switcher_spec.rb
|
196
|
+
- spec/uninstaller_spec.rb
|
197
|
+
- spec/vvm-rb_spec.rb
|
198
|
+
- vvm-rb.gemspec
|
199
|
+
homepage: http://github.com/calorie/vvm-rb
|
200
|
+
licenses:
|
201
|
+
- MIT
|
202
|
+
metadata: {}
|
203
|
+
post_install_message:
|
204
|
+
rdoc_options: []
|
205
|
+
require_paths:
|
206
|
+
- lib
|
207
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - '>='
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '0'
|
212
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - '>='
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
requirements: []
|
218
|
+
rubyforge_project:
|
219
|
+
rubygems_version: 2.1.3
|
220
|
+
signing_key:
|
221
|
+
specification_version: 4
|
222
|
+
summary: vim version manager
|
223
|
+
test_files: []
|