ruby-zoom 3.0.1 → 3.1.0
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 +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 +47 -38
- data/lib/zoom/error.rb +2 -0
- data/lib/zoom/executable_not_found_error.rb +7 -0
- data/lib/{zoom_profile.rb → zoom/profile.rb} +8 -4
- data/lib/{ack_profile.rb → zoom/profile/ack.rb} +4 -16
- data/lib/{ag_profile.rb → zoom/profile/ag.rb} +2 -2
- data/lib/{find_profile.rb → zoom/profile/find.rb} +2 -2
- data/lib/{grep_profile.rb → zoom/profile/grep.rb} +2 -2
- data/lib/{passwords_profile.rb → zoom/profile/passwords.rb} +13 -8
- data/lib/zoom/profile_already_exists_error.rb +7 -0
- data/lib/zoom/profile_can_not_be_modified_error.rb +7 -0
- data/lib/zoom/profile_class_unknown_error.rb +7 -0
- data/lib/zoom/profile_does_not_exist_error.rb +7 -0
- metadata +14 -9
- data/lib/zoom_error.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9141f80aa31064c2d7ccf3957398b2ccbed8426f
|
4
|
+
data.tar.gz: 708740ad09f2a5805126618ac5cc5ca9ec3b8736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1523d19e9f3e6c87f4f44350a0682c3f6c2263f56357928766c7150f6d4b678c5972cc5052bcaf0bac031149795f4d2a54f4abc810fef471fc4c166a2d5b3f2d
|
7
|
+
data.tar.gz: 9dd372e874aa7a2cdbe535b672fefe1d0b5a15da849a516e0b53ff99c0dc434c8fcd4f5af9255cdec282b320ccc81eab475153915e1af1059e21eb2fc7a10859
|
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
@@ -1,19 +1,11 @@
|
|
1
|
-
require "ack_profile"
|
2
|
-
require "ag_profile"
|
3
|
-
require "find_profile"
|
4
|
-
require "grep_profile"
|
5
1
|
require "io/wait"
|
6
2
|
require "json"
|
7
3
|
require "pathname"
|
8
|
-
require "passwords_profile"
|
9
4
|
require "singleton"
|
10
5
|
require "string"
|
11
|
-
require "zoom_error"
|
12
|
-
require "zoom_profile"
|
13
6
|
|
14
7
|
class Zoom
|
15
8
|
include Singleton
|
16
|
-
include ZoomError
|
17
9
|
|
18
10
|
def add_profile(
|
19
11
|
name,
|
@@ -24,14 +16,14 @@ class Zoom
|
|
24
16
|
append = nil
|
25
17
|
)
|
26
18
|
if (@profiles.has_key?(name))
|
27
|
-
raise
|
19
|
+
raise Zoom::ProfileAlreadyExistsError.new(name)
|
28
20
|
end
|
29
21
|
|
30
22
|
default_class = nil
|
31
23
|
begin
|
32
24
|
default_class = Object::const_get(clas).new
|
33
25
|
rescue NameError => e
|
34
|
-
raise
|
26
|
+
raise Zoom::ProfileClassUnknownError.new(clas)
|
35
27
|
end
|
36
28
|
|
37
29
|
edit_profile(
|
@@ -51,7 +43,7 @@ class Zoom
|
|
51
43
|
def configure_editor(editor)
|
52
44
|
e = ScoobyDoo.where_are_you(editor)
|
53
45
|
if (e.nil?)
|
54
|
-
raise
|
46
|
+
raise Zoom::ExecutableNotFoundError.new(editor)
|
55
47
|
end
|
56
48
|
|
57
49
|
@rc["editor"] = e
|
@@ -82,8 +74,8 @@ class Zoom
|
|
82
74
|
|
83
75
|
# Default ag profiles
|
84
76
|
if (ScoobyDoo.where_are_you("ag"))
|
85
|
-
ag =
|
86
|
-
all =
|
77
|
+
ag = Zoom::Profile::Ag.new
|
78
|
+
all = Zoom::Profile::Ag.new(nil, "-uS")
|
87
79
|
else
|
88
80
|
ag = nil
|
89
81
|
end
|
@@ -93,15 +85,15 @@ class Zoom
|
|
93
85
|
ScoobyDoo.where_are_you("ack") ||
|
94
86
|
ScoobyDoo.where_are_you("ack-grep")
|
95
87
|
)
|
96
|
-
ack =
|
88
|
+
ack = Zoom::Profile::Ack.new
|
97
89
|
else
|
98
90
|
ack = nil
|
99
91
|
end
|
100
92
|
|
101
93
|
# Default grep profile (emulate ag/ack as much as possible)
|
102
|
-
grep =
|
94
|
+
grep = Zoom::Profile::Grep.new
|
103
95
|
if (all.nil?)
|
104
|
-
all =
|
96
|
+
all = Zoom::ProfileGrep.new
|
105
97
|
all.flags("--color=always -EHinR")
|
106
98
|
end
|
107
99
|
|
@@ -115,7 +107,7 @@ class Zoom
|
|
115
107
|
end
|
116
108
|
|
117
109
|
# Create find profile
|
118
|
-
find =
|
110
|
+
find = Zoom::Profile::Find.new
|
119
111
|
|
120
112
|
# Put profiles into rc
|
121
113
|
@profiles["ack"] = ack if (ack)
|
@@ -123,7 +115,7 @@ class Zoom
|
|
123
115
|
@profiles["all"] = all if (all)
|
124
116
|
@profiles["default"] = default
|
125
117
|
@profiles["grep"] = grep
|
126
|
-
@profiles["passwords"] =
|
118
|
+
@profiles["passwords"] = Zoom::Profile::Passwords.new
|
127
119
|
@profiles["zoom_find"] = find
|
128
120
|
|
129
121
|
# Default editor (use $EDITOR)
|
@@ -135,15 +127,15 @@ class Zoom
|
|
135
127
|
|
136
128
|
def delete_profile(name)
|
137
129
|
if (name == "default")
|
138
|
-
raise
|
130
|
+
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
139
131
|
end
|
140
132
|
|
141
133
|
if (name == "zoom_find")
|
142
|
-
raise
|
134
|
+
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
143
135
|
end
|
144
136
|
|
145
137
|
if (!@profiles.has_key?(name))
|
146
|
-
raise
|
138
|
+
raise Zoom::ProfileDoesNotExistError.new(name)
|
147
139
|
end
|
148
140
|
|
149
141
|
@profiles.delete(name)
|
@@ -164,13 +156,13 @@ class Zoom
|
|
164
156
|
append = nil
|
165
157
|
)
|
166
158
|
if (name == "zoom_find")
|
167
|
-
raise
|
159
|
+
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
168
160
|
end
|
169
161
|
|
170
162
|
profile = @profiles[name] if (profile.nil?)
|
171
163
|
|
172
164
|
if (profile.nil?)
|
173
|
-
raise
|
165
|
+
raise Zoom::ProfileDoesNotExistsError.new(name)
|
174
166
|
end
|
175
167
|
|
176
168
|
profile.operator(operator) if (operator)
|
@@ -186,7 +178,7 @@ class Zoom
|
|
186
178
|
name = @info["profile"] if (name.nil?)
|
187
179
|
|
188
180
|
if (!@profiles.has_key?(name))
|
189
|
-
raise
|
181
|
+
raise Zoom::ProfileDoesNotExistError.new(name)
|
190
182
|
end
|
191
183
|
|
192
184
|
@info["last_command"] = {
|
@@ -251,7 +243,7 @@ class Zoom
|
|
251
243
|
|
252
244
|
def interactive_add_profile(name)
|
253
245
|
if (@profiles.has_key?(name))
|
254
|
-
raise
|
246
|
+
raise Zoom::ProfileAlreadyExistsError.new(name)
|
255
247
|
end
|
256
248
|
|
257
249
|
default_op = "grep"
|
@@ -263,13 +255,17 @@ class Zoom
|
|
263
255
|
default_op = "ack-grep"
|
264
256
|
end
|
265
257
|
|
258
|
+
ack_class = Zoom::Profile::Ack.to_s
|
259
|
+
ag_class = Zoom::Profile::Ag.to_s
|
260
|
+
grep_class = Zoom::Profile::Grep.to_s
|
261
|
+
|
266
262
|
case default_op
|
267
263
|
when "ack", "ack-grep"
|
268
|
-
puts "Enter class (default
|
264
|
+
puts "Enter class (default #{ack_class}):"
|
269
265
|
when "ag"
|
270
|
-
puts "Enter class (default
|
266
|
+
puts "Enter class (default #{ag_class}):"
|
271
267
|
when "grep"
|
272
|
-
puts "Enter class (default
|
268
|
+
puts "Enter class (default #{grep_class}):"
|
273
269
|
end
|
274
270
|
|
275
271
|
clas = gets.chomp
|
@@ -277,11 +273,11 @@ class Zoom
|
|
277
273
|
|
278
274
|
case default_op
|
279
275
|
when "ack", "ack-grep"
|
280
|
-
clas =
|
276
|
+
clas = ack_class if (clas.nil? || clas.empty?)
|
281
277
|
when "ag"
|
282
|
-
clas =
|
278
|
+
clas = ag_class if (clas.nil? || clas.empty?)
|
283
279
|
when "grep"
|
284
|
-
clas =
|
280
|
+
clas = grep_class if (clas.nil? || clas.empty?)
|
285
281
|
end
|
286
282
|
|
287
283
|
add_profile(name, clas)
|
@@ -290,13 +286,13 @@ class Zoom
|
|
290
286
|
|
291
287
|
def interactive_edit_profile(name, profile = nil)
|
292
288
|
if (name == "zoom_find")
|
293
|
-
raise
|
289
|
+
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
294
290
|
end
|
295
291
|
|
296
292
|
profile = @profiles[name] if (profile.nil?)
|
297
293
|
|
298
294
|
if (profile.nil?)
|
299
|
-
raise
|
295
|
+
raise Zoom::ProfileDoesNotExistError.new(name)
|
300
296
|
end
|
301
297
|
|
302
298
|
# Get new operator
|
@@ -480,7 +476,7 @@ class Zoom
|
|
480
476
|
@rc = JSON.parse(File.read(@rc_file))
|
481
477
|
@profiles = Hash.new
|
482
478
|
@rc["profiles"].each do |name, prof|
|
483
|
-
@profiles[name] =
|
479
|
+
@profiles[name] = Zoom::Profile.from_json(prof)
|
484
480
|
end
|
485
481
|
@rc["profiles"] = @profiles
|
486
482
|
end
|
@@ -490,15 +486,15 @@ class Zoom
|
|
490
486
|
name = @info["profile"] if (name.nil?)
|
491
487
|
|
492
488
|
if ((name == "default") || (name == "zoom_find"))
|
493
|
-
raise
|
489
|
+
raise Zoom::ProfileCanNotBeModifiedError.new(name)
|
494
490
|
end
|
495
491
|
|
496
492
|
if (!@profiles.has_key?(name))
|
497
|
-
raise
|
493
|
+
raise Zoom::ProfileDoesNotExistError.new(name)
|
498
494
|
end
|
499
495
|
|
500
496
|
if (@profiles.has_key?(rename))
|
501
|
-
raise
|
497
|
+
raise Zoom::ProfileAlreadyExistsError.new(rename)
|
502
498
|
end
|
503
499
|
|
504
500
|
@profiles[rename] = @profiles[name]
|
@@ -597,7 +593,7 @@ class Zoom
|
|
597
593
|
|
598
594
|
def switch_profile(name)
|
599
595
|
if (!@profiles.has_key?(name))
|
600
|
-
raise
|
596
|
+
raise Zoom::ProfileDoesNotExistError.new(name)
|
601
597
|
end
|
602
598
|
|
603
599
|
@info["profile"] = name
|
@@ -619,3 +615,16 @@ class Zoom
|
|
619
615
|
end
|
620
616
|
private :write_zoomrc
|
621
617
|
end
|
618
|
+
|
619
|
+
require "zoom/error"
|
620
|
+
require "zoom/executable_not_found_error"
|
621
|
+
require "zoom/profile"
|
622
|
+
require "zoom/profile_already_exists_error"
|
623
|
+
require "zoom/profile_can_not_be_modified_error"
|
624
|
+
require "zoom/profile_class_unknown_error"
|
625
|
+
require "zoom/profile_does_not_exist_error"
|
626
|
+
require "zoom/profile/ack"
|
627
|
+
require "zoom/profile/ag"
|
628
|
+
require "zoom/profile/find"
|
629
|
+
require "zoom/profile/grep"
|
630
|
+
require "zoom/profile/passwords"
|
data/lib/zoom/error.rb
ADDED
@@ -1,7 +1,8 @@
|
|
1
1
|
require "scoobydoo"
|
2
2
|
require "shellwords"
|
3
|
+
require "zoom/profile_class_unknown_error"
|
3
4
|
|
4
|
-
class
|
5
|
+
class Zoom::Profile < Hash
|
5
6
|
attr_accessor :taggable
|
6
7
|
|
7
8
|
def append(append = nil)
|
@@ -26,13 +27,13 @@ class ZoomProfile < Hash
|
|
26
27
|
def self.from_json(json)
|
27
28
|
begin
|
28
29
|
return Object::const_get(json["class"]).new(
|
29
|
-
json["operator"].nil? ? "" : json["
|
30
|
+
json["operator"].nil? ? "" : json["operator"],
|
30
31
|
json["flags"].nil? ? "" : json["flags"],
|
31
32
|
json["prepend"].nil? ? "" : json["prepend"],
|
32
33
|
json["append"].nil? ? "" : json["append"]
|
33
34
|
)
|
34
35
|
rescue NameError => e
|
35
|
-
raise
|
36
|
+
raise Zoom::ProfileClassUnknownError.new(
|
36
37
|
json["class"]
|
37
38
|
)
|
38
39
|
end
|
@@ -55,10 +56,10 @@ class ZoomProfile < Hash
|
|
55
56
|
append = ""
|
56
57
|
)
|
57
58
|
self["class"] = self.class.to_s
|
58
|
-
self.operator(operator)
|
59
59
|
self.flags(flags)
|
60
60
|
self.prepend(envprepend)
|
61
61
|
self.append(append)
|
62
|
+
self.operator(operator)
|
62
63
|
@pager = "z --pager"
|
63
64
|
@taggable = false
|
64
65
|
end
|
@@ -70,6 +71,9 @@ class ZoomProfile < Hash
|
|
70
71
|
self["operator"] = op
|
71
72
|
else
|
72
73
|
self["operator"] = ScoobyDoo.where_are_you("echo")
|
74
|
+
flags("")
|
75
|
+
prepend("")
|
76
|
+
append("#{operator} is not installed!")
|
73
77
|
end
|
74
78
|
end
|
75
79
|
return self["operator"]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "shellwords"
|
2
|
-
require "
|
2
|
+
require "zoom/profile"
|
3
3
|
|
4
|
-
class
|
4
|
+
class Zoom::Profile::Ack < Zoom::Profile
|
5
5
|
def colors
|
6
6
|
'ACK_COLOR_LINENO=white ACK_COLOR_MATCH="black on_white"'
|
7
7
|
end
|
@@ -27,20 +27,8 @@ class AckProfile < ZoomProfile
|
|
27
27
|
append = ""
|
28
28
|
)
|
29
29
|
# Special case because of debian
|
30
|
-
operator =
|
31
|
-
if (ScoobyDoo.where_are_you("ack"))
|
32
|
-
operator = "ack"
|
33
|
-
elsif (ScoobyDoo.where_are_you("ack-grep"))
|
34
|
-
operator = "ack-grep"
|
35
|
-
else
|
36
|
-
# Oops
|
37
|
-
operator = "echo"
|
38
|
-
if (operator == "echo")
|
39
|
-
flags = "#"
|
40
|
-
envprepend = ""
|
41
|
-
append = ""
|
42
|
-
end
|
43
|
-
end
|
30
|
+
operator = "ack"
|
31
|
+
operator = "ack-grep" if (ScoobyDoo.where_are_you("ack-grep"))
|
44
32
|
|
45
33
|
super(operator, flags, envprepend, append)
|
46
34
|
@taggable = true
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require "ag_profile"
|
2
|
-
require "ack_profile"
|
3
|
-
require "grep_profile"
|
4
1
|
require "shellwords"
|
5
|
-
require "
|
2
|
+
require "zoom/profile"
|
3
|
+
require "zoom/profile/ag"
|
4
|
+
require "zoom/profile/ack"
|
5
|
+
require "zoom/profile/grep"
|
6
6
|
|
7
|
-
class
|
7
|
+
class Zoom::Profile::Passwords < Zoom::Profile
|
8
8
|
def colors
|
9
9
|
return @profile.colors
|
10
10
|
end
|
@@ -32,19 +32,24 @@ class PasswordsProfile < ZoomProfile
|
|
32
32
|
@passwd_regex = "\"pass(word|wd)?[^:=,>]? *[:=,>]\""
|
33
33
|
|
34
34
|
if (ScoobyDoo.where_are_you("ag"))
|
35
|
-
@profile =
|
35
|
+
@profile = Zoom::Profile::Ag.new(
|
36
|
+
nil,
|
37
|
+
"-uS",
|
38
|
+
"",
|
39
|
+
@passwd_regex
|
40
|
+
)
|
36
41
|
elsif (
|
37
42
|
ScoobyDoo.where_are_you("ack") ||
|
38
43
|
ScoobyDoo.where_are_you("ack-grep")
|
39
44
|
)
|
40
|
-
@profile =
|
45
|
+
@profile = Zoom::Profile::Ack.new(
|
41
46
|
nil,
|
42
47
|
"--smart-case",
|
43
48
|
"",
|
44
49
|
@passwd_regex
|
45
50
|
)
|
46
51
|
else
|
47
|
-
@profile =
|
52
|
+
@profile = Zoom::Profile::Grep.new(
|
48
53
|
nil,
|
49
54
|
"--color=always -EHinR",
|
50
55
|
"",
|
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.0
|
4
|
+
version: 3.1.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: 2015-10-
|
11
|
+
date: 2015-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -75,15 +75,20 @@ files:
|
|
75
75
|
- bin/zg
|
76
76
|
- bin/zl
|
77
77
|
- bin/zr
|
78
|
-
- lib/ack_profile.rb
|
79
|
-
- lib/ag_profile.rb
|
80
|
-
- lib/find_profile.rb
|
81
|
-
- lib/grep_profile.rb
|
82
|
-
- lib/passwords_profile.rb
|
83
78
|
- lib/string.rb
|
84
79
|
- lib/zoom.rb
|
85
|
-
- lib/
|
86
|
-
- lib/
|
80
|
+
- lib/zoom/error.rb
|
81
|
+
- lib/zoom/executable_not_found_error.rb
|
82
|
+
- lib/zoom/profile.rb
|
83
|
+
- lib/zoom/profile/ack.rb
|
84
|
+
- lib/zoom/profile/ag.rb
|
85
|
+
- lib/zoom/profile/find.rb
|
86
|
+
- lib/zoom/profile/grep.rb
|
87
|
+
- lib/zoom/profile/passwords.rb
|
88
|
+
- lib/zoom/profile_already_exists_error.rb
|
89
|
+
- lib/zoom/profile_can_not_be_modified_error.rb
|
90
|
+
- lib/zoom/profile_class_unknown_error.rb
|
91
|
+
- lib/zoom/profile_does_not_exist_error.rb
|
87
92
|
homepage: http://mjwhitta.github.io/zoom
|
88
93
|
licenses:
|
89
94
|
- GPL-3.0
|
data/lib/zoom_error.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module ZoomError
|
2
|
-
class Error < RuntimeError
|
3
|
-
end
|
4
|
-
|
5
|
-
class ExecutableNotFoundError < Error
|
6
|
-
def initialize(exe)
|
7
|
-
super("Executable #{exe} not found!")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class ProfileAlreadyExistsError < Error
|
12
|
-
def initialize(profile)
|
13
|
-
super("Profile #{profile} already exists!")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class ProfileCanNotBeModifiedError < Error
|
18
|
-
def initialize(profile)
|
19
|
-
super("Profile #{profile} can not be modified!")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class ProfileClassUnknownError < Error
|
24
|
-
def initialize(clas)
|
25
|
-
super("Profile class #{clas} unknown!")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class ProfileDoesNotExistError < Error
|
30
|
-
def initialize(profile)
|
31
|
-
super("Profile #{profile} does not exist!")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|