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
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ script: rake test
data/README.md CHANGED
@@ -1,83 +1,5 @@
1
1
  # vim-flavor, a tool to manage your favorite Vim plugins
2
2
 
3
-
4
-
5
-
6
- ## Set up the tool for a new-style plugin management
7
-
8
- ### Requirements
9
-
10
- * [Git](http://git-scm.com/) 1.7.9 or later
11
- * [Ruby](http://www.ruby-lang.org/) 1.9.2 or later
12
- * Recommendation: Use [RVM](http://beginrescueend.com/) or other tools
13
- for ease of installation across different envinronments.
14
- * [Vim](http://www.vim.org/) 7.3 or later
15
- * Note that Vim should be compiled as normal, big or huge version
16
- to use most of plugins.
17
-
18
-
19
- ### Supported platforms
20
-
21
- * Unix-like environments such as Linux, Mac OS X, etc.
22
- * Though Microsoft Windows is not directly supported,
23
- it is possible to manage Vim plugins via Cygwin or other environments.
24
-
25
-
26
- ### Installation steps
27
-
28
- gem install vim-flavor
29
-
30
-
31
- ### Installable plugins
32
-
33
- Not all Vim plugins can be installed with vim-flavor.
34
- vim-flavor can install plugins which meet the following conditions:
35
-
36
- * Plugins must have dedicated Git repositories.
37
- vim-flavor does not support other version control systems.
38
- This is an intentional design. Because:
39
- * [vim-scripts.org](http://vim-scripts.org/) provides
40
- [a comprehensive Git mirrors](https://github.com/vim-scripts) for
41
- [plugins uploaded to www.vim.org](http://www.vim.org/scripts/index.php).
42
- * Experimental plugins which are not uploaded to www.vim.org
43
- are usually found in [GitHub](https://github.com/).
44
- * Plugins must follow [the versioning pocilies of
45
- RubyGems](http://docs.rubygems.org/read/chapter/7#page26) and have "version"
46
- tags in their repositories. For example, if there is the version 1.2.3 of
47
- a plugin, its repository must have the tag `1.2.3`, and the files of the
48
- version 1.2.3 can be checked out via the tag `1.2.3`. In other words,
49
- plugins which do not have proper tags are not installabe.
50
- This is an intentional design. Because:
51
- * It's not possible to determine whether two versions are compatible or not
52
- without "version" tags. Compatibility is a big problem to resolve
53
- dependencies of plugins. For example, if plugin A requires plugin X 1.2.3
54
- or later while plugin B requires plugin X 2.0 or later, it's not possible
55
- to use A and B at the same time. Such problems should be detected before
56
- installing plugins.
57
- * Git mirrors by vim-scripts.org are tagged with version numbers.
58
- * Some Git repositories might not have "version" tags.
59
- Such plugins are not ready to use for everyone.
60
- So that it should not be installable.
61
- * Plugins must have proper directory structures.
62
- For example, directories such as `autoload`, `syntax` etc should exist in
63
- the roots of plugins.
64
- This is an intentional design. Because:
65
- * Git mirrors by vim-scripts.org have proper directory structures even if
66
- the original plugins are uploaded to www.vim.org without proper directory
67
- structures. (A good example is
68
- [a.vim](http://www.vim.org/scripts/script.php?script_id=31) and
69
- [its mirror](https://github.com/vim-scripts/a.vim).)
70
- * Other Git repositoris might not have proper directory structures.
71
- Such plugins are not ready to use for everyone.
72
- So that it should not be installable.
73
-
74
-
75
-
76
-
77
- ## Typical usage
78
-
79
- ### Start using vim-flavor
80
-
81
3
  cd $YOUR_REPOSITORY_FOR_DOTFILES
82
4
 
83
5
  cat >VimFlavor <<'END'
@@ -123,102 +45,9 @@ vim-flavor can install plugins which meet the following conditions:
123
45
  git add VimFlavor VimFlavor.lock vimrc
124
46
  git commit -m 'Use vim-flavor to manage my favorite Vim plugins'
125
47
 
126
-
127
- ### Upgrade all plugins to the latest version
128
-
129
- vim-flavor upgrade
130
-
131
- git add VimFlavor.lock
132
- git commit -m 'Upgrade my favorite Vim plugins'
133
-
134
-
135
- ### Add more plugins into your dotfile repository
136
-
137
- cat >>VimFlavor <<'END'
138
-
139
- flavor 'kana/vim-operator-replace'
140
-
141
- END
142
-
143
- # Fetch newly added plugins,
144
- # update VimFlavor.lock for the plugins,
145
- # then install the plugins into ~/.vim etc.
146
- vim-flavor install
147
-
148
- git add VimFlavor VimFlavor.lock
149
- git commit -m 'Use kana/vim-operator-replace'
150
-
151
-
152
- ### Remove plugins from your dotfile repository
153
-
154
- # Remove declarations of unused plugins from VimFlavor.
155
- sed -i~ -e '/vim-smartchr/d' VimFlavor
156
-
157
- # Update VimFlavor.lock for the removed plugins,
158
- # then clean up the plugins from ~/.vim etc.
159
- vim-flavor install
160
-
161
- git add VimFlavor VimFlavor.lock
162
- git commit -m 'Farewell kana/vim-smartchr'
163
-
164
-
165
-
166
- ### Install plugins into a non-standard directory
167
-
168
- vim-flavor install --vimfiles-path=/cygdrive/c/Users/kana/vimfiles
169
-
170
-
171
- ### Farewell to vim-flavor
172
-
173
- rm -r ~/.vim-flavor
174
- rm -r ~/.vim/flavors # or ~/vimfiles/flavors etc.
175
-
176
- cd $YOUR_REPOSITORY_FOR_DOTFILES
177
- rm VimFlavor VimFlavor.lock
178
- git commit -am 'Farewell to vim-flavor'
179
-
180
-
181
-
182
-
183
- ## Philosophy
184
-
185
- I know that there are several implementations for the same purpose and many
186
- users love them, but all of them do not meet my taste. That's why I wrote
187
- vim-flavor. The philosofy on vim-flavor is as follows:
188
-
189
- Whole configuration including *versions of plugins* should be under a version
190
- control system. All of existing implementations do not manage versions of
191
- plugins. This means that *it's not possible to use the same configuration
192
- across multiple environments* (the only one exception is using
193
- [pathogen](https://github.com/tpope/vim-pathogen) with Git submodules,
194
- but you'll find it's painful to manually manage many plugins).
195
-
196
- There should be a standard way to describe proper dependencies of plugins to
197
- install dependencies without explicit declarations. Most of existing
198
- implementations do not resolve dependencies automatically (the only one
199
- exception is
200
- [vim-addon-manager](https://github.com/MarcWeber/vim-addon-manager), but it
201
- doesn't take care about required versions). The configuration file formats of
202
- vim-flavor are also used to describe dependencies of plugins with required
203
- versions. This means that vim-flavor installs plugins and their dependencies
204
- automatically (unfortunately this feature is not implemented yet, but it'll be
205
- available soon).
206
-
207
- Any software should have enough and reproducable test cases.
208
- But existing implementations such as
209
- [vundle](https://github.com/gmarik/vundle) and
210
- [neobundle](https://github.com/Shougo/neobundle.vim) are not developed so.
211
- It's horrible for me.
212
-
213
- Installation steps should be small, be reproducable, and not affect existing
214
- envinronment as less as possible. Most of existing implementations require to
215
- manually tweak `~/.vim` etc. It's painful to set up such stuffs manually
216
- because a vimfiles path is varied on each platform.
217
-
218
- Finally, a tool and files deployed by the tool should be uninstalled easily.
219
- [Vimana](https://github.com/c9s/Vimana) does not meet this because it directly
220
- puts files into `~/.vim/colors` etc and it doesn't provide `uninstall`
221
- command.
48
+ See also
49
+ [the documentation on relish](https://www.relishapp.com/kana/vim-flavor) or
50
+ `features/` directory for the details.
222
51
 
223
52
 
224
53
 
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ task :test => [:spec, :cucumber]
5
+
6
+ task :spec do
7
+ sh 'bundle exec rspec'
8
+ end
9
+
10
+ task :cucumber do
11
+ sh 'bundle exec cucumber --format=progress'
12
+ end
data/features/.nav ADDED
@@ -0,0 +1,12 @@
1
+ - philosophy.md
2
+ - install_vim_flavor.md (Install vim-flavor)
3
+ - uninstall_vim_flavor.md (Uninstall vim-flavor)
4
+ - typical_usage:
5
+ - install_vim_plugins.feature
6
+ - upgrade_vim_plugins.feature
7
+ - uninstall_vim_plugins.feature
8
+ - deploy_to_arbitrary_place.feature
9
+ - flavorfile:
10
+ - version_lock.feature
11
+ - caching.feature
12
+ - resolve_dependencies.feature
@@ -0,0 +1,17 @@
1
+ vim-flavor is a tool to manage Vim plugins.
2
+
3
+
4
+
5
+
6
+ ## Issues
7
+
8
+ Both vim-flavor and its documentation are
9
+ [open source](https://github.com/kana/vim-flavor), and work in progress.
10
+ If you find it incomplete or confusing,
11
+ please [submit an issue](https://github.com/kana/vim-flavor/issues), or,
12
+ better yet, [a pull request](https://github.com/kana/vim-flavor/pulls).
13
+
14
+
15
+
16
+
17
+ <!-- vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=78 : -->
@@ -0,0 +1,50 @@
1
+ Feature: Caching
2
+ In order to finish deployment as fast as possible,
3
+ as a lazy Vim user,
4
+ I want to cache repositories of plugins which are installed before.
5
+
6
+ Background:
7
+ Given a temporary directory called 'tmp'
8
+ And a home directory called 'home' in '$tmp/home'
9
+ And a repository 'foo' with versions '1.0.0 1.0.1 1.0.2'
10
+ And flavorfile
11
+ """ruby
12
+ flavor '$foo_uri', '~> 1.0'
13
+ """
14
+ And I run `vim-flavor install`
15
+ And I disable network to the original repository of 'foo'
16
+
17
+ Scenario: Install plugins - locked and compatible with new flavorfile
18
+ Given I delete '$home/.vim'
19
+ When I run `vim-flavor install` again
20
+ Then I get lockfile
21
+ """
22
+ $foo_uri (1.0.2)
23
+ """
24
+ And I get flavor '$foo_uri' with '1.0.2' in '$home/.vim'
25
+
26
+ Scenario: Install plugins - locked but incompatible with new flavorfile
27
+ Given I edit flavorfile as
28
+ """ruby
29
+ flavor '$foo_uri', '~> 2.0'
30
+ """
31
+ When I run `vim-flavor install` but
32
+ Then it fails with messages like
33
+ """
34
+ fatal: \S+ does not appear to be a git repository
35
+ """
36
+
37
+ Scenario: Install plugins - not locked
38
+ Given I delete lockfile
39
+ When I run `vim-flavor install` but
40
+ Then it fails with messages like
41
+ """
42
+ fatal: \S+ does not appear to be a git repository
43
+ """
44
+
45
+ Scenario: Upgrading plugins
46
+ When I run `vim-flavor upgrade` but
47
+ Then it fails with messages like
48
+ """
49
+ fatal: \S+ does not appear to be a git repository
50
+ """
@@ -0,0 +1,9 @@
1
+ The `vim-flavor` command comes with a few subcommands and options.
2
+ For a full list of available subcommands, try the `help` subcommand:
3
+
4
+ $ vim-flavor help
5
+
6
+
7
+
8
+
9
+ <!-- vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=78 : -->
@@ -0,0 +1,44 @@
1
+ Feature: Progress messages
2
+ In order to know what is going on,
3
+ as a lazy Vim user,
4
+ I want to see messages about the current progress.
5
+
6
+ Background:
7
+ Given a temporary directory called 'tmp'
8
+ And a home directory called 'home' in '$tmp/home'
9
+
10
+ Scenario: Install Vim plugins successfully
11
+ Given a repository 'foo' with versions '1.0.0 1.0.1 1.0.2'
12
+ And a repository 'bar' with versions '2.0.0 2.0.1 2.0.2'
13
+ And flavorfile
14
+ """ruby
15
+ flavor '$foo_uri', '~> 1.0'
16
+ flavor '$bar_uri'
17
+ """
18
+ When I run `vim-flavor install`
19
+ Then it outputs progress like
20
+ """
21
+ Checking versions...
22
+ Use $bar_uri ... 2.0.2
23
+ Use $foo_uri ... 1.0.2
24
+ Deploying plugins...
25
+ $bar_uri 2.0.2 ... done
26
+ $foo_uri 1.0.2 ... done
27
+ Completed.
28
+ """
29
+
30
+ Scenario: Install Vim plugins which are not existing
31
+ Given flavorfile
32
+ """ruby
33
+ flavor 'no-such-plugin'
34
+ """
35
+ When I run `vim-flavor install` but
36
+ Then it fails with messages like
37
+ """
38
+ fatal: '\S+' does not appear to be a git repository
39
+ """
40
+ And it outputs progress like
41
+ """
42
+ Checking versions...
43
+ Use no-such-plugin ... failed
44
+ """
@@ -0,0 +1,9 @@
1
+ Flavorfile is a DSL to declare which versions of Vim plugins to use.
2
+ Whenever `vim-flavor` is invoked to manage Vim plugins,
3
+ `vim-flavor` reads a file `VimFlavor` in the current working directory,
4
+ and evaluates it as a flavorfile.
5
+
6
+
7
+
8
+
9
+ <!-- vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=78 : -->
@@ -0,0 +1,24 @@
1
+ Feature: Comments
2
+ In order to remind notable points,
3
+ as a lazy Vim user,
4
+ I want to leave comments in my flavorfile.
5
+
6
+ Background:
7
+ Given a temporary directory called 'tmp'
8
+ And a home directory called 'home' in '$tmp/home'
9
+ And a repository 'foo' with versions '1.0 1.1 1.2 2.0'
10
+
11
+ Scenario: Comment out declarations
12
+ Given flavorfile
13
+ """ruby
14
+ # Since flavorfile is parsed as a Ruby script,
15
+ # you can comment out arbitrary lines like this.
16
+
17
+ # flavor '$foo_uri', '~> 1.0'
18
+ """
19
+ When I run `vim-flavor install`
20
+ Then I get lockfile
21
+ """
22
+ """
23
+ And I get a bootstrap script in '$home/.vim'
24
+ But I don't have flavor '$foo_uri' in '$home/.vim'
@@ -0,0 +1,53 @@
1
+ Feature: Repository name
2
+ In order to keep flavorfile terse and readable,
3
+ as a lazy Vim user,
4
+ I also want to use shorthands for frequently used repositories.
5
+
6
+ Background:
7
+ Given a temporary directory called 'tmp'
8
+ And a home directory called 'home' in '$tmp/home'
9
+
10
+ Scenario: Declare using a Vim plugin from www.vim.org
11
+ Given a repository 'vim-scripts/vspec' with versions '0.0.4 1.2.0'
12
+ And flavorfile
13
+ """ruby
14
+ # Fetch the plugin from git://github.com/vim-scripts/vspec.git
15
+ flavor 'vspec', '~> 0.0'
16
+ """
17
+ When I run `vim-flavor install`
18
+ Then I get lockfile
19
+ """
20
+ vspec (0.0.4)
21
+ """
22
+ And I get a bootstrap script in '$home/.vim'
23
+ And I get flavor 'vspec' with '0.0.4' in '$home/.vim'
24
+
25
+ Scenario: Declare using a Vim plugin from GitHub
26
+ Given a repository 'kana/vim-vspec' with versions '0.0.4 1.2.0'
27
+ And flavorfile
28
+ """ruby
29
+ # Fetch the plugin from git://github.com/kana/vim-vspec.git
30
+ flavor 'kana/vim-vspec', '~> 0.0'
31
+ """
32
+ When I run `vim-flavor install`
33
+ Then I get lockfile
34
+ """
35
+ kana/vim-vspec (0.0.4)
36
+ """
37
+ And I get a bootstrap script in '$home/.vim'
38
+ And I get flavor 'kana/vim-vspec' with '0.0.4' in '$home/.vim'
39
+
40
+ Scenario: Declare using a Vim plugin from an arbitrary URI
41
+ Given a repository 'vspec' with versions '0.0.4 1.2.0'
42
+ And flavorfile
43
+ """ruby
44
+ # Fetch the plugin from the URI.
45
+ flavor '$vspec_uri', '~> 0.0'
46
+ """
47
+ When I run `vim-flavor install`
48
+ Then I get lockfile
49
+ """
50
+ $vspec_uri (0.0.4)
51
+ """
52
+ And I get a bootstrap script in '$home/.vim'
53
+ And I get flavor '$vspec_uri' with '0.0.4' in '$home/.vim'
@@ -0,0 +1,52 @@
1
+ Feature: Version constraint
2
+ In order to use Vim plugins which are compatible with my configuration,
3
+ as a lazy Vim user,
4
+ I want to declare desirable versions of Vim plugins.
5
+
6
+ Note that vim-flavor assumes that plugins follow [the versioning pocilies of
7
+ RubyGems](http://docs.rubygems.org/read/chapter/7#page26), to determine
8
+ compatibility of plugins. See also [Philosophy](philosophy) for the details.
9
+
10
+ Background:
11
+ Given a temporary directory called 'tmp'
12
+ And a home directory called 'home' in '$tmp/home'
13
+ And a repository 'foo' with versions '1.0 1.1 1.2 2.0'
14
+
15
+ Scenario: Declare using the latest version of a Vim plugin
16
+ Given flavorfile
17
+ """ruby
18
+ flavor '$foo_uri'
19
+ """
20
+ When I run `vim-flavor install`
21
+ Then I get lockfile
22
+ """
23
+ $foo_uri (2.0)
24
+ """
25
+ And I get a bootstrap script in '$home/.vim'
26
+ And I get flavor '$foo_uri' with '2.0' in '$home/.vim'
27
+
28
+ Scenario: Declare using a Vim plugin not older than a specific version
29
+ Given flavorfile
30
+ """ruby
31
+ flavor '$foo_uri', '>= 1.1'
32
+ """
33
+ When I run `vim-flavor install`
34
+ Then I get lockfile
35
+ """
36
+ $foo_uri (2.0)
37
+ """
38
+ And I get a bootstrap script in '$home/.vim'
39
+ And I get flavor '$foo_uri' with '2.0' in '$home/.vim'
40
+
41
+ Scenario: Declare using the latest and compatible version of a Vim plugin
42
+ Given flavorfile
43
+ """ruby
44
+ flavor '$foo_uri', '~> 1.0'
45
+ """
46
+ When I run `vim-flavor install`
47
+ Then I get lockfile
48
+ """
49
+ $foo_uri (1.2)
50
+ """
51
+ And I get a bootstrap script in '$home/.vim'
52
+ And I get flavor '$foo_uri' with '1.2' in '$home/.vim'