utils 0.68.0 → 0.69.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +251 -18
  3. data/bin/ascii7 +28 -0
  4. data/bin/blameline +17 -0
  5. data/bin/changes +69 -5
  6. data/bin/classify +128 -7
  7. data/bin/code_comment +102 -104
  8. data/bin/commit_message +26 -2
  9. data/bin/create_cstags +18 -0
  10. data/bin/create_tags +10 -0
  11. data/bin/discover +38 -1
  12. data/bin/edit +14 -1
  13. data/bin/edit_wait +14 -0
  14. data/bin/enum +139 -15
  15. data/bin/git-empty +50 -0
  16. data/bin/git-versions +20 -0
  17. data/bin/json_check +15 -1
  18. data/bin/long_lines +11 -2
  19. data/bin/myex +38 -0
  20. data/bin/on_change +22 -0
  21. data/bin/path +21 -0
  22. data/bin/print_method +29 -1
  23. data/bin/probe +52 -4
  24. data/bin/rainbow +52 -0
  25. data/bin/rd2md +15 -0
  26. data/bin/search +83 -1
  27. data/bin/sedit +6 -0
  28. data/bin/serve +18 -3
  29. data/bin/ssh-tunnel +14 -2
  30. data/bin/strip_spaces +17 -9
  31. data/bin/sync_dir +48 -1
  32. data/bin/untest +19 -1
  33. data/bin/utils-utilsrc +42 -6
  34. data/bin/vcf2alias +33 -0
  35. data/bin/yaml_check +24 -2
  36. data/lib/utils/config_dir.rb +127 -0
  37. data/lib/utils/config_file.rb +445 -1
  38. data/lib/utils/editor.rb +215 -3
  39. data/lib/utils/finder.rb +127 -16
  40. data/lib/utils/grepper.rb +90 -1
  41. data/lib/utils/irb.rb +387 -39
  42. data/lib/utils/line_blamer.rb +28 -0
  43. data/lib/utils/line_formatter.rb +198 -0
  44. data/lib/utils/md5.rb +14 -0
  45. data/lib/utils/patterns.rb +77 -3
  46. data/lib/utils/probe_server.rb +302 -23
  47. data/lib/utils/ssh_tunnel_specification.rb +58 -0
  48. data/lib/utils/version.rb +1 -1
  49. data/lib/utils/xt/source_location_extension.rb +18 -6
  50. data/lib/utils.rb +3 -1
  51. data/tests/utils_test.rb +7 -1
  52. data/utils.gemspec +5 -5
  53. metadata +4 -6
  54. data/bin/number_files +0 -26
  55. data/lib/utils/xdg_config.rb +0 -10
  56. /data/{COPYING → LICENSE} +0 -0
@@ -1,5 +1,4 @@
1
1
  require 'tins'
2
- require 'tins/xt/string'
3
2
 
4
3
  class Utils::ConfigFile
5
4
  class << self
@@ -15,15 +14,41 @@ class Utils::ConfigFile
15
14
 
16
15
  class ConfigFileError < StandardError; end
17
16
 
17
+ # The initialize method sets up a new instance of the class.
18
+ #
19
+ # This method is called when creating a new object and performs any necessary
20
+ # initialization tasks for the instance variables and internal state.
18
21
  def initialize
19
22
  end
20
23
 
24
+ # The configure_from_paths method initializes the configuration by parsing
25
+ # configuration files from the specified paths.
26
+ #
27
+ # This method iterates through an array of configuration file paths and
28
+ # processes each one to load the configuration settings. It is typically used
29
+ # to set up the application's configuration from multiple sources.
30
+ #
31
+ # @param paths [ Array<String> ] an array of file paths pointing to configuration files
21
32
  def configure_from_paths(paths = self.class.config_file_paths)
22
33
  for config_file_path in paths
23
34
  parse_config_file config_file_path
24
35
  end
25
36
  end
26
37
 
38
+ # The parse_config_file method reads and processes a configuration file.
39
+ #
40
+ # This method opens the specified configuration file, reads its contents,
41
+ # and parses the configuration data. It handles file path expansion and
42
+ # includes error handling for system call errors during file operations.
43
+ #
44
+ # @param config_file_path [ String ] the path to the configuration file to be parsed
45
+ #
46
+ # @return [ Utils::ConfigFile ] returns self after parsing the configuration file
47
+ #
48
+ # @raise [ SystemCallError ] if there is an issue reading the configuration file
49
+ #
50
+ # @note The method will output a warning message to standard error if it fails
51
+ # to read the configuration file and return nil.
27
52
  def parse_config_file(config_file_path)
28
53
  config_file_path = File.expand_path(config_file_path)
29
54
  File.open(config_file_path) do |cf|
@@ -36,6 +61,16 @@ class Utils::ConfigFile
36
61
  return nil
37
62
  end
38
63
 
64
+ # The parse method processes the provided source code by interpreting it
65
+ # within the given binding context.
66
+ #
67
+ # This method takes a source code string and evaluates it in the context of
68
+ # the specified binding, allowing for dynamic execution of code with access
69
+ # to the current variable scope.
70
+ #
71
+ # @param source [ String ] the source code to be interpreted and executed
72
+ #
73
+ # @return [ Object ] returns self after processing the source code
39
74
  def parse(source)
40
75
  interpret_with_binding source, binding
41
76
  self
@@ -43,11 +78,29 @@ class Utils::ConfigFile
43
78
 
44
79
  class BlockConfig
45
80
  class << self
81
+ # The inherited method extends the module with DSL accessor functionality
82
+ # and calls the superclass implementation.
83
+ #
84
+ # @param modul [ Module ] the module that inherited this class
46
85
  def inherited(modul)
47
86
  modul.extend DSLKit::DSLAccessor
48
87
  super
49
88
  end
50
89
 
90
+ # The config method sets up a configuration accessor with the specified
91
+ # name and options.
92
+ #
93
+ # This method registers a new configuration setting by adding it to the
94
+ # list of configuration settings and then creates an accessor for it
95
+ # using the dsl_accessor method, allowing for easy retrieval and
96
+ # assignment of configuration values.
97
+ #
98
+ # @param name [ Object ] the name of the configuration setting
99
+ # @param r [ Array ] additional arguments passed to the dsl_accessor method
100
+ #
101
+ # @yield [ block ] optional block to be passed to the dsl_accessor method
102
+ #
103
+ # @return [ Object ] returns self to allow for method chaining
51
104
  def config(name, *r, &block)
52
105
  self.config_settings ||= []
53
106
  config_settings << name.to_sym
@@ -55,13 +108,39 @@ class Utils::ConfigFile
55
108
  self
56
109
  end
57
110
 
111
+ # The config_settings method provides access to the configuration
112
+ # settings.
113
+ #
114
+ # This method returns the configuration settings stored in the instance
115
+ # variable, allowing for reading and modification of the object's
116
+ # configuration state.
117
+ #
118
+ # @return [ Object ] the current configuration settings stored in the
119
+ # instance variable
58
120
  attr_accessor :config_settings
59
121
  end
60
122
 
123
+ # The initialize method sets up the instance by evaluating the provided
124
+ # block in the instance's context.
125
+ #
126
+ # This method allows for dynamic configuration of the object by executing
127
+ # the given block within the instance's scope, enabling flexible
128
+ # initialization patterns.
129
+ #
130
+ # @param block [ Proc ] the block to be evaluated for instance setup
61
131
  def initialize(&block)
62
132
  block and instance_eval(&block)
63
133
  end
64
134
 
135
+ # The to_ruby method generates a Ruby configuration block representation by
136
+ # recursively processing the object's configuration settings and their
137
+ # values.
138
+ # It creates a nested structure with proper indentation and formatting
139
+ # suitable for configuration files.
140
+ #
141
+ # @param depth [ Integer ] the current nesting depth for indentation purposes
142
+ #
143
+ # @return [ String ] a formatted Ruby string representing the configuration block
65
144
  def to_ruby(depth = 0)
66
145
  result = ''
67
146
  result << ' ' * 2 * depth <<
@@ -80,14 +159,41 @@ class Utils::ConfigFile
80
159
  end
81
160
 
82
161
  class Probe < BlockConfig
162
+ # The config method sets up a configuration option for the test framework.
163
+ #
164
+ # This method defines a configuration parameter that specifies which test
165
+ # framework should be used, allowing for flexible test execution environments.
166
+ #
167
+ # @param name [ Symbol ] the name of the configuration option
168
+ # @param value [ Object ] the value to set for the configuration option
83
169
  config :test_framework, :'test-unit'
84
170
 
171
+ # The include_dirs method configures the directories to be included in the
172
+ # search.
173
+ #
174
+ # @param dirs [ Array<String> ] the array of directory names to include
85
175
  config :include_dirs, %w[lib test tests ext spec]
86
176
 
177
+ # The include_dirs_argument method constructs a colon-separated string from
178
+ # include directories.
179
+ #
180
+ # This method takes the include directories configuration and converts it
181
+ # into a single colon-delimited string suitable for use in command-line
182
+ # arguments or environment variables.
183
+ #
184
+ # @return [ String ] a colon-separated string of include directory paths
87
185
  def include_dirs_argument
88
186
  Array(include_dirs) * ':'
89
187
  end
90
188
 
189
+ # The initialize method sets up the configuration by validating the test
190
+ # framework.
191
+ #
192
+ # This method initializes the configuration object and ensures that the
193
+ # specified test framework is one of the allowed values. It raises an error
194
+ # if the test framework is not supported.
195
+ #
196
+ # @param block [ Proc ] a block to be passed to the superclass initializer
91
197
  def initialize(&block)
92
198
  super
93
199
  test_frameworks_allowed = [ :'test-unit', :rspec ]
@@ -97,6 +203,17 @@ class Utils::ConfigFile
97
203
  end
98
204
  end
99
205
 
206
+ # The probe method initializes and returns a Probe object.
207
+ #
208
+ # This method creates a new Probe instance either from the provided block or
209
+ # with default settings, storing it for later use. It ensures that only one
210
+ # Probe instance is created per object, returning the existing instance
211
+ # on subsequent calls.
212
+ #
213
+ # @param block [ Proc ] optional block to configure the Probe instance
214
+ #
215
+ # @return [ Utils::Probe ] a Probe instance configured either by the block
216
+ # or with default settings
100
217
  def probe(&block)
101
218
  if block
102
219
  @probe = Probe.new(&block)
@@ -105,21 +222,76 @@ class Utils::ConfigFile
105
222
  end
106
223
 
107
224
  class FileFinder < BlockConfig
225
+ # The prune? method checks if a basename matches any of the configured
226
+ # prune directories.
227
+ #
228
+ # This method determines whether a given filename or directory name should
229
+ # be excluded based on the prune directories configuration. It iterates
230
+ # through the list of prune patterns and returns true if any pattern
231
+ # matches the provided basename.
232
+ #
233
+ # @param basename [ String, Object ] the basename to check against prune patterns
234
+ #
235
+ # @return [ TrueClass, FalseClass ] true if the basename matches any prune pattern,
236
+ # false otherwise
108
237
  def prune?(basename)
109
238
  Array(prune_dirs).any? { |pd| pd.match(basename.to_s) }
110
239
  end
111
240
 
241
+ # The skip? method determines whether a file should be skipped based on
242
+ # configured patterns.
243
+ #
244
+ # This method checks if the provided basename matches any of the configured
245
+ # skip patterns. It converts the basename to a string and tests it against
246
+ # all defined skip files.
247
+ #
248
+ # @param basename [ Object] the file or directory name to check
249
+ #
250
+ # @return [ TrueClass, FalseClass ] true if the basename matches any skip
251
+ # pattern, false otherwise
112
252
  def skip?(basename)
113
253
  Array(skip_files).any? { |sf| sf.match(basename.to_s) }
114
254
  end
115
255
  end
116
256
 
117
257
  class Search < FileFinder
258
+ # The prune_dirs method configures the pattern for identifying directories
259
+ # to be pruned during file system operations.
260
+ #
261
+ # This method sets up a regular expression pattern that matches directory
262
+ # names which should be excluded from processing. The default pattern
263
+ # excludes version control directories (.svn, .git, CVS) and temporary
264
+ # directories (tmp).
265
+ #
266
+ # @param first [ Regexp ] the regular expression pattern for matching
267
+ # directories to prune
118
268
  config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\z/
119
269
 
270
+ # The skip_files configuration method sets up a regular expression pattern
271
+ # for filtering out files based on their names.
272
+ #
273
+ # This method configures a pattern that matches filenames which should be
274
+ # skipped during file processing operations.
275
+ # It uses a regular expression to identify files that start with a dot, end
276
+ # with common temporary file extensions, or match other patterns typically
277
+ # associated with backup, swap, log, or temporary files.
278
+ #
279
+ # @param pattern [ Regexp ] the regular expression pattern used to identify
280
+ # files to skip
120
281
  config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
121
282
  end
122
283
 
284
+ # The search method initializes and returns a Search object.
285
+ #
286
+ # This method creates a Search instance either from a provided block or with
287
+ # default settings.
288
+ # It maintains a cached instance of the Search object, returning the same
289
+ # instance on subsequent calls.
290
+ #
291
+ # @param block [ Proc ] optional block to configure the Search object
292
+ #
293
+ # @return [ Utils::Search ] a Search object configured either by the provided
294
+ # block or with default settings
123
295
  def search(&block)
124
296
  if block
125
297
  @search = Search.new(&block)
@@ -128,15 +300,60 @@ class Utils::ConfigFile
128
300
  end
129
301
 
130
302
  class Discover < FileFinder
303
+ # The prune_dirs method configures the pattern for identifying directories
304
+ # to be pruned during file system operations.
305
+ #
306
+ # This method sets up a regular expression pattern that matches directory
307
+ # names which should be excluded from processing.
308
+ # The default pattern excludes version control directories (.svn, .git,
309
+ # CVS) and temporary directories (tmp).
310
+ #
311
+ # @param first [ Regexp ] the regular expression pattern for matching
312
+ # directories to prune
131
313
  config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\z/
132
314
 
315
+ # The skip_files configuration method sets up a regular expression pattern
316
+ # for filtering out files based on their names.
317
+ #
318
+ # This method configures a pattern that matches filenames which should be
319
+ # skipped during file processing operations. It uses a regular expression
320
+ # to identify files that start with a dot, end with common temporary file
321
+ # extensions, or match other patterns typically associated with backup,
322
+ # swap, log, or temporary files.
323
+ #
324
+ # @param pattern [ Regexp ] the regular expression pattern used to identify
325
+ # files to skip
133
326
  config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
134
327
 
328
+ # The config method sets up a configuration option with a default value.
329
+ #
330
+ # @param name [ Symbol ] the name of the configuration option
331
+ # @param default [ Object ] the default value for the configuration option
135
332
  config :max_matches, 10
136
333
 
334
+ # The index_expire_after method configures the expiration time for index
335
+ # files.
336
+ #
337
+ # This method sets up the duration after which index files should be
338
+ # considered expired and potentially refreshed or regenerated by the
339
+ # system.
340
+ #
341
+ # @param value [ Integer, nil ] the number of seconds after which indexes expire,
342
+ # or nil to disable automatic expiration
137
343
  config :index_expire_after
138
344
  end
139
345
 
346
+ # The discover method initializes and returns a Discover object.
347
+ #
348
+ # This method sets up a Discover instance, either using a provided block for
349
+ # configuration or creating a default instance. It ensures that only one
350
+ # Discover object is created per instance by storing it in an instance
351
+ # variable.
352
+ #
353
+ # @param block [ Proc ] optional block to configure the Discover object
354
+ #
355
+ # @return [ Utils::Discover ] a Discover object configured either with the
356
+ # provided block or with default settings
140
357
  def discover(&block)
141
358
  if block
142
359
  @discover = Discover.new(&block)
@@ -145,11 +362,41 @@ class Utils::ConfigFile
145
362
  end
146
363
 
147
364
  class Scope < FileFinder
365
+ # The prune_dirs method configures the pattern for identifying directories
366
+ # to be pruned during file system operations.
367
+ #
368
+ # This method sets up a regular expression pattern that matches directory
369
+ # names which should be excluded from processing. The default pattern
370
+ # excludes version control directories (.svn, .git, CVS) and temporary
371
+ # directories (tmp).
372
+ #
373
+ # @param first [ Regexp ] the regular expression pattern for matching directories to prune
148
374
  config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\z/
149
375
 
376
+ # The skip_files configuration method sets up a regular expression pattern
377
+ # for filtering out files based on their names.
378
+ #
379
+ # This method configures a pattern that matches filenames which should be
380
+ # skipped during file processing operations.
381
+ # It uses a regular expression to identify files that start with a dot, end
382
+ # with common temporary file extensions, or match other patterns typically
383
+ # associated with backup, swap, log, or temporary files.
384
+ #
385
+ # @param pattern [ Regexp ] the regular expression pattern used to identify files to skip
150
386
  config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
151
387
  end
152
388
 
389
+ # The scope method initializes and returns a Scope object.
390
+ #
391
+ # This method creates a new Scope instance either from the provided block or
392
+ # with default initialization if no block is given.
393
+ # The scope object is stored as an instance variable and reused on subsequent
394
+ # calls.
395
+ #
396
+ # @param block [ Proc ] optional block to pass to the Scope constructor
397
+ #
398
+ # @return [ Utils::Scope ] a Scope object configured with the provided block
399
+ # or default settings
153
400
  def scope(&block)
154
401
  if block
155
402
  @scope = Scope.new(&block)
@@ -158,11 +405,42 @@ class Utils::ConfigFile
158
405
  end
159
406
 
160
407
  class StripSpaces < FileFinder
408
+ # The prune_dirs method configures the pattern for directory names that
409
+ # should be pruned.
410
+ #
411
+ # This method sets up a regular expression pattern that identifies
412
+ # directories which should be excluded or removed during file system
413
+ # operations.
414
+ #
415
+ # @param pattern [ Regexp ] the regular expression pattern to match
416
+ # directory names
161
417
  config :prune_dirs, /\A(\..*|CVS)\z/
162
418
 
419
+ # The skip_files configuration method sets up a regular expression pattern
420
+ # for filtering out files based on their names.
421
+ #
422
+ # This method configures a pattern that matches filenames which should be
423
+ # skipped during file processing operations.
424
+ # It uses a regular expression to identify files that start with a dot, end
425
+ # with common temporary file extensions, or match other patterns typically
426
+ # associated with backup, swap, log, or temporary files.
427
+ #
428
+ # @param pattern [ Regexp ] the regular expression pattern used to identify
429
+ # files to skip
163
430
  config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
164
431
  end
165
432
 
433
+ # The strip_spaces method configures and returns a StripSpaces object for
434
+ # processing whitespace.
435
+ #
436
+ # This method initializes a StripSpaces processor that can be used to remove
437
+ # or modify whitespace in strings. When a block is provided, it sets up the
438
+ # processor with custom behavior defined by the block. Otherwise, it returns
439
+ # a default StripSpaces instance.
440
+ #
441
+ # @param block [ Proc ] optional block to customize the strip spaces behavior
442
+ #
443
+ # @return [ Utils::StripSpaces ] a configured StripSpaces processor instance
166
444
  def strip_spaces(&block)
167
445
  if block
168
446
  @strip_spaces = StripSpaces.new(&block)
@@ -171,25 +449,57 @@ class Utils::ConfigFile
171
449
  end
172
450
 
173
451
  class SshTunnel < BlockConfig
452
+ # The terminal_multiplexer method configures the terminal multiplexer
453
+ # setting.
454
+ #
455
+ # This method sets up the terminal multiplexer that will be used for
456
+ # managing multiple terminal sessions within the application environment.
457
+ #
458
+ # @param value [ String ] the name of the terminal multiplexer to use
174
459
  config :terminal_multiplexer, 'tmux'
175
460
 
461
+ # The env method configures the environment variables for the session.
462
+ #
463
+ # @param value [ Hash ] environment variable hash
176
464
  config :env, {}
177
465
 
466
+ # The login_session method configures the login session settings.
467
+ #
468
+ # @param block [ Proc ] a block containing the login session configuration
178
469
  config :login_session do
179
470
  ENV.fetch('HOME', 'session')
180
471
  end
181
472
 
473
+ # The initialize method sets up the instance by calling the superclass
474
+ # constructor and assigning the terminal multiplexer configuration.
475
+ #
476
+ # @param terminal_multiplexer [ Object ] the terminal multiplexer to be assigned
182
477
  def initialize
183
478
  super
184
479
  self.terminal_multiplexer = terminal_multiplexer
185
480
  end
186
481
 
482
+ # The terminal_multiplexer= method sets the terminal multiplexer type for
483
+ # the editor.
484
+ #
485
+ # This method assigns the specified terminal multiplexer to the editor
486
+ # configuration, validating that it is either 'screen' or 'tmux'. It
487
+ # converts the input to a string and ensures it matches one of the
488
+ # supported multiplexer types.
489
+ #
490
+ # @param terminal_multiplexer [ Symbol ] the terminal multiplexer type to
491
+ # be configured
187
492
  def terminal_multiplexer=(terminal_multiplexer)
188
493
  @multiplexer = terminal_multiplexer.to_s
189
494
  @multiplexer =~ /\A(screen|tmux)\z/ or
190
495
  fail "invalid terminal_multiplexer #{terminal_multiplexer.inspect} was configured"
191
496
  end
192
497
 
498
+ # The multiplexer_list method returns the appropriate command string for
499
+ # listing sessions based on the current multiplexer type.
500
+ #
501
+ # @return [ String, nil ] the command string to list sessions for the configured
502
+ # multiplexer ('screen -ls' or 'tmux ls'), or nil if no multiplexer is set
193
503
  def multiplexer_list
194
504
  case @multiplexer
195
505
  when 'screen'
@@ -199,6 +509,13 @@ class Utils::ConfigFile
199
509
  end
200
510
  end
201
511
 
512
+ # The multiplexer_new method generates a command string for creating a new
513
+ # session in the specified terminal multiplexer.
514
+ #
515
+ # @param session [ String ] the name of the session to be created
516
+ #
517
+ # @return [ String, nil ] a command string for creating a new session in screen
518
+ # or tmux, or nil if the multiplexer type is not supported
202
519
  def multiplexer_new(session)
203
520
  case @multiplexer
204
521
  when 'screen'
@@ -208,6 +525,12 @@ class Utils::ConfigFile
208
525
  end
209
526
  end
210
527
 
528
+ # The multiplexer_attach method generates a command string for attaching to
529
+ # a session using either screen or tmux multiplexer.
530
+ #
531
+ # @param session [ String ] the name or identifier of the session to attach to
532
+ #
533
+ # @return [ String ] a formatted command string ready for execution
211
534
  def multiplexer_attach(session)
212
535
  case @multiplexer
213
536
  when 'screen'
@@ -218,19 +541,65 @@ class Utils::ConfigFile
218
541
  end
219
542
 
220
543
  class CopyPaste < BlockConfig
544
+ # The bind_address method configures the network address to which the
545
+ # server will bind for incoming connections.
546
+ #
547
+ # @param value [ String ] the IP address or hostname to bind the server to
221
548
  config :bind_address, 'localhost'
222
549
 
550
+ # The port method configures the port number for the SSH tunnel
551
+ # specification.
552
+ #
553
+ # This method sets up the port component of an SSH tunnel configuration,
554
+ # allowing for the specification of a network port to be used in the
555
+ # tunnel.
556
+ #
557
+ # @param name [ String ] the name of the port configuration
558
+ # @param default [ Integer ] the default port number to use if none is specified
223
559
  config :port, 6166
224
560
 
561
+ # The host method configures the hostname for the SSH tunnel specification.
562
+ #
563
+ # This method sets up the host parameter that will be used in the SSH tunnel
564
+ # configuration, allowing connections to be established through the specified
565
+ # host address.
566
+ #
567
+ # @param value [ String ] the hostname or IP address to use for the SSH tunnel
225
568
  config :host, 'localhost'
226
569
 
570
+ # The host_port method configures the host port setting for the
571
+ # application.
572
+ #
573
+ # @param value [ Integer ] the port number to be used for host communication
227
574
  config :host_port, 6166
228
575
 
576
+ # The to_s method returns a colon-separated string representation of the
577
+ # SSH tunnel specification.
578
+ #
579
+ # This method combines the bind address, port, host, and host port components
580
+ # into a single string format using colons as separators.
581
+ #
582
+ # @return [ String ] a colon-separated string containing the tunnel specification
583
+ # in the format "bind_address:port:host:host_port"
229
584
  def to_s
230
585
  [ bind_address, port, host, host_port ] * ':'
231
586
  end
232
587
  end
233
588
 
589
+ # The copy_paste method manages the copy-paste functionality by returning
590
+ # an existing instance or creating a new one.
591
+ #
592
+ # This method checks if a copy-paste instance already exists and returns it
593
+ # if available. If no instance exists, it creates a new one based on
594
+ # whether a block is provided or
595
+ # the enable flag is set to true.
596
+ #
597
+ # @param enable [ TrueClass, FalseClass ] flag to enable copy-paste functionality
598
+ #
599
+ # @yield [ block ] optional block to initialize the copy-paste instance
600
+ #
601
+ # @return [ CopyPaste, nil ] the existing or newly created copy-paste
602
+ # instance, or nil if not enabled
234
603
  def copy_paste(enable = false, &block)
235
604
  if @copy_paste
236
605
  @copy_paste
@@ -253,11 +622,27 @@ class Utils::ConfigFile
253
622
  end
254
623
 
255
624
  class Edit < BlockConfig
625
+ # The vim_path method determines the path to the vim executable.
626
+ #
627
+ # This method executes the which command to locate the vim executable in
628
+ # the system's PATH and returns the resulting path after stripping any
629
+ # trailing whitespace.
630
+ #
631
+ # @return [ String ] the full path to the vim executable as determined by the which command
256
632
  config :vim_path do `which vim`.chomp end
257
633
 
258
634
  config :vim_default_args, nil
259
635
  end
260
636
 
637
+ # The edit method initializes and returns an Edit object.
638
+ #
639
+ # This method creates an Edit instance either from a provided block or with
640
+ # default settings. It stores the Edit object as an instance variable and
641
+ # returns it on subsequent calls.
642
+ #
643
+ # @param block [ Proc ] optional block to configure the Edit object
644
+ #
645
+ # @return [ Edit ] an Edit object configured either by the block or with default settings
261
646
  def edit(&block)
262
647
  if block
263
648
  @edit = Edit.new(&block)
@@ -266,11 +651,35 @@ class Utils::ConfigFile
266
651
  end
267
652
 
268
653
  class Classify < BlockConfig
654
+ # The shift_path_by_default method configuration accessor
655
+ #
656
+ # This method provides access to the shift_path_by_default configuration
657
+ # setting which determines the default path shifting value used in various
658
+ # operations.
659
+ #
660
+ # @return [ Integer ] the default path shifting value configured for the system
269
661
  config :shift_path_by_default, 0
270
662
 
663
+ # The shift_path_for_prefix method configures path shifting behavior for
664
+ # prefix handling.
665
+ #
666
+ # This method sets up the configuration for how paths should be shifted
667
+ # when dealing with prefix-based operations, typically used in file system
668
+ # or directory navigation contexts.
669
+ #
670
+ # @param config [ Array ] the configuration array for shift path settings
271
671
  config :shift_path_for_prefix, []
272
672
  end
273
673
 
674
+ # The classify method initializes and returns a Classify object.
675
+ #
676
+ # This method creates a Classify instance either from the provided block or
677
+ # with default settings if no block is given. It ensures that only one
678
+ # Classify object is created per instance by storing it in an instance variable.
679
+ #
680
+ # @param block [ Proc ] optional block to configure the Classify object
681
+ #
682
+ # @return [ Classify ] a Classify object configured either by the block or with defaults
274
683
  def classify(&block)
275
684
  if block
276
685
  @classify = Classify.new(&block)
@@ -279,13 +688,41 @@ class Utils::ConfigFile
279
688
  end
280
689
 
281
690
  class SyncDir < BlockConfig
691
+ # The skip_path method configures a regular expression pattern for skipping
692
+ # paths.
693
+ #
694
+ # This method sets up a configuration option that defines a regular
695
+ # expression used to identify and skip certain paths during processing
696
+ # operations.
697
+ #
698
+ # @param pattern [ Regexp ] the regular expression pattern used to match
699
+ # paths to be skipped
282
700
  config :skip_path, %r((\A|/)\.\w)
283
701
 
702
+ # The skip? method determines whether a given path should be skipped based
703
+ # on the skip_path pattern.
704
+ #
705
+ # This method checks if the provided path matches the internal skip_path
706
+ # regular expression, returning true if the path should be excluded from
707
+ # processing, or false otherwise.
708
+ #
709
+ # @param path [ String ] the path to check against the skip pattern
710
+ #
711
+ # @return [ TrueClass, FalseClass ] true if the path matches the skip
712
+ # pattern, false otherwise
284
713
  def skip?(path)
285
714
  path =~ skip_path
286
715
  end
287
716
  end
288
717
 
718
+ # The sync_dir method provides access to a SyncDir instance.
719
+ #
720
+ # This method returns the existing SyncDir instance if one has already been
721
+ # created, or initializes and returns a new SyncDir instance if no instance
722
+ # exists. If a block is provided, it will be passed to the SyncDir constructor
723
+ # when creating a new instance.
724
+ #
725
+ # @return [ SyncDir ] the SyncDir instance associated with this object
289
726
  def sync_dir(&block)
290
727
  if block
291
728
  @sync_dir = SyncDir.new(&block)
@@ -293,6 +730,13 @@ class Utils::ConfigFile
293
730
  @sync_dir ||= SyncDir.new
294
731
  end
295
732
 
733
+ # The to_ruby method generates a Ruby configuration string by collecting
734
+ # configuration data from various components and combining them into a
735
+ # single formatted output.
736
+ #
737
+ # @return [ String ] a Ruby formatted string containing configuration
738
+ # settings from search, discover, strip_spaces, probe, ssh_tunnel,
739
+ # edit, and classify components
296
740
  def to_ruby
297
741
  result = "# vim: set ft=ruby:\n"
298
742
  for bc in %w[search discover strip_spaces probe ssh_tunnel edit classify]