vim-flavor 0.0.4 → 1.0.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.
Files changed (52) hide show
  1. data/.rspec +1 -0
  2. data/.travis.yml +4 -0
  3. data/README.md +3 -174
  4. data/Rakefile +10 -0
  5. data/features/.nav +12 -0
  6. data/features/README.md +17 -0
  7. data/features/caching.feature +50 -0
  8. data/features/command_line/README.md +9 -0
  9. data/features/command_line/progress_messages.feature +44 -0
  10. data/features/flavorfile/README.md +9 -0
  11. data/features/flavorfile/comments.feature +24 -0
  12. data/features/flavorfile/repository_name.feature +53 -0
  13. data/features/flavorfile/version_constraint.feature +52 -0
  14. data/features/install_vim_flavor.md +42 -0
  15. data/features/philosophy.md +90 -0
  16. data/features/resolve_dependencies.feature +16 -0
  17. data/features/step_definitions/bootstrap_script_steps.rb +7 -0
  18. data/features/step_definitions/cli_steps.rb +34 -0
  19. data/features/step_definitions/directory_steps.rb +23 -0
  20. data/features/step_definitions/flavor_steps.rb +37 -0
  21. data/features/step_definitions/flavorfile_steps.rb +12 -0
  22. data/features/step_definitions/lockfile_steps.rb +13 -0
  23. data/features/support/env.rb +49 -0
  24. data/features/typical_usage/README.md +63 -0
  25. data/features/typical_usage/deploy_to_arbitrary_place.feature +24 -0
  26. data/features/typical_usage/install_vim_plugins.feature +26 -0
  27. data/features/typical_usage/uninstall_vim_plugins.feature +31 -0
  28. data/features/typical_usage/upgrade_vim_plugins.feature +27 -0
  29. data/features/uninstall_vim_flavor.md +16 -0
  30. data/features/version_lock.feature +26 -0
  31. data/lib/vim-flavor.rb +2 -12
  32. data/lib/vim-flavor/cli.rb +16 -12
  33. data/lib/vim-flavor/enumerableextension.rb +48 -0
  34. data/lib/vim-flavor/facade.rb +65 -102
  35. data/lib/vim-flavor/flavor.rb +70 -63
  36. data/lib/vim-flavor/flavorfile.rb +15 -47
  37. data/lib/vim-flavor/lockfile.rb +27 -44
  38. data/lib/vim-flavor/lockfileparser.rb +65 -0
  39. data/lib/vim-flavor/stringextension.rb +25 -1
  40. data/lib/vim-flavor/version.rb +1 -1
  41. data/lib/vim-flavor/versionconstraint.rb +12 -11
  42. data/spec/enumerableextension_spec.rb +100 -0
  43. data/spec/facade_spec.rb +49 -540
  44. data/spec/flavor_spec.rb +50 -250
  45. data/spec/flavorfile_spec.rb +34 -110
  46. data/spec/lockfile_spec.rb +79 -89
  47. data/spec/spec_helper.rb +0 -65
  48. data/spec/stringextension_spec.rb +10 -6
  49. data/spec/versionconstraint_spec.rb +37 -119
  50. data/vim-flavor.gemspec +3 -1
  51. metadata +135 -46
  52. data/spec/cli_spec.rb +0 -15
data/spec/flavor_spec.rb CHANGED
@@ -1,255 +1,55 @@
1
- require 'bundler/setup'
2
- require 'fileutils'
3
1
  require 'spec_helper'
4
- require 'vim-flavor'
5
2
 
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
- with_temporary_directory
24
-
25
- before :each do
26
- @test_repo_path = "#{@tmp_path}/test/origin"
27
-
28
- @flavor = described_class.new()
29
- @flavor.repo_name = '@test_repo_path'
30
- @flavor.repo_uri = @test_repo_path
31
- @flavor.locked_version = Gem::Version.create('1.0.0')
32
- end
33
-
34
- it 'should clone the repository into a given path' do
35
- create_a_test_repo(@test_repo_path)
36
-
37
- File.exists?(@flavor.cached_repo_path).should be_false
38
-
39
- @flavor.clone().should be_true
40
-
41
- File.exists?(@flavor.cached_repo_path).should be_true
42
- end
43
- end
44
-
45
- describe '#fetch' do
46
- with_temporary_directory
47
-
48
- before :each do
49
- @test_repo_path = "#{@tmp_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 = Gem::Version.create('1.0.0')
55
- end
56
-
57
- it 'should fail if the repository is not cloned yet' do
58
- expect {
59
- @flavor.fetch()
60
- }.to raise_error(RuntimeError)
61
- end
62
-
63
- it 'should fetch recent changes from the repository' do
64
- create_a_test_repo(@test_repo_path)
65
- @flavor.clone()
66
- cloned_id = %x{
67
- cd #{@flavor.cached_repo_path.inspect}
68
- git rev-list -n1 HEAD
69
- }
70
-
71
- update_a_test_repo(@test_repo_path)
72
-
73
- @flavor.fetch()
74
- %x{
75
- cd #{@flavor.cached_repo_path.inspect}
76
- git rev-list -n1 HEAD
77
- }.should == cloned_id
78
- fetch_id = %x{
79
- cd #{@flavor.cached_repo_path.inspect}
80
- git rev-list -n1 FETCH_HEAD
81
- }.should_not == cloned_id
82
- end
83
- end
84
-
85
- describe '#deploy' do
86
- with_temporary_directory
87
-
88
- before :each do
89
- @test_repo_path = "#{@tmp_path}/test/origin"
90
-
91
- @flavor = described_class.new()
92
- @flavor.repo_name = '@test_repo_path'
93
- @flavor.repo_uri = @test_repo_path
94
- @flavor.locked_version = Gem::Version.create('1.0.0')
95
-
96
- @vimfiles_path = "#{@tmp_path}/vimfiles"
97
- @deploy_path = @flavor.make_deploy_path(@vimfiles_path)
98
- end
99
-
100
- it 'should deploy files of a locked version to a given path' do
101
- create_a_test_repo(@test_repo_path)
102
- @flavor.clone()
103
-
104
- File.exists?(@deploy_path).should be_false
105
-
106
- @flavor.deploy(@vimfiles_path)
107
-
108
- File.exists?(@deploy_path).should be_true
109
- File.exists?("#{@deploy_path}/autoload/foo.vim").should be_true
110
- File.exists?("#{@deploy_path}/doc/foo.txt").should be_true
111
- File.exists?("#{@deploy_path}/plugin/foo.vim").should be_true
112
-
113
- head_id = %x{
114
- cd #{@flavor.cached_repo_path.inspect} &&
115
- git rev-list -n1 HEAD
116
- }
117
- $?.should == 0
118
- tag_id = %x{
119
- cd #{@flavor.cached_repo_path.inspect} &&
120
- git rev-list -n1 '#{@flavor.locked_version}'
121
- }
122
- $?.should == 0
123
- head_id.should == tag_id
124
- end
125
-
126
- it 'should :helptags automatically' do
127
- create_a_test_repo(@test_repo_path)
128
- @flavor.clone()
129
-
130
- File.exists?("#{@deploy_path}/doc/tags").should be_false
131
-
132
- @flavor.deploy(@vimfiles_path)
133
-
134
- File.exists?("#{@deploy_path}/doc/tags").should be_true
135
- end
136
-
137
- it 'should not :helptags if the plugin does not contain any document' do
138
- create_a_test_repo(@test_repo_path)
139
- @flavor.clone()
140
- system(<<-"END")
141
- {
142
- cd '#{@flavor.cached_repo_path}' &&
143
- rm -r doc &&
144
- git commit -am 'Remove the document' &&
145
- git tag -f '#{@flavor.locked_version}'
146
- } >/dev/null 2>&1
147
- END
148
-
149
- File.exists?("#{@deploy_path}/doc").should be_false
150
- File.exists?("#{@deploy_path}/doc/tags").should be_false
151
-
152
- @flavor.deploy(@vimfiles_path)
153
-
154
- File.exists?("#{@deploy_path}/doc").should be_false
155
- File.exists?("#{@deploy_path}/doc/tags").should be_false
156
- end
157
-
158
- it 'should not care about existing content' do
159
- create_a_test_repo(@test_repo_path)
160
- @flavor.clone()
161
-
162
- @flavor.deploy(@vimfiles_path)
163
- system(<<-"END")
164
- touch '#{@deploy_path}/plugin/oldname.vim'
165
- END
166
-
167
- File.exists?("#{@deploy_path}/plugin/oldname.vim").should be_true
168
-
169
- @flavor.deploy(@vimfiles_path)
170
-
171
- File.exists?("#{@deploy_path}/plugin/oldname.vim").should be_true
172
- end
173
- end
174
-
175
- describe '#undeploy' do
176
- with_temporary_directory
177
-
178
- before :each do
179
- @test_repo_path = "#{@tmp_path}/test/origin"
180
-
181
- @flavor = described_class.new()
182
- @flavor.repo_name = '@test_repo_path'
183
- @flavor.repo_uri = @test_repo_path
184
- @flavor.locked_version = Gem::Version.create('1.0.0')
185
-
186
- @vimfiles_path = "#{@tmp_path}/vimfiles"
187
- @deploy_path = @flavor.make_deploy_path(@vimfiles_path)
188
- end
189
-
190
- it 'should remove deployed files' do
191
- create_a_test_repo(@test_repo_path)
192
- @flavor.clone()
193
- @flavor.deploy(@vimfiles_path)
194
-
195
- File.exists?(@deploy_path).should be_true
196
-
197
- @flavor.undeploy(@vimfiles_path)
198
-
199
- File.exists?(@deploy_path).should be_false
200
- end
201
- end
202
-
203
- describe '#list_versions' do
204
- with_temporary_directory
205
-
206
- before :each do
207
- @test_repo_path = "#{@tmp_path}/test/origin"
208
-
209
- @flavor = described_class.new()
210
- @flavor.repo_name = '@test_repo_path'
211
- @flavor.repo_uri = @test_repo_path
212
- @flavor.locked_version = Gem::Version.create('1.0.0')
213
- end
214
-
215
- it 'should list tags as versions' do
216
- create_a_test_repo(@test_repo_path)
217
- @flavor.clone()
218
- @flavor.list_versions().should == [
219
- '1.0.0',
220
- '1.1.1',
221
- '1.1.2',
222
- '1.2.1',
223
- '1.2.2',
224
- ].map {|vs| Gem::Version.create(vs)}
225
- end
226
- end
227
-
228
- describe '#update_locked_version' do
229
- with_temporary_directory
230
-
231
- before :each do
232
- @test_repo_path = "#{@tmp_path}/test/origin"
233
-
234
- @flavor = described_class.new()
235
- @flavor.repo_name = '@test_repo_path'
236
- @flavor.repo_uri = @test_repo_path
237
- @flavor.locked_version = nil
238
- end
239
-
240
- it 'should update locked_version according to version_contraint' do
241
- create_a_test_repo(@test_repo_path)
242
- @flavor.clone()
243
-
244
- @flavor.version_contraint =
245
- Vim::Flavor::VersionConstraint.new('>= 0')
246
- @flavor.update_locked_version()
247
- @flavor.locked_version.should == Gem::Version.create('1.2.2')
248
-
249
- @flavor.version_contraint =
250
- Vim::Flavor::VersionConstraint.new('~> 1.1.0')
251
- @flavor.update_locked_version()
252
- @flavor.locked_version.should == Gem::Version.create('1.1.2')
3
+ module Vim
4
+ module Flavor
5
+ describe Flavor do
6
+ describe '#versions_from_tags' do
7
+ def example tags, versions
8
+ f = Flavor.new()
9
+ f.versions_from_tags(tags).sort.map(&:version).should == versions
10
+ end
11
+
12
+ it 'converts tags into versions' do
13
+ example ['1.2', '2.4.6', '3.6'], ['1.2', '2.4.6', '3.6']
14
+ end
15
+
16
+ it 'accepts also prelerease tags' do
17
+ example ['1.2a', '2.4.6b', '3.6c'], ['1.2a', '2.4.6b', '3.6c']
18
+ end
19
+
20
+ it 'drops non-version tags' do
21
+ example ['1.2', '2.4.6_', 'test', '2.9'], ['1.2', '2.9']
22
+ end
23
+ end
24
+
25
+ describe '#satisfied_with?' do
26
+ subject {
27
+ f = Flavor.new()
28
+ f.repo_name = 'foo'
29
+ f.version_constraint = VersionConstraint.new('>= 1.2.3')
30
+ f
31
+ }
32
+
33
+ def locked_flavor(repo_name, locked_version)
34
+ f = Flavor.new()
35
+ f.repo_name = repo_name
36
+ f.locked_version = locked_version
37
+ f
38
+ end
39
+
40
+ it {should be_satisfied_with locked_flavor('foo', '1.2.3')}
41
+
42
+ it {should be_satisfied_with locked_flavor('foo', '1.2.4')}
43
+ it {should be_satisfied_with locked_flavor('foo', '1.3.3')}
44
+ it {should be_satisfied_with locked_flavor('foo', '2.2.3')}
45
+
46
+ it {should_not be_satisfied_with locked_flavor('foo', '0.2.3')}
47
+ it {should_not be_satisfied_with locked_flavor('foo', '1.1.3')}
48
+ it {should_not be_satisfied_with locked_flavor('foo', '1.2.2')}
49
+
50
+ it {should_not be_satisfied_with locked_flavor('bar', '1.2.3')}
51
+ end
253
52
  end
254
53
  end
255
54
  end
55
+
@@ -1,122 +1,46 @@
1
- require 'bundler/setup'
2
1
  require 'spec_helper'
3
- require 'vim-flavor'
4
2
 
5
- describe Vim::Flavor::FlavorFile do
6
- describe 'flavor' do
7
- before :each do
8
- @ff = described_class.new()
9
- end
10
-
11
- it 'should treat "$USER/$REPO" as a GitHub repository' do
12
- @ff.interpret do
13
- flavor 'kana/vim-textobj-indent'
14
- end
15
-
16
- f = @ff.flavors.values[0]
17
- f.repo_name.should == 'kana/vim-textobj-indent'
18
- f.repo_uri.should == 'git://github.com/kana/vim-textobj-indent.git'
19
- end
20
-
21
- it 'should treat "$REPO" as a repository under vim-scripts.org' do
22
- @ff.interpret do
23
- flavor 'fakeclip'
24
- end
25
-
26
- f = @ff.flavors.values[0]
27
- f.repo_name.should == 'fakeclip'
28
- f.repo_uri.should == 'git://github.com/vim-scripts/fakeclip.git'
29
- end
30
-
31
- it 'should treat "git://..." as an arbitrary Git repository' do
32
- @ff.interpret do
33
- flavor 'git://github.com/kana/vim-smartinput.git'
34
- end
35
-
36
- f = @ff.flavors.values[0]
37
- f.repo_name.should == 'git://github.com/kana/vim-smartinput.git'
38
- f.repo_uri.should == 'git://github.com/kana/vim-smartinput.git'
39
- end
40
-
41
- it 'should treat "https://..." as an arbitrary Git repository' do
42
- @ff.interpret do
43
- flavor 'https://kana@github.com/kana/vim-smartinput.git'
44
- end
45
-
46
- f = @ff.flavors.values[0]
47
- f.repo_name.should == 'https://kana@github.com/kana/vim-smartinput.git'
48
- f.repo_uri.should == 'https://kana@github.com/kana/vim-smartinput.git'
49
- end
50
-
51
- it 'should use no version constraint by default' do
52
- @ff.interpret do
53
- flavor 'kana/vim-textobj-indent'
54
- end
55
-
56
- f = @ff.flavors.values[0]
57
- f.version_contraint.base_version.version.should == '0'
58
- f.version_contraint.operator.should == '>='
59
- end
60
-
61
- it 'should use a given version contraint' do
62
- @ff.interpret do
63
- flavor 'kana/vim-textobj-indent', '~> 0.1.0'
64
- end
65
-
66
- f = @ff.flavors.values[0]
67
- f.version_contraint.base_version.version.should == '0.1.0'
68
- f.version_contraint.operator.should == '~>'
69
- end
70
-
71
- it 'should categorize the given plugin into the :default group' do
72
- @ff.interpret do
73
- flavor 'kana/vim-textobj-indent'
74
- end
75
-
76
- f = @ff.flavors.values[0]
77
- f.groups.should == [:default]
78
- end
3
+ module Vim
4
+ module Flavor
5
+ describe FlavorFile do
6
+ describe '#flavor' do
7
+ it 'registers a flavor' do
8
+ ff = FlavorFile.new()
9
+ ff.flavor 'kana/vim-altr', '>= 1.2.3'
10
+ f = ff.flavor_table['kana/vim-altr']
11
+ f.repo_name.should == 'kana/vim-altr'
12
+ f.version_constraint.should == VersionConstraint.new('>= 1.2.3')
13
+ end
79
14
 
80
- it 'should categorize the given plugin into the specified groups' do
81
- @ff.interpret do
82
- flavor 'kana/vim-textobj-entire'
83
- flavor 'kana/vim-textobj-indent', :groups => [:development]
84
- flavor 'kana/vim-textobj-syntax', :groups => [:test]
15
+ it 'completes version constraint if it is not given' do
16
+ ff = FlavorFile.new()
17
+ ff.flavor 'kana/vim-altr'
18
+ f = ff.flavor_table['kana/vim-altr']
19
+ f.repo_name.should == 'kana/vim-altr'
20
+ f.version_constraint.should == VersionConstraint.new('>= 0')
21
+ end
85
22
  end
86
23
 
87
- fe = @ff.flavors['git://github.com/kana/vim-textobj-entire.git']
88
- fe.groups.should == [:default]
89
- fi = @ff.flavors['git://github.com/kana/vim-textobj-indent.git']
90
- fi.groups.should == [:default, :development]
91
- fs = @ff.flavors['git://github.com/kana/vim-textobj-syntax.git']
92
- fs.groups.should == [:default, :test]
93
- end
94
- end
95
-
96
- describe 'group' do
97
- before :each do
98
- @ff = described_class.new()
99
- end
100
-
101
- it 'should categorize inner flavors into the specified groups' do
102
- @ff.interpret do
103
- flavor 'kana/vim-textobj-entire'
104
-
105
- group :development do
106
- flavor 'kana/vim-textobj-indent'
24
+ describe '.load' do
25
+ around(:each) do |example|
26
+ Dir.mktmpdir do |dir|
27
+ @tmp_path = dir
28
+ example.run
29
+ end
107
30
  end
108
31
 
109
- group :test do
110
- flavor 'kana/vim-textobj-syntax', :groups => [:development]
32
+ it 'loads a given flavorfile' do
33
+ flavorfile_path = @tmp_path.to_flavorfile_path
34
+ File.open(flavorfile_path, 'w') do |io|
35
+ io.write("flavor 'kana/vim-altr', '~> 1.2'\n")
36
+ end
37
+ ff = FlavorFile.load(flavorfile_path)
38
+ f = ff.flavor_table['kana/vim-altr']
39
+ f.repo_name.should == 'kana/vim-altr'
40
+ f.version_constraint.should == VersionConstraint.new('~> 1.2')
111
41
  end
112
42
  end
113
-
114
- fe = @ff.flavors['git://github.com/kana/vim-textobj-entire.git']
115
- fe.groups.should == [:default]
116
- fi = @ff.flavors['git://github.com/kana/vim-textobj-indent.git']
117
- fi.groups.should == [:default, :development]
118
- fs = @ff.flavors['git://github.com/kana/vim-textobj-syntax.git']
119
- fs.groups.should == [:default, :test, :development]
120
43
  end
121
44
  end
122
45
  end
46
+