ruby-zoom 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/z +4 -1
- data/bin/zc +4 -1
- data/bin/zf +4 -1
- data/bin/zg +4 -1
- data/bin/zl +4 -1
- data/bin/zr +4 -1
- data/lib/zoom.rb +54 -55
- data/lib/zoom/profile.rb +3 -0
- data/lib/zoom/profile/find.rb +1 -0
- data/lib/zoom/profile/passwords.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a69c2cba288ca27e2764b47c1c9b5e45b5c1421
|
4
|
+
data.tar.gz: fb172ea95ccc3f4a59e3026965483a45d424a88a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d09ac12e8c720971bf54967dad1dc83477dfc0873e615f4ab871f94a3c58074e1923bbd0dc7348a1952470a4b2fb3a78356fa7b87c0965d18bb3c6aeaf6c08
|
7
|
+
data.tar.gz: c16313a83fdc52820e81344ed6251b513e0acb0cadcd3eef8b231e5505481da6310b5c620bf80697273803d9ea05a7abb8a2525c66394a661c850ea64f5a072b
|
data/bin/z
CHANGED
@@ -250,7 +250,7 @@ begin
|
|
250
250
|
when "repeat"
|
251
251
|
Zoom.instance.repeat
|
252
252
|
when "rc"
|
253
|
-
Zoom.
|
253
|
+
Zoom.default
|
254
254
|
when "rename"
|
255
255
|
Zoom.instance.rename_profile(
|
256
256
|
options["rename"],
|
@@ -271,5 +271,8 @@ begin
|
|
271
271
|
rescue Zoom::Error => e
|
272
272
|
puts e.message
|
273
273
|
exit ZoomExit::EXCEPTION
|
274
|
+
rescue Exception => e
|
275
|
+
puts e.message
|
276
|
+
exit ZoomExit::EXCEPTION
|
274
277
|
end
|
275
278
|
exit ZoomExit::GOOD
|
data/bin/zc
CHANGED
@@ -250,7 +250,7 @@ begin
|
|
250
250
|
when "repeat"
|
251
251
|
Zoom.instance.repeat
|
252
252
|
when "rc"
|
253
|
-
Zoom.
|
253
|
+
Zoom.default
|
254
254
|
when "rename"
|
255
255
|
Zoom.instance.rename_profile(
|
256
256
|
options["rename"],
|
@@ -271,5 +271,8 @@ begin
|
|
271
271
|
rescue Zoom::Error => e
|
272
272
|
puts e.message
|
273
273
|
exit ZoomExit::EXCEPTION
|
274
|
+
rescue Exception => e
|
275
|
+
puts e.message
|
276
|
+
exit ZoomExit::EXCEPTION
|
274
277
|
end
|
275
278
|
exit ZoomExit::GOOD
|
data/bin/zf
CHANGED
@@ -250,7 +250,7 @@ begin
|
|
250
250
|
when "repeat"
|
251
251
|
Zoom.instance.repeat
|
252
252
|
when "rc"
|
253
|
-
Zoom.
|
253
|
+
Zoom.default
|
254
254
|
when "rename"
|
255
255
|
Zoom.instance.rename_profile(
|
256
256
|
options["rename"],
|
@@ -271,5 +271,8 @@ begin
|
|
271
271
|
rescue Zoom::Error => e
|
272
272
|
puts e.message
|
273
273
|
exit ZoomExit::EXCEPTION
|
274
|
+
rescue Exception => e
|
275
|
+
puts e.message
|
276
|
+
exit ZoomExit::EXCEPTION
|
274
277
|
end
|
275
278
|
exit ZoomExit::GOOD
|
data/bin/zg
CHANGED
@@ -250,7 +250,7 @@ begin
|
|
250
250
|
when "repeat"
|
251
251
|
Zoom.instance.repeat
|
252
252
|
when "rc"
|
253
|
-
Zoom.
|
253
|
+
Zoom.default
|
254
254
|
when "rename"
|
255
255
|
Zoom.instance.rename_profile(
|
256
256
|
options["rename"],
|
@@ -271,5 +271,8 @@ begin
|
|
271
271
|
rescue Zoom::Error => e
|
272
272
|
puts e.message
|
273
273
|
exit ZoomExit::EXCEPTION
|
274
|
+
rescue Exception => e
|
275
|
+
puts e.message
|
276
|
+
exit ZoomExit::EXCEPTION
|
274
277
|
end
|
275
278
|
exit ZoomExit::GOOD
|
data/bin/zl
CHANGED
@@ -250,7 +250,7 @@ begin
|
|
250
250
|
when "repeat"
|
251
251
|
Zoom.instance.repeat
|
252
252
|
when "rc"
|
253
|
-
Zoom.
|
253
|
+
Zoom.default
|
254
254
|
when "rename"
|
255
255
|
Zoom.instance.rename_profile(
|
256
256
|
options["rename"],
|
@@ -271,5 +271,8 @@ begin
|
|
271
271
|
rescue Zoom::Error => e
|
272
272
|
puts e.message
|
273
273
|
exit ZoomExit::EXCEPTION
|
274
|
+
rescue Exception => e
|
275
|
+
puts e.message
|
276
|
+
exit ZoomExit::EXCEPTION
|
274
277
|
end
|
275
278
|
exit ZoomExit::GOOD
|
data/bin/zr
CHANGED
@@ -250,7 +250,7 @@ begin
|
|
250
250
|
when "repeat"
|
251
251
|
Zoom.instance.repeat
|
252
252
|
when "rc"
|
253
|
-
Zoom.
|
253
|
+
Zoom.default
|
254
254
|
when "rename"
|
255
255
|
Zoom.instance.rename_profile(
|
256
256
|
options["rename"],
|
@@ -271,5 +271,8 @@ begin
|
|
271
271
|
rescue Zoom::Error => e
|
272
272
|
puts e.message
|
273
273
|
exit ZoomExit::EXCEPTION
|
274
|
+
rescue Exception => e
|
275
|
+
puts e.message
|
276
|
+
exit ZoomExit::EXCEPTION
|
274
277
|
end
|
275
278
|
exit ZoomExit::GOOD
|
data/lib/zoom.rb
CHANGED
@@ -7,6 +7,11 @@ require "string"
|
|
7
7
|
class Zoom
|
8
8
|
include Singleton
|
9
9
|
|
10
|
+
@@cache_file = Pathname.new("~/.zoom_cache").expand_path
|
11
|
+
@@info_file = Pathname.new("~/.zoominfo").expand_path
|
12
|
+
@@rc_file = Pathname.new("~/.zoomrc").expand_path
|
13
|
+
@@shortcut_file = Pathname.new("~/.zoom_shortcuts").expand_path
|
14
|
+
|
10
15
|
def add_profile(
|
11
16
|
name,
|
12
17
|
clas,
|
@@ -37,7 +42,7 @@ class Zoom
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def clear_cache
|
40
|
-
|
45
|
+
@@cache_file.delete if (@@cache_file.exist?)
|
41
46
|
end
|
42
47
|
|
43
48
|
def configure_editor(editor)
|
@@ -50,25 +55,26 @@ class Zoom
|
|
50
55
|
write_zoomrc
|
51
56
|
end
|
52
57
|
|
53
|
-
def default
|
58
|
+
def self.default
|
54
59
|
default_zoominfo
|
55
60
|
default_zoomrc
|
56
61
|
end
|
57
62
|
|
58
|
-
def default_zoominfo
|
59
|
-
|
60
|
-
|
63
|
+
def self.default_zoominfo
|
64
|
+
info = Hash.new
|
65
|
+
info["profile"] = "default"
|
61
66
|
|
62
67
|
# Reset last command to be empty
|
63
|
-
|
68
|
+
info["last_command"] = Hash.new
|
64
69
|
|
65
|
-
|
70
|
+
File.open(@@info_file, "w") do |file|
|
71
|
+
file.write(JSON.pretty_generate(info))
|
72
|
+
end
|
66
73
|
end
|
67
|
-
private :default_zoominfo
|
68
74
|
|
69
|
-
def default_zoomrc
|
70
|
-
|
71
|
-
|
75
|
+
def self.default_zoomrc
|
76
|
+
rc = Hash.new
|
77
|
+
profiles = Hash.new
|
72
78
|
|
73
79
|
all = nil
|
74
80
|
|
@@ -110,34 +116,32 @@ class Zoom
|
|
110
116
|
find = Zoom::Profile::Find.new
|
111
117
|
|
112
118
|
# Put profiles into rc
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
119
|
+
profiles["ack"] = ack if (ack)
|
120
|
+
profiles["ag"] = ag if (ag)
|
121
|
+
profiles["all"] = all if (all)
|
122
|
+
profiles["default"] = default
|
123
|
+
profiles["grep"] = grep
|
124
|
+
profiles["passwords"] = Zoom::Profile::Passwords.new
|
125
|
+
profiles["zoom_find"] = find
|
126
|
+
rc["profiles"] = profiles
|
120
127
|
|
121
128
|
# Default editor (use $EDITOR)
|
122
|
-
|
129
|
+
rc["editor"] = ""
|
123
130
|
|
124
|
-
|
131
|
+
File.open(@@rc_file, "w") do |file|
|
132
|
+
file.write(JSON.pretty_generate(rc))
|
133
|
+
end
|
125
134
|
end
|
126
|
-
private :default_zoomrc
|
127
135
|
|
128
136
|
def delete_profile(name)
|
129
|
-
if (name
|
130
|
-
raise Zoom::
|
137
|
+
if (!@profiles.has_key?(name))
|
138
|
+
raise Zoom::ProfileDoesNotExistError.new(name)
|
131
139
|
end
|
132
140
|
|
133
|
-
if (name == "
|
141
|
+
if ((name == "default") || @profiles[name].immutable)
|
134
142
|
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
135
143
|
end
|
136
144
|
|
137
|
-
if (!@profiles.has_key?(name))
|
138
|
-
raise Zoom::ProfileDoesNotExistError.new(name)
|
139
|
-
end
|
140
|
-
|
141
145
|
@profiles.delete(name)
|
142
146
|
write_zoomrc
|
143
147
|
|
@@ -155,16 +159,16 @@ class Zoom
|
|
155
159
|
envprepend = nil,
|
156
160
|
append = nil
|
157
161
|
)
|
158
|
-
if (name == "zoom_find")
|
159
|
-
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
160
|
-
end
|
161
|
-
|
162
162
|
profile = @profiles[name] if (profile.nil?)
|
163
163
|
|
164
164
|
if (profile.nil?)
|
165
165
|
raise Zoom::ProfileDoesNotExistsError.new(name)
|
166
166
|
end
|
167
167
|
|
168
|
+
if (profile.immutable)
|
169
|
+
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
170
|
+
end
|
171
|
+
|
168
172
|
profile.operator(operator) if (operator)
|
169
173
|
profile.flags(flags) if (flags)
|
170
174
|
profile.prepend(envprepend) if (envprepend)
|
@@ -200,7 +204,7 @@ class Zoom
|
|
200
204
|
|
201
205
|
def get_location_of_result(result)
|
202
206
|
count = 0
|
203
|
-
File.open(
|
207
|
+
File.open(@@shortcut_file) do |file|
|
204
208
|
file.each do |line|
|
205
209
|
count += 1
|
206
210
|
if (count == result)
|
@@ -225,11 +229,6 @@ class Zoom
|
|
225
229
|
custom_profs = Pathname.new("~/.zoom_profiles.rb").expand_path
|
226
230
|
require_relative custom_profs if (custom_profs.exist?)
|
227
231
|
|
228
|
-
@cache_file = Pathname.new("~/.zoom_cache").expand_path
|
229
|
-
@info_file = Pathname.new("~/.zoominfo").expand_path
|
230
|
-
@rc_file = Pathname.new("~/.zoomrc").expand_path
|
231
|
-
@shortcut_file = Pathname.new("~/.zoom_shortcuts").expand_path
|
232
|
-
|
233
232
|
read_zoomrc
|
234
233
|
read_zoominfo
|
235
234
|
|
@@ -285,16 +284,16 @@ class Zoom
|
|
285
284
|
end
|
286
285
|
|
287
286
|
def interactive_edit_profile(name, profile = nil)
|
288
|
-
if (name == "zoom_find")
|
289
|
-
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
290
|
-
end
|
291
|
-
|
292
287
|
profile = @profiles[name] if (profile.nil?)
|
293
288
|
|
294
289
|
if (profile.nil?)
|
295
290
|
raise Zoom::ProfileDoesNotExistError.new(name)
|
296
291
|
end
|
297
292
|
|
293
|
+
if (profile.immutable)
|
294
|
+
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
295
|
+
end
|
296
|
+
|
298
297
|
# Get new operator
|
299
298
|
puts "Enter operator (default #{profile.operator}):"
|
300
299
|
|
@@ -348,13 +347,13 @@ class Zoom
|
|
348
347
|
end
|
349
348
|
|
350
349
|
def list_tags
|
351
|
-
return if (
|
350
|
+
return if (!@@cache_file.exist?)
|
352
351
|
|
353
352
|
# Open shortcut file for writing
|
354
|
-
shct = File.open(
|
353
|
+
shct = File.open(@@shortcut_file, "r")
|
355
354
|
|
356
355
|
# Read in cache
|
357
|
-
File.open(
|
356
|
+
File.open(@@cache_file) do |cache|
|
358
357
|
count = 1
|
359
358
|
|
360
359
|
cache.each do |line|
|
@@ -431,7 +430,7 @@ class Zoom
|
|
431
430
|
private :open_editor_to_result
|
432
431
|
|
433
432
|
def pager
|
434
|
-
File.open(
|
433
|
+
File.open(@@cache_file, "w") do |f|
|
435
434
|
f.write("ZOOM_EXE_DIR=#{Dir.pwd}\n")
|
436
435
|
begin
|
437
436
|
$stdin.each_line do |line|
|
@@ -462,18 +461,18 @@ class Zoom
|
|
462
461
|
private :parse_tags
|
463
462
|
|
464
463
|
def read_zoominfo
|
465
|
-
if (
|
464
|
+
if (!@@info_file.exist? && !@@info_file.symlink?)
|
466
465
|
default_zoominfo
|
467
466
|
end
|
468
467
|
|
469
|
-
@info = JSON.parse(File.read(
|
468
|
+
@info = JSON.parse(File.read(@@info_file))
|
470
469
|
end
|
471
470
|
private :read_zoominfo
|
472
471
|
|
473
472
|
def read_zoomrc
|
474
|
-
default_zoomrc if (
|
473
|
+
default_zoomrc if (!@@rc_file.exist? && !@@rc_file.symlink?)
|
475
474
|
|
476
|
-
@rc = JSON.parse(File.read(
|
475
|
+
@rc = JSON.parse(File.read(@@rc_file))
|
477
476
|
@profiles = Hash.new
|
478
477
|
@rc["profiles"].each do |name, prof|
|
479
478
|
@profiles[name] = Zoom::Profile.from_json(prof)
|
@@ -523,7 +522,7 @@ class Zoom
|
|
523
522
|
private :remove_colors
|
524
523
|
|
525
524
|
def shortcut_cache(profile = nil)
|
526
|
-
return if (
|
525
|
+
return if (!@@cache_file.exist?)
|
527
526
|
return if (@info["last_command"].empty?)
|
528
527
|
|
529
528
|
if (profile.nil?)
|
@@ -531,10 +530,10 @@ class Zoom
|
|
531
530
|
end
|
532
531
|
|
533
532
|
# Open shortcut file for writing
|
534
|
-
shct = File.open(
|
533
|
+
shct = File.open(@@shortcut_file, "w")
|
535
534
|
|
536
535
|
# Read in cache
|
537
|
-
File.open(
|
536
|
+
File.open(@@cache_file) do |cache|
|
538
537
|
start_dir = ""
|
539
538
|
file = nil
|
540
539
|
filename = ""
|
@@ -601,7 +600,7 @@ class Zoom
|
|
601
600
|
end
|
602
601
|
|
603
602
|
def write_zoominfo
|
604
|
-
File.open(
|
603
|
+
File.open(@@info_file, "w") do |file|
|
605
604
|
file.write(JSON.pretty_generate(@info))
|
606
605
|
end
|
607
606
|
end
|
@@ -609,7 +608,7 @@ class Zoom
|
|
609
608
|
|
610
609
|
def write_zoomrc
|
611
610
|
@rc["profiles"] = @profiles
|
612
|
-
File.open(
|
611
|
+
File.open(@@rc_file, "w") do |file|
|
613
612
|
file.write(JSON.pretty_generate(@rc))
|
614
613
|
end
|
615
614
|
end
|
data/lib/zoom/profile.rb
CHANGED
@@ -3,6 +3,7 @@ require "shellwords"
|
|
3
3
|
require "zoom/profile_class_unknown_error"
|
4
4
|
|
5
5
|
class Zoom::Profile < Hash
|
6
|
+
attr_accessor :immutable
|
6
7
|
attr_accessor :taggable
|
7
8
|
|
8
9
|
def append(append = nil)
|
@@ -60,6 +61,8 @@ class Zoom::Profile < Hash
|
|
60
61
|
self.prepend(envprepend)
|
61
62
|
self.append(append)
|
62
63
|
self.operator(operator)
|
64
|
+
|
65
|
+
@immutable = false
|
63
66
|
@pager = "z --pager"
|
64
67
|
@taggable = false
|
65
68
|
end
|
data/lib/zoom/profile/find.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "shellwords"
|
2
1
|
require "zoom/profile"
|
3
2
|
require "zoom/profile/ag"
|
4
3
|
require "zoom/profile/ack"
|
@@ -63,6 +62,7 @@ class Zoom::Profile::Passwords < Zoom::Profile
|
|
63
62
|
@profile.prepend,
|
64
63
|
@profile.append
|
65
64
|
)
|
65
|
+
@immutable = true
|
66
66
|
@taggable = true
|
67
67
|
end
|
68
68
|
|
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: 3.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Whittaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|