neobundle 0.1.0
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/.gitignore +23 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +126 -0
- data/Rakefile +6 -0
- data/bin/neobundle +5 -0
- data/lib/neobundle.rb +15 -0
- data/lib/neobundle/command_line.rb +77 -0
- data/lib/neobundle/runner.rb +50 -0
- data/lib/neobundle/version.rb +3 -0
- data/lib/neobundle/vimscript.rb +81 -0
- data/neobundle.gemspec +24 -0
- data/spec/fixtures/vim-command/non_vim.bat +2 -0
- data/spec/fixtures/vim-command/non_vim.rb +2 -0
- data/spec/fixtures/vim-command/non_vim2.bat +2 -0
- data/spec/fixtures/vim-command/non_vim2.rb +3 -0
- data/spec/fixtures/vimrc/base.vim +1 -0
- data/spec/fixtures/vimrc/with_neobundle.vim +6 -0
- data/spec/neobundle/command_line_spec.rb +113 -0
- data/spec/neobundle/runner_spec.rb +144 -0
- data/spec/neobundle/vimscript_spec.rb +71 -0
- data/spec/neobundle_spec.rb +7 -0
- data/spec/spec_helper.rb +17 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 350829563c57e414fb95e1ed8429f6bd516f895f
|
4
|
+
data.tar.gz: 77170cadbd091451248eb29787cf7286deb48b06
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b2a610737b1bdc2672185702f098f34c1b8ddd1a7c4177399785f23b57f03166f49093d231df920ebbeed723039cb22dbf0162b439709ec57e27ca16e3b11775
|
7
|
+
data.tar.gz: cbb2f04444ef8c21f8b8baf46a48880b1503af037c6bfc21e3cfcf4e777d596ba88571e0e3a63acb6a37578bcf69cd3d758127282556b49bd02a4d8acfdea3cc
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
/vendor/bundle
|
data/.gitmodules
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Yuichi Murata
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# NeoBundle
|
2
|
+
|
3
|
+
[NeoBundle](https://github.com/Shougo/neobundle.vim "Shougo/neobundle.vim") command line tools.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'neobundle'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install neobundle
|
18
|
+
|
19
|
+
## Setting
|
20
|
+
|
21
|
+
1\. Install the NeoBundle:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ mkdir -p ~/.vim/bundle
|
25
|
+
$ cd ~/.vim/bundle/
|
26
|
+
$ git clone https://github.com/Shougo/neobundle.vim
|
27
|
+
```
|
28
|
+
|
29
|
+
2\. Add the NeoBundle settings to the `~/.vimrc`:
|
30
|
+
|
31
|
+
```VimL
|
32
|
+
if has('vim_starting')
|
33
|
+
set runtimepath+=~/.vim/bundle/neobundle.vim
|
34
|
+
call neobundle#rc('~/.vim/bundle/')
|
35
|
+
endif
|
36
|
+
|
37
|
+
NeoBundle 'Shougo/vimproc.vim', {
|
38
|
+
\ 'build': {
|
39
|
+
\ 'windows': 'make -f make_mingw32.mak',
|
40
|
+
\ 'cygwin': 'make -f make_cygwin.mak',
|
41
|
+
\ 'mac': 'make -f make_mac.mak',
|
42
|
+
\ 'unix': 'make -f make_unix.mak',
|
43
|
+
\ },
|
44
|
+
\}
|
45
|
+
|
46
|
+
NeoBundle 'Shougo/neocomplete.vim'
|
47
|
+
NeoBundle 'Shougo/vimshell.vim'
|
48
|
+
NeoBundle 'Shougo/unite.vim'
|
49
|
+
```
|
50
|
+
|
51
|
+
## Usage
|
52
|
+
|
53
|
+
The structure of the command line is shown below:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
$ neobundle [--help] [--version]
|
57
|
+
[--vim=<path>] [--vimrc=<path>]
|
58
|
+
<command>
|
59
|
+
```
|
60
|
+
|
61
|
+
### commands
|
62
|
+
|
63
|
+
#### install
|
64
|
+
|
65
|
+
This command will install the Vim plugins by the NeoBundle which is described the `vimrc`.
|
66
|
+
It equals the `:NeoBundleInstall` vim command.
|
67
|
+
|
68
|
+
```bash
|
69
|
+
$ neobundle install
|
70
|
+
```
|
71
|
+
|
72
|
+
#### clean
|
73
|
+
|
74
|
+
This command will delete the Vim plugins which is unused.
|
75
|
+
It equals the `:NeoBundleClean!` vim command.
|
76
|
+
|
77
|
+
```bash
|
78
|
+
$ neobundle clean
|
79
|
+
```
|
80
|
+
|
81
|
+
#### list
|
82
|
+
|
83
|
+
This command will enumerate the Vim plugins by the NeoBundle which is described the `vimrc`.
|
84
|
+
It equals the `:NeoBundleList` vim command.
|
85
|
+
|
86
|
+
```bash
|
87
|
+
$ neobundle list
|
88
|
+
```
|
89
|
+
|
90
|
+
### options
|
91
|
+
|
92
|
+
#### --vim
|
93
|
+
|
94
|
+
This option designates the vim command location.
|
95
|
+
|
96
|
+
```bash
|
97
|
+
--vim=<path>
|
98
|
+
```
|
99
|
+
|
100
|
+
The default value is `vim`, and this case is searched from the `PATH` environment variable by the system.
|
101
|
+
Also, this value is able to overriden by the `NEOBUNDLE_CMD_VIM` environment variable.
|
102
|
+
|
103
|
+
#### --vimrc
|
104
|
+
|
105
|
+
This option designates the vimrc location.
|
106
|
+
|
107
|
+
```bash
|
108
|
+
--vimrc=<path>
|
109
|
+
```
|
110
|
+
|
111
|
+
The default value is shown below:
|
112
|
+
|
113
|
+
| platform | value |
|
114
|
+
| -------- | ----- |
|
115
|
+
| Mac OS X and Linux | $HOME/.vimrc |
|
116
|
+
| Windows | %USERPROFILE%\\\_vimrc |
|
117
|
+
|
118
|
+
Also, this value is able to overriden by the `NEOBUNDLE_CMD_VIMRC` environment variable.
|
119
|
+
|
120
|
+
## Contributing
|
121
|
+
|
122
|
+
1. Fork it ( https://github.com/mrk21/neobundle-cmd/fork )
|
123
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
124
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
125
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
126
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/neobundle
ADDED
data/lib/neobundle.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'neobundle/version'
|
2
|
+
require 'rake/pathmap'
|
3
|
+
|
4
|
+
module NeoBundle
|
5
|
+
class Error < StandardError; def status; 1 end end
|
6
|
+
class VimscriptError < Error; def status; 2 end end
|
7
|
+
class NeoBundleNotFoundError < Error; def status; 3 end end
|
8
|
+
class OperationAlreadyCompletedError < Error; def status; 4 end end
|
9
|
+
class CommandLineError < Error; def status; 5 end end
|
10
|
+
class VimCommandError < Error; def status; 6 end end
|
11
|
+
end
|
12
|
+
|
13
|
+
Dir[__FILE__.pathmap('%X/*.rb')].each do |rb|
|
14
|
+
require rb.pathmap('%-1d/%n')
|
15
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'neobundle/runner'
|
3
|
+
|
4
|
+
module NeoBundle
|
5
|
+
class CommandLine
|
6
|
+
attr_reader :arguments
|
7
|
+
|
8
|
+
def self.run
|
9
|
+
begin
|
10
|
+
if block_given? then
|
11
|
+
yield
|
12
|
+
else
|
13
|
+
self.new.execute
|
14
|
+
end
|
15
|
+
rescue NeoBundle::Error => e
|
16
|
+
$stderr.puts e.message unless e.instance_of? NeoBundle::OperationAlreadyCompletedError
|
17
|
+
exit e.status
|
18
|
+
rescue SystemExit => e
|
19
|
+
exit e.status
|
20
|
+
rescue Exception => e
|
21
|
+
$stderr.puts e.inspect
|
22
|
+
$stderr.puts e.backtrace
|
23
|
+
exit 255
|
24
|
+
else
|
25
|
+
exit 0
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(args=ARGV)
|
30
|
+
@arguments = {
|
31
|
+
command: nil,
|
32
|
+
config: {}
|
33
|
+
}
|
34
|
+
opt = OptionParser.new
|
35
|
+
opt.version = NeoBundle::VERSION
|
36
|
+
opt.banner = <<-SH.gsub(/^( {2}){4}/,'')
|
37
|
+
Usage: neobundle [--help] [--version]
|
38
|
+
[--vim=<path>] [--vimrc=<path>]
|
39
|
+
<command>
|
40
|
+
|
41
|
+
commands:
|
42
|
+
install:
|
43
|
+
$ neobundle install
|
44
|
+
|
45
|
+
clean:
|
46
|
+
$ neobundle clean
|
47
|
+
|
48
|
+
list:
|
49
|
+
$ neobundle list
|
50
|
+
|
51
|
+
options:
|
52
|
+
SH
|
53
|
+
|
54
|
+
opt.on('--vim=<path>','Path to the vim command.'){|v| @arguments[:config][:vim] = v}
|
55
|
+
opt.on('--vimrc=<path>','Path to the vimrc.'){|v| @arguments[:config][:vimrc] = v}
|
56
|
+
opt.order!(args)
|
57
|
+
|
58
|
+
command = args.shift.to_s.intern
|
59
|
+
case command
|
60
|
+
when :install, :clean, :list then
|
61
|
+
@arguments[:command] = command
|
62
|
+
opt.parse!(args)
|
63
|
+
when :'', :help then
|
64
|
+
opt.parse(['--help'])
|
65
|
+
else
|
66
|
+
raise NeoBundle::CommandLineError, 'Invalid command: %s' % command
|
67
|
+
end
|
68
|
+
rescue OptionParser::ParseError => e
|
69
|
+
raise NeoBundle::CommandLineError, e.message
|
70
|
+
end
|
71
|
+
|
72
|
+
def execute
|
73
|
+
runner = Runner.new(self.arguments[:config])
|
74
|
+
runner.send(self.arguments[:command])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'neobundle/vimscript'
|
2
|
+
|
3
|
+
module NeoBundle
|
4
|
+
class Runner
|
5
|
+
attr_reader :script
|
6
|
+
|
7
|
+
def self.default_config(platform = RUBY_PLATFORM)
|
8
|
+
config = {
|
9
|
+
vim: ENV['NEOBUNDLE_CMD_VIM'] || 'vim',
|
10
|
+
vimrc: ENV['NEOBUNDLE_CMD_VIMRC'],
|
11
|
+
}
|
12
|
+
case platform
|
13
|
+
when /darwin/,/linux/ then
|
14
|
+
config[:vimrc] ||= File.join(ENV['HOME'], '.vimrc')
|
15
|
+
when /mswin(?!ce)|mingw|cygwin|bccwin/ then
|
16
|
+
config[:vimrc] ||= File.join(ENV['HOME'], '_vimrc')
|
17
|
+
end
|
18
|
+
config
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(config={}, script=nil)
|
22
|
+
@script = script || Vimscript.new(self.class.default_config.merge(config))
|
23
|
+
begin
|
24
|
+
self.script.exec('NeoBundleList')
|
25
|
+
rescue NeoBundle::VimscriptError
|
26
|
+
raise NeoBundle::NeoBundleNotFoundError, 'NeoBundle not found!'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def list
|
31
|
+
@script.exec('NeoBundleList', $stdout)
|
32
|
+
end
|
33
|
+
|
34
|
+
def install
|
35
|
+
dir = @script.exec('echo neobundle#get_neobundle_dir()').strip
|
36
|
+
before = Dir['%s/*' % dir]
|
37
|
+
@script.exec('NeoBundleInstall', $stdout)
|
38
|
+
after = Dir['%s/*' % dir]
|
39
|
+
raise NeoBundle::OperationAlreadyCompletedError, 'Already installed!' if before == after
|
40
|
+
end
|
41
|
+
|
42
|
+
def clean
|
43
|
+
dir = @script.exec('echo neobundle#get_neobundle_dir()').strip
|
44
|
+
before = Dir['%s/*' % dir]
|
45
|
+
@script.exec('NeoBundleClean!', $stdout)
|
46
|
+
after = Dir['%s/*' % dir]
|
47
|
+
raise NeoBundle::OperationAlreadyCompletedError, 'Already cleaned!' if before == after
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
3
|
+
module NeoBundle
|
4
|
+
class Vimscript
|
5
|
+
MARK = '[neobundle-cmd/vim-script/command-part]'
|
6
|
+
|
7
|
+
def initialize(config={})
|
8
|
+
@config = {
|
9
|
+
vim: 'vim',
|
10
|
+
vimrc: 'NONE',
|
11
|
+
}
|
12
|
+
@config.merge!(config)
|
13
|
+
begin
|
14
|
+
result = %x[#{'%{vim} --version' % self.escaped_config}]
|
15
|
+
unless result =~ /^VIM - Vi IMproved / and $? == 0 then
|
16
|
+
raise NeoBundle::VimCommandError, 'command is not vim!'
|
17
|
+
end
|
18
|
+
rescue SystemCallError
|
19
|
+
raise NeoBundle::VimCommandError, 'vim command not found!'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def exec(cmd, io=nil)
|
24
|
+
raise NeoBundle::VimscriptError, 'Command is empty!' if cmd.to_s.strip.empty?
|
25
|
+
command = (<<-SH % self.escaped_config).gsub(/\s+/,' ').strip
|
26
|
+
%{vim} -u %{vimrc} -U NONE -i NONE -e -s -V1
|
27
|
+
-c "
|
28
|
+
try |
|
29
|
+
echo '#{MARK}' |
|
30
|
+
#{cmd} |
|
31
|
+
echo '#{MARK}' |
|
32
|
+
echo '' |
|
33
|
+
finally |
|
34
|
+
q! |
|
35
|
+
endtry
|
36
|
+
"
|
37
|
+
-c "
|
38
|
+
echo '#{MARK}' |
|
39
|
+
echo '' |
|
40
|
+
q
|
41
|
+
"
|
42
|
+
SH
|
43
|
+
r,w = IO.pipe
|
44
|
+
process = Process.detach spawn(command, out: w, err: w)
|
45
|
+
|
46
|
+
Thread.new do
|
47
|
+
process.join
|
48
|
+
r.close
|
49
|
+
w.close
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
result = []
|
54
|
+
is_outputting = false
|
55
|
+
|
56
|
+
loop do
|
57
|
+
line = r.gets.rstrip
|
58
|
+
if line == MARK then
|
59
|
+
is_outputting = !is_outputting
|
60
|
+
elsif is_outputting then
|
61
|
+
io.puts line unless io.nil?
|
62
|
+
result.push line
|
63
|
+
end
|
64
|
+
end
|
65
|
+
rescue IOError
|
66
|
+
result = result.join("\n")
|
67
|
+
raise NeoBundle::VimscriptError, result if process.value != 0
|
68
|
+
result
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
protected
|
73
|
+
|
74
|
+
def escaped_config
|
75
|
+
result = @config.clone
|
76
|
+
result[:vim] = Shellwords.escape result[:vim]
|
77
|
+
result[:vimrc] = Shellwords.escape result[:vimrc]
|
78
|
+
result
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/neobundle.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'neobundle/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "neobundle"
|
8
|
+
spec.version = NeoBundle::VERSION
|
9
|
+
spec.authors = ["Yuichi Murata"]
|
10
|
+
spec.email = ["mrk21info+rubygems@gmail.com"]
|
11
|
+
spec.summary = %q{NeoBundle command line tools.}
|
12
|
+
spec.description = %q{NeoBundle command line tools.}
|
13
|
+
spec.homepage = "https://github.com/mrk21/neobundle-cmd"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
set runtimepath=$_neobundle_root/tmp,$_neobundle_root/tmp/after
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module NeoBundle
|
5
|
+
describe NeoBundle::CommandLine do
|
6
|
+
subject do
|
7
|
+
CommandLine.new(self.args.split(/\s+/))
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:args){''}
|
11
|
+
|
12
|
+
describe '#arguments()' do
|
13
|
+
subject { super().arguments }
|
14
|
+
|
15
|
+
describe 'install command' do
|
16
|
+
let(:args){'install'}
|
17
|
+
it { is_expected.to eq(command: :install, config: {}) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'clean command' do
|
21
|
+
let(:args){'clean'}
|
22
|
+
it { is_expected.to eq(command: :clean, config: {}) }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'list command' do
|
26
|
+
let(:args){'list'}
|
27
|
+
it { is_expected.to eq(command: :list, config: {}) }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'help or version' do
|
31
|
+
before { $stderr = $stdout = StringIO.new }
|
32
|
+
after { $stderr = STDERR; $stdout = STDOUT }
|
33
|
+
|
34
|
+
['', 'help', '--help', '-h', '--version'].each do |args|
|
35
|
+
describe '"%s"' % args do
|
36
|
+
let(:args){args}
|
37
|
+
it { expect{subject}.to raise_error(SystemExit) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'options' do
|
43
|
+
let(:args){'--vim=path1 --vimrc=path3 install --vimrc=path4 --vim=path2'}
|
44
|
+
it do
|
45
|
+
is_expected.to eq(
|
46
|
+
command: :install,
|
47
|
+
config: {
|
48
|
+
vim: 'path2',
|
49
|
+
vimrc: 'path4'
|
50
|
+
}
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'invalid command' do
|
56
|
+
let(:args){'invalid-command'}
|
57
|
+
it { expect{subject}.to raise_error(NeoBundle::CommandLineError, 'Invalid command: invalid-command') }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'invalid option' do
|
61
|
+
let(:args){'--invalid-option'}
|
62
|
+
it { expect{subject}.to raise_error(NeoBundle::CommandLineError, 'invalid option: --invalid-option') }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '::run(&block)' do
|
67
|
+
subject do
|
68
|
+
begin
|
69
|
+
CommandLine.run do
|
70
|
+
self.exception
|
71
|
+
end
|
72
|
+
rescue SystemExit => e
|
73
|
+
self.io.rewind
|
74
|
+
return [e.status, self.io.read.strip]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
let(:exception){nil}
|
79
|
+
let(:io){StringIO.new('','r+')}
|
80
|
+
|
81
|
+
before { $stderr = self.io }
|
82
|
+
after { $stderr = STDERR }
|
83
|
+
|
84
|
+
context 'when became successful' do
|
85
|
+
it {expect(subject[0]).to eq(0) }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when the `NeoBundle::Error` was thrown' do
|
89
|
+
let(:exception){raise NeoBundle::VimscriptError, 'VimscriptError message'}
|
90
|
+
it { expect(subject[0]).to eq(2) }
|
91
|
+
it { expect(subject[1]).to eq('VimscriptError message') }
|
92
|
+
|
93
|
+
context 'when the `NeoBundle::Error` was thrown' do
|
94
|
+
let(:exception){raise NeoBundle::OperationAlreadyCompletedError, 'OperationAlreadyCompletedError'}
|
95
|
+
it { expect(subject[0]).to eq(4) }
|
96
|
+
it { expect(subject[1]).to eq('') }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when the `SystemExit` was thrown' do
|
101
|
+
let(:exception){abort 'abort message'}
|
102
|
+
it { expect(subject[0]).to eq(1) }
|
103
|
+
it { expect(subject[1]).to eq('abort message') }
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when the unknown exception was thrown' do
|
107
|
+
let(:exception){raise StandardError, 'StandardError message'}
|
108
|
+
it { expect(subject[0]).to eq(255) }
|
109
|
+
it { expect(subject[1]).to match(/^#<StandardError: StandardError message>/) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module NeoBundle
|
4
|
+
describe NeoBundle::Runner do
|
5
|
+
subject { Runner.new({}, self.script) }
|
6
|
+
|
7
|
+
let(:script){Vimscript.new(vimrc: './spec/fixtures/vimrc/with_neobundle.vim')}
|
8
|
+
|
9
|
+
before do
|
10
|
+
ENV['_neobundle_root'] = Dir.pwd
|
11
|
+
FileUtils.mkdir_p './tmp/after'
|
12
|
+
FileUtils.mkdir_p './tmp/plugin'
|
13
|
+
FileUtils.mkdir_p './tmp/bundle'
|
14
|
+
File.write('./tmp/plugin/empty.vim','')
|
15
|
+
end
|
16
|
+
|
17
|
+
it { expect{subject}.to_not raise_error }
|
18
|
+
|
19
|
+
context 'when the NeoBundle was not installed' do
|
20
|
+
let(:script){Vimscript.new(vimrc: './spec/fixtures/vimrc/base.vim')}
|
21
|
+
it { expect{subject}.to raise_error(NeoBundle::NeoBundleNotFoundError, 'NeoBundle not found!') }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#install()' do
|
25
|
+
subject { super().install }
|
26
|
+
|
27
|
+
let(:script) do
|
28
|
+
s = super()
|
29
|
+
d = double('Vimscript')
|
30
|
+
allow(d).to receive(:exec) do |cmd|
|
31
|
+
if cmd == 'NeoBundleInstall' then
|
32
|
+
self.on_install()
|
33
|
+
''
|
34
|
+
else
|
35
|
+
s.exec(cmd)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
d
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:on_install) do
|
42
|
+
File.write('./tmp/bundle/test.vim','')
|
43
|
+
end
|
44
|
+
|
45
|
+
it { expect{subject}.to_not raise_error }
|
46
|
+
|
47
|
+
context 'when installed nothing' do
|
48
|
+
let(:on_install){}
|
49
|
+
it { expect{subject}.to raise_error(NeoBundle::OperationAlreadyCompletedError, 'Already installed!') }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#clean()' do
|
54
|
+
subject { super().clean }
|
55
|
+
|
56
|
+
let(:script) do
|
57
|
+
s = super()
|
58
|
+
d = double('Vimscript')
|
59
|
+
allow(d).to receive(:exec) do |cmd|
|
60
|
+
if cmd == 'NeoBundleClean!' then
|
61
|
+
self.on_clean()
|
62
|
+
''
|
63
|
+
else
|
64
|
+
s.exec(cmd)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
d
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:on_clean) do
|
71
|
+
FileUtils.rm_f './tmp/bundle/test.vim'
|
72
|
+
end
|
73
|
+
|
74
|
+
before do
|
75
|
+
File.write('./tmp/bundle/test.vim','')
|
76
|
+
end
|
77
|
+
|
78
|
+
it { expect{subject}.to_not raise_error }
|
79
|
+
|
80
|
+
context 'when deleted nothing' do
|
81
|
+
let(:on_clean){}
|
82
|
+
it { expect{subject}.to raise_error(NeoBundle::OperationAlreadyCompletedError, 'Already cleaned!') }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '::default_config([platform])' do
|
87
|
+
subject { Runner.default_config(self.platform) }
|
88
|
+
|
89
|
+
before do
|
90
|
+
ENV['NEOBUNDLE_CMD_VIM'] = nil
|
91
|
+
ENV['NEOBUNDLE_CMD_VIMRC'] = nil
|
92
|
+
end
|
93
|
+
|
94
|
+
after do
|
95
|
+
ENV['NEOBUNDLE_CMD_VIM'] = nil
|
96
|
+
ENV['NEOBUNDLE_CMD_VIMRC'] = nil
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when the platform was "Mac OS X"' do
|
100
|
+
let(:platform){'x86_64-darwin13.0'}
|
101
|
+
it do
|
102
|
+
is_expected.to eq(
|
103
|
+
vim: 'vim',
|
104
|
+
vimrc: File.expand_path('~/.vimrc')
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'with options' do
|
109
|
+
before do
|
110
|
+
ENV['NEOBUNDLE_CMD_VIM'] = 'path/to/vim'
|
111
|
+
ENV['NEOBUNDLE_CMD_VIMRC'] = 'path/to/vimrc'
|
112
|
+
end
|
113
|
+
|
114
|
+
it do
|
115
|
+
is_expected.to eq(
|
116
|
+
vim: 'path/to/vim',
|
117
|
+
vimrc: 'path/to/vimrc'
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'when the platform was "Linux"' do
|
124
|
+
let(:platform){'x86_64-linux'}
|
125
|
+
it do
|
126
|
+
is_expected.to eq(
|
127
|
+
vim: 'vim',
|
128
|
+
vimrc: File.expand_path('~/.vimrc')
|
129
|
+
)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'when the platform was "Windows"' do
|
134
|
+
let(:platform){'x64-mingw32'}
|
135
|
+
it do
|
136
|
+
is_expected.to eq(
|
137
|
+
vim: 'vim',
|
138
|
+
vimrc: File.expand_path('~/_vimrc')
|
139
|
+
)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module NeoBundle
|
5
|
+
describe NeoBundle::Vimscript do
|
6
|
+
subject { Vimscript.new(self.config) }
|
7
|
+
let(:config){{}}
|
8
|
+
|
9
|
+
it { expect{subject}.to_not raise_error }
|
10
|
+
|
11
|
+
context 'when the vim command not found' do
|
12
|
+
let(:config){{vim: './not/existed/path'}}
|
13
|
+
it { expect{subject}.to raise_error(NeoBundle::VimCommandError, 'vim command not found!') }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when the command which is designated was not the "vim"' do
|
17
|
+
describe 'output' do
|
18
|
+
if ENV['OS'].nil?
|
19
|
+
let(:config){{vim: './spec/fixtures/vim-command/non_vim.rb'}}
|
20
|
+
else
|
21
|
+
let(:config){{vim: './spec/fixtures/vim-command/non_vim.bat'}}
|
22
|
+
end
|
23
|
+
it { expect{subject}.to raise_error(NeoBundle::VimCommandError, 'command is not vim!') }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'status' do
|
27
|
+
if ENV['OS'].nil?
|
28
|
+
let(:config){{vim: './spec/fixtures/vim-command/non_vim2.rb'}}
|
29
|
+
else
|
30
|
+
let(:config){{vim: './spec/fixtures/vim-command/non_vim2.bat'}}
|
31
|
+
end
|
32
|
+
it { expect{subject}.to raise_error(NeoBundle::VimCommandError, 'command is not vim!') }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#exec(cmd[, io])' do
|
37
|
+
subject { super().exec(self.cmd, self.io) }
|
38
|
+
let(:cmd){'echo 1'}
|
39
|
+
let(:io){nil}
|
40
|
+
|
41
|
+
it { is_expected.to eq(ENV['OS'].nil? ? '1' : "\n1\n") }
|
42
|
+
|
43
|
+
context 'when the `cmd` was empty' do
|
44
|
+
['""', 'nil', '" \n "'].each do |empty_cmd|
|
45
|
+
describe empty_cmd do
|
46
|
+
let(:cmd){eval empty_cmd}
|
47
|
+
it { expect{subject}.to raise_error(NeoBundle::VimscriptError, 'Command is empty!') }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when occured the Vim script error' do
|
53
|
+
let(:cmd){'invalid-command'}
|
54
|
+
it { expect{subject}.to raise_error(NeoBundle::VimscriptError, /E492:/) }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'IO output' do
|
58
|
+
subject do
|
59
|
+
super()
|
60
|
+
self.io.rewind
|
61
|
+
self.io.read
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:cmd){'echo 1 | echo 2'}
|
65
|
+
let(:io){StringIO.new('','r+')}
|
66
|
+
|
67
|
+
it { is_expected.to eq(ENV['OS'].nil? ? "1\n2\n" : "\n1\n\n2\n\n") }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'neobundle'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.before(:all) do
|
7
|
+
FileUtils.mkdir_p './tmp'
|
8
|
+
end
|
9
|
+
|
10
|
+
config.before(:each) do
|
11
|
+
FileUtils.rm_rf './tmp/*'
|
12
|
+
end
|
13
|
+
|
14
|
+
config.after(:all) do
|
15
|
+
FileUtils.rm_rf './tmp'
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neobundle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuichi Murata
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: NeoBundle command line tools.
|
56
|
+
email:
|
57
|
+
- mrk21info+rubygems@gmail.com
|
58
|
+
executables:
|
59
|
+
- neobundle
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".gitmodules"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/neobundle
|
72
|
+
- lib/neobundle.rb
|
73
|
+
- lib/neobundle/command_line.rb
|
74
|
+
- lib/neobundle/runner.rb
|
75
|
+
- lib/neobundle/version.rb
|
76
|
+
- lib/neobundle/vimscript.rb
|
77
|
+
- neobundle.gemspec
|
78
|
+
- spec/fixtures/vim-command/non_vim.bat
|
79
|
+
- spec/fixtures/vim-command/non_vim.rb
|
80
|
+
- spec/fixtures/vim-command/non_vim2.bat
|
81
|
+
- spec/fixtures/vim-command/non_vim2.rb
|
82
|
+
- spec/fixtures/vimrc/base.vim
|
83
|
+
- spec/fixtures/vimrc/with_neobundle.vim
|
84
|
+
- spec/neobundle/command_line_spec.rb
|
85
|
+
- spec/neobundle/runner_spec.rb
|
86
|
+
- spec/neobundle/vimscript_spec.rb
|
87
|
+
- spec/neobundle_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: https://github.com/mrk21/neobundle-cmd
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.2.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: NeoBundle command line tools.
|
113
|
+
test_files:
|
114
|
+
- spec/fixtures/vim-command/non_vim.bat
|
115
|
+
- spec/fixtures/vim-command/non_vim.rb
|
116
|
+
- spec/fixtures/vim-command/non_vim2.bat
|
117
|
+
- spec/fixtures/vim-command/non_vim2.rb
|
118
|
+
- spec/fixtures/vimrc/base.vim
|
119
|
+
- spec/fixtures/vimrc/with_neobundle.vim
|
120
|
+
- spec/neobundle/command_line_spec.rb
|
121
|
+
- spec/neobundle/runner_spec.rb
|
122
|
+
- spec/neobundle/vimscript_spec.rb
|
123
|
+
- spec/neobundle_spec.rb
|
124
|
+
- spec/spec_helper.rb
|