vim-sitter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +9 -0
- data/bin/vimsit +28 -0
- data/config.yaml.sample +26 -0
- data/lib/version.rb +3 -0
- data/lib/vim_sitter.rb +8 -0
- data/lib/vim_sitter/bundle.rb +27 -0
- data/lib/vim_sitter/config.rb +40 -0
- data/lib/vim_sitter/gitter.rb +19 -0
- data/lib/vim_sitter/pathogen.rb +13 -0
- data/lib/vim_sitter/system.rb +23 -0
- data/lib/vim_sitter/vim_dir.rb +94 -0
- data/test/bundle_test.rb +65 -0
- data/test/config_test.rb +91 -0
- data/test/gitter_test.rb +56 -0
- data/test/pathongen_test.rb +38 -0
- data/test/system_test.rb +35 -0
- data/test/test_helper.rb +10 -0
- data/test/vim_dir_test.rb +135 -0
- data/vim_setter.gemspec +24 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7d48ed65a7e13bb9488f6c6813c74e42fdf4f272
|
4
|
+
data.tar.gz: 94a243d4100b25f71c294b0f994bbb5b024d02eb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e934266e70332ada08105d8004fec7749c52693be4e1272ae9620fb3998d91a79953ab8fa6a36231e2b004c9d6de47539d156144b6cf84500104cfb51afcd618
|
7
|
+
data.tar.gz: 6b708b5d2ad329354d4af506372014cb03e23553c62d23168244c67cfec4254736e53ee2ad087e7d992a792d1f9554dd1faffaf5504481c19cd1a3313328df1c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Zhon Johansen
|
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,33 @@
|
|
1
|
+
# vim-sitter
|
2
|
+
|
3
|
+
__vimsit__ a tool for keeping _your_ __VIM__ just the way _you_ like it:
|
4
|
+
|
5
|
+
1. Create your backup, undo and swap directories.
|
6
|
+
2. Setup sensible options (using tpope's vim-sensible)
|
7
|
+
2. Create a minimal config file for you
|
8
|
+
3. Install/update your plugins (via tpope's vim-pathogen)
|
9
|
+
4. Remove any plugins not listed in your config.yaml
|
10
|
+
|
11
|
+
Works on Window, Unix, Mac.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
$ gem install vim-sitter
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
You will need vim installed: http://www.vim.org/
|
20
|
+
|
21
|
+
You will need git installed: http://git-scm.com/
|
22
|
+
|
23
|
+
Configure your list of plugins to make VIM awesome! (you could copy config.yaml.sample to ~/.vim/config.yaml)
|
24
|
+
|
25
|
+
$ vimsit
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/vimsit
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.dirname(__FILE__)+'/../lib'
|
3
|
+
|
4
|
+
require 'vim_sitter'
|
5
|
+
|
6
|
+
include VimSitter
|
7
|
+
|
8
|
+
def exit_with message
|
9
|
+
puts "Error #{message}!"
|
10
|
+
exit -1
|
11
|
+
end
|
12
|
+
|
13
|
+
exit_with "Missing 'Vim'" unless System.vim_installed?
|
14
|
+
exit_with "Missing 'git'" unless System.git_installed?
|
15
|
+
|
16
|
+
VimDir.create_autoload
|
17
|
+
VimDir.create_bundle
|
18
|
+
VimDir.create_swap
|
19
|
+
VimDir.create_backup
|
20
|
+
VimDir.create_undo
|
21
|
+
|
22
|
+
Pathogen.install
|
23
|
+
|
24
|
+
VimSitter::Config.create
|
25
|
+
|
26
|
+
Bundle.install
|
27
|
+
|
28
|
+
Bundle.delete_unused
|
data/config.yaml.sample
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
digitaltoad:
|
3
|
+
- vim-jade
|
4
|
+
godlygeek:
|
5
|
+
- tabular
|
6
|
+
msanders:
|
7
|
+
- snipmate.vim
|
8
|
+
pangloss:
|
9
|
+
- vim-javascript
|
10
|
+
tpope:
|
11
|
+
- vim-abolish
|
12
|
+
- vim-cucumber
|
13
|
+
- vim-endwise
|
14
|
+
- vim-fugitive
|
15
|
+
- vim-git
|
16
|
+
- vim-haml
|
17
|
+
- vim-pathogen
|
18
|
+
- vim-rails
|
19
|
+
- vim-repeat
|
20
|
+
- vim-sensible
|
21
|
+
- vim-surround
|
22
|
+
- vim-unimpaired
|
23
|
+
- vim-vividchalk
|
24
|
+
scrooloose:
|
25
|
+
- nerdtree
|
26
|
+
- nerdcommenter
|
data/lib/version.rb
ADDED
data/lib/vim_sitter.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
require 'vim_sitter/config'
|
3
|
+
require 'vim_sitter/gitter'
|
4
|
+
require 'vim_sitter/vim_dir'
|
5
|
+
|
6
|
+
module VimSitter
|
7
|
+
class Bundle
|
8
|
+
|
9
|
+
def self.install
|
10
|
+
Config.each do |key, value|
|
11
|
+
value.each do |item|
|
12
|
+
Gitter.get key, item
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.delete_unused
|
18
|
+
bundles = Dir.entries(VimDir.bundle_dir).select { |item|
|
19
|
+
File.directory?("#{VimDir.bundle_dir}/#{item}") && (item !~ /\.$/)
|
20
|
+
}
|
21
|
+
(bundles - Config.bundles).each do |item|
|
22
|
+
FileUtils.rm_rf "#{VimDir.bundle_dir}/#{item}", verbose: true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'vim_sitter/vim_dir'
|
2
|
+
require 'yaml/store'
|
3
|
+
|
4
|
+
module VimSitter
|
5
|
+
class Config
|
6
|
+
|
7
|
+
@@config = nil
|
8
|
+
|
9
|
+
def self.create
|
10
|
+
unless File.exist?("#{VimDir.base_dir}/config.yaml")
|
11
|
+
store = YAML::Store.new "#{VimDir.base_dir}/config.yaml"
|
12
|
+
store.transaction do
|
13
|
+
store['tpope'] = [ 'vim-pathogen', 'vim-sensible' ]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.each &block
|
19
|
+
reload unless @@config
|
20
|
+
@@config.each &block
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.bundles
|
24
|
+
bundles = []
|
25
|
+
Config.each do |k,v|
|
26
|
+
bundles << v
|
27
|
+
end
|
28
|
+
bundles.flatten
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.reload
|
32
|
+
@@config = YAML::load_file "#{VimDir.base_dir}/config.yaml"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.reset
|
36
|
+
@@config = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'vim_sitter/vim_dir'
|
2
|
+
|
3
|
+
module VimSitter
|
4
|
+
class Gitter
|
5
|
+
|
6
|
+
def self.get author, repo_name
|
7
|
+
if VimDir.repo_exists? repo_name
|
8
|
+
puts "Pulling #{repo_name}"
|
9
|
+
VimDir.cd_to_bundle repo_name
|
10
|
+
system "git pull origin master"
|
11
|
+
else
|
12
|
+
puts "Cloning #{repo_name}"
|
13
|
+
VimDir.cd_to_bundle
|
14
|
+
system "git clone git://github.com/#{author}/#{repo_name}.git"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'vim_sitter/gitter'
|
2
|
+
|
3
|
+
module VimSitter
|
4
|
+
class Pathogen
|
5
|
+
|
6
|
+
def self.install
|
7
|
+
Gitter.get 'tpope', 'vim-pathogen'
|
8
|
+
VimDir.cp_to_autoload 'vim-pathogen/autoload/pathogen.vim'
|
9
|
+
VimDir.add_to_vimrc "call pathogen#infect()\ncall pathogen#helptags()"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module VimSitter
|
3
|
+
class System
|
4
|
+
|
5
|
+
def self.git_installed?
|
6
|
+
app_installed? 'git'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.vim_installed?
|
10
|
+
app_installed? 'vim'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.app_installed? app
|
14
|
+
begin
|
15
|
+
`#{app} --version`
|
16
|
+
rescue
|
17
|
+
return false
|
18
|
+
end
|
19
|
+
return true
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module VimSitter
|
4
|
+
class VimDir
|
5
|
+
# TODO need
|
6
|
+
# linux
|
7
|
+
|
8
|
+
def self.create_bundle
|
9
|
+
FileUtils.mkdir_p(bundle_dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.create_autoload
|
13
|
+
FileUtils.mkdir_p autoload_dir
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.create_swap
|
17
|
+
FileUtils.mkdir_p(data_dir + '/swap')
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create_backup
|
21
|
+
FileUtils.mkdir_p(data_dir + '/backup')
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.create_undo
|
25
|
+
FileUtils.mkdir_p(data_dir + '/undo')
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.cd_to_bundle repo_name=''
|
29
|
+
FileUtils.cd "#{bundle_dir}/#{repo_name}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.repo_exists? repo_name
|
33
|
+
File.exists? "#{bundle_dir}/#{repo_name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.cp_to_autoload path
|
37
|
+
FileUtils.cp "#{bundle_dir}/#{path}", autoload_dir
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.add_to_vimrc s
|
41
|
+
new_lines = s.split("\n").map {|item| item + "\n"}
|
42
|
+
lines = IO.readlines(vimrc_path)
|
43
|
+
unless lines & new_lines == new_lines
|
44
|
+
require 'tempfile'
|
45
|
+
begin
|
46
|
+
tmp = Tempfile.new('vimrc')
|
47
|
+
tmp.binmode
|
48
|
+
tmp.print new_lines.join
|
49
|
+
tmp.print lines.join
|
50
|
+
tmp.close
|
51
|
+
FileUtils.copy_file(tmp.path, vimrc_path)
|
52
|
+
ensure
|
53
|
+
tmp.close
|
54
|
+
tmp.unlink
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.data_dir
|
60
|
+
if windows?
|
61
|
+
ENV['AppData'].gsub('\\','/') + '/Vim'
|
62
|
+
elsif mac?
|
63
|
+
File.expand_path "~/Library/Vim"
|
64
|
+
else
|
65
|
+
raise "os '#{RUBY_PLATFORM}' not recognized!"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.base_dir
|
70
|
+
File.expand_path("~/#{windows? ? 'vimfiles' : '.vim'}")
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.bundle_dir
|
74
|
+
"#{base_dir}/bundle"
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.autoload_dir
|
78
|
+
"#{base_dir}/autoload"
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.vimrc_path
|
82
|
+
File.expand_path("~/#{windows? ? '_vimrc' : '.vimrc'}")
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.windows?
|
86
|
+
RUBY_PLATFORM =~ /(win|w)32$/
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.mac?
|
90
|
+
RUBY_PLATFORM =~ /darwin/
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
data/test/bundle_test.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require "vim_sitter/bundle"
|
2
|
+
|
3
|
+
require_relative 'test_helper'
|
4
|
+
|
5
|
+
class BundleTest < FlexMockTestCase
|
6
|
+
|
7
|
+
def test_install_bundle
|
8
|
+
Config.reset
|
9
|
+
flexmock(YAML)
|
10
|
+
.should_receive(:load_file)
|
11
|
+
.once
|
12
|
+
.and_return({
|
13
|
+
author1: ['bundle'],
|
14
|
+
author2: ['bundle1', 'bundle2']
|
15
|
+
})
|
16
|
+
flexmock(Gitter)
|
17
|
+
.should_receive(:get)
|
18
|
+
.once
|
19
|
+
.with(:author1, 'bundle')
|
20
|
+
.should_receive(:get)
|
21
|
+
.once
|
22
|
+
.with(:author2, 'bundle1')
|
23
|
+
.should_receive(:get)
|
24
|
+
.once
|
25
|
+
.with(:author2, 'bundle2')
|
26
|
+
Bundle.install
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_remove_bundle_not_listed_in_config
|
30
|
+
Config.reset
|
31
|
+
flexmock(YAML)
|
32
|
+
.should_receive(:load_file)
|
33
|
+
.and_return({
|
34
|
+
author1: ['bundle'],
|
35
|
+
})
|
36
|
+
flexmock(Dir)
|
37
|
+
.should_receive(:entries)
|
38
|
+
.with(/bundle/)
|
39
|
+
.and_return(['.', '..', 'file.txt', 'bundle', 'bundle2'])
|
40
|
+
.once
|
41
|
+
flexmock(File)
|
42
|
+
.should_receive(:directory?).with(/file.txt$/).and_return(false).once
|
43
|
+
.should_receive(:directory?).and_return(true)
|
44
|
+
flexmock(FileUtils)
|
45
|
+
.should_receive(:rm_rf).with(/bundle\/bundle2/).with_any_args.once
|
46
|
+
.should_receive(:rm_rf).with(%r{.}).never
|
47
|
+
.should_receive(:rm_rf).with(%r{..}).never
|
48
|
+
.should_receive(:rm_rf).with(/bundle$/).never
|
49
|
+
.should_receive(:rm_rf).with(/file.txt/).never
|
50
|
+
.should_receive(:rm_rf).with(%r{/$}).never
|
51
|
+
Bundle.delete_unused
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_each_loads_file_only_once
|
55
|
+
Config.reset
|
56
|
+
flexmock(YAML)
|
57
|
+
.should_receive(:load_file)
|
58
|
+
.once
|
59
|
+
.and_return({
|
60
|
+
key: ['v1', 'v2']
|
61
|
+
})
|
62
|
+
Config.each
|
63
|
+
Config.each
|
64
|
+
end
|
65
|
+
end
|
data/test/config_test.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
|
2
|
+
require "vim_sitter/config"
|
3
|
+
|
4
|
+
require_relative 'test_helper'
|
5
|
+
|
6
|
+
class ConfigTest < FlexMockTestCase
|
7
|
+
|
8
|
+
def test_create_does_nothing_if_config_exists
|
9
|
+
flexmock(File)
|
10
|
+
.should_receive(:exist?)
|
11
|
+
.with(/config.yaml/)
|
12
|
+
.and_return(true)
|
13
|
+
.once
|
14
|
+
flexmock(YAML::Store)
|
15
|
+
.should_receive(:new)
|
16
|
+
.never
|
17
|
+
Config.create
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_create
|
21
|
+
store = flexmock('store')
|
22
|
+
store
|
23
|
+
.should_receive(:transaction)
|
24
|
+
.once
|
25
|
+
.and_return { |block|
|
26
|
+
block.call
|
27
|
+
}
|
28
|
+
.should_receive(:[]=)
|
29
|
+
.with('tpope', [ 'vim-pathogen', 'vim-sensible' ])
|
30
|
+
.once
|
31
|
+
flexmock(YAML::Store)
|
32
|
+
.should_receive(:new)
|
33
|
+
.with(/config.yaml/)
|
34
|
+
.and_return(store)
|
35
|
+
.once
|
36
|
+
flexmock(File)
|
37
|
+
.should_receive(:exist?)
|
38
|
+
.and_return(false)
|
39
|
+
Config.create
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_each_iterates_over_config_file
|
43
|
+
Config.reset
|
44
|
+
flexmock(YAML)
|
45
|
+
.should_receive(:load_file)
|
46
|
+
.with(/config.yaml/)
|
47
|
+
.once
|
48
|
+
.and_return({
|
49
|
+
key: ['v1', 'v2']
|
50
|
+
})
|
51
|
+
Config.each { |k,v|
|
52
|
+
assert_equal(:key, k)
|
53
|
+
assert_equal('v1', v[0])
|
54
|
+
assert_equal('v2', v[1])
|
55
|
+
}
|
56
|
+
Config.each
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_each_loads_file_only_once
|
60
|
+
Config.reset
|
61
|
+
flexmock(YAML)
|
62
|
+
.should_receive(:load_file)
|
63
|
+
.once
|
64
|
+
.and_return({
|
65
|
+
key: ['v1', 'v2']
|
66
|
+
})
|
67
|
+
Config.each
|
68
|
+
Config.each
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_list_bundles
|
72
|
+
Config.reset
|
73
|
+
flexmock(YAML)
|
74
|
+
.should_receive(:load_file)
|
75
|
+
.once
|
76
|
+
.and_return({
|
77
|
+
key: ['v1', 'v2'],
|
78
|
+
key2: ['v3', 'v4']
|
79
|
+
})
|
80
|
+
assert_equal ['v1','v2','v3','v4'], Config.bundles
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_reload
|
84
|
+
flexmock(YAML)
|
85
|
+
.should_receive(:load_file)
|
86
|
+
.twice
|
87
|
+
Config.reload
|
88
|
+
Config.reload
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
data/test/gitter_test.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
require "vim_sitter/gitter"
|
3
|
+
|
4
|
+
require_relative 'test_helper'
|
5
|
+
|
6
|
+
class GitterTest < FlexMockTestCase
|
7
|
+
|
8
|
+
def test_clone_repo
|
9
|
+
author = 'jim'
|
10
|
+
repo_name = 'silly_code'
|
11
|
+
flexmock(VimDir)
|
12
|
+
.should_receive(:repo_exists?)
|
13
|
+
.and_return(false)
|
14
|
+
flexmock(Gitter)
|
15
|
+
.should_receive(:puts)
|
16
|
+
.with("Cloning #{repo_name}")
|
17
|
+
.once
|
18
|
+
flexmock(VimDir)
|
19
|
+
.should_receive(:cd_to_bundle)
|
20
|
+
.once
|
21
|
+
flexmock(Gitter)
|
22
|
+
.should_receive(:system)
|
23
|
+
.with(/git clone .*#{author}.*#{repo_name}/)
|
24
|
+
.once
|
25
|
+
|
26
|
+
Gitter.get author, repo_name
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_pull_repo
|
30
|
+
author = 'jim'
|
31
|
+
repo_name = 'silly_code'
|
32
|
+
flexmock(VimDir)
|
33
|
+
.should_receive(:repo_exists?)
|
34
|
+
.with(repo_name)
|
35
|
+
.and_return(true)
|
36
|
+
.once
|
37
|
+
flexmock(Gitter)
|
38
|
+
.should_receive(:puts)
|
39
|
+
.with("Pulling #{repo_name}")
|
40
|
+
.once
|
41
|
+
flexmock(VimDir)
|
42
|
+
.should_receive(:cd_to_bundle)
|
43
|
+
.with(repo_name)
|
44
|
+
.once
|
45
|
+
flexmock(Gitter)
|
46
|
+
.should_receive(:system)
|
47
|
+
.with('git pull origin master')
|
48
|
+
.once
|
49
|
+
|
50
|
+
Gitter.get author, repo_name
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "vim_sitter/pathogen"
|
2
|
+
require "vim_sitter/vim_dir"
|
3
|
+
|
4
|
+
require_relative 'test_helper'
|
5
|
+
|
6
|
+
class PathogenTest < FlexMockTestCase
|
7
|
+
|
8
|
+
def test_install_gets_pathoten
|
9
|
+
flexmock(VimDir).should_receive(:cp_to_autoload)
|
10
|
+
flexmock(VimDir).should_receive(:add_to_vimrc)
|
11
|
+
flexmock(Gitter)
|
12
|
+
.should_receive(:get)
|
13
|
+
.with('tpope', 'vim-pathogen')
|
14
|
+
.once
|
15
|
+
Pathogen.install
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_install_copies_pathogen_to_autoload
|
19
|
+
flexmock(Gitter).should_receive(:get)
|
20
|
+
flexmock(VimDir).should_receive(:add_to_vimrc)
|
21
|
+
flexmock(VimDir)
|
22
|
+
.should_receive(:cp_to_autoload)
|
23
|
+
.with(%r{vim-pathogen/autoload/pathogen.vim})
|
24
|
+
.once
|
25
|
+
Pathogen.install
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_install_adds_to_vimrc
|
29
|
+
flexmock(Gitter).should_receive(:get)
|
30
|
+
flexmock(VimDir).should_receive(:cp_to_autoload)
|
31
|
+
flexmock(VimDir)
|
32
|
+
.should_receive(:add_to_vimrc)
|
33
|
+
.with("call pathogen#infect()\ncall pathogen#helptags()")
|
34
|
+
.once
|
35
|
+
Pathogen.install
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/test/system_test.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'vim_sitter/system'
|
2
|
+
|
3
|
+
require_relative 'test_helper'
|
4
|
+
|
5
|
+
class SystemTest < FlexMockTestCase
|
6
|
+
|
7
|
+
def test_app_is_installed
|
8
|
+
flexmock(System)
|
9
|
+
.should_receive(:`)
|
10
|
+
.once
|
11
|
+
.with(/some_app/)
|
12
|
+
assert System.app_installed? 'some_app'
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_app_is_not_installed
|
16
|
+
flexmock(System)
|
17
|
+
.should_receive(:`)
|
18
|
+
.once
|
19
|
+
.and_raise(Errno::ENOENT)
|
20
|
+
refute System.app_installed? 'some_app'
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_git_is_installed
|
24
|
+
flexmock(System).should_receive(:app_installed?).once
|
25
|
+
.with(/git/)
|
26
|
+
System.git_installed?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_vim_is_installed
|
30
|
+
flexmock(System).should_receive(:app_installed?).once
|
31
|
+
.with(/vim/)
|
32
|
+
System.vim_installed?
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
|
2
|
+
require "vim_sitter/vim_dir"
|
3
|
+
|
4
|
+
require_relative 'test_helper'
|
5
|
+
|
6
|
+
class VimDirTest < FlexMockTestCase
|
7
|
+
|
8
|
+
def test_create_windows_dirs
|
9
|
+
check :create_bundle, /vimfiles.bundle/
|
10
|
+
check :create_autoload, /vimfiles.autoload/
|
11
|
+
check :create_swap, /AppData.+Vim.swap/
|
12
|
+
check :create_backup, /AppData.+Vim.backup/
|
13
|
+
check :create_undo, /AppData.+Vim.undo/
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_vimrc_path_on_windows
|
17
|
+
flexmock(VimDir)
|
18
|
+
.should_receive(:windows?)
|
19
|
+
.and_return(true)
|
20
|
+
.once
|
21
|
+
assert_match /_vimrc/, VimDir.vimrc_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_vimrc_path_on_unix_and_mac
|
25
|
+
flexmock(VimDir)
|
26
|
+
.should_receive(:windows?)
|
27
|
+
.and_return(false)
|
28
|
+
.once
|
29
|
+
assert_match /\.vimrc/, VimDir.vimrc_path
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_base_dir_on_windows
|
33
|
+
flexmock(VimDir)
|
34
|
+
.should_receive(:windows?)
|
35
|
+
.and_return(true)
|
36
|
+
.once
|
37
|
+
assert_match /vimfiles/, VimDir.base_dir
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_base_dir_on_unix_and_mac
|
41
|
+
flexmock(VimDir)
|
42
|
+
.should_receive(:windows?)
|
43
|
+
.and_return(false)
|
44
|
+
.once
|
45
|
+
assert_match /\.vim/, VimDir.base_dir
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_data_dir_on_windows
|
49
|
+
flexmock(VimDir)
|
50
|
+
.should_receive(:windows?)
|
51
|
+
.and_return(true)
|
52
|
+
.once
|
53
|
+
assert_match /AppData/, VimDir.data_dir
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_data_dir_on_mac
|
57
|
+
flexmock(VimDir)
|
58
|
+
.should_receive(:windows?)
|
59
|
+
.and_return(false)
|
60
|
+
.once
|
61
|
+
.should_receive(:mac?)
|
62
|
+
.and_return(true)
|
63
|
+
.once
|
64
|
+
assert_match /Library\/Vim/, VimDir.data_dir
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_cd_to_bundle
|
68
|
+
flexmock(FileUtils)
|
69
|
+
.should_receive(:cd)
|
70
|
+
.with(/bundle\/$/)
|
71
|
+
.once
|
72
|
+
VimDir.cd_to_bundle
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_cd_to_bundle_repo
|
76
|
+
flexmock(FileUtils)
|
77
|
+
.should_receive(:cd)
|
78
|
+
.with(/repo$/)
|
79
|
+
.once
|
80
|
+
VimDir.cd_to_bundle 'repo'
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_repo_exists
|
84
|
+
flexmock(File)
|
85
|
+
.should_receive(:exists?)
|
86
|
+
.with(/repo/)
|
87
|
+
.once
|
88
|
+
VimDir.repo_exists? 'repo'
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_cp_to_autoload
|
92
|
+
flexmock(FileUtils)
|
93
|
+
.should_receive(:cp)
|
94
|
+
.with(%r{/bundle/hello}, /autoload/)
|
95
|
+
.once
|
96
|
+
VimDir.cp_to_autoload 'hello'
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_add_to_vimrc_does_nothing_if_already_there
|
100
|
+
flexmock(IO)
|
101
|
+
.should_receive(:readlines)
|
102
|
+
.with(/vimrc$/)
|
103
|
+
.and_return(["something\n", "silly\n"])
|
104
|
+
.once
|
105
|
+
flexmock(FileUtils)
|
106
|
+
.should_receive(:copy_file)
|
107
|
+
.never
|
108
|
+
VimDir.add_to_vimrc "something\nsilly"
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_add_to_vimrc
|
112
|
+
require 'tempfile'
|
113
|
+
tempfile_mock = flexmock(close:nil, unlink:nil, print:nil,path:'',binmode:nil)
|
114
|
+
flexmock(Tempfile).should_receive(:new).and_return(tempfile_mock)
|
115
|
+
flexmock(IO)
|
116
|
+
.should_receive(:readlines)
|
117
|
+
.and_return(["some config\n", "silly\n"])
|
118
|
+
.once
|
119
|
+
flexmock(FileUtils)
|
120
|
+
.should_receive(:copy_file)
|
121
|
+
.with(//, /vimrc$/)
|
122
|
+
.once
|
123
|
+
VimDir.add_to_vimrc "something\nsilly"
|
124
|
+
end
|
125
|
+
|
126
|
+
def check(method, regex)
|
127
|
+
dir = VimDir
|
128
|
+
flexmock(FileUtils)
|
129
|
+
.should_receive(:mkdir_p)
|
130
|
+
.once
|
131
|
+
.with(regex)
|
132
|
+
dir.send method
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
data/vim_setter.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 'version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vim-sitter"
|
8
|
+
spec.version = VimSitter::VERSION
|
9
|
+
spec.authors = ["zhon"]
|
10
|
+
spec.email = ["zhon@xputah.org"]
|
11
|
+
spec.description = %q{vim-sitter will install/remove plugins; setup directories; and help you manage your vim settings}
|
12
|
+
spec.summary = %q{Helping you manage your settings}
|
13
|
+
spec.homepage = "https://github.com/zhon/vim-sitter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "flexmock"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vim-sitter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- zhon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-14 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
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: flexmock
|
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
|
+
description: vim-sitter will install/remove plugins; setup directories; and help you
|
56
|
+
manage your vim settings
|
57
|
+
email:
|
58
|
+
- zhon@xputah.org
|
59
|
+
executables:
|
60
|
+
- vimsit
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/vimsit
|
70
|
+
- config.yaml.sample
|
71
|
+
- lib/version.rb
|
72
|
+
- lib/vim_sitter.rb
|
73
|
+
- lib/vim_sitter/bundle.rb
|
74
|
+
- lib/vim_sitter/config.rb
|
75
|
+
- lib/vim_sitter/gitter.rb
|
76
|
+
- lib/vim_sitter/pathogen.rb
|
77
|
+
- lib/vim_sitter/system.rb
|
78
|
+
- lib/vim_sitter/vim_dir.rb
|
79
|
+
- test/bundle_test.rb
|
80
|
+
- test/config_test.rb
|
81
|
+
- test/gitter_test.rb
|
82
|
+
- test/pathongen_test.rb
|
83
|
+
- test/system_test.rb
|
84
|
+
- test/test_helper.rb
|
85
|
+
- test/vim_dir_test.rb
|
86
|
+
- vim_setter.gemspec
|
87
|
+
homepage: https://github.com/zhon/vim-sitter
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.0.0
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Helping you manage your settings
|
111
|
+
test_files:
|
112
|
+
- test/bundle_test.rb
|
113
|
+
- test/config_test.rb
|
114
|
+
- test/gitter_test.rb
|
115
|
+
- test/pathongen_test.rb
|
116
|
+
- test/system_test.rb
|
117
|
+
- test/test_helper.rb
|
118
|
+
- test/vim_dir_test.rb
|