vim-flavor 1.0.3 → 1.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.
data/README.md CHANGED
@@ -17,7 +17,6 @@
17
17
  # * kana/vim-textobj-indent requires kana/vim-textobj-user.
18
18
  # Such dependencies are automatically installed
19
19
  # if the flavored plugin declares its dependencies with VimFlavor file.
20
- # (FIXME: Resolving dependencies will be implemented later.)
21
20
  flavor 'kana/vim-textobj-indent'
22
21
 
23
22
  # * Declare using git://github.com/vim-scripts/fakeclip.git
@@ -0,0 +1,11 @@
1
+ Feature: `version` command
2
+ In order to know the current version of `vim-flavor`,
3
+ as a lazy Vim user,
4
+ I want to show it from command-line.
5
+
6
+ Scenario: Show the current version
7
+ When I run `vim-flavor version`
8
+ Then it should pass with template:
9
+ """
10
+ $version
11
+ """
@@ -65,8 +65,7 @@ exception is
65
65
  doesn't take care about required versions). The configuration file formats of
66
66
  vim-flavor are also used to describe dependencies of plugins with required
67
67
  versions. This means that vim-flavor installs plugins and their dependencies
68
- automatically (unfortunately this feature is not implemented yet, but it'll be
69
- available soon).
68
+ automatically.
70
69
 
71
70
  Any software should have enough and reproducible test cases.
72
71
  But existing implementations such as
@@ -0,0 +1,27 @@
1
+ Vim plugins sometimes require other plugins as libraries. For example,
2
+ [vim-textobj-entire](https://github.com/kana/vim-textobj-entire) provides text
3
+ objects to deal with the entire text in the current buffer. But it is hard to
4
+ properly implement text objects because of many pitfalls and repetitive
5
+ routines. So that vim-textobj-entire uses
6
+ [vim-textobj-user](https://github.com/kana/vim-textobj-user) to define text
7
+ objects in a simplified and declarative way. Therefore, if user wants to use
8
+ vim-textobj-entire, he or she must install both vim-textobj-entire and
9
+ vim-textobj-user.
10
+
11
+ But it is a boring task to install dependencies by hand. Even if the authors
12
+ of a plugin noted about dependencies in its document, such notes are often
13
+ overlooked.
14
+
15
+ So that `vim-flavor` automatically resolves dependencies of Vim plugins. If
16
+ a plugin declares its dependencies as a [flavorfile](flavorfile) and saves it
17
+ as `VimFlavor`, `vim-flavor` reads the file and automatically installs
18
+ dependencies according to the file.
19
+
20
+ `vim-flavor` also takes care about versions of Vim plugins. If two plugins
21
+ require the same plugin but required versions are not compatible to others,
22
+ installation will be stopped to avoid using Vim with a broken configuration.
23
+
24
+
25
+
26
+
27
+ <!-- vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=78 : -->
@@ -0,0 +1,150 @@
1
+ Feature: Resolve dependencies of Vim plugins
2
+ In order to hide details of dependencies,
3
+ as a lazy Vim user,
4
+ I want to resolve and install dependencies of Vim plugins automatically.
5
+
6
+ Scenario: Resolve 2-level dependencies
7
+ Given a repository "foo" with versions "1.0 1.1 2.0 2.1"
8
+ And a repository "bar" with versions "1.0 1.1 2.0 2.1"
9
+ And a repository "qux" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
10
+ """ruby
11
+ flavor '$foo_uri', '~> 1.0'
12
+ flavor '$bar_uri', '>= 1.0'
13
+ """
14
+ And a flavorfile with:
15
+ """ruby
16
+ flavor '$qux_uri'
17
+ """
18
+ When I run `vim-flavor install`
19
+ Then it should pass with template:
20
+ """
21
+ Checking versions...
22
+ Use $qux_uri ... 2.1
23
+ Use $bar_uri ... 2.1
24
+ Use $foo_uri ... 1.1
25
+ Deploying plugins...
26
+ $bar_uri 2.1 ... done
27
+ $foo_uri 1.1 ... done
28
+ $qux_uri 2.1 ... done
29
+ Completed.
30
+ """
31
+ And a lockfile is created with:
32
+ """
33
+ $bar_uri (2.1)
34
+ $foo_uri (1.1)
35
+ $qux_uri (2.1)
36
+ """
37
+ And a bootstrap script is created in "$home/.vim"
38
+ And a flavor "$foo_uri" version "1.1" is deployed to "$home/.vim"
39
+ And a flavor "$bar_uri" version "2.1" is deployed to "$home/.vim"
40
+ And a flavor "$qux_uri" version "2.1" is deployed to "$home/.vim"
41
+
42
+ Scenario: Resolve 3-level dependencies
43
+ Given a repository "foo" with versions "1.0 1.1 2.0 2.1"
44
+ And a repository "bar" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
45
+ """ruby
46
+ flavor '$foo_uri', '~> 1.0'
47
+ """
48
+ And a repository "qux" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
49
+ """ruby
50
+ flavor '$bar_uri', '~> 2.0'
51
+ """
52
+ And a flavorfile with:
53
+ """ruby
54
+ flavor '$qux_uri', '~> 1.0'
55
+ """
56
+ When I run `vim-flavor install`
57
+ Then it should pass with template:
58
+ """
59
+ Checking versions...
60
+ Use $qux_uri ... 1.1
61
+ Use $bar_uri ... 2.1
62
+ Use $foo_uri ... 1.1
63
+ Deploying plugins...
64
+ $bar_uri 2.1 ... done
65
+ $foo_uri 1.1 ... done
66
+ $qux_uri 1.1 ... done
67
+ Completed.
68
+ """
69
+ And a lockfile is created with:
70
+ """
71
+ $bar_uri (2.1)
72
+ $foo_uri (1.1)
73
+ $qux_uri (1.1)
74
+ """
75
+ And a bootstrap script is created in "$home/.vim"
76
+ And a flavor "$foo_uri" version "1.1" is deployed to "$home/.vim"
77
+ And a flavor "$bar_uri" version "2.1" is deployed to "$home/.vim"
78
+ And a flavor "$qux_uri" version "1.1" is deployed to "$home/.vim"
79
+
80
+ Scenario: Resolve dependencies of a plugin required by two or more plugins
81
+ Given a repository "foo" with versions "1.0 1.1 2.0 2.1"
82
+ And a repository "bar" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
83
+ """ruby
84
+ flavor '$foo_uri', '>= 1.0'
85
+ """
86
+ And a repository "qux" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
87
+ """ruby
88
+ flavor '$foo_uri', '~> 2.0'
89
+ """
90
+ And a flavorfile with:
91
+ """ruby
92
+ flavor '$bar_uri'
93
+ flavor '$qux_uri'
94
+ """
95
+ When I run `vim-flavor install`
96
+ Then it should pass with template:
97
+ """
98
+ Checking versions...
99
+ Use $bar_uri ... 2.1
100
+ Use $foo_uri ... 2.1
101
+ Use $qux_uri ... 2.1
102
+ Use $foo_uri ... 2.1
103
+ Deploying plugins...
104
+ $bar_uri 2.1 ... done
105
+ $foo_uri 2.1 ... done
106
+ $qux_uri 2.1 ... done
107
+ Completed.
108
+ """
109
+ And a lockfile is created with:
110
+ """
111
+ $bar_uri (2.1)
112
+ $foo_uri (2.1)
113
+ $qux_uri (2.1)
114
+ """
115
+ And a bootstrap script is created in "$home/.vim"
116
+ And a flavor "$foo_uri" version "2.1" is deployed to "$home/.vim"
117
+ And a flavor "$bar_uri" version "2.1" is deployed to "$home/.vim"
118
+ And a flavor "$qux_uri" version "2.1" is deployed to "$home/.vim"
119
+
120
+ Scenario: Resolve dependencies of a plugin required by plugins and user
121
+ Given a repository "foo" with versions "1.0 1.1 2.0 2.1"
122
+ And a repository "bar" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
123
+ """ruby
124
+ flavor '$foo_uri', '>= 1.0'
125
+ """
126
+ And a flavorfile with:
127
+ """ruby
128
+ flavor '$foo_uri'
129
+ flavor '$bar_uri'
130
+ """
131
+ When I run `vim-flavor install`
132
+ Then it should pass with template:
133
+ """
134
+ Checking versions...
135
+ Use $bar_uri ... 2.1
136
+ Use $foo_uri ... 2.1
137
+ Use $foo_uri ... 2.1
138
+ Deploying plugins...
139
+ $bar_uri 2.1 ... done
140
+ $foo_uri 2.1 ... done
141
+ Completed.
142
+ """
143
+ And a lockfile is created with:
144
+ """
145
+ $bar_uri (2.1)
146
+ $foo_uri (2.1)
147
+ """
148
+ And a bootstrap script is created in "$home/.vim"
149
+ And a flavor "$foo_uri" version "2.1" is deployed to "$home/.vim"
150
+ And a flavor "$bar_uri" version "2.1" is deployed to "$home/.vim"
@@ -0,0 +1,64 @@
1
+ Feature: Version conflict
2
+ In order to avoid using Vim with a broken configuration,
3
+ as a lazy Vim user,
4
+ I want to stop installation as soon as possible.
5
+
6
+ Scenario: Two or more plugins require incompatible versions of the same plugin
7
+ Given a repository "foo" with versions "1.0 1.1 2.0 2.1"
8
+ And a repository "bar" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
9
+ """ruby
10
+ flavor '$foo_uri', '~> 1.0'
11
+ """
12
+ And a repository "qux" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
13
+ """ruby
14
+ flavor '$foo_uri', '~> 2.0'
15
+ """
16
+ And a flavorfile with:
17
+ """ruby
18
+ flavor '$bar_uri'
19
+ flavor '$qux_uri'
20
+ """
21
+ When I run `vim-flavor install`
22
+ Then it should fail with template:
23
+ """
24
+ Checking versions...
25
+ Use $bar_uri ... 2.1
26
+ Use $foo_uri ... 1.1
27
+ Use $qux_uri ... 2.1
28
+ Use $foo_uri ... 2.1
29
+ Found incompatible declarations:
30
+ $foo_uri ~> 1.0 is required by $bar_uri
31
+ $foo_uri ~> 2.0 is required by $qux_uri
32
+ Please resolve the conflict.
33
+ """
34
+ And a bootstrap script is not created in "$home/.vim"
35
+ And a flavor "$foo_uri" is not deployed to "$home/.vim"
36
+ And a flavor "$bar_uri" is not deployed to "$home/.vim"
37
+ And a flavor "$qux_uri" is not deployed to "$home/.vim"
38
+
39
+ Scenario: Flavorfile and a plugin require incompatible versions of the same plugin
40
+ Given a repository "foo" with versions "1.0 1.1 2.0 2.1"
41
+ And a repository "bar" with versions "1.0 1.1 2.0 2.1" and a flavorfile:
42
+ """ruby
43
+ flavor '$foo_uri', '~> 1.0'
44
+ """
45
+ And a flavorfile with:
46
+ """ruby
47
+ flavor '$bar_uri'
48
+ flavor '$foo_uri', '>= 2.0'
49
+ """
50
+ When I run `vim-flavor install`
51
+ Then it should fail with template:
52
+ """
53
+ Checking versions...
54
+ Use $bar_uri ... 2.1
55
+ Use $foo_uri ... 1.1
56
+ Use $foo_uri ... 2.1
57
+ Found incompatible declarations:
58
+ $foo_uri ~> 1.0 is required by $bar_uri
59
+ $foo_uri >= 2.0 is required by you
60
+ Please resolve the conflict.
61
+ """
62
+ And a bootstrap script is not created in "$home/.vim"
63
+ And a flavor "$foo_uri" is not deployed to "$home/.vim"
64
+ And a flavor "$bar_uri" is not deployed to "$home/.vim"
@@ -1,6 +1,6 @@
1
- Then /^a bootstrap script is created in "(.+)"$/ do |v_vimfiles_path|
1
+ Then /^a bootstrap script (is|is not) created in "(.+)"$/ do |mode, v_vimfiles_path|
2
2
  p = expand(v_vimfiles_path).to_flavors_path.to_bootstrap_path
3
3
  steps %Q{
4
- Then a file named "#{p}" should exist
4
+ Then a file named "#{p}" #{mode == 'is' ? 'should' : 'should not'} exist
5
5
  }
6
6
  end
@@ -1,42 +1,50 @@
1
- Given /^a (?:(?:GitHub|local) )?repository "(.+)" with versions "(.+)"$/ do |basename, versions|
1
+ Given /^a (?:(?:GitHub|local) )?repository "([^"]*)"$/ do |basename|
2
2
  repository_path = make_repo_path(basename)
3
- doc_name = basename.split('/').last.sub(/^vim-/, '')
4
3
  variable_table["#{basename}_uri"] = make_repo_uri(basename)
5
4
  sh <<-"END"
6
5
  {
7
6
  mkdir -p '#{repository_path}' &&
8
7
  cd '#{repository_path}' &&
9
8
  git init &&
10
- mkdir doc &&
11
- for v in #{versions}
12
- do
13
- echo "*#{doc_name}* $v" >'doc/#{doc_name}.txt'
14
- git add doc
15
- git commit -m "Version $v"
16
- git tag -m "Version $v" "$v"
17
- done
9
+ echo 'README' >README.md &&
10
+ git add README.md &&
11
+ git commit -m 'Write README'
18
12
  } >/dev/null
19
13
  END
20
14
  end
21
15
 
22
- Given /^"(.+)" version "(.+)" is released$/ do |basename, version|
23
- repository_path = make_repo_path(basename)
24
- doc_name = basename.split('/').last.sub(/^vim-/, '')
25
- sh <<-"END"
26
- {
27
- cd '#{repository_path}' &&
28
- for v in #{version}
29
- do
30
- echo "*#{doc_name}* $v" >'doc/#{doc_name}.txt'
31
- git add doc
32
- git commit -m "Version $v"
33
- git tag -m "Version $v" "$v"
34
- done
35
- } >/dev/null
36
- END
16
+ Given /^the repository "([^"]*)" has versions "([^"]*)"$/ do |basename, versions|
17
+ add_new_versions_to_repo(basename, versions)
18
+ end
19
+
20
+ Given /^the repository "([^"]*)" has versions "([^"]*)" and a flavorfile:$/ do |basename, versions, flavorfile_content|
21
+ add_new_versions_to_repo(basename, versions, flavorfile_content)
22
+ end
23
+
24
+ Given /^a (?:(?:GitHub|local) )?repository "([^"]*)" with versions "([^"]*)"$/ do |basename, versions|
25
+ steps %Q{
26
+ Given a repository "#{basename}"
27
+ And the repository "#{basename}" has versions "#{versions}"
28
+ }
29
+ end
30
+
31
+ Given /^a (?:(?:GitHub|local) )?repository "([^"]*)" with versions "([^"]*)" and a flavorfile:$/ do |basename, versions, flavorfile_content|
32
+ steps %Q{
33
+ Given a repository "#{basename}"
34
+ And the repository "#{basename}" has versions "#{versions}" and a flavorfile:
35
+ """
36
+ #{flavorfile_content}
37
+ """
38
+ }
39
+ end
40
+
41
+ Given /^"([^"]*)" version "([^"]*)" is released$/ do |basename, version|
42
+ steps %Q{
43
+ Given the repository "#{basename}" has versions "#{version}"
44
+ }
37
45
  end
38
46
 
39
- Given /^a repository "(.+)" from offline cache$/ do |repo_name|
47
+ Given /^a repository "([^"]*)" from offline cache$/ do |repo_name|
40
48
  repository_path = make_repo_path(repo_name).sub(expand('$tmp/'), '')
41
49
  sh <<-"END"
42
50
  {
@@ -45,13 +53,13 @@ Given /^a repository "(.+)" from offline cache$/ do |repo_name|
45
53
  END
46
54
  end
47
55
 
48
- Given /^I disable network to the original repository of "(.+)"$/ do |basename|
56
+ Given /^I disable network to the original repository of "([^"]*)"$/ do |basename|
49
57
  steps %Q{
50
58
  Given I remove the directory "#{make_repo_path(basename)}"
51
59
  }
52
60
  end
53
61
 
54
- When /^I create a file named "(.+?)" in "(.+?)" deployed to "(.+?)"$/ do |file_name, v_repo_name, v_vimfiles_path|
62
+ When /^I create a file named "([^"]*)" in "([^"]*)" deployed to "([^"]*)"$/ do |file_name, v_repo_name, v_vimfiles_path|
55
63
  flavor_path = make_flavor_path(expand(v_vimfiles_path), expand(v_repo_name))
56
64
  steps %Q{
57
65
  When I write to "#{flavor_path}/#{file_name}" with:
@@ -60,7 +68,7 @@ When /^I create a file named "(.+?)" in "(.+?)" deployed to "(.+?)"$/ do |file_n
60
68
  }
61
69
  end
62
70
 
63
- Then /^a flavor "(.+)" version "(.+)" is deployed to "(.+)"$/ do |v_repo_name, version, v_vimfiles_path|
71
+ Then /^a flavor "([^"]*)" version "([^"]*)" is deployed to "([^"]*)"$/ do |v_repo_name, version, v_vimfiles_path|
64
72
  flavor_path = make_flavor_path(expand(v_vimfiles_path), expand(v_repo_name))
65
73
  basename = expand(v_repo_name).split('/').last.sub(/^vim-/, '')
66
74
  steps %Q{
@@ -72,14 +80,14 @@ Then /^a flavor "(.+)" version "(.+)" is deployed to "(.+)"$/ do |v_repo_name, v
72
80
  }
73
81
  end
74
82
 
75
- Then /^a flavor "(.+)" is not deployed to "(.+)"$/ do |v_repo_name, v_vimfiles_path|
83
+ Then /^a flavor "([^"]*)" is not deployed to "([^"]*)"$/ do |v_repo_name, v_vimfiles_path|
76
84
  flavor_path = make_flavor_path(expand(v_vimfiles_path), expand(v_repo_name))
77
85
  steps %Q{
78
86
  Then a directory named "#{flavor_path}" should not exist
79
87
  }
80
88
  end
81
89
 
82
- Then /^"(.+)" version "(.+)" is (?:(not) )?cached$/ do |v_repo_name, version, p|
90
+ Then /^"([^"]*)" version "([^"]*)" is (?:(not) )?cached$/ do |v_repo_name, version, p|
83
91
  d = make_cached_repo_path(expand(v_repo_name), expand('$home').to_stash_path)
84
92
  (system <<-"END").should == (p != 'not')
85
93
  {
@@ -89,7 +97,7 @@ Then /^"(.+)" version "(.+)" is (?:(not) )?cached$/ do |v_repo_name, version, p|
89
97
  END
90
98
  end
91
99
 
92
- Then /^a file named "(.+?)" (should(?: not)?) exist in "(.+?)" deployed to "(.+?)"$/ do |file_name, should, v_repo_name, v_vimfiles_path|
100
+ Then /^a file named "([^"]*)" (should(?: not)?) exist in "([^"]*)" deployed to "([^"]*)"$/ do |file_name, should, v_repo_name, v_vimfiles_path|
93
101
  flavor_path = make_flavor_path(expand(v_vimfiles_path), expand(v_repo_name))
94
102
  steps %Q{
95
103
  Then a file named "#{flavor_path}/#{file_name}" #{should} exist
@@ -6,6 +6,32 @@ require 'vim-flavor'
6
6
  class FakeUserEnvironment
7
7
  include Vim::Flavor::ShellUtility
8
8
 
9
+ def add_new_versions_to_repo(basename, versions, flavorfile_content = nil)
10
+ repository_path = make_repo_path(basename)
11
+ doc_name = basename.split('/').last.sub(/^vim-/, '')
12
+ sh <<-"END"
13
+ {
14
+ cd '#{repository_path}' &&
15
+ mkdir -p doc &&
16
+ for v in #{versions}
17
+ do
18
+ echo "*#{doc_name}* $v" >'doc/#{doc_name}.txt'
19
+ git add doc
20
+ #{
21
+ %Q{
22
+ cat <<'FF' >#{'.'.to_flavorfile_path}
23
+ #{expand(flavorfile_content)}
24
+ FF
25
+ git add #{'.'.to_flavorfile_path}
26
+ } if flavorfile_content
27
+ }
28
+ git commit -m "Version $v"
29
+ git tag -m "Version $v" "$v"
30
+ done
31
+ } >/dev/null
32
+ END
33
+ end
34
+
9
35
  def expand(virtual_path)
10
36
  virtual_path.gsub(/\$([a-z_]+)/) {
11
37
  variable_table[$1]
@@ -34,12 +60,16 @@ class FakeUserEnvironment
34
60
  end
35
61
 
36
62
  Before do
63
+ variable_table['version'] = Vim::Flavor::VERSION
64
+
37
65
  variable_table['tmp'] = File.absolute_path(current_dir)
38
66
 
39
67
  steps %Q{
40
68
  Given a directory named "home"
41
69
  }
42
70
  variable_table['home'] = File.absolute_path(File.join([current_dir, 'home']))
71
+
72
+ @aruba_timeout_seconds = 5
43
73
  end
44
74
 
45
75
  Aruba.configure do |config|
@@ -41,6 +41,7 @@ Feature: Dependencies
41
41
  Deploying plugins...
42
42
  kana/vim-textobj-user 0.3.12 ... done
43
43
  kana/vim-vspec 1.1.0 ... done
44
+ Completed.
44
45
  -------- Testing a Vim plugin
45
46
  Files=0, Tests=0, \d+ wallclock secs .*
46
47
  Result: NOTESTS
@@ -32,6 +32,7 @@ Feature: Failures
32
32
  Use kana/vim-vspec ... 1.1.0
33
33
  Deploying plugins...
34
34
  kana/vim-vspec 1.1.0 ... done
35
+ Completed.
35
36
  -------- Testing a Vim plugin
36
37
  Files=0, Tests=0, 0 wallclock secs (.*)
37
38
  Result: NOTESTS
@@ -41,6 +41,7 @@ Feature: Typical usage
41
41
  Use kana/vim-vspec ... 1.1.0
42
42
  Deploying plugins...
43
43
  kana/vim-vspec 1.1.0 ... done
44
+ Completed.
44
45
  -------- Testing a Vim plugin
45
46
  t/sh.t .. ok
46
47
  All tests successful.
@@ -30,6 +30,11 @@ module Vim
30
30
  Facade.new().test()
31
31
  end
32
32
 
33
+ desc 'version', 'Show the current version.'
34
+ def version
35
+ puts VERSION
36
+ end
37
+
33
38
  no_tasks do
34
39
  def default_vimfiles_path
35
40
  ENV['HOME'].to_vimfiles_path
@@ -3,15 +3,60 @@ require 'fileutils'
3
3
  module Vim
4
4
  module Flavor
5
5
  class Facade
6
- include ShellUtility
6
+ def install(vimfiles_path)
7
+ install_or_upgrade(:install, vimfiles_path)
8
+ end
7
9
 
8
- def trace message
9
- print message
10
+ def upgrade(vimfiles_path)
11
+ install_or_upgrade(:upgrade, vimfiles_path)
12
+ end
13
+
14
+ def test()
15
+ trace "-------- Preparing dependencies\n"
16
+
17
+ flavorfile = FlavorFile.load_or_new(Dir.getwd().to_flavorfile_path)
18
+ flavorfile.flavor 'kana/vim-vspec', '~> 1.0', :group => :development unless
19
+ flavorfile.flavor_table.has_key?('kana/vim-vspec')
20
+ lockfile = LockFile.load_or_new(Dir.getwd().to_lockfile_path)
21
+
22
+ refresh_flavors(
23
+ :install,
24
+ flavorfile,
25
+ lockfile,
26
+ [:runtime, :development],
27
+ Dir.getwd().to_stash_path.to_deps_path
28
+ )
29
+
30
+ trace "-------- Testing a Vim plugin\n"
31
+
32
+ prove_options = '--comments --failure --directives'
33
+ deps_path = Dir.getwd().to_stash_path.to_deps_path
34
+ vspec = "#{deps_path}/#{'kana/vim-vspec'.zap}/bin/vspec"
35
+ plugin_paths = lockfile.flavors.map {|f|
36
+ "#{deps_path}/#{f.repo_name.zap}"
37
+ }
38
+ succeeded = system %Q{
39
+ prove --ext '.t' #{prove_options} &&
40
+ prove --ext '.vim' #{prove_options} \
41
+ --exec '#{vspec} #{Dir.getwd()} #{plugin_paths.join(' ')}'
42
+ }
43
+ exit(1) unless succeeded
10
44
  end
11
45
 
12
- def refresh_flavors(mode, vimfiles_path)
46
+ def install_or_upgrade(mode, vimfiles_path)
13
47
  flavorfile = FlavorFile.load(Dir.getwd().to_flavorfile_path)
14
48
  lockfile = LockFile.load_or_new(Dir.getwd().to_lockfile_path)
49
+ refresh_flavors(
50
+ mode,
51
+ flavorfile,
52
+ lockfile,
53
+ [:runtime],
54
+ vimfiles_path.to_flavors_path
55
+ )
56
+ end
57
+
58
+ def refresh_flavors(mode, flavorfile, lockfile, groups, flavors_path)
59
+ trace "Checking versions...\n"
15
60
 
16
61
  lockfile.update(
17
62
  complete(
@@ -23,53 +68,79 @@ module Vim
23
68
  lockfile.save()
24
69
 
25
70
  deploy_flavors(
26
- lockfile.flavors.select {|f| f.group == :runtime},
27
- File.absolute_path(vimfiles_path).to_flavors_path
71
+ lockfile.flavors.select {|f| groups.include?(f.group)},
72
+ File.absolute_path(flavors_path)
28
73
  )
29
74
 
30
75
  trace "Completed.\n"
31
76
  end
32
77
 
33
- def install(vimfiles_path)
34
- refresh_flavors(:install, vimfiles_path)
78
+ def complete(current_flavor_table, locked_flavor_table, mode, level = 1)
79
+ nfs = complete_flavors(current_flavor_table, locked_flavor_table, mode, level, 'you')
80
+ nfgs = nfs.group_by {|nf| nf.repo_name}
81
+
82
+ Hash[
83
+ nfgs.keys.map {|repo_name|
84
+ nfg = nfgs[repo_name]
85
+ vs = nfg.group_by {|nf| nf.locked_version}.values
86
+ if 2 <= vs.length
87
+ ss = []
88
+ ss << 'Found incompatible declarations:'
89
+ nfg.each do |nf|
90
+ ss << " #{nf.repo_name} #{nf.version_constraint} is required by #{nf.requirer}"
91
+ end
92
+ ss << 'Please resolve the conflict.'
93
+ abort ss.join("\n")
94
+ end
95
+ [repo_name, nfg.first]
96
+ }
97
+ ]
35
98
  end
36
99
 
37
- def upgrade(vimfiles_path)
38
- refresh_flavors(:upgrade, vimfiles_path)
100
+ def complete_flavors(current_flavor_table, locked_flavor_table, mode, level, requirer)
101
+ current_flavor_table.values.map(&:dup).sort_by(&:repo_name).
102
+ on_failure {trace " failed\n"}.
103
+ flat_map {|nf|
104
+ complete_a_flavor(nf, locked_flavor_table, mode, level, requirer)
105
+ }
39
106
  end
40
107
 
41
- def complete(current_flavor_table, locked_flavor_table, mode)
42
- completed_flavor_table = {}
108
+ def complete_a_flavor(nf, locked_flavor_table, mode, level, requirer)
109
+ lf = locked_flavor_table[nf.repo_name]
110
+ [complete_a_flavor_itself(nf, lf, mode, level, requirer)] +
111
+ complete_a_flavor_dependencies(nf, locked_flavor_table, mode, level)
112
+ end
43
113
 
44
- trace "Checking versions...\n"
114
+ def complete_a_flavor_itself(nf, lf, mode, level, requirer)
115
+ trace "#{' ' * level}Use #{nf.repo_name} ..."
45
116
 
46
- current_flavor_table.values.map(&:dup).sort_by(&:repo_name).
47
- before_each {|nf| trace " Use #{nf.repo_name} ..."}.
48
- after_each {|nf| trace " #{nf.locked_version}\n"}.
49
- on_failure {trace " failed\n"}.
50
- each do |nf|
51
- lf = locked_flavor_table[nf.repo_name]
52
-
53
- already_cached = nf.cached?
54
- nf.clone() unless already_cached
117
+ already_cached = nf.cached?
118
+ nf.clone() unless already_cached
55
119
 
56
- if mode == :install and lf and nf.satisfied_with?(lf)
120
+ if mode == :install and lf and nf.satisfied_with?(lf)
121
+ if not nf.cached_version?(lf.locked_version)
122
+ nf.fetch()
57
123
  if not nf.cached_version?(lf.locked_version)
58
- nf.fetch()
59
- if not nf.cached_version?(lf.locked_version)
60
- raise RuntimeError, "#{nf.repo_name} is locked to #{lf.locked_version}, but no such version exists"
61
- end
124
+ raise RuntimeError, "#{nf.repo_name} is locked to #{lf.locked_version}, but no such version exists"
62
125
  end
63
- nf.use_specific_version(lf.locked_version)
64
- else
65
- nf.fetch() if already_cached
66
- nf.use_appropriate_version()
67
126
  end
68
-
69
- completed_flavor_table[nf.repo_name] = nf
127
+ nf.use_specific_version(lf.locked_version)
128
+ else
129
+ nf.fetch() if already_cached
130
+ nf.use_appropriate_version()
70
131
  end
71
132
 
72
- completed_flavor_table
133
+ nf.requirer = requirer
134
+
135
+ trace " #{nf.locked_version}\n"
136
+
137
+ nf
138
+ end
139
+
140
+ def complete_a_flavor_dependencies(nf, locked_flavor_table, mode, level)
141
+ nf.checkout()
142
+ ff = FlavorFile.load_or_new(nf.cached_repo_path.to_flavorfile_path)
143
+ complete_flavors(ff.flavor_table, locked_flavor_table, mode, level + 1, nf.repo_name)
73
144
  end
74
145
 
75
146
  def deploy_flavors(flavors, flavors_path)
@@ -155,43 +226,8 @@ module Vim
155
226
  end
156
227
  end
157
228
 
158
- def test()
159
- trace "-------- Preparing dependencies\n"
160
-
161
- flavorfile = FlavorFile.load_or_new(Dir.getwd().to_flavorfile_path)
162
- flavorfile.flavor 'kana/vim-vspec', '~> 1.0', :group => :development unless
163
- flavorfile.flavor_table.has_key?('kana/vim-vspec')
164
- lockfile = LockFile.load_or_new(Dir.getwd().to_lockfile_path)
165
-
166
- lockfile.update(
167
- complete(
168
- flavorfile.flavor_table,
169
- lockfile.flavor_table,
170
- :install
171
- )
172
- )
173
- lockfile.save()
174
-
175
- # FIXME: It's somewhat wasteful to refresh flavors every time.
176
- deploy_flavors(
177
- lockfile.flavors,
178
- Dir.getwd().to_stash_path.to_deps_path
179
- )
180
-
181
- trace "-------- Testing a Vim plugin\n"
182
-
183
- prove_options = '--comments --failure --directives'
184
- deps_path = Dir.getwd().to_stash_path.to_deps_path
185
- vspec = "#{deps_path}/#{'kana/vim-vspec'.zap}/bin/vspec"
186
- plugin_paths = lockfile.flavors.map {|f|
187
- "#{deps_path}/#{f.repo_name.zap}"
188
- }
189
- succeeded = system %Q{
190
- prove --ext '.t' #{prove_options} &&
191
- prove --ext '.vim' #{prove_options} \
192
- --exec '#{vspec} #{Dir.getwd()} #{plugin_paths.join(' ')}'
193
- }
194
- exit(1) unless succeeded
229
+ def trace message
230
+ print message
195
231
  end
196
232
  end
197
233
  end
@@ -16,6 +16,9 @@ module Vim
16
16
  # A version of a plugin to be installed.
17
17
  attr_accessor :locked_version
18
18
 
19
+ # repo_name of a flavor which requires this flavor.
20
+ attr_accessor :requirer
21
+
19
22
  # Return true if this flavor's repository is already cloned.
20
23
  def cached?
21
24
  Dir.exists?(cached_repo_path)
@@ -78,6 +81,15 @@ module Vim
78
81
  }
79
82
  end
80
83
 
84
+ def checkout()
85
+ sh %Q[
86
+ {
87
+ cd '#{cached_repo_path}' &&
88
+ git checkout -f '#{locked_version}'
89
+ } 2>&1
90
+ ]
91
+ end
92
+
81
93
  def deploy(flavors_path)
82
94
  deployment_path = make_deployment_path(flavors_path)
83
95
  sh %Q[
@@ -1,5 +1,5 @@
1
1
  module Vim
2
2
  module Flavor
3
- VERSION = '1.0.3'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vim-flavor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-07 00:00:00.000000000 Z
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parslet
@@ -116,6 +116,7 @@ files:
116
116
  - features/caching/edge_cases.feature
117
117
  - features/command_line/README.md
118
118
  - features/command_line/progress_messages.feature
119
+ - features/command_line/version.feature
119
120
  - features/flavorfile/README.md
120
121
  - features/flavorfile/comments.feature
121
122
  - features/flavorfile/groups.feature
@@ -123,7 +124,9 @@ files:
123
124
  - features/flavorfile/version_constraint.feature
124
125
  - features/install_vim_flavor.md
125
126
  - features/philosophy.md
126
- - features/resolve_dependencies.feature
127
+ - features/resolve_dependencies/README.md
128
+ - features/resolve_dependencies/basics.feature
129
+ - features/resolve_dependencies/version_conflict.feature
127
130
  - features/step_definitions/bootstrap_script_steps.rb
128
131
  - features/step_definitions/cli_steps.rb
129
132
  - features/step_definitions/dependency_steps.rb
@@ -197,6 +200,7 @@ test_files:
197
200
  - features/caching/edge_cases.feature
198
201
  - features/command_line/README.md
199
202
  - features/command_line/progress_messages.feature
203
+ - features/command_line/version.feature
200
204
  - features/flavorfile/README.md
201
205
  - features/flavorfile/comments.feature
202
206
  - features/flavorfile/groups.feature
@@ -204,7 +208,9 @@ test_files:
204
208
  - features/flavorfile/version_constraint.feature
205
209
  - features/install_vim_flavor.md
206
210
  - features/philosophy.md
207
- - features/resolve_dependencies.feature
211
+ - features/resolve_dependencies/README.md
212
+ - features/resolve_dependencies/basics.feature
213
+ - features/resolve_dependencies/version_conflict.feature
208
214
  - features/step_definitions/bootstrap_script_steps.rb
209
215
  - features/step_definitions/cli_steps.rb
210
216
  - features/step_definitions/dependency_steps.rb
@@ -1,16 +0,0 @@
1
- Feature: Resolve dependencies of Vim plugins
2
- In order to hide details of dependencies,
3
- as a lazy Vim user,
4
- I want to resolve and install dependencies of Vim plugins automatically.
5
-
6
- # TODO
7
- Scenario: Resolve 2-level dependencies
8
-
9
- # TODO
10
- Scenario: Resolve 3-level dependencies
11
-
12
- # TODO
13
- Scenario: Resolve dependencies of a plugin required by two or more plugins
14
-
15
- # TODO
16
- Scenario: Resolve dependencies of a plugin required by plugins and user