ruby-zoom 5.0.4 → 5.1.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 +1 -1
- data/bin/zc +1 -1
- data/bin/zf +1 -1
- data/bin/zg +1 -1
- data/bin/zl +1 -1
- data/bin/zr +1 -1
- data/lib/zoom.rb +2 -2
- data/lib/zoom/cache.rb +28 -12
- data/lib/zoom/cache/result.rb +17 -15
- data/lib/zoom/profile.rb +5 -0
- data/lib/zoom/profile/find.rb +6 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 715a46499be98c374a04e1bb17fa2356cbe3bee6e5750f5797c8b0093fbfb4af
|
4
|
+
data.tar.gz: af7f4f2561cd87d0d47946093ec1ef47a3f93433051148db1d03712c2ea824f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dafe4fa2a2443b2815bee0d9e42d89b3ad78f9add3a4ea2e10ffbaf9ef45ecbda8d12bb3dbf81f83cad7f5364c2a7a142895f93143436000f7a39206adfa95dc
|
7
|
+
data.tar.gz: 260228d8cff988427ec57d8f86bb6b5a2800167a11812bde1bfa0bbad8f086a96e7321d2523125c5e5821b84697d6ed4b098d9a76d46000ad27a56de46690d8c
|
data/bin/z
CHANGED
data/bin/zc
CHANGED
data/bin/zf
CHANGED
data/bin/zg
CHANGED
data/bin/zl
CHANGED
data/bin/zr
CHANGED
data/lib/zoom.rb
CHANGED
@@ -86,8 +86,8 @@ class Zoom
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def initialize(cache = nil, rc = nil)
|
89
|
-
@cache = Zoom::Cache.new(cache)
|
90
89
|
@config = Zoom::Config.new(rc)
|
90
|
+
@cache = Zoom::Cache.new(@config, cache)
|
91
91
|
@@hilight = @config.hilight
|
92
92
|
end
|
93
93
|
|
@@ -132,7 +132,7 @@ class Zoom
|
|
132
132
|
@cache.write(profile.exe(header), header["regex"])
|
133
133
|
|
134
134
|
# Display results from cache
|
135
|
-
@cache.shortcut
|
135
|
+
@cache.shortcut if (shortcut)
|
136
136
|
rescue Interrupt
|
137
137
|
# ^C
|
138
138
|
end
|
data/lib/zoom/cache.rb
CHANGED
@@ -71,10 +71,11 @@ class Zoom::Cache
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
def initialize(file = nil)
|
74
|
+
def initialize(config, file = nil)
|
75
75
|
file = "~/.cache/zoom/cache" if (file.nil?)
|
76
76
|
|
77
77
|
@cache_file = Pathname.new(file).expand_path
|
78
|
+
@config = config
|
78
79
|
@results = nil
|
79
80
|
@thread = nil
|
80
81
|
@header = Hash.new
|
@@ -128,6 +129,8 @@ class Zoom::Cache
|
|
128
129
|
tag = 1
|
129
130
|
@thread.kill if (@thread)
|
130
131
|
@thread = Thread.new do
|
132
|
+
profile = nil
|
133
|
+
|
131
134
|
# Read in cache
|
132
135
|
File.open(@cache_file) do |cache|
|
133
136
|
cache.each do |line|
|
@@ -136,12 +139,25 @@ class Zoom::Cache
|
|
136
139
|
@header = JSON.parse(
|
137
140
|
line.gsub("ZOOM_HEADER=", "")
|
138
141
|
)
|
142
|
+
|
143
|
+
if (!@config.has_profile?(profile_name))
|
144
|
+
raise
|
145
|
+
Zoom::Error::ProfileDoesNotExist.new(
|
146
|
+
profile_name
|
147
|
+
)
|
148
|
+
end
|
149
|
+
profile = @config.get_profile(profile_name)
|
139
150
|
elsif (line.match(/^-?-?$/))
|
140
151
|
# Ignore dividers when searching with context
|
141
152
|
# and empty lines
|
142
153
|
else
|
143
154
|
@results.push(
|
144
|
-
Zoom::Cache::Result.new(
|
155
|
+
Zoom::Cache::Result.new(
|
156
|
+
tag,
|
157
|
+
line,
|
158
|
+
self,
|
159
|
+
profile.grep_like_tags?
|
160
|
+
)
|
145
161
|
)
|
146
162
|
tag += 1
|
147
163
|
end
|
@@ -155,15 +171,15 @@ class Zoom::Cache
|
|
155
171
|
return @header["regex"]
|
156
172
|
end
|
157
173
|
|
158
|
-
def shortcut
|
174
|
+
def shortcut
|
159
175
|
return if (empty?)
|
160
176
|
|
161
|
-
config.validate_colors
|
162
|
-
if (
|
177
|
+
@config.validate_colors
|
178
|
+
if (!@config.has_profile?(profile_name))
|
163
179
|
raise Zoom::Error::ProfileDoesNotExist.new(profile_name)
|
164
180
|
end
|
165
181
|
|
166
|
-
profile = config.get_profile(profile_name)
|
182
|
+
profile = @config.get_profile(profile_name)
|
167
183
|
if (!profile.taggable)
|
168
184
|
get_results.each do |result|
|
169
185
|
puts result.contents
|
@@ -176,30 +192,30 @@ class Zoom::Cache
|
|
176
192
|
if (result.grep_like?)
|
177
193
|
if (result.filename != curr_filename)
|
178
194
|
puts if (curr_filename)
|
179
|
-
puts config.hilight_filename(result.filename)
|
195
|
+
puts @config.hilight_filename(result.filename)
|
180
196
|
curr_filename = result.filename
|
181
197
|
end
|
182
198
|
|
183
199
|
puts [
|
184
|
-
config.hilight_tag("[#{result.tag}]"),
|
185
|
-
"#{config.hilight_lineno(result.lineno)}:",
|
200
|
+
@config.hilight_tag("[#{result.tag}]"),
|
201
|
+
"#{@config.hilight_lineno(result.lineno)}:",
|
186
202
|
result.match.gsub(
|
187
203
|
/(#{regex})/i,
|
188
|
-
config.hilight_match("\\1")
|
204
|
+
@config.hilight_match("\\1")
|
189
205
|
)
|
190
206
|
].join(" ")
|
191
207
|
else
|
192
208
|
if (result.filename)
|
193
209
|
if (result.filename != curr_filename)
|
194
210
|
puts if (curr_filename)
|
195
|
-
puts config.hilight_filename(result.filename)
|
211
|
+
puts @config.hilight_filename(result.filename)
|
196
212
|
curr_filename = result.filename
|
197
213
|
end
|
198
214
|
end
|
199
215
|
|
200
216
|
tag = result.tag
|
201
217
|
line = result.contents
|
202
|
-
puts [config.hilight_tag("[#{tag}]"), line].join(" ")
|
218
|
+
puts [@config.hilight_tag("[#{tag}]"), line].join(" ")
|
203
219
|
end
|
204
220
|
end
|
205
221
|
end
|
data/lib/zoom/cache/result.rb
CHANGED
@@ -9,7 +9,7 @@ class Zoom::Cache::Result
|
|
9
9
|
return @grep_like
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(tag, contents, cache)
|
12
|
+
def initialize(tag, contents, cache, grep_like_tags)
|
13
13
|
@cache = cache
|
14
14
|
@contents = contents.unpack("C*").pack("U*").gsub(
|
15
15
|
/([\u0080-\u00ff]+)/,
|
@@ -21,21 +21,23 @@ class Zoom::Cache::Result
|
|
21
21
|
@match = nil
|
22
22
|
@tag = tag
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
if (grep_like_tags)
|
25
|
+
case @contents
|
26
|
+
when /^Binary file (.+) matches\.$/
|
27
|
+
@contents.match(/^Binary file (.+) matches\.$/) do |m|
|
28
|
+
next if (m.nil?)
|
29
|
+
@filename = "Binary file"
|
30
|
+
@contents = m[1]
|
31
|
+
end
|
32
|
+
when /^([^:]+)[:-](\d+)[:-](.*)$/
|
33
|
+
@contents.match(/^([^:]+)[:-](\d+)[:-](.*)$/) do |m|
|
34
|
+
next if (m.nil?)
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
@grep_like = true
|
37
|
+
@filename = m[1].gsub(/^\.\//, "")
|
38
|
+
@lineno = m[2]
|
39
|
+
@match = m[3]
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
data/lib/zoom/profile.rb
CHANGED
@@ -86,6 +86,10 @@ class Zoom::Profile < Hash
|
|
86
86
|
@taggable = false # Should results be tagged like grep
|
87
87
|
end
|
88
88
|
|
89
|
+
def grep_like_tags?
|
90
|
+
return @grep_like_tags
|
91
|
+
end
|
92
|
+
|
89
93
|
def hilight_after(str)
|
90
94
|
return str if (!Zoom.hilight?)
|
91
95
|
return str.yellow
|
@@ -148,6 +152,7 @@ class Zoom::Profile < Hash
|
|
148
152
|
|
149
153
|
# In case someone overrides grep_like_format_flags
|
150
154
|
@format_flags = ""
|
155
|
+
@grep_like_tags = true
|
151
156
|
@taggable = false
|
152
157
|
|
153
158
|
grep_like_format_flags
|
data/lib/zoom/profile/find.rb
CHANGED
@@ -23,6 +23,7 @@ class Zoom::Profile::Find < Zoom::Profile
|
|
23
23
|
|
24
24
|
def grep_like_format_flags(all = false)
|
25
25
|
super
|
26
|
+
@grep_like_tags = false
|
26
27
|
@taggable = true
|
27
28
|
end
|
28
29
|
|
@@ -41,9 +42,12 @@ class Zoom::Profile::Find < Zoom::Profile
|
|
41
42
|
header["regex"] = ""
|
42
43
|
end
|
43
44
|
|
44
|
-
# If regex was provided then assume it's an
|
45
|
+
# If regex was provided then assume it's an iregex search
|
45
46
|
if (!header["regex"].empty?)
|
46
|
-
header["regex"] =
|
47
|
+
header["regex"] = [
|
48
|
+
"-regextype posix-extended",
|
49
|
+
"-iregex \".*#{header["regex"]}.*\""
|
50
|
+
].join(" ")
|
47
51
|
end
|
48
52
|
|
49
53
|
return header
|