ruby-zoom 4.1.0 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/z +28 -9
- data/bin/zc +28 -9
- data/bin/zf +28 -9
- data/bin/zg +28 -9
- data/bin/zl +28 -9
- data/bin/zr +28 -9
- data/lib/zoom.rb +24 -26
- data/lib/zoom/cache.rb +39 -80
- data/lib/zoom/cache/result.rb +8 -4
- data/lib/zoom/profile.rb +62 -28
- data/lib/zoom/profile/grep.rb +1 -1
- data/lib/zoom/profile/passwords.rb +12 -12
- 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: 406a2c7c4be5d5beb4bb9475c35f0bbaede64de7
|
4
|
+
data.tar.gz: f696609ec371176906fd10c30b01da026fdfcf75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c30089b0a1e4530f08ab4b2a2d3a8d71357c7473d13414cd4fff8a1408e340584ac0da1bb3f059a3b8afa99647a20309116ae3d54963fc9b8639bf63c7ae73b1
|
7
|
+
data.tar.gz: dc8cc5d5e0f9bb2fbd6ae951894c0ad65e7bb2f1312269ce04cb1fa91109592495672c1f45ad22be1291602d85201039c6e100569d66640e0f24446c910c74fd
|
data/bin/z
CHANGED
@@ -40,8 +40,10 @@ def parse(args)
|
|
40
40
|
parser = OptionParser.new do |opts|
|
41
41
|
opts.summary_width = 25
|
42
42
|
|
43
|
-
opts.banner =
|
44
|
-
"Usage: #{File.basename($0)} [OPTIONS] [pattern]"
|
43
|
+
opts.banner = [
|
44
|
+
"Usage: #{File.basename($0)} [OPTIONS] [pattern]",
|
45
|
+
"[path1]...[pathN]"
|
46
|
+
].join(" ")
|
45
47
|
|
46
48
|
opts.on("", "DESCRIPTION")
|
47
49
|
|
@@ -193,12 +195,27 @@ def parse(args)
|
|
193
195
|
options["action"] = "repeat"
|
194
196
|
when "z"
|
195
197
|
# Do nothing, this is the normal usage
|
198
|
+
# Add to this case if renaming
|
196
199
|
else
|
197
200
|
options["use"] = File.basename($0)
|
198
201
|
end
|
199
202
|
|
200
|
-
|
203
|
+
paths = Array.new
|
204
|
+
path = args.delete_at(-1)
|
205
|
+
while (path && Pathname.new(path).exist?)
|
206
|
+
paths.push(path)
|
207
|
+
path = args.delete_at(-1)
|
208
|
+
end
|
209
|
+
|
210
|
+
if (!paths.empty?)
|
211
|
+
options["paths"] = paths.reverse.join(" ")
|
212
|
+
else
|
213
|
+
options["paths"] = "."
|
214
|
+
end
|
215
|
+
|
216
|
+
options["pattern"] = path
|
201
217
|
options["subargs"] = args.join(" ")
|
218
|
+
|
202
219
|
return options
|
203
220
|
end
|
204
221
|
|
@@ -209,7 +226,8 @@ begin
|
|
209
226
|
FileUtils.rm_f(Pathname.new("~/.zoomrc").expand_path)
|
210
227
|
end
|
211
228
|
|
212
|
-
zoom = Zoom.new(options["cache_file"]
|
229
|
+
zoom = Zoom.new(options["cache_file"])
|
230
|
+
Zoom.hilight(!Hilighter.disable?)
|
213
231
|
|
214
232
|
case options["action"]
|
215
233
|
when "cache"
|
@@ -279,11 +297,12 @@ begin
|
|
279
297
|
end
|
280
298
|
else
|
281
299
|
# Search and cache results
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
300
|
+
header = Hash.new
|
301
|
+
header["profile_name"] = options["use"]
|
302
|
+
header["args"] = options["subargs"]
|
303
|
+
header["pattern"] = options["pattern"]
|
304
|
+
header["paths"] = options["paths"]
|
305
|
+
zoom.run(header)
|
287
306
|
end
|
288
307
|
rescue SystemExit
|
289
308
|
# Quit from djinni
|
data/bin/zc
CHANGED
@@ -40,8 +40,10 @@ def parse(args)
|
|
40
40
|
parser = OptionParser.new do |opts|
|
41
41
|
opts.summary_width = 25
|
42
42
|
|
43
|
-
opts.banner =
|
44
|
-
"Usage: #{File.basename($0)} [OPTIONS] [pattern]"
|
43
|
+
opts.banner = [
|
44
|
+
"Usage: #{File.basename($0)} [OPTIONS] [pattern]",
|
45
|
+
"[path1]...[pathN]"
|
46
|
+
].join(" ")
|
45
47
|
|
46
48
|
opts.on("", "DESCRIPTION")
|
47
49
|
|
@@ -193,12 +195,27 @@ def parse(args)
|
|
193
195
|
options["action"] = "repeat"
|
194
196
|
when "z"
|
195
197
|
# Do nothing, this is the normal usage
|
198
|
+
# Add to this case if renaming
|
196
199
|
else
|
197
200
|
options["use"] = File.basename($0)
|
198
201
|
end
|
199
202
|
|
200
|
-
|
203
|
+
paths = Array.new
|
204
|
+
path = args.delete_at(-1)
|
205
|
+
while (path && Pathname.new(path).exist?)
|
206
|
+
paths.push(path)
|
207
|
+
path = args.delete_at(-1)
|
208
|
+
end
|
209
|
+
|
210
|
+
if (!paths.empty?)
|
211
|
+
options["paths"] = paths.reverse.join(" ")
|
212
|
+
else
|
213
|
+
options["paths"] = "."
|
214
|
+
end
|
215
|
+
|
216
|
+
options["pattern"] = path
|
201
217
|
options["subargs"] = args.join(" ")
|
218
|
+
|
202
219
|
return options
|
203
220
|
end
|
204
221
|
|
@@ -209,7 +226,8 @@ begin
|
|
209
226
|
FileUtils.rm_f(Pathname.new("~/.zoomrc").expand_path)
|
210
227
|
end
|
211
228
|
|
212
|
-
zoom = Zoom.new(options["cache_file"]
|
229
|
+
zoom = Zoom.new(options["cache_file"])
|
230
|
+
Zoom.hilight(!Hilighter.disable?)
|
213
231
|
|
214
232
|
case options["action"]
|
215
233
|
when "cache"
|
@@ -279,11 +297,12 @@ begin
|
|
279
297
|
end
|
280
298
|
else
|
281
299
|
# Search and cache results
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
300
|
+
header = Hash.new
|
301
|
+
header["profile_name"] = options["use"]
|
302
|
+
header["args"] = options["subargs"]
|
303
|
+
header["pattern"] = options["pattern"]
|
304
|
+
header["paths"] = options["paths"]
|
305
|
+
zoom.run(header)
|
287
306
|
end
|
288
307
|
rescue SystemExit
|
289
308
|
# Quit from djinni
|
data/bin/zf
CHANGED
@@ -40,8 +40,10 @@ def parse(args)
|
|
40
40
|
parser = OptionParser.new do |opts|
|
41
41
|
opts.summary_width = 25
|
42
42
|
|
43
|
-
opts.banner =
|
44
|
-
"Usage: #{File.basename($0)} [OPTIONS] [pattern]"
|
43
|
+
opts.banner = [
|
44
|
+
"Usage: #{File.basename($0)} [OPTIONS] [pattern]",
|
45
|
+
"[path1]...[pathN]"
|
46
|
+
].join(" ")
|
45
47
|
|
46
48
|
opts.on("", "DESCRIPTION")
|
47
49
|
|
@@ -193,12 +195,27 @@ def parse(args)
|
|
193
195
|
options["action"] = "repeat"
|
194
196
|
when "z"
|
195
197
|
# Do nothing, this is the normal usage
|
198
|
+
# Add to this case if renaming
|
196
199
|
else
|
197
200
|
options["use"] = File.basename($0)
|
198
201
|
end
|
199
202
|
|
200
|
-
|
203
|
+
paths = Array.new
|
204
|
+
path = args.delete_at(-1)
|
205
|
+
while (path && Pathname.new(path).exist?)
|
206
|
+
paths.push(path)
|
207
|
+
path = args.delete_at(-1)
|
208
|
+
end
|
209
|
+
|
210
|
+
if (!paths.empty?)
|
211
|
+
options["paths"] = paths.reverse.join(" ")
|
212
|
+
else
|
213
|
+
options["paths"] = "."
|
214
|
+
end
|
215
|
+
|
216
|
+
options["pattern"] = path
|
201
217
|
options["subargs"] = args.join(" ")
|
218
|
+
|
202
219
|
return options
|
203
220
|
end
|
204
221
|
|
@@ -209,7 +226,8 @@ begin
|
|
209
226
|
FileUtils.rm_f(Pathname.new("~/.zoomrc").expand_path)
|
210
227
|
end
|
211
228
|
|
212
|
-
zoom = Zoom.new(options["cache_file"]
|
229
|
+
zoom = Zoom.new(options["cache_file"])
|
230
|
+
Zoom.hilight(!Hilighter.disable?)
|
213
231
|
|
214
232
|
case options["action"]
|
215
233
|
when "cache"
|
@@ -279,11 +297,12 @@ begin
|
|
279
297
|
end
|
280
298
|
else
|
281
299
|
# Search and cache results
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
300
|
+
header = Hash.new
|
301
|
+
header["profile_name"] = options["use"]
|
302
|
+
header["args"] = options["subargs"]
|
303
|
+
header["pattern"] = options["pattern"]
|
304
|
+
header["paths"] = options["paths"]
|
305
|
+
zoom.run(header)
|
287
306
|
end
|
288
307
|
rescue SystemExit
|
289
308
|
# Quit from djinni
|
data/bin/zg
CHANGED
@@ -40,8 +40,10 @@ def parse(args)
|
|
40
40
|
parser = OptionParser.new do |opts|
|
41
41
|
opts.summary_width = 25
|
42
42
|
|
43
|
-
opts.banner =
|
44
|
-
"Usage: #{File.basename($0)} [OPTIONS] [pattern]"
|
43
|
+
opts.banner = [
|
44
|
+
"Usage: #{File.basename($0)} [OPTIONS] [pattern]",
|
45
|
+
"[path1]...[pathN]"
|
46
|
+
].join(" ")
|
45
47
|
|
46
48
|
opts.on("", "DESCRIPTION")
|
47
49
|
|
@@ -193,12 +195,27 @@ def parse(args)
|
|
193
195
|
options["action"] = "repeat"
|
194
196
|
when "z"
|
195
197
|
# Do nothing, this is the normal usage
|
198
|
+
# Add to this case if renaming
|
196
199
|
else
|
197
200
|
options["use"] = File.basename($0)
|
198
201
|
end
|
199
202
|
|
200
|
-
|
203
|
+
paths = Array.new
|
204
|
+
path = args.delete_at(-1)
|
205
|
+
while (path && Pathname.new(path).exist?)
|
206
|
+
paths.push(path)
|
207
|
+
path = args.delete_at(-1)
|
208
|
+
end
|
209
|
+
|
210
|
+
if (!paths.empty?)
|
211
|
+
options["paths"] = paths.reverse.join(" ")
|
212
|
+
else
|
213
|
+
options["paths"] = "."
|
214
|
+
end
|
215
|
+
|
216
|
+
options["pattern"] = path
|
201
217
|
options["subargs"] = args.join(" ")
|
218
|
+
|
202
219
|
return options
|
203
220
|
end
|
204
221
|
|
@@ -209,7 +226,8 @@ begin
|
|
209
226
|
FileUtils.rm_f(Pathname.new("~/.zoomrc").expand_path)
|
210
227
|
end
|
211
228
|
|
212
|
-
zoom = Zoom.new(options["cache_file"]
|
229
|
+
zoom = Zoom.new(options["cache_file"])
|
230
|
+
Zoom.hilight(!Hilighter.disable?)
|
213
231
|
|
214
232
|
case options["action"]
|
215
233
|
when "cache"
|
@@ -279,11 +297,12 @@ begin
|
|
279
297
|
end
|
280
298
|
else
|
281
299
|
# Search and cache results
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
300
|
+
header = Hash.new
|
301
|
+
header["profile_name"] = options["use"]
|
302
|
+
header["args"] = options["subargs"]
|
303
|
+
header["pattern"] = options["pattern"]
|
304
|
+
header["paths"] = options["paths"]
|
305
|
+
zoom.run(header)
|
287
306
|
end
|
288
307
|
rescue SystemExit
|
289
308
|
# Quit from djinni
|
data/bin/zl
CHANGED
@@ -40,8 +40,10 @@ def parse(args)
|
|
40
40
|
parser = OptionParser.new do |opts|
|
41
41
|
opts.summary_width = 25
|
42
42
|
|
43
|
-
opts.banner =
|
44
|
-
"Usage: #{File.basename($0)} [OPTIONS] [pattern]"
|
43
|
+
opts.banner = [
|
44
|
+
"Usage: #{File.basename($0)} [OPTIONS] [pattern]",
|
45
|
+
"[path1]...[pathN]"
|
46
|
+
].join(" ")
|
45
47
|
|
46
48
|
opts.on("", "DESCRIPTION")
|
47
49
|
|
@@ -193,12 +195,27 @@ def parse(args)
|
|
193
195
|
options["action"] = "repeat"
|
194
196
|
when "z"
|
195
197
|
# Do nothing, this is the normal usage
|
198
|
+
# Add to this case if renaming
|
196
199
|
else
|
197
200
|
options["use"] = File.basename($0)
|
198
201
|
end
|
199
202
|
|
200
|
-
|
203
|
+
paths = Array.new
|
204
|
+
path = args.delete_at(-1)
|
205
|
+
while (path && Pathname.new(path).exist?)
|
206
|
+
paths.push(path)
|
207
|
+
path = args.delete_at(-1)
|
208
|
+
end
|
209
|
+
|
210
|
+
if (!paths.empty?)
|
211
|
+
options["paths"] = paths.reverse.join(" ")
|
212
|
+
else
|
213
|
+
options["paths"] = "."
|
214
|
+
end
|
215
|
+
|
216
|
+
options["pattern"] = path
|
201
217
|
options["subargs"] = args.join(" ")
|
218
|
+
|
202
219
|
return options
|
203
220
|
end
|
204
221
|
|
@@ -209,7 +226,8 @@ begin
|
|
209
226
|
FileUtils.rm_f(Pathname.new("~/.zoomrc").expand_path)
|
210
227
|
end
|
211
228
|
|
212
|
-
zoom = Zoom.new(options["cache_file"]
|
229
|
+
zoom = Zoom.new(options["cache_file"])
|
230
|
+
Zoom.hilight(!Hilighter.disable?)
|
213
231
|
|
214
232
|
case options["action"]
|
215
233
|
when "cache"
|
@@ -279,11 +297,12 @@ begin
|
|
279
297
|
end
|
280
298
|
else
|
281
299
|
# Search and cache results
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
300
|
+
header = Hash.new
|
301
|
+
header["profile_name"] = options["use"]
|
302
|
+
header["args"] = options["subargs"]
|
303
|
+
header["pattern"] = options["pattern"]
|
304
|
+
header["paths"] = options["paths"]
|
305
|
+
zoom.run(header)
|
287
306
|
end
|
288
307
|
rescue SystemExit
|
289
308
|
# Quit from djinni
|
data/bin/zr
CHANGED
@@ -40,8 +40,10 @@ def parse(args)
|
|
40
40
|
parser = OptionParser.new do |opts|
|
41
41
|
opts.summary_width = 25
|
42
42
|
|
43
|
-
opts.banner =
|
44
|
-
"Usage: #{File.basename($0)} [OPTIONS] [pattern]"
|
43
|
+
opts.banner = [
|
44
|
+
"Usage: #{File.basename($0)} [OPTIONS] [pattern]",
|
45
|
+
"[path1]...[pathN]"
|
46
|
+
].join(" ")
|
45
47
|
|
46
48
|
opts.on("", "DESCRIPTION")
|
47
49
|
|
@@ -193,12 +195,27 @@ def parse(args)
|
|
193
195
|
options["action"] = "repeat"
|
194
196
|
when "z"
|
195
197
|
# Do nothing, this is the normal usage
|
198
|
+
# Add to this case if renaming
|
196
199
|
else
|
197
200
|
options["use"] = File.basename($0)
|
198
201
|
end
|
199
202
|
|
200
|
-
|
203
|
+
paths = Array.new
|
204
|
+
path = args.delete_at(-1)
|
205
|
+
while (path && Pathname.new(path).exist?)
|
206
|
+
paths.push(path)
|
207
|
+
path = args.delete_at(-1)
|
208
|
+
end
|
209
|
+
|
210
|
+
if (!paths.empty?)
|
211
|
+
options["paths"] = paths.reverse.join(" ")
|
212
|
+
else
|
213
|
+
options["paths"] = "."
|
214
|
+
end
|
215
|
+
|
216
|
+
options["pattern"] = path
|
201
217
|
options["subargs"] = args.join(" ")
|
218
|
+
|
202
219
|
return options
|
203
220
|
end
|
204
221
|
|
@@ -209,7 +226,8 @@ begin
|
|
209
226
|
FileUtils.rm_f(Pathname.new("~/.zoomrc").expand_path)
|
210
227
|
end
|
211
228
|
|
212
|
-
zoom = Zoom.new(options["cache_file"]
|
229
|
+
zoom = Zoom.new(options["cache_file"])
|
230
|
+
Zoom.hilight(!Hilighter.disable?)
|
213
231
|
|
214
232
|
case options["action"]
|
215
233
|
when "cache"
|
@@ -279,11 +297,12 @@ begin
|
|
279
297
|
end
|
280
298
|
else
|
281
299
|
# Search and cache results
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
300
|
+
header = Hash.new
|
301
|
+
header["profile_name"] = options["use"]
|
302
|
+
header["args"] = options["subargs"]
|
303
|
+
header["pattern"] = options["pattern"]
|
304
|
+
header["paths"] = options["paths"]
|
305
|
+
zoom.run(header)
|
287
306
|
end
|
288
307
|
rescue SystemExit
|
289
308
|
# Quit from djinni
|
data/lib/zoom.rb
CHANGED
@@ -13,13 +13,10 @@ class Zoom
|
|
13
13
|
return @@hilight
|
14
14
|
end
|
15
15
|
|
16
|
-
def initialize(cache = nil, rc = nil
|
17
|
-
@@hilight = hilight
|
16
|
+
def initialize(cache = nil, rc = nil)
|
18
17
|
@cache = Zoom::Cache.new(cache)
|
19
18
|
@config = Zoom::Config.new(rc)
|
20
|
-
|
21
|
-
# Prioritize false, so only reassign if true
|
22
|
-
@@hilight = @config.hilight if (hilight)
|
19
|
+
@@hilight = @config.hilight
|
23
20
|
end
|
24
21
|
|
25
22
|
def open(results)
|
@@ -32,38 +29,39 @@ class Zoom
|
|
32
29
|
|
33
30
|
def repeat
|
34
31
|
return if (@cache.empty?)
|
35
|
-
|
36
|
-
run(
|
37
|
-
@cache.profile_name,
|
38
|
-
@cache.args,
|
39
|
-
@cache.pattern
|
40
|
-
)
|
32
|
+
run(@cache.header)
|
41
33
|
end
|
42
34
|
|
43
|
-
def run(
|
44
|
-
|
35
|
+
def run(header)
|
36
|
+
profile_name = header["profile_name"]
|
37
|
+
args = header["args"]
|
38
|
+
pattern = header["pattern"]
|
39
|
+
paths = header["paths"]
|
40
|
+
|
41
|
+
if (profile_name.nil?)
|
42
|
+
profile_name = @config.current_profile_name
|
43
|
+
header["profile_name"] = profile_name
|
44
|
+
end
|
45
|
+
|
46
|
+
if (!@config.has_profile?(profile_name))
|
47
|
+
raise Zoom::Error::ProfileDoesNotExist.new(profile_name)
|
48
|
+
end
|
45
49
|
|
46
|
-
|
47
|
-
|
50
|
+
profile = @config.get_profile(profile_name)
|
51
|
+
if (pattern.nil? || !profile.pattern.empty?)
|
52
|
+
header["pattern"] = profile.pattern
|
48
53
|
end
|
54
|
+
header["pwd"] = Dir.pwd
|
49
55
|
|
50
|
-
profile = @config.get_profile(prof_name)
|
51
56
|
begin
|
57
|
+
# Clear cache
|
52
58
|
@cache.clear
|
53
59
|
|
54
60
|
# Store needed details
|
55
|
-
|
56
|
-
@cache.args(args)
|
57
|
-
@cache.pattern(pattern)
|
58
|
-
else
|
59
|
-
@cache.args("")
|
60
|
-
@cache.pattern(profile.pattern)
|
61
|
-
end
|
62
|
-
@cache.profile_name(prof_name)
|
63
|
-
@cache.pwd(Dir.pwd)
|
61
|
+
@cache.header(header)
|
64
62
|
|
65
63
|
# Execute profile
|
66
|
-
@cache.write(profile.exe(args, pattern))
|
64
|
+
@cache.write(profile.exe(args, pattern, paths))
|
67
65
|
|
68
66
|
# Display results from cache
|
69
67
|
@cache.shortcut(@config)
|
data/lib/zoom/cache.rb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
1
|
require "io/wait"
|
2
|
+
require "json"
|
2
3
|
require "pathname"
|
3
4
|
|
4
5
|
class Zoom::Cache
|
5
|
-
attr_reader :
|
6
|
-
attr_reader :zoom_pattern
|
7
|
-
attr_reader :zoom_profile_name
|
8
|
-
attr_reader :zoom_pwd
|
9
|
-
|
10
|
-
def args(a = nil)
|
11
|
-
if (a.nil?)
|
12
|
-
return nil if (empty?)
|
13
|
-
return @zoom_args
|
14
|
-
end
|
6
|
+
attr_reader :header
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
def args
|
9
|
+
return nil if (@header.nil?)
|
10
|
+
return @header["args"]
|
19
11
|
end
|
20
12
|
|
21
13
|
def available_tags
|
@@ -27,34 +19,16 @@ class Zoom::Cache
|
|
27
19
|
@results = nil
|
28
20
|
@thread.kill if (@thread)
|
29
21
|
@thread = nil
|
30
|
-
@
|
31
|
-
@zoom_pattern = nil
|
32
|
-
@zoom_profile_name = nil
|
33
|
-
@zoom_pwd = nil
|
22
|
+
@header = nil
|
34
23
|
end
|
35
24
|
|
36
25
|
def empty?
|
37
26
|
read if (@thread.nil?)
|
38
27
|
return true if (@thread.nil?)
|
39
|
-
|
40
|
-
while (
|
41
|
-
@thread.alive? &&
|
42
|
-
(
|
43
|
-
@zoom_args.nil? ||
|
44
|
-
@zoom_pattern.nil? ||
|
45
|
-
@zoom_profile_name.nil? ||
|
46
|
-
@zoom_pwd.nil?
|
47
|
-
)
|
48
|
-
)
|
28
|
+
while (@thread.alive? && (@header.nil? || @header.empty?))
|
49
29
|
sleep 0.1
|
50
30
|
end
|
51
|
-
|
52
|
-
return (
|
53
|
-
@zoom_args.nil? ||
|
54
|
-
@zoom_pattern.nil? ||
|
55
|
-
@zoom_profile_name.nil? ||
|
56
|
-
@zoom_pwd.nil?
|
57
|
-
)
|
31
|
+
return @header.empty?
|
58
32
|
end
|
59
33
|
|
60
34
|
def get_results(tags = nil)
|
@@ -86,16 +60,22 @@ class Zoom::Cache
|
|
86
60
|
return results
|
87
61
|
end
|
88
62
|
|
63
|
+
def header(header = nil)
|
64
|
+
return nil if (header.nil? && empty?)
|
65
|
+
return @header if (header.nil?)
|
66
|
+
|
67
|
+
File.open(@cache_file, "a") do |f|
|
68
|
+
f.write("ZOOM_HEADER=#{JSON.generate(header)}\n")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
89
72
|
def initialize(file = nil)
|
90
73
|
file = "~/.cache/zoom/cache" if (file.nil?)
|
91
74
|
|
92
75
|
@cache_file = Pathname.new(file).expand_path
|
93
76
|
@results = nil
|
94
77
|
@thread = nil
|
95
|
-
@
|
96
|
-
@zoom_pattern = nil
|
97
|
-
@zoom_profile_name = nil
|
98
|
-
@zoom_pwd = nil
|
78
|
+
@header = Hash.new
|
99
79
|
|
100
80
|
FileUtils.mkdir_p(@cache_file.dirname)
|
101
81
|
read
|
@@ -122,37 +102,24 @@ class Zoom::Cache
|
|
122
102
|
end
|
123
103
|
private :parse_tags
|
124
104
|
|
125
|
-
def
|
126
|
-
if (
|
127
|
-
|
128
|
-
return @zoom_pattern
|
129
|
-
end
|
130
|
-
|
131
|
-
File.open(@cache_file, "a") do |f|
|
132
|
-
f.write("ZOOM_PATTERN=#{p}\n")
|
133
|
-
end
|
105
|
+
def paths
|
106
|
+
return nil if (@header.nil?)
|
107
|
+
return @header["paths"]
|
134
108
|
end
|
135
109
|
|
136
|
-
def
|
137
|
-
if (
|
138
|
-
|
139
|
-
return @zoom_profile_name
|
140
|
-
end
|
141
|
-
|
142
|
-
File.open(@cache_file, "a") do |f|
|
143
|
-
f.write("ZOOM_PROFILE_NAME=#{name}\n")
|
144
|
-
end
|
110
|
+
def pattern
|
111
|
+
return nil if (@header.nil?)
|
112
|
+
return @header["pattern"]
|
145
113
|
end
|
146
114
|
|
147
|
-
def
|
148
|
-
if (
|
149
|
-
|
150
|
-
|
151
|
-
end
|
115
|
+
def profile_name
|
116
|
+
return nil if (@header.nil?)
|
117
|
+
return @header["profile_name"]
|
118
|
+
end
|
152
119
|
|
153
|
-
|
154
|
-
|
155
|
-
|
120
|
+
def pwd
|
121
|
+
return nil if (@header.nil?)
|
122
|
+
return @header["pwd"]
|
156
123
|
end
|
157
124
|
|
158
125
|
def read
|
@@ -166,22 +133,11 @@ class Zoom::Cache
|
|
166
133
|
File.open(@cache_file) do |cache|
|
167
134
|
cache.each do |line|
|
168
135
|
line.chomp!
|
169
|
-
if (line.start_with?("
|
170
|
-
@
|
171
|
-
|
172
|
-
@zoom_pattern = line.gsub("ZOOM_PATTERN=", "")
|
173
|
-
elsif (line.start_with?("ZOOM_PROFILE_NAME="))
|
174
|
-
@zoom_profile_name = line.gsub(
|
175
|
-
"ZOOM_PROFILE_NAME=",
|
176
|
-
""
|
136
|
+
if (line.start_with?("ZOOM_HEADER="))
|
137
|
+
@header = JSON.parse(
|
138
|
+
line.gsub("ZOOM_HEADER=", "")
|
177
139
|
)
|
178
|
-
elsif (line.
|
179
|
-
@zoom_pwd = line.gsub("ZOOM_PWD=", "")
|
180
|
-
elsif (
|
181
|
-
(line == "-") ||
|
182
|
-
(line == "--") ||
|
183
|
-
line.empty?
|
184
|
-
)
|
140
|
+
elsif (line.match(/^-?-?$/))
|
185
141
|
# Ignore dividers when searching with context
|
186
142
|
# and empty lines
|
187
143
|
else
|
@@ -199,8 +155,11 @@ class Zoom::Cache
|
|
199
155
|
return if (empty?)
|
200
156
|
|
201
157
|
config.validate_colors
|
202
|
-
|
158
|
+
if (!config.has_profile?(profile_name))
|
159
|
+
raise Zoom::Error::ProfileDoesNotExists.new(profile_name)
|
160
|
+
end
|
203
161
|
|
162
|
+
profile = config.get_profile(profile_name)
|
204
163
|
if (!profile.taggable)
|
205
164
|
get_results.each do |result|
|
206
165
|
puts result.contents
|
data/lib/zoom/cache/result.rb
CHANGED
@@ -6,7 +6,7 @@ class Zoom::Cache::Result
|
|
6
6
|
attr_reader :tag
|
7
7
|
|
8
8
|
def args
|
9
|
-
return @cache.
|
9
|
+
return @cache.args
|
10
10
|
end
|
11
11
|
|
12
12
|
def grep_like?
|
@@ -35,15 +35,19 @@ class Zoom::Cache::Result
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def paths
|
39
|
+
return @cache.paths
|
40
|
+
end
|
41
|
+
|
38
42
|
def pattern
|
39
|
-
return @cache.
|
43
|
+
return @cache.pattern
|
40
44
|
end
|
41
45
|
|
42
46
|
def profile_name
|
43
|
-
return @cache.
|
47
|
+
return @cache.profile_name
|
44
48
|
end
|
45
49
|
|
46
50
|
def pwd
|
47
|
-
return @cache.
|
51
|
+
return @cache.pwd
|
48
52
|
end
|
49
53
|
end
|
data/lib/zoom/profile.rb
CHANGED
@@ -7,20 +7,20 @@ class Zoom::Profile < Hash
|
|
7
7
|
attr_reader :taggable
|
8
8
|
|
9
9
|
def after(a = nil)
|
10
|
-
self["after"] = a if (a)
|
11
|
-
return self["after"]
|
10
|
+
self["after"] = a.strip if (a)
|
11
|
+
return self["after"]
|
12
12
|
end
|
13
13
|
|
14
14
|
def before(b = nil)
|
15
|
-
self["before"] = b if (b)
|
16
|
-
return self["before"]
|
15
|
+
self["before"] = b.strip if (b)
|
16
|
+
return self["before"]
|
17
17
|
end
|
18
18
|
|
19
19
|
def class_name
|
20
20
|
return self["class"]
|
21
21
|
end
|
22
22
|
|
23
|
-
def exe(args, pattern)
|
23
|
+
def exe(args, pattern, paths)
|
24
24
|
# Use hard-coded pattern if defined
|
25
25
|
pattern = @pattern if (@pattern && !@pattern.empty?)
|
26
26
|
|
@@ -29,55 +29,88 @@ class Zoom::Profile < Hash
|
|
29
29
|
return "" if (after.nil? || after.empty? || after == ".")
|
30
30
|
end
|
31
31
|
|
32
|
+
# If paths are specified then remove "." for profiles like
|
33
|
+
# grep
|
34
|
+
after.gsub!(/^\.\s+/, "") if (!paths.empty?)
|
35
|
+
|
32
36
|
# Emulate grep
|
33
37
|
case operator.split("/")[-1]
|
34
38
|
when "ack", "ack-grep"
|
35
|
-
|
39
|
+
cmd = [
|
36
40
|
before,
|
37
41
|
operator,
|
38
42
|
"-H --nobreak --nocolor --noheading -s",
|
39
|
-
flags
|
43
|
+
flags,
|
44
|
+
args,
|
45
|
+
pattern.shellescape,
|
46
|
+
paths,
|
47
|
+
after
|
40
48
|
].join(" ").strip
|
41
|
-
return %x(#{str} #{args} #{pattern.shellescape} #{after})
|
42
49
|
when "ag"
|
43
|
-
|
50
|
+
cmd = [
|
44
51
|
before,
|
45
52
|
operator,
|
46
53
|
"--filename --nobreak --nocolor --noheading --silent",
|
47
|
-
flags
|
54
|
+
flags,
|
55
|
+
args,
|
56
|
+
pattern.shellescape,
|
57
|
+
paths,
|
58
|
+
after
|
48
59
|
].join(" ").strip
|
49
|
-
return %x(#{str} #{args} #{pattern.shellescape} #{after})
|
50
60
|
when "find"
|
51
|
-
|
52
|
-
|
61
|
+
flags.gsub!(/^\.\s+/, "") if (!paths.empty?)
|
62
|
+
cmd = [
|
63
|
+
before,
|
64
|
+
operator,
|
65
|
+
paths,
|
66
|
+
flags,
|
67
|
+
args,
|
68
|
+
"\"#{pattern}\"",
|
69
|
+
after
|
70
|
+
].join(" ").strip
|
53
71
|
when "grep"
|
54
|
-
|
72
|
+
cmd = [
|
55
73
|
before,
|
56
74
|
operator,
|
57
|
-
"--color=never -
|
75
|
+
"--color=never -EHInRs",
|
58
76
|
"--exclude-dir=.bzr",
|
59
77
|
"--exclude-dir=.git",
|
78
|
+
"--exclude-dir=.git-crypt",
|
60
79
|
"--exclude-dir=.svn",
|
61
|
-
flags
|
80
|
+
flags,
|
81
|
+
args,
|
82
|
+
pattern.shellescape,
|
83
|
+
paths,
|
84
|
+
after
|
62
85
|
].join(" ").strip
|
63
|
-
return %x(#{str} #{args} #{pattern.shellescape} #{after})
|
64
86
|
when "pt"
|
65
|
-
|
87
|
+
cmd = [
|
66
88
|
before,
|
67
89
|
operator,
|
68
90
|
"-e --nocolor --nogroup",
|
69
|
-
flags
|
91
|
+
flags,
|
92
|
+
args,
|
93
|
+
pattern.shellescape,
|
94
|
+
paths,
|
95
|
+
after
|
70
96
|
].join(" ").strip
|
71
|
-
return %x(#{str} #{args} #{pattern.shellescape} #{after})
|
72
97
|
else
|
73
|
-
|
74
|
-
|
98
|
+
cmd = [
|
99
|
+
before,
|
100
|
+
operator,
|
101
|
+
flags,
|
102
|
+
args,
|
103
|
+
pattern,
|
104
|
+
paths,
|
105
|
+
after
|
106
|
+
].join(" ").strip
|
75
107
|
end
|
108
|
+
return %x(#{cmd})
|
76
109
|
end
|
77
110
|
|
78
111
|
def flags(f = nil)
|
79
|
-
self["flags"] = f if (f)
|
80
|
-
return self["flags"]
|
112
|
+
self["flags"] = f.strip if (f)
|
113
|
+
return self["flags"]
|
81
114
|
end
|
82
115
|
|
83
116
|
def self.from_json(json)
|
@@ -146,7 +179,7 @@ class Zoom::Profile < Hash
|
|
146
179
|
self["class"] = self.class.to_s
|
147
180
|
after(a)
|
148
181
|
before(b)
|
149
|
-
flags(f
|
182
|
+
flags(f)
|
150
183
|
name(n)
|
151
184
|
operator(o)
|
152
185
|
|
@@ -155,17 +188,18 @@ class Zoom::Profile < Hash
|
|
155
188
|
end
|
156
189
|
|
157
190
|
def name(n = nil)
|
158
|
-
self["name"] = n if (n)
|
159
|
-
return self["name"]
|
191
|
+
self["name"] = n.strip if (n)
|
192
|
+
return self["name"]
|
160
193
|
end
|
161
194
|
|
162
195
|
def operator(o = nil)
|
163
196
|
if (o)
|
197
|
+
o.strip!
|
164
198
|
op = ScoobyDoo.where_are_you(o)
|
165
199
|
raise Zoom::Error::ExecutableNotFound.new(o) if (op.nil?)
|
166
200
|
self["operator"] = o
|
167
201
|
end
|
168
|
-
return self["operator"]
|
202
|
+
return self["operator"]
|
169
203
|
end
|
170
204
|
|
171
205
|
def self.profile_by_name(clas)
|
data/lib/zoom/profile/grep.rb
CHANGED
@@ -2,17 +2,15 @@ require "zoom/profile_manager"
|
|
2
2
|
|
3
3
|
case Zoom::ProfileManager.default_profile
|
4
4
|
when /^ack(-grep)?$/
|
5
|
-
class Zoom::Profile::Passwords < Zoom::Profile::Ack
|
6
|
-
end
|
5
|
+
class Zoom::Profile::Passwords < Zoom::Profile::Ack; end
|
7
6
|
when "ag"
|
8
|
-
class Zoom::Profile::Passwords < Zoom::Profile::Ag
|
9
|
-
end
|
7
|
+
class Zoom::Profile::Passwords < Zoom::Profile::Ag; end
|
10
8
|
when "pt"
|
11
|
-
class Zoom::Profile::Passwords < Zoom::Profile::Pt
|
12
|
-
|
9
|
+
class Zoom::Profile::Passwords < Zoom::Profile::Pt; end
|
10
|
+
when "grep"
|
11
|
+
class Zoom::Profile::Passwords < Zoom::Profile::Grep; end
|
13
12
|
else
|
14
|
-
|
15
|
-
end
|
13
|
+
# Shouldn't happen
|
16
14
|
end
|
17
15
|
|
18
16
|
class Zoom::Profile::Passwords
|
@@ -22,13 +20,15 @@ class Zoom::Profile::Passwords
|
|
22
20
|
|
23
21
|
case op
|
24
22
|
when /^ack(-grep)?$/
|
25
|
-
super(n, op, "--smart-case", "", after)
|
23
|
+
super(n, op, "--smart-case #{f}", "", after)
|
26
24
|
when "ag"
|
27
|
-
super(n, op, "-Su", "", after)
|
25
|
+
super(n, op, "-Su #{f}", "", after)
|
28
26
|
when "pt"
|
29
|
-
super(n, op, "-SU --hidden", "", after)
|
27
|
+
super(n, op, "-SU --hidden #{f}", "", after)
|
28
|
+
when "grep"
|
29
|
+
super(n, op, "-ai #{f}", "", after)
|
30
30
|
else
|
31
|
-
|
31
|
+
# Shouldn't happen
|
32
32
|
end
|
33
33
|
|
34
34
|
@pattern = "(key|pass(word|wd)?)[^:=,>]? *[:=,>]"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-zoom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Whittaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
205
|
version: '0'
|
206
206
|
requirements: []
|
207
207
|
rubyforge_project:
|
208
|
-
rubygems_version: 2.4.
|
208
|
+
rubygems_version: 2.4.5.1
|
209
209
|
signing_key:
|
210
210
|
specification_version: 4
|
211
211
|
summary: Quickly open CLI search results in your favorite editor!
|