vim-flavor 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.asciidoc +142 -0
- data/Rakefile +2 -0
- data/bin/vim-flavor +3 -0
- data/lib/vim-flavor.rb +471 -0
- data/lib/vim-flavor/version.rb +5 -0
- data/spec/cli_spec.rb +15 -0
- data/spec/facade_spec.rb +563 -0
- data/spec/flavor_spec.rb +246 -0
- data/spec/flavorfile_spec.rb +121 -0
- data/spec/lockfile_spec.rb +94 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/stringextension_spec.rb +11 -0
- data/spec/versionconstraint_spec.rb +137 -0
- data/vim-flavor.gemspec +20 -0
- metadata +102 -0
data/spec/flavor_spec.rb
ADDED
@@ -0,0 +1,246 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'vim-flavor'
|
5
|
+
|
6
|
+
describe Vim::Flavor::Flavor do
|
7
|
+
describe '#==' do
|
8
|
+
it 'should return true only for equivalent flavors' do
|
9
|
+
f0 = {:x => :y}
|
10
|
+
f1 = described_class.new()
|
11
|
+
f2 = described_class.new()
|
12
|
+
f3 = described_class.new()
|
13
|
+
f3.groups = [:test]
|
14
|
+
|
15
|
+
f1.should_not == f0
|
16
|
+
f1.should == f1
|
17
|
+
f1.should == f2
|
18
|
+
f1.should_not == f3
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#clone' do
|
23
|
+
before :each do
|
24
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
25
|
+
|
26
|
+
@flavor = described_class.new()
|
27
|
+
@flavor.repo_name = '@test_repo_path'
|
28
|
+
@flavor.repo_uri = @test_repo_path
|
29
|
+
@flavor.locked_version = '1.0.0'
|
30
|
+
end
|
31
|
+
|
32
|
+
after :each do
|
33
|
+
clean_up_stashed_stuffs()
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should clone the repository into a given path' do
|
37
|
+
create_a_test_repo(@test_repo_path)
|
38
|
+
|
39
|
+
File.exists?(@flavor.cached_repo_path).should be_false
|
40
|
+
|
41
|
+
@flavor.clone().should be_true
|
42
|
+
|
43
|
+
File.exists?(@flavor.cached_repo_path).should be_true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#fetch' do
|
48
|
+
before :each do
|
49
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
50
|
+
|
51
|
+
@flavor = described_class.new()
|
52
|
+
@flavor.repo_name = '@test_repo_path'
|
53
|
+
@flavor.repo_uri = @test_repo_path
|
54
|
+
@flavor.locked_version = '1.0.0'
|
55
|
+
end
|
56
|
+
|
57
|
+
after :each do
|
58
|
+
clean_up_stashed_stuffs()
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should fail if the repository is not cloned yet' do
|
62
|
+
expect {
|
63
|
+
@flavor.fetch()
|
64
|
+
}.to raise_error(RuntimeError)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should fetch recent changes from the repository' do
|
68
|
+
create_a_test_repo(@test_repo_path)
|
69
|
+
@flavor.clone()
|
70
|
+
cloned_id = %x{
|
71
|
+
cd #{@flavor.cached_repo_path.inspect}
|
72
|
+
git rev-list -n1 HEAD
|
73
|
+
}
|
74
|
+
|
75
|
+
update_a_test_repo(@test_repo_path)
|
76
|
+
|
77
|
+
@flavor.fetch()
|
78
|
+
%x{
|
79
|
+
cd #{@flavor.cached_repo_path.inspect}
|
80
|
+
git rev-list -n1 HEAD
|
81
|
+
}.should == cloned_id
|
82
|
+
fetch_id = %x{
|
83
|
+
cd #{@flavor.cached_repo_path.inspect}
|
84
|
+
git rev-list -n1 FETCH_HEAD
|
85
|
+
}.should_not == cloned_id
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#deploy' do
|
90
|
+
before :each do
|
91
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
92
|
+
|
93
|
+
@flavor = described_class.new()
|
94
|
+
@flavor.repo_name = '@test_repo_path'
|
95
|
+
@flavor.repo_uri = @test_repo_path
|
96
|
+
@flavor.locked_version = '1.0.0'
|
97
|
+
|
98
|
+
@vimfiles_path = "#{Vim::Flavor::DOT_PATH}/vimfiles"
|
99
|
+
@deploy_path = @flavor.make_deploy_path(@vimfiles_path)
|
100
|
+
end
|
101
|
+
|
102
|
+
after :each do
|
103
|
+
clean_up_stashed_stuffs()
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should deploy files of a locked version to a given path' do
|
107
|
+
create_a_test_repo(@test_repo_path)
|
108
|
+
@flavor.clone()
|
109
|
+
|
110
|
+
File.exists?(@deploy_path).should be_false
|
111
|
+
|
112
|
+
@flavor.deploy(@vimfiles_path)
|
113
|
+
|
114
|
+
File.exists?(@deploy_path).should be_true
|
115
|
+
File.exists?("#{@deploy_path}/autoload/foo.vim").should be_true
|
116
|
+
File.exists?("#{@deploy_path}/doc/foo.txt").should be_true
|
117
|
+
File.exists?("#{@deploy_path}/plugin/foo.vim").should be_true
|
118
|
+
|
119
|
+
head_id = %x{
|
120
|
+
cd #{@flavor.cached_repo_path.inspect} &&
|
121
|
+
git rev-list -n1 HEAD
|
122
|
+
}
|
123
|
+
$?.should == 0
|
124
|
+
tag_id = %x{
|
125
|
+
cd #{@flavor.cached_repo_path.inspect} &&
|
126
|
+
git rev-list -n1 #{@flavor.locked_version.inspect}
|
127
|
+
}
|
128
|
+
$?.should == 0
|
129
|
+
head_id.should == tag_id
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should :helptags automatically' do
|
133
|
+
create_a_test_repo(@test_repo_path)
|
134
|
+
@flavor.clone()
|
135
|
+
|
136
|
+
File.exists?("#{@deploy_path}/doc/tags").should be_false
|
137
|
+
|
138
|
+
@flavor.deploy(@vimfiles_path)
|
139
|
+
|
140
|
+
File.exists?("#{@deploy_path}/doc/tags").should be_true
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should not care about existing content' do
|
144
|
+
create_a_test_repo(@test_repo_path)
|
145
|
+
@flavor.clone()
|
146
|
+
|
147
|
+
@flavor.deploy(@vimfiles_path)
|
148
|
+
system(<<-"END")
|
149
|
+
touch '#{@deploy_path}/plugin/oldname.vim'
|
150
|
+
END
|
151
|
+
|
152
|
+
File.exists?("#{@deploy_path}/plugin/oldname.vim").should be_true
|
153
|
+
|
154
|
+
@flavor.deploy(@vimfiles_path)
|
155
|
+
|
156
|
+
File.exists?("#{@deploy_path}/plugin/oldname.vim").should be_true
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe '#undeploy' do
|
161
|
+
before :each do
|
162
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
163
|
+
|
164
|
+
@flavor = described_class.new()
|
165
|
+
@flavor.repo_name = '@test_repo_path'
|
166
|
+
@flavor.repo_uri = @test_repo_path
|
167
|
+
@flavor.locked_version = '1.0.0'
|
168
|
+
|
169
|
+
@vimfiles_path = "#{Vim::Flavor::DOT_PATH}/vimfiles"
|
170
|
+
@deploy_path = @flavor.make_deploy_path(@vimfiles_path)
|
171
|
+
end
|
172
|
+
|
173
|
+
after :each do
|
174
|
+
clean_up_stashed_stuffs()
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'should remove deployed files' do
|
178
|
+
create_a_test_repo(@test_repo_path)
|
179
|
+
@flavor.clone()
|
180
|
+
@flavor.deploy(@vimfiles_path)
|
181
|
+
|
182
|
+
File.exists?(@deploy_path).should be_true
|
183
|
+
|
184
|
+
@flavor.undeploy(@vimfiles_path)
|
185
|
+
|
186
|
+
File.exists?(@deploy_path).should be_false
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe '#list_versions' do
|
191
|
+
before :each do
|
192
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
193
|
+
|
194
|
+
@flavor = described_class.new()
|
195
|
+
@flavor.repo_name = '@test_repo_path'
|
196
|
+
@flavor.repo_uri = @test_repo_path
|
197
|
+
@flavor.locked_version = '1.0.0'
|
198
|
+
end
|
199
|
+
|
200
|
+
after :each do
|
201
|
+
clean_up_stashed_stuffs()
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'should list tags as versions' do
|
205
|
+
create_a_test_repo(@test_repo_path)
|
206
|
+
@flavor.clone()
|
207
|
+
@flavor.list_versions().should == [
|
208
|
+
'1.0.0',
|
209
|
+
'1.1.1',
|
210
|
+
'1.1.2',
|
211
|
+
'1.2.1',
|
212
|
+
'1.2.2',
|
213
|
+
].map {|vs| Gem::Version.create(vs)}
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe '#update_locked_version' do
|
218
|
+
before :each do
|
219
|
+
@test_repo_path = "#{Vim::Flavor::DOT_PATH}/test/origin"
|
220
|
+
|
221
|
+
@flavor = described_class.new()
|
222
|
+
@flavor.repo_name = '@test_repo_path'
|
223
|
+
@flavor.repo_uri = @test_repo_path
|
224
|
+
@flavor.locked_version = nil
|
225
|
+
end
|
226
|
+
|
227
|
+
after :each do
|
228
|
+
clean_up_stashed_stuffs()
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should update locked_version according to version_contraint' do
|
232
|
+
create_a_test_repo(@test_repo_path)
|
233
|
+
@flavor.clone()
|
234
|
+
|
235
|
+
@flavor.version_contraint =
|
236
|
+
Vim::Flavor::VersionConstraint.new('>= 0')
|
237
|
+
@flavor.update_locked_version()
|
238
|
+
@flavor.locked_version.should == Gem::Version.create('1.2.2')
|
239
|
+
|
240
|
+
@flavor.version_contraint =
|
241
|
+
Vim::Flavor::VersionConstraint.new('~> 1.1.0')
|
242
|
+
@flavor.update_locked_version()
|
243
|
+
@flavor.locked_version.should == Gem::Version.create('1.1.2')
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'vim-flavor'
|
3
|
+
|
4
|
+
describe Vim::Flavor::FlavorFile do
|
5
|
+
describe 'flavor' do
|
6
|
+
before :each do
|
7
|
+
@ff = described_class.new()
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should treat "$USER/$REPO" as a GitHub repository' do
|
11
|
+
@ff.interpret do
|
12
|
+
flavor 'kana/vim-textobj-indent'
|
13
|
+
end
|
14
|
+
|
15
|
+
f = @ff.flavors.values[0]
|
16
|
+
f.repo_name.should == 'kana/vim-textobj-indent'
|
17
|
+
f.repo_uri.should == 'git://github.com/kana/vim-textobj-indent.git'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should treat "$REPO" as a repository under vim-scripts.org' do
|
21
|
+
@ff.interpret do
|
22
|
+
flavor 'fakeclip'
|
23
|
+
end
|
24
|
+
|
25
|
+
f = @ff.flavors.values[0]
|
26
|
+
f.repo_name.should == 'fakeclip'
|
27
|
+
f.repo_uri.should == 'git://github.com/vim-scripts/fakeclip.git'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should treat "git://..." as an arbitrary Git repository' do
|
31
|
+
@ff.interpret do
|
32
|
+
flavor 'git://github.com/kana/vim-smartinput.git'
|
33
|
+
end
|
34
|
+
|
35
|
+
f = @ff.flavors.values[0]
|
36
|
+
f.repo_name.should == 'git://github.com/kana/vim-smartinput.git'
|
37
|
+
f.repo_uri.should == 'git://github.com/kana/vim-smartinput.git'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should treat "https://..." as an arbitrary Git repository' do
|
41
|
+
@ff.interpret do
|
42
|
+
flavor 'https://kana@github.com/kana/vim-smartinput.git'
|
43
|
+
end
|
44
|
+
|
45
|
+
f = @ff.flavors.values[0]
|
46
|
+
f.repo_name.should == 'https://kana@github.com/kana/vim-smartinput.git'
|
47
|
+
f.repo_uri.should == 'https://kana@github.com/kana/vim-smartinput.git'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should use no version constraint by default' do
|
51
|
+
@ff.interpret do
|
52
|
+
flavor 'kana/vim-textobj-indent'
|
53
|
+
end
|
54
|
+
|
55
|
+
f = @ff.flavors.values[0]
|
56
|
+
f.version_contraint.base_version.version.should == '0'
|
57
|
+
f.version_contraint.operator.should == '>='
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should use a given version contraint' do
|
61
|
+
@ff.interpret do
|
62
|
+
flavor 'kana/vim-textobj-indent', '~> 0.1.0'
|
63
|
+
end
|
64
|
+
|
65
|
+
f = @ff.flavors.values[0]
|
66
|
+
f.version_contraint.base_version.version.should == '0.1.0'
|
67
|
+
f.version_contraint.operator.should == '~>'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should categorize the given plugin into the :default group' do
|
71
|
+
@ff.interpret do
|
72
|
+
flavor 'kana/vim-textobj-indent'
|
73
|
+
end
|
74
|
+
|
75
|
+
f = @ff.flavors.values[0]
|
76
|
+
f.groups.should == [:default]
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should categorize the given plugin into the specified groups' do
|
80
|
+
@ff.interpret do
|
81
|
+
flavor 'kana/vim-textobj-entire'
|
82
|
+
flavor 'kana/vim-textobj-indent', :groups => [:development]
|
83
|
+
flavor 'kana/vim-textobj-syntax', :groups => [:test]
|
84
|
+
end
|
85
|
+
|
86
|
+
fe = @ff.flavors['git://github.com/kana/vim-textobj-entire.git']
|
87
|
+
fe.groups.should == [:default]
|
88
|
+
fi = @ff.flavors['git://github.com/kana/vim-textobj-indent.git']
|
89
|
+
fi.groups.should == [:default, :development]
|
90
|
+
fs = @ff.flavors['git://github.com/kana/vim-textobj-syntax.git']
|
91
|
+
fs.groups.should == [:default, :test]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'group' do
|
96
|
+
before :each do
|
97
|
+
@ff = described_class.new()
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should categorize inner flavors into the specified groups' do
|
101
|
+
@ff.interpret do
|
102
|
+
flavor 'kana/vim-textobj-entire'
|
103
|
+
|
104
|
+
group :development do
|
105
|
+
flavor 'kana/vim-textobj-indent'
|
106
|
+
end
|
107
|
+
|
108
|
+
group :test do
|
109
|
+
flavor 'kana/vim-textobj-syntax', :groups => [:development]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
fe = @ff.flavors['git://github.com/kana/vim-textobj-entire.git']
|
114
|
+
fe.groups.should == [:default]
|
115
|
+
fi = @ff.flavors['git://github.com/kana/vim-textobj-indent.git']
|
116
|
+
fi.groups.should == [:default, :development]
|
117
|
+
fs = @ff.flavors['git://github.com/kana/vim-textobj-syntax.git']
|
118
|
+
fs.groups.should == [:default, :test, :development]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'vim-flavor'
|
4
|
+
|
5
|
+
describe Vim::Flavor::LockFile do
|
6
|
+
before :each do
|
7
|
+
@lockfile_path = "#{Vim::Flavor::DOT_PATH}/VimFlavor.lock"
|
8
|
+
end
|
9
|
+
|
10
|
+
after :each do
|
11
|
+
FileUtils.rm_rf([Vim::Flavor::DOT_PATH], :secure => true)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should be initialized with a given path and no flavor' do
|
15
|
+
lf = described_class.new(@lockfile_path)
|
16
|
+
|
17
|
+
lf.path.should == @lockfile_path
|
18
|
+
lf.flavors.should be_empty
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should be able to persist its content' do
|
22
|
+
@flavor1 = Vim::Flavor::Flavor.new()
|
23
|
+
@flavor1.groups = [:default]
|
24
|
+
@flavor1.locked_version = Gem::Version.create('1.2.3')
|
25
|
+
@flavor1.repo_name = 'kana/vim-smartinput'
|
26
|
+
@flavor1.repo_uri = 'git://github.com/kana/vim-smartinput.git'
|
27
|
+
@flavor1.version_contraint = Vim::Flavor::VersionConstraint.new('>= 0')
|
28
|
+
|
29
|
+
FileUtils.mkdir_p(File.dirname(@lockfile_path))
|
30
|
+
lf = described_class.new("#{@lockfile_path}.1")
|
31
|
+
|
32
|
+
lf.flavors.should be_empty
|
33
|
+
|
34
|
+
File.exists?(lf.path).should be_false
|
35
|
+
|
36
|
+
lf.save()
|
37
|
+
|
38
|
+
File.exists?(lf.path).should be_true
|
39
|
+
|
40
|
+
lf.flavors[@flavor1.repo_uri] = @flavor1
|
41
|
+
lf.load()
|
42
|
+
|
43
|
+
lf.flavors.should be_empty
|
44
|
+
|
45
|
+
lf.flavors[@flavor1.repo_uri] = @flavor1
|
46
|
+
lf.save()
|
47
|
+
lf.load()
|
48
|
+
|
49
|
+
lf.flavors.should == {@flavor1.repo_uri => @flavor1}
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '::poro_from_flavors and ::flavors_from_poro' do
|
53
|
+
before :each do
|
54
|
+
@flavor1 = Vim::Flavor::Flavor.new()
|
55
|
+
@flavor1.groups = [:default]
|
56
|
+
@flavor1.locked_version = Gem::Version.create('1.2.3')
|
57
|
+
@flavor1.repo_name = 'kana/vim-smartinput'
|
58
|
+
@flavor1.repo_uri = 'git://github.com/kana/vim-smartinput.git'
|
59
|
+
@flavor1.version_contraint = Vim::Flavor::VersionConstraint.new('>= 0')
|
60
|
+
@flavor2 = Vim::Flavor::Flavor.new()
|
61
|
+
@flavor2.groups = [:default]
|
62
|
+
@flavor2.locked_version = Gem::Version.create('4.5.6')
|
63
|
+
@flavor2.repo_name = 'kana/vim-smarttill'
|
64
|
+
@flavor2.repo_uri = 'git://github.com/kana/vim-smarttill.git'
|
65
|
+
@flavor2.version_contraint = Vim::Flavor::VersionConstraint.new('>= 0')
|
66
|
+
@flavors = {
|
67
|
+
@flavor1.repo_uri => @flavor1,
|
68
|
+
@flavor2.repo_uri => @flavor2,
|
69
|
+
}
|
70
|
+
@flavors_in_poro = {
|
71
|
+
@flavor1.repo_uri => {
|
72
|
+
:groups => @flavor1.groups,
|
73
|
+
:locked_version => @flavor1.locked_version.to_s(),
|
74
|
+
:repo_name => @flavor1.repo_name,
|
75
|
+
:version_contraint => @flavor1.version_contraint.to_s(),
|
76
|
+
},
|
77
|
+
@flavor2.repo_uri => {
|
78
|
+
:groups => @flavor2.groups,
|
79
|
+
:locked_version => @flavor2.locked_version.to_s(),
|
80
|
+
:repo_name => @flavor2.repo_name,
|
81
|
+
:version_contraint => @flavor2.version_contraint.to_s(),
|
82
|
+
},
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should create PORO from flavors' do
|
87
|
+
described_class.poro_from_flavors(@flavors).should == @flavors_in_poro
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should create flavors from PORO' do
|
91
|
+
described_class.flavors_from_poro(@flavors_in_poro).should == @flavors
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|