vim-flavor 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,93 +1,83 @@
1
- require 'bundler/setup'
2
- require 'fileutils'
3
1
  require 'spec_helper'
4
- require 'vim-flavor'
5
-
6
- describe Vim::Flavor::LockFile do
7
- with_temporary_directory
8
-
9
- before :each do
10
- @lockfile_path = "#{@tmp_path}/VimFlavor.lock"
11
- end
12
-
13
- it 'should be initialized with a given path and no flavor' do
14
- lf = described_class.new(@lockfile_path)
15
-
16
- lf.path.should == @lockfile_path
17
- lf.flavors.should be_empty
18
- end
19
-
20
- it 'should be able to persist its content' do
21
- @flavor1 = Vim::Flavor::Flavor.new()
22
- @flavor1.groups = [:default]
23
- @flavor1.locked_version = Gem::Version.create('1.2.3')
24
- @flavor1.repo_name = 'kana/vim-smartinput'
25
- @flavor1.repo_uri = 'git://github.com/kana/vim-smartinput.git'
26
- @flavor1.version_contraint = Vim::Flavor::VersionConstraint.new('>= 0')
27
-
28
- FileUtils.mkdir_p(File.dirname(@lockfile_path))
29
- lf = described_class.new("#{@lockfile_path}.1")
30
-
31
- lf.flavors.should be_empty
32
-
33
- File.exists?(lf.path).should be_false
34
-
35
- lf.save()
36
-
37
- File.exists?(lf.path).should be_true
38
-
39
- lf.flavors[@flavor1.repo_uri] = @flavor1
40
- lf.load()
41
-
42
- lf.flavors.should be_empty
43
-
44
- lf.flavors[@flavor1.repo_uri] = @flavor1
45
- lf.save()
46
- lf.load()
47
-
48
- lf.flavors.should == {@flavor1.repo_uri => @flavor1}
49
- end
50
-
51
- describe '::poro_from_flavors and ::flavors_from_poro' do
52
- before :each do
53
- @flavor1 = Vim::Flavor::Flavor.new()
54
- @flavor1.groups = [:default]
55
- @flavor1.locked_version = Gem::Version.create('1.2.3')
56
- @flavor1.repo_name = 'kana/vim-smartinput'
57
- @flavor1.repo_uri = 'git://github.com/kana/vim-smartinput.git'
58
- @flavor1.version_contraint = Vim::Flavor::VersionConstraint.new('>= 0')
59
- @flavor2 = Vim::Flavor::Flavor.new()
60
- @flavor2.groups = [:default]
61
- @flavor2.locked_version = Gem::Version.create('4.5.6')
62
- @flavor2.repo_name = 'kana/vim-smarttill'
63
- @flavor2.repo_uri = 'git://github.com/kana/vim-smarttill.git'
64
- @flavor2.version_contraint = Vim::Flavor::VersionConstraint.new('>= 0')
65
- @flavors = {
66
- @flavor1.repo_uri => @flavor1,
67
- @flavor2.repo_uri => @flavor2,
68
- }
69
- @flavors_in_poro = {
70
- @flavor1.repo_uri => {
71
- :groups => @flavor1.groups,
72
- :locked_version => @flavor1.locked_version.to_s(),
73
- :repo_name => @flavor1.repo_name,
74
- :version_contraint => @flavor1.version_contraint.to_s(),
75
- },
76
- @flavor2.repo_uri => {
77
- :groups => @flavor2.groups,
78
- :locked_version => @flavor2.locked_version.to_s(),
79
- :repo_name => @flavor2.repo_name,
80
- :version_contraint => @flavor2.version_contraint.to_s(),
81
- },
82
- }
83
- end
84
-
85
- it 'should create PORO from flavors' do
86
- described_class.poro_from_flavors(@flavors).should == @flavors_in_poro
87
- end
88
-
89
- it 'should create flavors from PORO' do
90
- described_class.flavors_from_poro(@flavors_in_poro).should == @flavors
2
+ require 'tmpdir'
3
+
4
+ module Vim
5
+ module Flavor
6
+ describe LockFile do
7
+ around :each do |example|
8
+ Dir.mktmpdir do |tmp_path|
9
+ @tmp_path = tmp_path
10
+ example.run
11
+ end
12
+ end
13
+
14
+ def flavor(repo_name, locked_version)
15
+ f = Flavor.new()
16
+ f.repo_name = repo_name
17
+ f.locked_version = locked_version
18
+ f
19
+ end
20
+
21
+ it 'has flavors sorted by repo_name' do
22
+ l = LockFile.new(@tmp_path.to_lockfile_path)
23
+ foo = flavor('foo', '1.2.3')
24
+ bar = flavor('bar', '2.3.4')
25
+ baz = flavor('baz', '3.4.5')
26
+ [foo, bar, baz].each do |f|
27
+ l.flavor_table[f.repo_name] = f
28
+ end
29
+
30
+ l.flavors.should == [bar, baz, foo]
31
+ end
32
+
33
+ describe '::serialize_lock_status' do
34
+ it 'converts a flavor into an array of lines' do
35
+ LockFile.serialize_lock_status(flavor('foo', '1.2.3')).should ==
36
+ ['foo (1.2.3)']
37
+ end
38
+ end
39
+
40
+ describe '#load' do
41
+ it 'loads locked information from a lockfile' do
42
+ File.open(@tmp_path.to_lockfile_path, 'w') do |io|
43
+ io.write(<<-'END')
44
+ foo (1.2.3)
45
+ bar (2.3.4)
46
+ baz (3.4.5)
47
+ END
48
+ end
49
+
50
+ l = LockFile.new(@tmp_path.to_lockfile_path)
51
+ l.flavor_table.should be_empty
52
+
53
+ l.load()
54
+ l.flavor_table['foo'].repo_name.should == 'foo'
55
+ l.flavor_table['foo'].locked_version.should == '1.2.3'
56
+ l.flavor_table['bar'].repo_name.should == 'bar'
57
+ l.flavor_table['bar'].locked_version.should == '2.3.4'
58
+ l.flavor_table['baz'].repo_name.should == 'baz'
59
+ l.flavor_table['baz'].locked_version.should == '3.4.5'
60
+ end
61
+ end
62
+
63
+ describe '::load_or_new' do
64
+ it 'creates a new instance then loads a lockfile' do
65
+ File.open(@tmp_path.to_lockfile_path, 'w') do |io|
66
+ io.write(<<-'END')
67
+ foo (1.2.3)
68
+ END
69
+ end
70
+
71
+ l = LockFile.load_or_new(@tmp_path.to_lockfile_path)
72
+ l.flavor_table['foo'].repo_name.should == 'foo'
73
+ l.flavor_table['foo'].locked_version.should == '1.2.3'
74
+ end
75
+
76
+ it 'only creates a new instance if a given path does not exist' do
77
+ l = LockFile.load_or_new(@tmp_path.to_lockfile_path)
78
+ l.flavor_table.should be_empty
79
+ end
80
+ end
91
81
  end
92
82
  end
93
83
  end
data/spec/spec_helper.rb CHANGED
@@ -1,67 +1,2 @@
1
1
  require 'bundler/setup'
2
- require 'fileutils'
3
- require 'spec_helper'
4
- require 'tmpdir'
5
2
  require 'vim-flavor'
6
-
7
- def create_a_test_repo(path)
8
- system(<<-"END")
9
- {
10
- mkdir -p #{path.inspect}
11
- cd #{path.inspect}
12
- git init
13
- mkdir autoload doc plugin
14
- touch autoload/foo.vim doc/foo.txt plugin/foo.vim
15
- git add autoload doc plugin
16
- git commit -am 'Commit foo'
17
- for version in '1.0.0' '1.1.1' '1.1.2' '1.2.1' '1.2.2'
18
- do
19
- echo "*foo* $version" >doc/foo.txt
20
- git commit -am 'Update foo'
21
- git tag -a -m "Version $version" "$version"
22
- done
23
- for non_version in 'foo' 'bar' 'baz'
24
- do
25
- git tag -a -m "Non-version $non_version" "$non_version"
26
- done
27
- } >/dev/null
28
- END
29
- end
30
-
31
- def update_a_test_repo(path)
32
- system(<<-"END")
33
- {
34
- cd #{path.inspect} &&
35
- for version in '1.0.9' '1.1.9' '1.2.9' '1.3.9'
36
- do
37
- echo "*foo* $version" >doc/foo.txt
38
- git commit -am 'Update foo'
39
- git tag -a -m "Version $version" "$version"
40
- done
41
- } >/dev/null
42
- END
43
- end
44
-
45
- def create_temporary_directory()
46
- Dir.mktmpdir()
47
- end
48
-
49
- def remove_temporary_directory(path)
50
- FileUtils.remove_entry_secure(path)
51
- end
52
-
53
- def with_temporary_directory()
54
- before :each do
55
- @tmp_path = create_temporary_directory()
56
-
57
- @original_dot_path = Vim::Flavor.dot_path
58
- @dot_path = "#{@tmp_path}/.vim-flavor"
59
- Vim::Flavor.dot_path = @dot_path
60
- end
61
-
62
- after :each do
63
- Vim::Flavor.dot_path = @original_dot_path
64
-
65
- remove_temporary_directory(@tmp_path)
66
- end
67
- end
@@ -1,11 +1,15 @@
1
- require 'bundler/setup'
2
1
  require 'spec_helper'
3
- require 'vim-flavor'
4
2
 
5
- describe Vim::Flavor::StringExtension do
6
- describe '#to_flavors_path' do
7
- it 'should return a flavors path from a vimfiles path' do
8
- '~/.vim'.to_flavors_path().should == '~/.vim/flavors'
3
+ module Vim
4
+ module Flavor
5
+ describe StringExtension do
6
+ describe '#zap' do
7
+ it 'replace unsafe characters with "_"' do
8
+ 'fakeclip'.zap.should == 'fakeclip'
9
+ 'kana/vim-altr'.zap.should == 'kana_vim-altr'
10
+ 'git://example.com/foo.git'.zap.should == 'git___example.com_foo.git'
11
+ end
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -1,138 +1,56 @@
1
- require 'bundler/setup'
2
1
  require 'spec_helper'
3
- require 'vim-flavor'
4
2
 
5
- describe Vim::Flavor::VersionConstraint do
6
- before :all do
7
- @base_version_s = '1.2'
8
- @backward_compatible_versions = [
9
- '1.2.4',
10
- '1.2.10',
11
- '1.3.5',
12
- '1.10.100',
13
- ]
14
- @backward_incompatible_versions = [
15
- '2.0',
16
- '3000',
17
- ]
18
- @old_versions = [
19
- '1.1.1',
20
- '1.1',
21
- '0.2.4',
22
- ]
23
- end
3
+ module Vim
4
+ module Flavor
5
+ describe VersionConstraint do
6
+ describe '#compatible?' do
7
+ describe '>=' do
8
+ subject {VersionConstraint.new('>= 1.2.3')}
24
9
 
25
- it 'should accept ">=" operator' do
26
- vc = described_class.new('>= 0.0.0')
27
- vc.base_version.should == Gem::Version.create('0.0.0')
28
- vc.operator.should == '>='
29
- end
10
+ it {should be_compatible '1.2.3'}
30
11
 
31
- it 'should accept "~>" operator' do
32
- vc = described_class.new('~> 1.2.3')
33
- vc.base_version.should == Gem::Version.create('1.2.3')
34
- vc.operator.should == '~>'
35
- end
12
+ it {should be_compatible '1.2.4'}
13
+ it {should be_compatible '1.3.3'}
14
+ it {should be_compatible '2.2.3'}
36
15
 
37
- it 'should not accept unknown operators' do
38
- expect {
39
- described_class.new('?? 6.6.6')
40
- }.to raise_error(RuntimeError)
41
- end
16
+ it {should be_compatible '1.3'}
42
17
 
43
- it 'should not accept invalid format' do
44
- expect {
45
- described_class.new('6.6.6')
46
- }.to raise_error(RuntimeError)
47
- end
18
+ it {should_not be_compatible '1.2.2'}
19
+ it {should_not be_compatible '1.1.3'}
20
+ it {should_not be_compatible '0.2.3'}
48
21
 
49
- describe '#==' do
50
- it 'should compare instances by their properties' do
51
- vc_gc1 = described_class.new('~> 1')
52
- vc_ge1 = described_class.new('>= 1')
53
- vc_ge1d = described_class.new('>= 1')
54
- vc_ge2 = described_class.new('>= 2')
22
+ it {should_not be_compatible '1.2'}
23
+ end
55
24
 
56
- vc_ge1.should == vc_ge1d
57
- vc_ge1.should_not == vc_gc1
58
- vc_ge1.should_not == vc_ge2
59
- end
60
- end
25
+ describe '~>' do
26
+ subject {VersionConstraint.new('~> 1.2.3')}
61
27
 
62
- describe '>=' do
63
- it 'should be compatible with backward-compatible versions' do
64
- vc = described_class.new('>= ' + @base_version_s)
65
- @backward_compatible_versions.each do |v|
66
- vc.compatible?(v).should be_true
67
- end
68
- end
28
+ it {should be_compatible '1.2.3'}
69
29
 
70
- it 'should be compatible with backward-incompatible versions' do
71
- vc = described_class.new('>= ' + @base_version_s)
72
- @backward_incompatible_versions.each do |v|
73
- vc.compatible?(v).should be_true
74
- end
75
- end
30
+ it {should be_compatible '1.2.4'}
31
+ it {should_not be_compatible '1.3.3'}
32
+ it {should_not be_compatible '2.2.3'}
76
33
 
77
- it 'should not be compatible with any older versions' do
78
- vc = described_class.new('>= ' + @base_version_s)
79
- @old_versions.each do |v|
80
- vc.compatible?(v).should be_false
81
- end
82
- end
83
- end
34
+ it {should_not be_compatible '1.3'}
84
35
 
85
- describe '~>' do
86
- it 'should be compatible with backward-compatible versions' do
87
- vc = described_class.new('~> ' + @base_version_s)
88
- @backward_compatible_versions.each do |v|
89
- vc.compatible?(v).should be_true
90
- end
91
- end
36
+ it {should_not be_compatible '1.2.2'}
37
+ it {should_not be_compatible '1.1.3'}
38
+ it {should_not be_compatible '0.2.3'}
92
39
 
93
- it 'should not be compatible with backward-incompatible versions' do
94
- vc = described_class.new('~> ' + @base_version_s)
95
- @backward_incompatible_versions.each do |v|
96
- vc.compatible?(v).should be_false
40
+ it {should_not be_compatible '1.2'}
41
+ end
97
42
  end
98
- end
99
43
 
100
- it 'should not be compatible with any older versions' do
101
- vc = described_class.new('~> ' + @base_version_s)
102
- @old_versions.each do |v|
103
- vc.compatible?(v).should be_false
44
+ describe '#find_the_best_version' do
45
+ it 'returns the best version from given versions' do
46
+ VersionConstraint.new('>= 1.2.3').
47
+ find_the_best_version(['1.2.2', '1.2.3', '1.2.4', '1.3.3', '2.0']).
48
+ should == '2.0'
49
+ VersionConstraint.new('~> 1.2.3').
50
+ find_the_best_version(['1.2.2', '1.2.3', '1.2.4', '1.3.3', '2.0']).
51
+ should == '1.2.4'
52
+ end
104
53
  end
105
54
  end
106
55
  end
107
-
108
- describe 'find_the_best_version' do
109
- it 'should find the best version from given versions' do
110
- described_class.new('~> 1.2.3').find_the_best_version([
111
- '1.2.3',
112
- '1.2.6',
113
- '1.2.9',
114
- '1.3.0',
115
- '2.0.0',
116
- ].map {|vs| Gem::Version.create(vs)}).should ==
117
- Gem::Version.create('1.2.9')
118
-
119
- described_class.new('>= 0').find_the_best_version([
120
- '1.2.3',
121
- '1.2.6',
122
- '1.2.9',
123
- '1.3.0',
124
- '2.0.0',
125
- ].map {|vs| Gem::Version.create(vs)}).should ==
126
- Gem::Version.create('2.0.0')
127
- end
128
- end
129
-
130
- describe '#to_s' do
131
- it 'should convert into a string representation' do
132
- vc1 = described_class.new('~> 1.2.3')
133
- described_class.new(vc1.to_s()).should == vc1
134
- vc2 = described_class.new('>= 0')
135
- described_class.new(vc2.to_s()).should == vc2
136
- end
137
- end
138
56
  end
data/vim-flavor.gemspec CHANGED
@@ -15,7 +15,9 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ['lib']
16
16
  gem.version = Vim::Flavor::VERSION
17
17
 
18
- gem.add_dependency('thor', '~> 0.14.6')
18
+ gem.add_dependency('parslet', '~> 1.0')
19
+ gem.add_dependency('thor', '~> 0.14')
19
20
 
21
+ gem.add_development_dependency('cucumber', '~> 1.2')
20
22
  gem.add_development_dependency('rspec', '~> 2.8')
21
23
  end