ruby-zoom 3.0.1 → 3.1.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: 9e1f69ab0f382c214c1dc45f2c7be2582b30fdfa
4
- data.tar.gz: b4d5e32bb2a5d928652dfbdaf070a22d806033bd
3
+ metadata.gz: 9141f80aa31064c2d7ccf3957398b2ccbed8426f
4
+ data.tar.gz: 708740ad09f2a5805126618ac5cc5ca9ec3b8736
5
5
  SHA512:
6
- metadata.gz: d53bd4c5f32c7adbb988dc9e45933156cf6a276898029d64130a89255a02c7e4ef821b7f422d38e1fb7aeee33d71de5e1408e2a780ad6c9eee50d442dacec2a5
7
- data.tar.gz: 8fc378eb702c002f991f536fea13f9eea8da6a7f8c75cbba665b2f4a9769cd08c1085acb34d3378f3bd4042e69ea56f761d90a4e2f396a2c0ec139533fb43f30
6
+ metadata.gz: 1523d19e9f3e6c87f4f44350a0682c3f6c2263f56357928766c7150f6d4b678c5972cc5052bcaf0bac031149795f4d2a54f4abc810fef471fc4c166a2d5b3f2d
7
+ data.tar.gz: 9dd372e874aa7a2cdbe535b672fefe1d0b5a15da849a516e0b53ff99c0dc434c8fcd4f5af9255cdec282b320ccc81eab475153915e1af1059e21eb2fc7a10859
data/bin/z CHANGED
@@ -268,7 +268,7 @@ begin
268
268
  options["pattern"]
269
269
  )
270
270
  end
271
- rescue ZoomError::Error => e
271
+ rescue Zoom::Error => e
272
272
  puts e.message
273
273
  exit ZoomExit::EXCEPTION
274
274
  end
data/bin/zc CHANGED
@@ -268,7 +268,7 @@ begin
268
268
  options["pattern"]
269
269
  )
270
270
  end
271
- rescue ZoomError::Error => e
271
+ rescue Zoom::Error => e
272
272
  puts e.message
273
273
  exit ZoomExit::EXCEPTION
274
274
  end
data/bin/zf CHANGED
@@ -268,7 +268,7 @@ begin
268
268
  options["pattern"]
269
269
  )
270
270
  end
271
- rescue ZoomError::Error => e
271
+ rescue Zoom::Error => e
272
272
  puts e.message
273
273
  exit ZoomExit::EXCEPTION
274
274
  end
data/bin/zg CHANGED
@@ -268,7 +268,7 @@ begin
268
268
  options["pattern"]
269
269
  )
270
270
  end
271
- rescue ZoomError::Error => e
271
+ rescue Zoom::Error => e
272
272
  puts e.message
273
273
  exit ZoomExit::EXCEPTION
274
274
  end
data/bin/zl CHANGED
@@ -268,7 +268,7 @@ begin
268
268
  options["pattern"]
269
269
  )
270
270
  end
271
- rescue ZoomError::Error => e
271
+ rescue Zoom::Error => e
272
272
  puts e.message
273
273
  exit ZoomExit::EXCEPTION
274
274
  end
data/bin/zr CHANGED
@@ -268,7 +268,7 @@ begin
268
268
  options["pattern"]
269
269
  )
270
270
  end
271
- rescue ZoomError::Error => e
271
+ rescue Zoom::Error => e
272
272
  puts e.message
273
273
  exit ZoomExit::EXCEPTION
274
274
  end
@@ -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 ZoomError::ProfileAlreadyExistsError.new(name)
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 ZoomError::ProfileClassUnknownError.new(clas)
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 ZoomError::ExecutableNotFoundError.new(editor)
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 = AgProfile.new
86
- all = AgProfile.new(nil, "-uS")
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 = AckProfile.new
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 = GrepProfile.new
94
+ grep = Zoom::Profile::Grep.new
103
95
  if (all.nil?)
104
- all = GrepProfile.new
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 = FindProfile.new
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"] = PasswordsProfile.new
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 ZoomError::ProfileCanNotBeModifiedError.new(name)
130
+ raise Zoom::ProfileCanNotBeModifiedError.new(name)
139
131
  end
140
132
 
141
133
  if (name == "zoom_find")
142
- raise ZoomError::ProfileCanNotBeModifiedError.new(name)
134
+ raise Zoom::ProfileCanNotBeModifiedError.new(name)
143
135
  end
144
136
 
145
137
  if (!@profiles.has_key?(name))
146
- raise ZoomError::ProfileDoesNotExistError.new(name)
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 ZoomError::ProfileCanNotBeModified.new(name)
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 ZoomError::ProfileDoesNotExists.new(name)
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 ZoomError::ProfileDoesNotExistError.new(name)
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 ZoomError::ProfileAlreadyExistsError.new(name)
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 AckProfile):"
264
+ puts "Enter class (default #{ack_class}):"
269
265
  when "ag"
270
- puts "Enter class (default AgProfile):"
266
+ puts "Enter class (default #{ag_class}):"
271
267
  when "grep"
272
- puts "Enter class (default GrepProfile):"
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 = "AckProfile" if (clas.nil? || clas.empty?)
276
+ clas = ack_class if (clas.nil? || clas.empty?)
281
277
  when "ag"
282
- clas = "AgProfile" if (clas.nil? || clas.empty?)
278
+ clas = ag_class if (clas.nil? || clas.empty?)
283
279
  when "grep"
284
- clas = "GrepProfile" if (clas.nil? || clas.empty?)
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 ZoomError::ProfileCanNotBeModifiedError.new(name)
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 ZoomError::ProfileDoesNotExistError.new(name)
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] = ZoomProfile.from_json(prof)
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 ZoomError::ProfileCanNotBeModifiedError.new(name)
489
+ raise Zoom::ProfileCanNotBeModifiedError.new(name)
494
490
  end
495
491
 
496
492
  if (!@profiles.has_key?(name))
497
- raise ZoomError::ProfileDoesNotExistError.new(name)
493
+ raise Zoom::ProfileDoesNotExistError.new(name)
498
494
  end
499
495
 
500
496
  if (@profiles.has_key?(rename))
501
- raise ZoomError::ProfileAlreadyExistsError.new(rename)
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 ZoomError::ProfileDoesNotExistError.new(name)
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"
@@ -0,0 +1,2 @@
1
+ class Zoom::Error < RuntimeError
2
+ end
@@ -0,0 +1,7 @@
1
+ require "zoom/error"
2
+
3
+ class Zoom::ExecutableNotFoundError < Zoom::Error
4
+ def initialize(exe)
5
+ super("Executable #{exe} not found!")
6
+ end
7
+ end
@@ -1,7 +1,8 @@
1
1
  require "scoobydoo"
2
2
  require "shellwords"
3
+ require "zoom/profile_class_unknown_error"
3
4
 
4
- class ZoomProfile < Hash
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["class"],
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 ZoomError::ProfileClassUnknownError.new(
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 "zoom_profile"
2
+ require "zoom/profile"
3
3
 
4
- class AckProfile < ZoomProfile
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 = nil
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,7 +1,7 @@
1
1
  require "shellwords"
2
- require "zoom_profile"
2
+ require "zoom/profile"
3
3
 
4
- class AgProfile < ZoomProfile
4
+ class Zoom::Profile::Ag < Zoom::Profile
5
5
  def colors
6
6
  '--color-match "47;1;30" --color-line-number "0;37"'
7
7
  end
@@ -1,7 +1,7 @@
1
1
  require "shellwords"
2
- require "zoom_profile"
2
+ require "zoom/profile"
3
3
 
4
- class FindProfile < ZoomProfile
4
+ class Zoom::Profile::Find < Zoom::Profile
5
5
  def exe(args, pattern)
6
6
  if (pattern.nil? || pattern.empty?)
7
7
  system(
@@ -1,7 +1,7 @@
1
1
  require "shellwords"
2
- require "zoom_profile"
2
+ require "zoom/profile"
3
3
 
4
- class GrepProfile < ZoomProfile
4
+ class Zoom::Profile::Grep < Zoom::Profile
5
5
  def colors
6
6
  [
7
7
  'GREP_COLORS="',
@@ -1,10 +1,10 @@
1
- require "ag_profile"
2
- require "ack_profile"
3
- require "grep_profile"
4
1
  require "shellwords"
5
- require "zoom_profile"
2
+ require "zoom/profile"
3
+ require "zoom/profile/ag"
4
+ require "zoom/profile/ack"
5
+ require "zoom/profile/grep"
6
6
 
7
- class PasswordsProfile < ZoomProfile
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 = AgProfile.new(nil, "-uS", "", @passwd_regex)
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 = AckProfile.new(
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 = GrepProfile.new(
52
+ @profile = Zoom::Profile::Grep.new(
48
53
  nil,
49
54
  "--color=always -EHinR",
50
55
  "",
@@ -0,0 +1,7 @@
1
+ require "zoom/error"
2
+
3
+ class Zoom::ProfileAlreadyExistsError < Zoom::Error
4
+ def initialize(profile)
5
+ super("Profile #{profile} already exists!")
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require "zoom/error"
2
+
3
+ class Zoom::ProfileCanNotBeModifiedError < Zoom::Error
4
+ def initialize(profile)
5
+ super("Profile #{profile} can not be modified!")
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require "zoom/error"
2
+
3
+ class Zoom::ProfileClassUnknownError < Zoom::Error
4
+ def initialize(clas)
5
+ super("Profile class Zoom::#{clas} unknown!")
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require "zoom/error"
2
+
3
+ class Zoom::ProfileDoesNotExistError < Zoom::Error
4
+ def initialize(profile)
5
+ super("Profile #{profile} does not exist!")
6
+ end
7
+ end
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.1
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-10 00:00:00.000000000 Z
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/zoom_error.rb
86
- - lib/zoom_profile.rb
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
@@ -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