ruby-zoom 4.3.2 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69f08853e0d57951199bd5457687518398ed65eb
4
- data.tar.gz: 05bc33a3d915ee9a1d4bc819f0943c8de682febc
3
+ metadata.gz: cae14a1830640da75b5ab95bc66e0039676601a2
4
+ data.tar.gz: a027b2d2e95ffc2a151bad4fe9d05ef9c4d2db13
5
5
  SHA512:
6
- metadata.gz: 12dc726079299ef9971130305bfde110b7a96e4384f4718bcbb4a03a7f6bdafbcb13f5586197a77176e36d9778f5322b57f28ccde571f162df98756abfa288f9
7
- data.tar.gz: 58515511ddba68d407730311e4330b500970fd3b47adcf0652cac6863db61f87a6a6d7e685a217cf91b147901c22bd59c397d99251e4ce93a4ee8ad387eba475
6
+ metadata.gz: ac0e4985295cb5d5b5cb44b75acee5b3ae174aebd916c2f939fa5b1979e80d355edaa5da51d871a2c51c7d7e46264e0575e85927160a375a1e71890bb6a14b1f
7
+ data.tar.gz: fb425a3f9d85016af48964168ed8e2afeb102a8f68841b8321357d667c36bffa9018af49673b570da119e0a356902d35d43a7164e174361f87976ee35f41f7f1
data/bin/z CHANGED
@@ -20,6 +20,7 @@ def parse(args)
20
20
  options = Hash.new
21
21
  options["action"] = "exec"
22
22
  options["cache_file"] = nil
23
+ options["translate_flags"] = Hash.new
23
24
  options["use"] = nil
24
25
  options["verbose"] = false
25
26
 
@@ -83,6 +84,14 @@ def parse(args)
83
84
  exit ZoomExit::GOOD
84
85
  end
85
86
 
87
+ opts.on(
88
+ "-i",
89
+ "--ignore=PATTERN",
90
+ "Ignore files/directories matching PATTERN"
91
+ ) do |pattern|
92
+ options["translate_flags"]["ignore"] = pattern
93
+ end
94
+
86
95
  opts.on("-l", "--list", "List profiles") do
87
96
  options["action"] = "list_profiles"
88
97
  end
@@ -95,7 +104,11 @@ def parse(args)
95
104
  options["use"] = name
96
105
  end
97
106
 
98
- opts.on("-w", "--which", "Display current profile") do
107
+ opts.on("-w", "--word-regexp", "Only match whole words") do
108
+ options["translate_flags"]["word-regexp"] = ""
109
+ end
110
+
111
+ opts.on("--which", "Display current profile") do
99
112
  options["action"] = "which"
100
113
  end
101
114
 
@@ -221,7 +234,7 @@ def parse(args)
221
234
  end
222
235
 
223
236
  options["pattern"] = path
224
- options["subargs"] = args.join(" ")
237
+ options["pass_args"] = args.join(" ")
225
238
 
226
239
  return options
227
240
  end
@@ -307,10 +320,11 @@ begin
307
320
  else
308
321
  # Search and cache results
309
322
  header = Hash.new
310
- header["profile_name"] = options["use"]
311
- header["args"] = options["subargs"]
312
- header["pattern"] = options["pattern"]
323
+ header["args"] = options["pass_args"]
313
324
  header["paths"] = options["paths"]
325
+ header["pattern"] = options["pattern"]
326
+ header["profile_name"] = options["use"]
327
+ header["translate"] = options["translate_flags"]
314
328
  zoom.run(header)
315
329
  end
316
330
  rescue SystemExit
data/bin/zc CHANGED
@@ -20,6 +20,7 @@ def parse(args)
20
20
  options = Hash.new
21
21
  options["action"] = "exec"
22
22
  options["cache_file"] = nil
23
+ options["translate_flags"] = Hash.new
23
24
  options["use"] = nil
24
25
  options["verbose"] = false
25
26
 
@@ -83,6 +84,14 @@ def parse(args)
83
84
  exit ZoomExit::GOOD
84
85
  end
85
86
 
87
+ opts.on(
88
+ "-i",
89
+ "--ignore=PATTERN",
90
+ "Ignore files/directories matching PATTERN"
91
+ ) do |pattern|
92
+ options["translate_flags"]["ignore"] = pattern
93
+ end
94
+
86
95
  opts.on("-l", "--list", "List profiles") do
87
96
  options["action"] = "list_profiles"
88
97
  end
@@ -95,7 +104,11 @@ def parse(args)
95
104
  options["use"] = name
96
105
  end
97
106
 
98
- opts.on("-w", "--which", "Display current profile") do
107
+ opts.on("-w", "--word-regexp", "Only match whole words") do
108
+ options["translate_flags"]["word-regexp"] = ""
109
+ end
110
+
111
+ opts.on("--which", "Display current profile") do
99
112
  options["action"] = "which"
100
113
  end
101
114
 
@@ -221,7 +234,7 @@ def parse(args)
221
234
  end
222
235
 
223
236
  options["pattern"] = path
224
- options["subargs"] = args.join(" ")
237
+ options["pass_args"] = args.join(" ")
225
238
 
226
239
  return options
227
240
  end
@@ -307,10 +320,11 @@ begin
307
320
  else
308
321
  # Search and cache results
309
322
  header = Hash.new
310
- header["profile_name"] = options["use"]
311
- header["args"] = options["subargs"]
312
- header["pattern"] = options["pattern"]
323
+ header["args"] = options["pass_args"]
313
324
  header["paths"] = options["paths"]
325
+ header["pattern"] = options["pattern"]
326
+ header["profile_name"] = options["use"]
327
+ header["translate"] = options["translate_flags"]
314
328
  zoom.run(header)
315
329
  end
316
330
  rescue SystemExit
data/bin/zf CHANGED
@@ -20,6 +20,7 @@ def parse(args)
20
20
  options = Hash.new
21
21
  options["action"] = "exec"
22
22
  options["cache_file"] = nil
23
+ options["translate_flags"] = Hash.new
23
24
  options["use"] = nil
24
25
  options["verbose"] = false
25
26
 
@@ -83,6 +84,14 @@ def parse(args)
83
84
  exit ZoomExit::GOOD
84
85
  end
85
86
 
87
+ opts.on(
88
+ "-i",
89
+ "--ignore=PATTERN",
90
+ "Ignore files/directories matching PATTERN"
91
+ ) do |pattern|
92
+ options["translate_flags"]["ignore"] = pattern
93
+ end
94
+
86
95
  opts.on("-l", "--list", "List profiles") do
87
96
  options["action"] = "list_profiles"
88
97
  end
@@ -95,7 +104,11 @@ def parse(args)
95
104
  options["use"] = name
96
105
  end
97
106
 
98
- opts.on("-w", "--which", "Display current profile") do
107
+ opts.on("-w", "--word-regexp", "Only match whole words") do
108
+ options["translate_flags"]["word-regexp"] = ""
109
+ end
110
+
111
+ opts.on("--which", "Display current profile") do
99
112
  options["action"] = "which"
100
113
  end
101
114
 
@@ -221,7 +234,7 @@ def parse(args)
221
234
  end
222
235
 
223
236
  options["pattern"] = path
224
- options["subargs"] = args.join(" ")
237
+ options["pass_args"] = args.join(" ")
225
238
 
226
239
  return options
227
240
  end
@@ -307,10 +320,11 @@ begin
307
320
  else
308
321
  # Search and cache results
309
322
  header = Hash.new
310
- header["profile_name"] = options["use"]
311
- header["args"] = options["subargs"]
312
- header["pattern"] = options["pattern"]
323
+ header["args"] = options["pass_args"]
313
324
  header["paths"] = options["paths"]
325
+ header["pattern"] = options["pattern"]
326
+ header["profile_name"] = options["use"]
327
+ header["translate"] = options["translate_flags"]
314
328
  zoom.run(header)
315
329
  end
316
330
  rescue SystemExit
data/bin/zg CHANGED
@@ -20,6 +20,7 @@ def parse(args)
20
20
  options = Hash.new
21
21
  options["action"] = "exec"
22
22
  options["cache_file"] = nil
23
+ options["translate_flags"] = Hash.new
23
24
  options["use"] = nil
24
25
  options["verbose"] = false
25
26
 
@@ -83,6 +84,14 @@ def parse(args)
83
84
  exit ZoomExit::GOOD
84
85
  end
85
86
 
87
+ opts.on(
88
+ "-i",
89
+ "--ignore=PATTERN",
90
+ "Ignore files/directories matching PATTERN"
91
+ ) do |pattern|
92
+ options["translate_flags"]["ignore"] = pattern
93
+ end
94
+
86
95
  opts.on("-l", "--list", "List profiles") do
87
96
  options["action"] = "list_profiles"
88
97
  end
@@ -95,7 +104,11 @@ def parse(args)
95
104
  options["use"] = name
96
105
  end
97
106
 
98
- opts.on("-w", "--which", "Display current profile") do
107
+ opts.on("-w", "--word-regexp", "Only match whole words") do
108
+ options["translate_flags"]["word-regexp"] = ""
109
+ end
110
+
111
+ opts.on("--which", "Display current profile") do
99
112
  options["action"] = "which"
100
113
  end
101
114
 
@@ -221,7 +234,7 @@ def parse(args)
221
234
  end
222
235
 
223
236
  options["pattern"] = path
224
- options["subargs"] = args.join(" ")
237
+ options["pass_args"] = args.join(" ")
225
238
 
226
239
  return options
227
240
  end
@@ -307,10 +320,11 @@ begin
307
320
  else
308
321
  # Search and cache results
309
322
  header = Hash.new
310
- header["profile_name"] = options["use"]
311
- header["args"] = options["subargs"]
312
- header["pattern"] = options["pattern"]
323
+ header["args"] = options["pass_args"]
313
324
  header["paths"] = options["paths"]
325
+ header["pattern"] = options["pattern"]
326
+ header["profile_name"] = options["use"]
327
+ header["translate"] = options["translate_flags"]
314
328
  zoom.run(header)
315
329
  end
316
330
  rescue SystemExit
data/bin/zl CHANGED
@@ -20,6 +20,7 @@ def parse(args)
20
20
  options = Hash.new
21
21
  options["action"] = "exec"
22
22
  options["cache_file"] = nil
23
+ options["translate_flags"] = Hash.new
23
24
  options["use"] = nil
24
25
  options["verbose"] = false
25
26
 
@@ -83,6 +84,14 @@ def parse(args)
83
84
  exit ZoomExit::GOOD
84
85
  end
85
86
 
87
+ opts.on(
88
+ "-i",
89
+ "--ignore=PATTERN",
90
+ "Ignore files/directories matching PATTERN"
91
+ ) do |pattern|
92
+ options["translate_flags"]["ignore"] = pattern
93
+ end
94
+
86
95
  opts.on("-l", "--list", "List profiles") do
87
96
  options["action"] = "list_profiles"
88
97
  end
@@ -95,7 +104,11 @@ def parse(args)
95
104
  options["use"] = name
96
105
  end
97
106
 
98
- opts.on("-w", "--which", "Display current profile") do
107
+ opts.on("-w", "--word-regexp", "Only match whole words") do
108
+ options["translate_flags"]["word-regexp"] = ""
109
+ end
110
+
111
+ opts.on("--which", "Display current profile") do
99
112
  options["action"] = "which"
100
113
  end
101
114
 
@@ -221,7 +234,7 @@ def parse(args)
221
234
  end
222
235
 
223
236
  options["pattern"] = path
224
- options["subargs"] = args.join(" ")
237
+ options["pass_args"] = args.join(" ")
225
238
 
226
239
  return options
227
240
  end
@@ -307,10 +320,11 @@ begin
307
320
  else
308
321
  # Search and cache results
309
322
  header = Hash.new
310
- header["profile_name"] = options["use"]
311
- header["args"] = options["subargs"]
312
- header["pattern"] = options["pattern"]
323
+ header["args"] = options["pass_args"]
313
324
  header["paths"] = options["paths"]
325
+ header["pattern"] = options["pattern"]
326
+ header["profile_name"] = options["use"]
327
+ header["translate"] = options["translate_flags"]
314
328
  zoom.run(header)
315
329
  end
316
330
  rescue SystemExit
data/bin/zr CHANGED
@@ -20,6 +20,7 @@ def parse(args)
20
20
  options = Hash.new
21
21
  options["action"] = "exec"
22
22
  options["cache_file"] = nil
23
+ options["translate_flags"] = Hash.new
23
24
  options["use"] = nil
24
25
  options["verbose"] = false
25
26
 
@@ -83,6 +84,14 @@ def parse(args)
83
84
  exit ZoomExit::GOOD
84
85
  end
85
86
 
87
+ opts.on(
88
+ "-i",
89
+ "--ignore=PATTERN",
90
+ "Ignore files/directories matching PATTERN"
91
+ ) do |pattern|
92
+ options["translate_flags"]["ignore"] = pattern
93
+ end
94
+
86
95
  opts.on("-l", "--list", "List profiles") do
87
96
  options["action"] = "list_profiles"
88
97
  end
@@ -95,7 +104,11 @@ def parse(args)
95
104
  options["use"] = name
96
105
  end
97
106
 
98
- opts.on("-w", "--which", "Display current profile") do
107
+ opts.on("-w", "--word-regexp", "Only match whole words") do
108
+ options["translate_flags"]["word-regexp"] = ""
109
+ end
110
+
111
+ opts.on("--which", "Display current profile") do
99
112
  options["action"] = "which"
100
113
  end
101
114
 
@@ -221,7 +234,7 @@ def parse(args)
221
234
  end
222
235
 
223
236
  options["pattern"] = path
224
- options["subargs"] = args.join(" ")
237
+ options["pass_args"] = args.join(" ")
225
238
 
226
239
  return options
227
240
  end
@@ -307,10 +320,11 @@ begin
307
320
  else
308
321
  # Search and cache results
309
322
  header = Hash.new
310
- header["profile_name"] = options["use"]
311
- header["args"] = options["subargs"]
312
- header["pattern"] = options["pattern"]
323
+ header["args"] = options["pass_args"]
313
324
  header["paths"] = options["paths"]
325
+ header["pattern"] = options["pattern"]
326
+ header["profile_name"] = options["use"]
327
+ header["translate"] = options["translate_flags"]
314
328
  zoom.run(header)
315
329
  end
316
330
  rescue SystemExit
@@ -27,18 +27,21 @@ class Zoom
27
27
  profile.go(@config.editor, results)
28
28
  end
29
29
 
30
- def repeat
30
+ def repeat(shortcut = true)
31
31
  return if (@cache.empty?)
32
- run(@cache.header)
32
+ run(@cache.header, shortcut)
33
33
  end
34
34
 
35
- def run(header)
36
- profile_name = header["profile_name"]
37
- args = header["args"]
38
- pattern = header["pattern"]
39
- paths = header["paths"]
35
+ def run(header, shortcut = true)
36
+ # Ensure header has no nil
37
+ ["args", "paths", "pattern", "profile_name"].each do |key|
38
+ header[key] ||= ""
39
+ end
40
+ header["pwd"] = Dir.pwd
41
+ header["translate"] ||= Array.new
40
42
 
41
- if (profile_name.nil?)
43
+ profile_name = header["profile_name"]
44
+ if (profile_name.empty?)
42
45
  profile_name = @config.current_profile_name
43
46
  header["profile_name"] = profile_name
44
47
  end
@@ -48,10 +51,9 @@ class Zoom
48
51
  end
49
52
 
50
53
  profile = @config.get_profile(profile_name)
51
- if (pattern.nil? || !profile.pattern.empty?)
54
+ if (!profile.pattern.empty?)
52
55
  header["pattern"] = profile.pattern
53
56
  end
54
- header["pwd"] = Dir.pwd
55
57
 
56
58
  begin
57
59
  # Clear cache
@@ -60,11 +62,15 @@ class Zoom
60
62
  # Store needed details
61
63
  @cache.header(header)
62
64
 
65
+ # This will translate and/or append args such that the
66
+ # output will be something Zoom can process
67
+ header = profile.preprocess(header)
68
+
63
69
  # Execute profile
64
- @cache.write(profile.exe(args, pattern, paths))
70
+ @cache.write(profile.exe(header))
65
71
 
66
72
  # Display results from cache
67
- @cache.shortcut(@config)
73
+ @cache.shortcut(@config) if (shortcut)
68
74
  rescue Interrupt
69
75
  # ^C
70
76
  end
@@ -82,7 +82,9 @@ class Zoom::Cache
82
82
  end
83
83
 
84
84
  def parse_tags(input)
85
- raise Zoom::Error::InvalidTag.new if (input.nil? || input.empty?)
85
+ if (input.nil? || input.empty?)
86
+ raise Zoom::Error::InvalidTag.new
87
+ end
86
88
 
87
89
  tags = Array.new
88
90
  input.split(",").each do |num|
@@ -5,10 +5,6 @@ class Zoom::Cache::Result
5
5
  attr_reader :match
6
6
  attr_reader :tag
7
7
 
8
- def args
9
- return @cache.args
10
- end
11
-
12
8
  def grep_like?
13
9
  return @grep_like
14
10
  end
@@ -35,14 +31,6 @@ class Zoom::Cache::Result
35
31
  end
36
32
  end
37
33
 
38
- def paths
39
- return @cache.paths
40
- end
41
-
42
- def pattern
43
- return @cache.pattern
44
- end
45
-
46
34
  def profile_name
47
35
  return @cache.profile_name
48
36
  end
@@ -3,16 +3,19 @@ require "scoobydoo"
3
3
  require "shellwords"
4
4
 
5
5
  class Zoom::Profile < Hash
6
+ attr_reader :format_flags
6
7
  attr_reader :pattern
7
8
  attr_reader :taggable
8
9
 
9
10
  def after(a = nil)
10
11
  self["after"] = a.strip if (a)
12
+ self["after"] ||= ""
11
13
  return self["after"]
12
14
  end
13
15
 
14
16
  def before(b = nil)
15
17
  self["before"] = b.strip if (b)
18
+ self["before"] ||= ""
16
19
  return self["before"]
17
20
  end
18
21
 
@@ -20,86 +23,28 @@ class Zoom::Profile < Hash
20
23
  return self["class"]
21
24
  end
22
25
 
23
- def exe(args, pattern, paths)
24
- # Use hard-coded pattern if defined
25
- if (@pattern && !@pattern.empty? && (pattern != @pattern))
26
- args += " #{pattern}"
27
- pattern = @pattern
28
- end
29
-
30
- # If not pattern and no after, then return nothing
31
- if (pattern.nil? || pattern.empty?)
32
- return "" if (after.nil? || after.empty?)
33
- end
34
-
26
+ def exe(header)
35
27
  # Emulate grep
36
28
  case operator.split("/")[-1]
37
- when "ack", "ack-grep"
38
- cmd = [
39
- before,
40
- operator,
41
- "-H --nobreak --nocolor --noheading -s",
42
- flags,
43
- args,
44
- pattern.shellescape,
45
- paths,
46
- after
47
- ].join(" ").strip
48
- when "ag"
49
- cmd = [
50
- before,
51
- operator,
52
- "--filename --nobreak --nocolor --noheading --silent",
53
- flags,
54
- args,
55
- pattern.shellescape,
56
- paths,
57
- after
58
- ].join(" ").strip
59
29
  when "find"
60
30
  cmd = [
61
31
  before,
62
32
  operator,
63
- paths,
64
- flags,
65
- args,
66
- "\"#{pattern}\"",
67
- after
68
- ].join(" ").strip
69
- when "grep"
70
- cmd = [
71
- before,
72
- operator,
73
- "--color=never -EHInRs",
74
- flags,
75
- args,
76
- "--exclude-dir=.bzr",
77
- "--exclude-dir=.git",
78
- "--exclude-dir=.git-crypt",
79
- "--exclude-dir=.svn",
80
- pattern.shellescape,
81
- paths,
82
- after
83
- ].join(" ").strip
84
- when "pt"
85
- cmd = [
86
- before,
87
- operator,
88
- "-e --nocolor --nogroup",
33
+ header["paths"],
89
34
  flags,
90
- args,
91
- pattern.shellescape,
92
- paths,
35
+ header["args"],
36
+ header["pattern"],
93
37
  after
94
38
  ].join(" ").strip
95
39
  else
96
40
  cmd = [
97
41
  before,
98
42
  operator,
43
+ @format_flags,
99
44
  flags,
100
- args,
101
- pattern,
102
- paths,
45
+ header["args"],
46
+ header["pattern"],
47
+ header["paths"],
103
48
  after
104
49
  ].join(" ").strip
105
50
  end
@@ -108,6 +53,7 @@ class Zoom::Profile < Hash
108
53
 
109
54
  def flags(f = nil)
110
55
  self["flags"] = f.strip if (f)
56
+ self["flags"] ||= ""
111
57
  return self["flags"]
112
58
  end
113
59
 
@@ -187,6 +133,7 @@ class Zoom::Profile < Hash
187
133
 
188
134
  def name(n = nil)
189
135
  self["name"] = n.strip if (n)
136
+ self["name"] ||= ""
190
137
  return self["name"]
191
138
  end
192
139
 
@@ -200,6 +147,38 @@ class Zoom::Profile < Hash
200
147
  return self["operator"]
201
148
  end
202
149
 
150
+ def preprocess(header)
151
+ # Use hard-coded pattern if defined
152
+ pattern = header["pattern"]
153
+ if (@pattern && !@pattern.empty? && (pattern != @pattern))
154
+ header["args"] += " #{pattern}"
155
+ header["pattern"] = @pattern
156
+ end
157
+
158
+ case operator.split("/")[-1]
159
+ when /^ack(-grep)?$/, "ag", "grep", "pt"
160
+ header["pattern"] = header["pattern"].shellescape
161
+ when "find"
162
+ # If additional args are passed, then assume pattern is
163
+ # actually and arg
164
+ if (header["args"] && !header["args"].empty?)
165
+ header["args"] += " #{header["pattern"]}"
166
+ header["pattern"] = ""
167
+ end
168
+
169
+ # If pattern was provided then assume it's an iname search
170
+ if (header["pattern"] && !header["pattern"].empty?)
171
+ header["pattern"] = "-iname \"#{header["pattern"]}\""
172
+ end
173
+ end
174
+
175
+ # Translate any needed flags
176
+ header["args"] += " #{translate(header["translate"])}"
177
+ header["args"].strip!
178
+
179
+ return header
180
+ end
181
+
203
182
  def self.profile_by_name(clas)
204
183
  clas.split("::").inject(Object) do |mod, class_name|
205
184
  mod.const_get(class_name)
@@ -236,6 +215,10 @@ class Zoom::Profile < Hash
236
215
  ret.push(hilight_after(after)) if (!after.empty?)
237
216
  return ret.join(" ").strip
238
217
  end
218
+
219
+ def translate(from)
220
+ return ""
221
+ end
239
222
  end
240
223
 
241
224
  require "zoom/profile/ack"
@@ -6,6 +6,27 @@ class Zoom::Profile::Ack < Zoom::Profile
6
6
  end
7
7
 
8
8
  super(n, o, f, b, a)
9
+ @format_flags = [
10
+ "-H",
11
+ "--follow",
12
+ "--nobreak",
13
+ "--nocolor",
14
+ "--noheading",
15
+ "-s"
16
+ ].join(" ")
9
17
  @taggable = true
10
18
  end
19
+
20
+ def translate(from)
21
+ to = Array.new
22
+ from.each do |flag, value|
23
+ case flag
24
+ when "ignore"
25
+ to.push("--type-set=zoom:match:/#{value}/ --zoom")
26
+ when "word-regexp"
27
+ to.push("-w")
28
+ end
29
+ end
30
+ return to.join(" ")
31
+ end
11
32
  end
@@ -1,6 +1,26 @@
1
1
  class Zoom::Profile::Ag < Zoom::Profile
2
2
  def initialize(n, o = "ag", f = "-S", b = "", a = "")
3
3
  super(n, o, f, b, a)
4
+ @format_flags = [
5
+ "--filename",
6
+ "--nobreak",
7
+ "--nocolor",
8
+ "--noheading",
9
+ "--silent"
10
+ ].join(" ")
4
11
  @taggable = true
5
12
  end
13
+
14
+ def translate(from)
15
+ to = Array.new
16
+ from.each do |flag, value|
17
+ case flag
18
+ when "ignore"
19
+ to.push("--ignore=#{value}")
20
+ when "word-regexp"
21
+ to.push("-w")
22
+ end
23
+ end
24
+ return to.join(" ")
25
+ end
6
26
  end
@@ -1,5 +1,5 @@
1
1
  class Zoom::Profile::Find < Zoom::Profile
2
- def initialize(n, o = "find", f = "-name", b = "", a = "")
2
+ def initialize(n, o = "find", f = "", b = "", a = "")
3
3
  super(n, o, f, b, a)
4
4
  @taggable = true
5
5
  end
@@ -1,6 +1,27 @@
1
1
  class Zoom::Profile::Grep < Zoom::Profile
2
2
  def initialize(n, o = "grep", f = "-i", b = "", a = "")
3
3
  super(n, o, f, b, a)
4
+ @format_flags = [
5
+ "--color=never",
6
+ "-EHInRs",
7
+ "--exclude-dir=.bzr",
8
+ "--exclude-dir=.git",
9
+ "--exclude-dir=.git-crypt",
10
+ "--exclude-dir=.svn"
11
+ ].join(" ")
4
12
  @taggable = true
5
13
  end
14
+
15
+ def translate(from)
16
+ to = Array.new
17
+ from.each do |flag, value|
18
+ case flag
19
+ when "ignore"
20
+ to.push("--exclude=#{value}")
21
+ when "word-regexp"
22
+ to.push("-w")
23
+ end
24
+ end
25
+ return to.join(" ")
26
+ end
6
27
  end
@@ -4,10 +4,7 @@ clas = Zoom::ProfileManager.default_profile.capitalize
4
4
  superclass = Zoom::Profile.profile_by_name("Zoom::Profile::#{clas}")
5
5
  class Zoom::Profile::Passwords < superclass
6
6
  def initialize(n, o = nil, f = "", b = "", a = "")
7
- # I don't care about test code
8
- after = "| \\grep -v \"^[^:]*test[^:]*:[0-9]+:\""
9
7
  flags = ""
10
-
11
8
  op = Zoom::ProfileManager.default_profile
12
9
  case op
13
10
  when /^ack(-grep)?$/
@@ -20,8 +17,8 @@ class Zoom::Profile::Passwords < superclass
20
17
  flags = "-ai"
21
18
  end
22
19
 
23
- super(n, op, flags, "", after)
24
- @pattern = "(key|pass(word|wd)?)[^:=,>]? *[:=,>]"
20
+ super(n, op, flags)
21
+ @pattern = "(key|pass(wd|word)?)[^:=,>]? *[:=,>]"
25
22
  @taggable = true
26
23
  end
27
24
  end
@@ -1,6 +1,20 @@
1
1
  class Zoom::Profile::Pt < Zoom::Profile
2
2
  def initialize(n, o = "pt", f = "-S", b = "", a = "")
3
3
  super(n, o, f, b, a)
4
+ @format_flags = "-e --nocolor --nogroup"
4
5
  @taggable = true
5
6
  end
7
+
8
+ def translate(from)
9
+ to = Array.new
10
+ from.each do |flag, value|
11
+ case flag
12
+ when "ignore"
13
+ to.push("--ignore=#{value}")
14
+ when "word-regexp"
15
+ to.push("-w")
16
+ end
17
+ end
18
+ return to.join(" ")
19
+ end
6
20
  end
@@ -4,10 +4,7 @@ clas = Zoom::ProfileManager.default_profile.capitalize
4
4
  superclass = Zoom::Profile.profile_by_name("Zoom::Profile::#{clas}")
5
5
  class Zoom::Profile::UnsafeC < superclass
6
6
  def initialize(n, o = nil, f = "", b = "", a = "")
7
- # I don't care about test code
8
- after = "| \\grep -v \"^[^:]*test[^:]*:[0-9]+:\""
9
7
  flags = ""
10
-
11
8
  op = Zoom::ProfileManager.default_profile
12
9
  case op
13
10
  when /^ack(-grep)?$/
@@ -20,7 +17,7 @@ class Zoom::Profile::UnsafeC < superclass
20
17
  flags = "-i --include=\"*.[ch]\" --include=\"*.[ch]pp\""
21
18
  end
22
19
 
23
- super(n, op, flags, "", after)
20
+ super(n, op, flags)
24
21
  @pattern = [
25
22
  "(",
26
23
  [
@@ -4,10 +4,7 @@ clas = Zoom::ProfileManager.default_profile.capitalize
4
4
  superclass = Zoom::Profile.profile_by_name("Zoom::Profile::#{clas}")
5
5
  class Zoom::Profile::UnsafeJava < superclass
6
6
  def initialize(n, o = nil, f = "", b = "", a = "")
7
- # I don't care about test code
8
- after = "| \\grep -v \"^[^:]*test[^:]*:[0-9]+:\""
9
7
  flags = ""
10
-
11
8
  op = Zoom::ProfileManager.default_profile
12
9
  case op
13
10
  when /^ack(-grep)?$/
@@ -24,8 +21,8 @@ class Zoom::Profile::UnsafeJava < superclass
24
21
  ].join(" ")
25
22
  end
26
23
 
27
- super(n, op, flags, "", after)
28
- @pattern = "(sun\\.misc\\.)?Unsafe|readObject\\(\\)"
24
+ super(n, op, flags)
25
+ @pattern = "(sun\\.misc\\.)?Unsafe|readObject\\("
29
26
  @taggable = true
30
27
  end
31
28
  end
@@ -4,10 +4,7 @@ clas = Zoom::ProfileManager.default_profile.capitalize
4
4
  superclass = Zoom::Profile.profile_by_name("Zoom::Profile::#{clas}")
5
5
  class Zoom::Profile::UnsafeJs < superclass
6
6
  def initialize(n, o = nil, f = "", b = "", a = "")
7
- # I don't care about test code
8
- after = "| \\grep -v \"^[^:]*test[^:]*:[0-9]+:\""
9
7
  flags = ""
10
-
11
8
  op = Zoom::ProfileManager.default_profile
12
9
  case op
13
10
  when /^ack(-grep)?$/
@@ -20,8 +17,8 @@ class Zoom::Profile::UnsafeJs < superclass
20
17
  flags = "-i --include=\"*.js\""
21
18
  end
22
19
 
23
- super(n, op, flags, "", after)
24
- @pattern = "\\.((eval|html)\\(|innerHTML)"
20
+ super(n, op, flags)
21
+ @pattern = "\\.((append|eval|html)\\(|innerHTML)"
25
22
  @taggable = true
26
23
  end
27
24
  end
@@ -4,10 +4,7 @@ clas = Zoom::ProfileManager.default_profile.capitalize
4
4
  superclass = Zoom::Profile.profile_by_name("Zoom::Profile::#{clas}")
5
5
  class Zoom::Profile::UnsafePhp < superclass
6
6
  def initialize(n, o = nil, f = "", b = "", a = "")
7
- # I don't care about test code
8
- after = "| \\grep -v \"^[^:]*test[^:]*:[0-9]+:\""
9
7
  flags = ""
10
-
11
8
  op = Zoom::ProfileManager.default_profile
12
9
  case op
13
10
  when /^ack(-grep)?$/
@@ -25,12 +22,13 @@ class Zoom::Profile::UnsafePhp < superclass
25
22
  ].join(" ")
26
23
  end
27
24
 
28
- super(n, op, flags, "", after)
25
+ super(n, op, flags)
29
26
  # From here: https://www.eukhost.com/blog/webhosting/dangerous-php-functions-must-be-disabled/
30
27
  # OMG is anything safe?!
31
28
  @pattern = [
32
29
  "\\`|",
33
30
  "\\$_GET\\[|",
31
+ "(include|require)(_once)?|",
34
32
  "(",
35
33
  [
36
34
  "apache_(child_terminate|setenv)",
@@ -42,7 +40,6 @@ class Zoom::Profile::UnsafePhp < superclass
42
40
  "fp(ut)?",
43
41
  "ftp_(connect|exec|get|login|(nb_f)?put|raw(list)?)",
44
42
  "highlight_file",
45
- "include(_once)?",
46
43
  "ini_(alter|get_all|restore)",
47
44
  "inject_code",
48
45
  "mysql_pconnect",
@@ -52,10 +49,9 @@ class Zoom::Profile::UnsafePhp < superclass
52
49
  "php_uname",
53
50
  "phpAds_(remoteInfo|XmlRpc|xmlrpc(De|En)code)",
54
51
  "popen",
55
- "posix_(getpwuid|kill|mkfifo|set(pg|s|u)id|_uname)",
52
+ "posix_(getpwuid|kill|mkfifo|set(pg|s|u)id|uname)",
56
53
  "preg_replace",
57
54
  "proc_(close|get_status|nice|open|terminate)",
58
- "require(_once)?",
59
55
  "(shell_)?exec",
60
56
  "sys(log|tem)",
61
57
  "xmlrpc_entity_decode"
@@ -4,10 +4,7 @@ clas = Zoom::ProfileManager.default_profile.capitalize
4
4
  superclass = Zoom::Profile.profile_by_name("Zoom::Profile::#{clas}")
5
5
  class Zoom::Profile::UnsafePython < superclass
6
6
  def initialize(n, o = nil, f = "", b = "", a = "")
7
- # I don't care about test code
8
- after = "| \\grep -v \"^[^:]*test[^:]*:[0-9]+:\""
9
7
  flags = ""
10
-
11
8
  op = Zoom::ProfileManager.default_profile
12
9
  case op
13
10
  when /^ack(-grep)?$/
@@ -20,7 +17,7 @@ class Zoom::Profile::UnsafePython < superclass
20
17
  flags = "-i --include=\"*.py\""
21
18
  end
22
19
 
23
- super(n, op, flags, "", after)
20
+ super(n, op, flags)
24
21
  @pattern = [
25
22
  "(",
26
23
  [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-zoom
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.2
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker