vimrunner 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +6 -3
- data/lib/vimrunner/client.rb +24 -17
- data/lib/vimrunner/command.rb +11 -0
- data/lib/vimrunner/path.rb +11 -0
- data/lib/vimrunner/server.rb +8 -5
- data/lib/vimrunner/version.rb +1 -1
- data/vim/vimrc +0 -2
- data/vim/vimrunner_rc +1 -0
- metadata +30 -39
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 909bbbe33a49a9bab23bc10ac3dd7be7a651e45a
|
4
|
+
data.tar.gz: 481ed70f35cb0553c30cd640bd35b8219c2b2ac6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db74708c88bbf8469fec2208ce52fc2dff56a032e4c38c8ab3f1577875047de6b02f2b997d062eb68de1c0e7290b9b457194f6cdfb33322bf6217c4579cf71fd
|
7
|
+
data.tar.gz: ab74da6d7d93ad25a30ddcdf16da44e58a10c48b3ad1bf4bad6262801d855646d47b1f23a792cb7ccbfee279242088f47af4d30b4f758a90d603cbeb43d14f49
|
data/README.md
CHANGED
@@ -6,6 +6,9 @@ functionality, this library exposes a way to spawn a Vim instance and control
|
|
6
6
|
it programatically. Apart from being a fun party trick, this can be used to do
|
7
7
|
integration testing on Vimscript.
|
8
8
|
|
9
|
+
The latest stable documentation can be found
|
10
|
+
[on rubydoc.info](http://rubydoc.info/gems/vimrunner/frames).
|
11
|
+
|
9
12
|
This is still fairly experimental, so use with caution. Any issue reports or
|
10
13
|
contributions are very welcome on the
|
11
14
|
[GitHub issue tracker](https://github.com/AndrewRadev/Vimrunner/issues).
|
@@ -64,8 +67,8 @@ examples.)
|
|
64
67
|
|
65
68
|
Calling `start` (or `start_gvim`) will return a `Client` instance with which
|
66
69
|
you can control Vim. For a full list of methods you can invoke on the remote
|
67
|
-
Vim instance, check out the
|
68
|
-
documentation](http://rubydoc.info/gems/vimrunner/Vimrunner/Client).
|
70
|
+
Vim instance, check out the `Client`
|
71
|
+
[documentation](http://rubydoc.info/gems/vimrunner/Vimrunner/Client).
|
69
72
|
|
70
73
|
If you already have a remote-capable Vim server running, you can connect
|
71
74
|
Vimrunner to it directly by using `Vimrunner.connect` or `Vimrunner.connect!`
|
@@ -110,7 +113,7 @@ Vimrunner::RSpec.configure do |config|
|
|
110
113
|
# vim = Vimrunner.start_gvim
|
111
114
|
|
112
115
|
# Setup your plugin in the Vim instance
|
113
|
-
plugin_path = File.expand_path('
|
116
|
+
plugin_path = File.expand_path('../..', __FILE__)
|
114
117
|
vim.add_plugin(plugin_path, 'plugin/my_plugin.vim')
|
115
118
|
|
116
119
|
# The returned value is the Client available in the tests.
|
data/lib/vimrunner/client.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "vimrunner/path"
|
2
|
+
require "vimrunner/command"
|
3
|
+
|
1
4
|
module Vimrunner
|
2
5
|
class Client
|
3
6
|
attr_reader :server
|
@@ -22,7 +25,10 @@ module Vimrunner
|
|
22
25
|
# Returns nothing.
|
23
26
|
def add_plugin(dir, entry_script = nil)
|
24
27
|
append_runtimepath(dir)
|
25
|
-
|
28
|
+
if entry_script
|
29
|
+
entry_script_path = Path.new(entry_script)
|
30
|
+
command("runtime #{entry_script_path}")
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
34
|
# Public: source a script in Vim server
|
@@ -35,7 +41,8 @@ module Vimrunner
|
|
35
41
|
#
|
36
42
|
# Returns nothing.
|
37
43
|
def source(script)
|
38
|
-
|
44
|
+
script_path = Path.new(script)
|
45
|
+
feedkeys(":\\<C-u>source #{script_path}\\<CR>")
|
39
46
|
end
|
40
47
|
|
41
48
|
# Public: Appends a directory to Vim's runtimepath
|
@@ -44,7 +51,8 @@ module Vimrunner
|
|
44
51
|
#
|
45
52
|
# Returns nothing.
|
46
53
|
def append_runtimepath(dir)
|
47
|
-
|
54
|
+
dir_path = Path.new(dir)
|
55
|
+
command("set runtimepath+=#{dir_path}")
|
48
56
|
end
|
49
57
|
|
50
58
|
# Public: Prepends a directory to Vim's runtimepath. Use this instead of
|
@@ -55,8 +63,9 @@ module Vimrunner
|
|
55
63
|
#
|
56
64
|
# Returns nothing.
|
57
65
|
def prepend_runtimepath(dir)
|
58
|
-
|
59
|
-
|
66
|
+
dir_path = Path.new(dir)
|
67
|
+
runtimepath = Path.new(echo('&runtimepath'))
|
68
|
+
command("set runtimepath=#{dir_path},#{runtimepath}")
|
60
69
|
end
|
61
70
|
|
62
71
|
# Public: Switches Vim to normal mode and types in the given keys.
|
@@ -157,7 +166,8 @@ module Vimrunner
|
|
157
166
|
#
|
158
167
|
# Returns the Client instance.
|
159
168
|
def edit(filename)
|
160
|
-
|
169
|
+
file_path = Path.new(filename)
|
170
|
+
command "edit #{file_path}"
|
161
171
|
self
|
162
172
|
end
|
163
173
|
|
@@ -167,7 +177,8 @@ module Vimrunner
|
|
167
177
|
#
|
168
178
|
# Returns the Client instance.
|
169
179
|
def edit!(filename)
|
170
|
-
|
180
|
+
file_path = Path.new(filename)
|
181
|
+
command "edit! #{file_path}"
|
171
182
|
self
|
172
183
|
end
|
173
184
|
|
@@ -177,8 +188,9 @@ module Vimrunner
|
|
177
188
|
# Returns the String output.
|
178
189
|
# Raises InvalidCommandError if the command is not recognised by vim.
|
179
190
|
def command(commands)
|
180
|
-
|
181
|
-
|
191
|
+
command = Command.new(commands)
|
192
|
+
server.remote_expr("VimrunnerEvaluateCommandOutput('#{command}')").tap do |output|
|
193
|
+
raise InvalidCommandError.new(output) if output =~ /^Vim(\(call\))?:E\d+:/
|
182
194
|
end
|
183
195
|
end
|
184
196
|
|
@@ -187,14 +199,9 @@ module Vimrunner
|
|
187
199
|
server.kill
|
188
200
|
end
|
189
201
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
name.gsub(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1")
|
194
|
-
end
|
195
|
-
|
196
|
-
def escape_single_quote(string)
|
197
|
-
string.to_s.gsub("'", "''")
|
202
|
+
# Bring the server to foreground
|
203
|
+
def foreground
|
204
|
+
server.remote_expr("foreground()")
|
198
205
|
end
|
199
206
|
end
|
200
207
|
end
|
data/lib/vimrunner/server.rb
CHANGED
@@ -13,13 +13,13 @@ module Vimrunner
|
|
13
13
|
# an existing Vim instance, it can control that instance without the need to
|
14
14
|
# start a new process.
|
15
15
|
#
|
16
|
-
# A Client would be necessary as
|
16
|
+
# A Client would be necessary as an actual interface, though it is possible
|
17
17
|
# to use a Server directly to invoke --remote commands on its Vim instance.
|
18
18
|
class Server
|
19
19
|
VIMRC = File.expand_path("../../../vim/vimrc", __FILE__)
|
20
20
|
VIMRUNNER_RC = File.expand_path("../../../vim/vimrunner_rc", __FILE__)
|
21
21
|
|
22
|
-
attr_reader :name, :executable, :vimrc
|
22
|
+
attr_reader :name, :executable, :vimrc, :gvimrc
|
23
23
|
|
24
24
|
# Public: Initialize a Server
|
25
25
|
#
|
@@ -35,8 +35,9 @@ module Vimrunner
|
|
35
35
|
#
|
36
36
|
def initialize(options = {})
|
37
37
|
@executable = options.fetch(:executable) { Platform.vim }
|
38
|
-
@name = options.fetch(:name) { "VIMRUNNER#{rand}" }
|
38
|
+
@name = options.fetch(:name) { "VIMRUNNER#{rand}" }.upcase
|
39
39
|
@vimrc = options.fetch(:vimrc) { VIMRC }
|
40
|
+
@gvimrc = options.fetch(:gvimrc) { "NONE" }
|
40
41
|
@foreground = options.fetch(:foreground, true)
|
41
42
|
end
|
42
43
|
|
@@ -149,7 +150,7 @@ module Vimrunner
|
|
149
150
|
end
|
150
151
|
|
151
152
|
# Public: Sends the given keys
|
152
|
-
# A wrapper around --remote-
|
153
|
+
# A wrapper around --remote-send.
|
153
154
|
#
|
154
155
|
# keys - a String with a sequence of Vim-compatible keystrokes.
|
155
156
|
#
|
@@ -169,7 +170,9 @@ module Vimrunner
|
|
169
170
|
end
|
170
171
|
|
171
172
|
def spawn
|
172
|
-
PTY.spawn(
|
173
|
+
PTY.spawn(executable, *%W[
|
174
|
+
#{foreground_option} --servername #{name} -u #{vimrc} -U #{gvimrc}
|
175
|
+
])
|
173
176
|
end
|
174
177
|
|
175
178
|
def wait_until_running(seconds)
|
data/lib/vimrunner/version.rb
CHANGED
data/vim/vimrc
CHANGED
data/vim/vimrunner_rc
CHANGED
@@ -24,6 +24,7 @@ else
|
|
24
24
|
function! VimrunnerEvaluateCommandOutput(command)
|
25
25
|
let base_command = split(a:command, '\s\+')[0]
|
26
26
|
let base_command = substitute(base_command, '!$', '', '')
|
27
|
+
let base_command = substitute(base_command, '^\d\+', '', '')
|
27
28
|
|
28
29
|
if !exists(':'.base_command)
|
29
30
|
let output = 'Vim:E492: Not an editor command: '.base_command
|
metadata
CHANGED
@@ -1,83 +1,76 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vimrunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Andrew Radev
|
8
|
+
- Paul Mucur
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
17
|
requirements:
|
19
|
-
- -
|
18
|
+
- - ">="
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: '0'
|
22
21
|
type: :development
|
23
22
|
prerelease: false
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
|
-
- -
|
25
|
+
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
27
|
version: '0'
|
30
28
|
- !ruby/object:Gem::Dependency
|
31
29
|
name: rdoc
|
32
30
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
31
|
requirements:
|
35
|
-
- -
|
32
|
+
- - ">="
|
36
33
|
- !ruby/object:Gem::Version
|
37
34
|
version: '0'
|
38
35
|
type: :development
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
|
-
- -
|
39
|
+
- - ">="
|
44
40
|
- !ruby/object:Gem::Version
|
45
41
|
version: '0'
|
46
42
|
- !ruby/object:Gem::Dependency
|
47
43
|
name: simplecov
|
48
44
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
45
|
requirements:
|
51
|
-
- -
|
46
|
+
- - ">="
|
52
47
|
- !ruby/object:Gem::Version
|
53
48
|
version: '0'
|
54
49
|
type: :development
|
55
50
|
prerelease: false
|
56
51
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
52
|
requirements:
|
59
|
-
- -
|
53
|
+
- - ">="
|
60
54
|
- !ruby/object:Gem::Version
|
61
55
|
version: '0'
|
62
56
|
- !ruby/object:Gem::Dependency
|
63
57
|
name: rspec
|
64
58
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
59
|
requirements:
|
67
|
-
- -
|
60
|
+
- - ">="
|
68
61
|
- !ruby/object:Gem::Version
|
69
62
|
version: 2.13.0
|
70
63
|
type: :development
|
71
64
|
prerelease: false
|
72
65
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
66
|
requirements:
|
75
|
-
- -
|
67
|
+
- - ">="
|
76
68
|
- !ruby/object:Gem::Version
|
77
69
|
version: 2.13.0
|
78
|
-
description:
|
79
|
-
|
80
|
-
|
70
|
+
description: |2
|
71
|
+
Using Vim's client/server functionality, this library exposes a way to
|
72
|
+
spawn a Vim instance and control it programatically. Apart from being a fun
|
73
|
+
party trick, this can be used to integration test Vim script.
|
81
74
|
email:
|
82
75
|
- andrey.radev@gmail.com
|
83
76
|
executables:
|
@@ -85,44 +78,42 @@ executables:
|
|
85
78
|
extensions: []
|
86
79
|
extra_rdoc_files: []
|
87
80
|
files:
|
81
|
+
- LICENSE
|
82
|
+
- README.md
|
83
|
+
- bin/vimrunner
|
88
84
|
- lib/vimrunner.rb
|
89
85
|
- lib/vimrunner/client.rb
|
90
|
-
- lib/vimrunner/
|
91
|
-
- lib/vimrunner/rspec.rb
|
86
|
+
- lib/vimrunner/command.rb
|
92
87
|
- lib/vimrunner/errors.rb
|
93
|
-
- lib/vimrunner/
|
94
|
-
- lib/vimrunner/server.rb
|
88
|
+
- lib/vimrunner/path.rb
|
95
89
|
- lib/vimrunner/platform.rb
|
96
|
-
-
|
90
|
+
- lib/vimrunner/rspec.rb
|
91
|
+
- lib/vimrunner/server.rb
|
92
|
+
- lib/vimrunner/testing.rb
|
93
|
+
- lib/vimrunner/version.rb
|
97
94
|
- vim/vimrc
|
98
|
-
-
|
99
|
-
- LICENSE
|
100
|
-
- README.md
|
95
|
+
- vim/vimrunner_rc
|
101
96
|
homepage: http://github.com/AndrewRadev/vimrunner
|
102
97
|
licenses: []
|
98
|
+
metadata: {}
|
103
99
|
post_install_message:
|
104
100
|
rdoc_options: []
|
105
101
|
require_paths:
|
106
102
|
- lib
|
107
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
-
none: false
|
109
104
|
requirements:
|
110
|
-
- -
|
105
|
+
- - ">="
|
111
106
|
- !ruby/object:Gem::Version
|
112
107
|
version: '0'
|
113
|
-
segments:
|
114
|
-
- 0
|
115
|
-
hash: -1164770989909868074
|
116
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
109
|
requirements:
|
119
|
-
- -
|
110
|
+
- - ">="
|
120
111
|
- !ruby/object:Gem::Version
|
121
112
|
version: 1.3.6
|
122
113
|
requirements: []
|
123
114
|
rubyforge_project: vimrunner
|
124
|
-
rubygems_version:
|
115
|
+
rubygems_version: 2.2.0
|
125
116
|
signing_key:
|
126
|
-
specification_version:
|
117
|
+
specification_version: 4
|
127
118
|
summary: Lets you control a Vim instance through Ruby
|
128
119
|
test_files: []
|