utils 0.0.73 → 0.0.74
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/edit +9 -8
- data/lib/utils/config/config_file.rb +13 -0
- data/lib/utils/editor.rb +25 -43
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deaf61a0df60f65e04301eb84fa27629fceef709
|
4
|
+
data.tar.gz: 16cc2ea9dbd7444a678a50933c116ec3ec81e8ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d31164ba3abf67beb45d57b3d549fafcd10e459cf139b657d48f582d6b8a1da9c6152af8ab26dbf6ee8ad553159be0ce4b2e369372f1478800324bbe14b19fa
|
7
|
+
data.tar.gz: ad04f5f16545cb81cb1fe086250dbf333983eeee4c4600267237ae4e62488cd7ad2070bc1bd9d772aaf8bc7c8291cc16618b54e801946563c48383cde193214e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.74
|
data/bin/edit
CHANGED
@@ -29,11 +29,14 @@ end
|
|
29
29
|
$opt = go 'p:S:wsmh'
|
30
30
|
$opt['h'] and usage
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
config = Utils::Config::ConfigFile.new
|
33
|
+
config.configure_from_paths
|
34
|
+
|
35
|
+
editor = Editor.new do |c|
|
36
|
+
c.wait = $opt['w']
|
37
|
+
c.pause_duration = ($opt['p'] || 1).to_i
|
38
|
+
s = $opt['S'] and c.servername = s
|
39
|
+
c.mkdir = $opt['m']
|
37
40
|
end
|
38
41
|
|
39
42
|
if $opt['s']
|
@@ -49,7 +52,7 @@ if $opt['s']
|
|
49
52
|
else
|
50
53
|
argv = ARGV.dup
|
51
54
|
if argv.empty?
|
52
|
-
|
55
|
+
unless STDIN.tty?
|
53
56
|
file = File.new(File.join(Dir.tmpdir, "edit_tmp.#$$"), 'w')
|
54
57
|
until STDIN.eof?
|
55
58
|
buffer = STDIN.read(8192)
|
@@ -57,8 +60,6 @@ else
|
|
57
60
|
end
|
58
61
|
file.close
|
59
62
|
argv << file.path
|
60
|
-
else
|
61
|
-
editor.ensure_running
|
62
63
|
end
|
63
64
|
end
|
64
65
|
unless argv.empty?
|
@@ -229,6 +229,19 @@ class Utils::Config::ConfigFile
|
|
229
229
|
@ssh_tunnel ||= SshTunnel.new
|
230
230
|
end
|
231
231
|
|
232
|
+
class Edit < BlockConfig
|
233
|
+
config :vim_path do `which vim`.chomp end
|
234
|
+
|
235
|
+
config :vim_default_args, nil
|
236
|
+
end
|
237
|
+
|
238
|
+
def edit(&block)
|
239
|
+
if block
|
240
|
+
@edit = Edit.new(&block)
|
241
|
+
end
|
242
|
+
@edit ||= Edit.new
|
243
|
+
end
|
244
|
+
|
232
245
|
def to_ruby
|
233
246
|
result = "# vim: set ft=ruby:\n"
|
234
247
|
for bc in %w[search discover strip_spaces probe ssh_tunnel]
|
data/lib/utils/editor.rb
CHANGED
@@ -50,6 +50,9 @@ module Utils
|
|
50
50
|
self.wait = false
|
51
51
|
self.pause_duration = 1
|
52
52
|
self.servername = ENV['VIM_SERVER'] || "G#{ENV['USER'].upcase}"
|
53
|
+
config = Utils::Config::ConfigFile.new
|
54
|
+
config.configure_from_paths
|
55
|
+
self.config = config.edit
|
53
56
|
yield self if block_given?
|
54
57
|
end
|
55
58
|
|
@@ -61,23 +64,12 @@ module Utils
|
|
61
64
|
|
62
65
|
attr_accessor :mkdir
|
63
66
|
|
67
|
+
attr_accessor :config
|
68
|
+
|
64
69
|
alias wait? wait
|
65
70
|
|
66
71
|
def vim
|
67
|
-
|
68
|
-
@vim ||=
|
69
|
-
case `uname -s`
|
70
|
-
when /\Adarwin/i
|
71
|
-
if File.directory?(path = File.expand_path('~/Applications/MacVim.app')) or
|
72
|
-
File.directory?(path = File.expand_path('/Applications/MacVim.app'))
|
73
|
-
then
|
74
|
-
File.join(path, 'Contents/MacOS/Vim')
|
75
|
-
else
|
76
|
-
vim_in_path
|
77
|
-
end
|
78
|
-
else
|
79
|
-
vim_in_path
|
80
|
-
end
|
72
|
+
([ config.vim_path ] + Array(config.vim_default_args))
|
81
73
|
end
|
82
74
|
|
83
75
|
def cmd(*parts)
|
@@ -96,7 +88,7 @@ module Utils
|
|
96
88
|
end
|
97
89
|
|
98
90
|
def fullscreen=(enabled)
|
99
|
-
|
91
|
+
start
|
100
92
|
sleep pause_duration
|
101
93
|
if enabled
|
102
94
|
edit_remote_send '<ESC>:set fullscreen<CR>'
|
@@ -118,8 +110,7 @@ module Utils
|
|
118
110
|
if filenames.size == 1 and
|
119
111
|
source_location = filenames.first.source_location
|
120
112
|
then
|
121
|
-
edit_source_location(source_location) ||
|
122
|
-
edit_file(expand_globs(source_location[0, 1]))
|
113
|
+
edit_source_location(source_location) # || edit_file(expand_globs(source_location[0, 1]))
|
123
114
|
elsif source_locations = filenames.map(&:source_location).compact.full?
|
124
115
|
filenames = expand_globs(source_locations.map(&:first))
|
125
116
|
edit_file(*filenames)
|
@@ -136,25 +127,16 @@ module Utils
|
|
136
127
|
private :make_dirs
|
137
128
|
|
138
129
|
def edit_file(*filenames)
|
139
|
-
make_dirs
|
140
|
-
|
141
|
-
edit_remote_file(*filenames)
|
142
|
-
else
|
143
|
-
cmd(vim, *filenames)
|
144
|
-
end
|
130
|
+
make_dirs(*filenames)
|
131
|
+
edit_remote_file(*filenames)
|
145
132
|
end
|
146
133
|
|
147
134
|
def edit_file_linenumber(filename, linenumber)
|
148
135
|
make_dirs filename
|
149
136
|
if wait?
|
150
|
-
|
151
|
-
sleep pause_duration
|
152
|
-
edit_remote_send("<ESC>:#{linenumber}<CR>")
|
153
|
-
edit_remote_wait(filename)
|
137
|
+
edit_remote_wait("+#{linenumber}", filename)
|
154
138
|
else
|
155
|
-
edit_remote(filename)
|
156
|
-
sleep pause_duration
|
157
|
-
edit_remote_send("<ESC>:#{linenumber}<CR>")
|
139
|
+
edit_remote("+#{linenumber}", filename)
|
158
140
|
end
|
159
141
|
end
|
160
142
|
|
@@ -167,12 +149,8 @@ module Utils
|
|
167
149
|
self
|
168
150
|
end
|
169
151
|
|
170
|
-
def gui
|
171
|
-
ENV['TERM'] =~ /xterm/ ? '-g' : nil
|
172
|
-
end
|
173
|
-
|
174
152
|
def start
|
175
|
-
cmd(vim,
|
153
|
+
started? or cmd(*vim, '--servername', servername)
|
176
154
|
end
|
177
155
|
|
178
156
|
def stop
|
@@ -180,13 +158,17 @@ module Utils
|
|
180
158
|
end
|
181
159
|
|
182
160
|
def activate
|
183
|
-
|
184
|
-
|
185
|
-
|
161
|
+
if Array(config.vim_default_args).include?('-g')
|
162
|
+
edit_remote("stupid_trick#{rand}")
|
163
|
+
sleep pause_duration
|
164
|
+
edit_remote_send('<ESC>:bw<CR>')
|
165
|
+
else
|
166
|
+
# TODO use tmux to switch to editor pane?
|
167
|
+
end
|
186
168
|
end
|
187
169
|
|
188
170
|
def serverlist
|
189
|
-
@serverlist ||= `#{vim
|
171
|
+
@serverlist ||= `#{vim.map(&:inspect) * ' '} --serverlist`.split
|
190
172
|
end
|
191
173
|
|
192
174
|
def started?(name = servername)
|
@@ -194,19 +176,19 @@ module Utils
|
|
194
176
|
end
|
195
177
|
|
196
178
|
def edit_remote(*args)
|
197
|
-
|
179
|
+
cmd(*vim, '--servername', servername, '--remote', *args)
|
198
180
|
end
|
199
181
|
|
200
182
|
def edit_remote_wait(*args)
|
201
|
-
|
183
|
+
cmd(*vim, '--servername', servername, '--remote-wait', *args)
|
202
184
|
end
|
203
185
|
|
204
186
|
def edit_remote_send(*args)
|
205
|
-
|
187
|
+
cmd(*vim, '--servername', servername, '--remote-send', *args)
|
206
188
|
end
|
207
189
|
|
208
190
|
def edit_remote_file(*filenames)
|
209
|
-
if
|
191
|
+
if wait?
|
210
192
|
edit_remote_wait(*filenames)
|
211
193
|
else
|
212
194
|
edit_remote(*filenames)
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "utils"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.74"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Florian Frank"]
|
9
|
-
s.date = "2013-03-
|
9
|
+
s.date = "2013-03-11"
|
10
10
|
s.description = "This ruby gem provides some useful command line utilities"
|
11
11
|
s.email = "flori@ping.de"
|
12
12
|
s.executables = ["create_tags", "untest", "chroot-libs", "edit_wait", "chroot-exec", "irb_connect", "number_files", "search", "strip_spaces", "path", "enum", "edit", "git-empty", "classify", "utils-install-config", "xmp", "discover", "ssh-tunnel", "myex", "probe", "remote_copy", "errf", "same_files", "utils-utilsrc", "unquarantine_apps", "vacuum_firefox_sqlite", "on_change", "sedit"]
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.homepage = "http://github.com/flori/utils"
|
16
16
|
s.rdoc_options = ["--title", "Utils - Some useful command line utilities", "--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib"]
|
18
|
-
s.rubygems_version = "2.0.
|
18
|
+
s.rubygems_version = "2.0.2"
|
19
19
|
s.summary = "Some useful command line utilities"
|
20
20
|
|
21
21
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.74
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
206
|
rubyforge_project:
|
207
|
-
rubygems_version: 2.0.
|
207
|
+
rubygems_version: 2.0.2
|
208
208
|
signing_key:
|
209
209
|
specification_version: 4
|
210
210
|
summary: Some useful command line utilities
|