utils 0.73.1 → 0.75.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeb8c50e8895ed05192b62c4c7c86d0f5eccd34234e6878233c5324542c2c5ef
4
- data.tar.gz: f0c4adb49862333e4c85fba3ccde54c1a899dffb23a0cd846123d4bcc6ee7fa8
3
+ metadata.gz: 6f4bbd1ff8f20adf6d2f9876330c263ddf9108bd2d46ceb68e45211c5b8fbea7
4
+ data.tar.gz: cad94f08ffcd2b55eed18ab9ce7e0f9b44a6efe6162a0655b1e70da24bd1327e
5
5
  SHA512:
6
- metadata.gz: 18e205eb300082bdd1341083a63ac508c80e3af31faabcbe4675ec4c2c7c3c7b5975e1479ec426aba98ebadad3dc2d8e66b0b351aeae092eb525a1caf23ff1a7
7
- data.tar.gz: 8c3f8ec933935f36b4d79e5224dd49e71f5839bc152969f528b459f19240e743089ff7234e17eb644d6e19dda511eb8fdcf1a58e05cb4278752f831a9d87e5dd
6
+ metadata.gz: 3e8abfc5598071b791206ead4d6dd2efe1cdf344e880521ffe020f0a360cb36f1801a64f879c9d29687096afae2c19dd4d9291a050c1b59b66c9616238e3594b
7
+ data.tar.gz: 730dfcd09cceadd29734c36f7f02c2937c7053e9d74ff5df302dae3e522fabc5cd674eede9d90311fe86aa43cfd18dde5a8dfa957d002fc1c8f9125f23290dd1
data/.utilsrc CHANGED
@@ -1,12 +1,12 @@
1
1
  # vim: set ft=ruby:
2
2
 
3
3
  search do
4
- prune_dirs /\A(\.svn|\.git|\.terraform|CVS|tmp|coverage|corpus|pkg|\.yardoc)\z/
4
+ prune_dirs /\A(\.svn|\.git|\.terraform|CVS|tmp|coverage|corpus|pkg|\.yardoc|doc)\z/
5
5
  skip_files /(\A\.|\.sw[pon]\z|\.(log|fnm|jpg|jpeg|png|pdf|svg)\z|\Atags\z|~\z)/i
6
6
  end
7
7
 
8
8
  discover do
9
- prune_dirs /\A(\.svn|\.git|\.terraform|\.yardoc|CVS|tmp|coverage|corpus|pkg|\.yardoc)\z/
9
+ prune_dirs /\A(\.svn|\.git|\.terraform|\.yardoc|CVS|tmp|coverage|corpus|pkg|\.yardoc|doc)\z/
10
10
  skip_files /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
11
11
  index_expire_after 3_600
12
12
  end
@@ -31,3 +31,7 @@ end
31
31
  classify do
32
32
  shift_path_by_default 1
33
33
  end
34
+
35
+ code_indexer do
36
+ verbose true
37
+ end
data/Rakefile CHANGED
@@ -14,7 +14,8 @@ GemHadar do
14
14
  map(&File.method(:basename))
15
15
  test_dir 'tests'
16
16
  ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', '.AppleDouble',
17
- 'tags', '.bundle', '.DS_Store', '.byebug_history'
17
+ 'tags', '.bundle', '.DS_Store', '.byebug_history', '.yardoc', 'doc',
18
+ 'cscope.out', '.starscope.db'
18
19
  package_ignore '.gitignore', 'VERSION'
19
20
  readme 'README.md'
20
21
  licenses << 'GPL-2.0'
@@ -31,6 +32,7 @@ GemHadar do
31
32
  dependency 'ollama-ruby', '~> 1.6'
32
33
  dependency 'kramdown-ansi', '~> 0.1'
33
34
  dependency 'figlet', '~> 1.0'
35
+ dependency 'starscope'
34
36
  dependency 'context_spook', '~> 0.2'
35
37
  dependency 'simplecov'
36
38
  dependency 'debug'
data/bin/code_comment CHANGED
@@ -11,7 +11,7 @@
11
11
  # descriptions, parameters, return values, and exceptions.
12
12
  #
13
13
  # Requires:
14
- # - Git repository with Ruby files in lib/, spec/, or test/ directories
14
+ # - Git repository with Ruby files in lib/, spec/, or tests/ directories
15
15
  # - Ollama server running locally or accessible via OLLAMA_URL / OLLAMA_HOST
16
16
  # - Configuration files in ~/.config/code_comment/
17
17
  # - system.txt: System prompt for LLM
@@ -113,12 +113,18 @@ def build_method_prompt(construct_type, construct, context)
113
113
 
114
114
  1. Focus on providing a description of the %{construct_type}'s purpose
115
115
  without including any code snippets.
116
- 2. You should omit the @raise if you are not sure.
117
- 3. Never use `, `ruby, ```, ```ruby in your response.
118
- 4. Never add any other remarks or explanation to your response.
119
- 5. Start each line of your comment with a single # character.
116
+ 2. **Always** output just the line comments starting each with a single #
117
+ character.
118
+ 3. **Never** output blank lines between comment lines that belong to the
119
+ same logical section
120
+ 4. **Never** output any executable ruby code like class or module
121
+ definitions, or method definitions or other code outside of such
122
+ comments.
123
+ 5. You should omit the @raise if you are not sure.
124
+ 6. **Never** use `, `ruby, ```, ```ruby in your response.
125
+ 7. **Never** add any other remarks or explanation to your response.
120
126
  EOT
121
- $config.read('method-prompt.txt', default: default_prompt) % {
127
+ $config_dir.read('method-prompt.txt', default: default_prompt) % {
122
128
  construct_type:, construct:, context:,
123
129
  }
124
130
  end
@@ -148,13 +154,18 @@ def build_class_module_prompt(construct_type, construct, context)
148
154
 
149
155
  1. Focus on providing a description of the %{construct_type}'s purpose
150
156
  without including any code snippets.
151
- 2. Include @example tag if there are notable usage patterns for this
152
- construct.
153
- 3. Never use `, `ruby, ```, ```ruby in your response.
154
- 4. Never add any other remarks or explanation to your response.
155
- 5. Start each line of your comment with a single # character.
157
+ 2. **Always** output just the line comments starting each with a single #
158
+ character.
159
+ 3. **Never** output blank lines between comment lines that belong to the
160
+ same logical section
161
+ 4. **Never** output any executable ruby code like class or module
162
+ definitions, or method definitions or other code outside of such
163
+ comments.
164
+ 5. You should omit the @raise if you are not sure.
165
+ 6. **Never** use `, `ruby, ```, ```ruby in your response.
166
+ 7. **Never** add any other remarks or explanation to your response.
156
167
  EOT
157
- $config.read('class-module-prompt.txt', default: default_prompt) % {
168
+ $config_dir.read('class-module-prompt.txt', default: default_prompt) % {
158
169
  construct_type:, construct:, context:,
159
170
  }
160
171
  end
@@ -171,7 +182,9 @@ def build_prompt(construct_type, construct, context)
171
182
  end
172
183
 
173
184
  filename_linenumber = ARGV.shift or fail "require file_name as second argument"
174
- $config = Utils::ConfigDir.new('code_comment', env_var: 'XDG_CONFIG_HOME')
185
+ $config = Utils::ConfigFile.new
186
+ $config.configure_from_paths
187
+ $config_dir = Utils::ConfigDir.new('code_comment', env_var: 'XDG_CONFIG_HOME')
175
188
  base_url = ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST')
176
189
  model = ENV.fetch('OLLAMA_MODEL', 'llama3.1')
177
190
  construct, construct_type = fetch_construct(filename_linenumber)
@@ -185,15 +198,17 @@ default_context = ContextSpook.generate_context do
185
198
  file "README.md", tags: %w[ documentation ]
186
199
 
187
200
  # Auto-discover files using globs
188
- %w[ lib spec test ].each do |dir|
201
+ $config.code_comment.code_globs.each do |dir_glob|
202
+ dir = dir_glob.sub(%r(/.*), '').full? || 'none'
189
203
  namespace dir do
190
- Dir["#{dir}/**/*.rb"].each do |filename|
191
- file filename, tags: %w[ ruby ]
204
+ Dir[dir_glob].each do |filename|
205
+ file filename
192
206
  end
193
207
  end
194
208
  end
195
209
  end
196
210
  end
211
+
197
212
  context = if File.exist?(context_filename)
198
213
  STDERR.puts "Using context from #{context_filename.inspect}."
199
214
  ContextSpook.generate_context(context_filename)
@@ -223,7 +238,7 @@ default_system = <<~EOT
223
238
  * @example usage patterns when helpful
224
239
  * Avoid version information (@since)
225
240
  EOT
226
- system = $config.read('system.txt', default: default_system)
241
+ system = $config_dir.read('system.txt', default: default_system)
227
242
 
228
243
  prompt = build_prompt(construct_type, construct, context)
229
244
 
@@ -238,10 +253,10 @@ default_options = JSON(
238
253
  min_p: 0.1,
239
254
  )
240
255
 
241
- client_config = Client::Config.load_from_json $config + 'client.json'
256
+ client_config = Client::Config.load_from_json $config_dir + 'client.json'
242
257
  client_config.base_url = base_url
243
258
  ollama = Client.configure_with(client_config)
244
- options = JSON.parse($config.read('options.json', default: default_options))
259
+ options = JSON.parse($config_dir.read('options.json', default: default_options))
245
260
 
246
261
  if ENV['DEBUG'].to_i == 1
247
262
  File.open('debug.log', ?w) do |log|
data/bin/code_indexer ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'utils'
4
+ config = Utils::ConfigFile.new
5
+ config.configure_from_paths
6
+
7
+ config.code_indexer.formats.each do |format, output|
8
+ paths = config.code_indexer.paths.grep_v(/Resolving dependencies/)
9
+ puts "Indexing code for #{format}…"
10
+ cmd = [ 'starscope', '-e', format, '-f', output, '--no-read' ]
11
+ config.code_indexer.verbose and cmd << '--verbose'
12
+ cmd.push(*paths)
13
+ system(*cmd)
14
+ puts "Done."
15
+ end
data/bin/serve CHANGED
@@ -6,7 +6,7 @@ require 'tins/go'
6
6
  include Tins::GO
7
7
  require 'webrick'
8
8
 
9
- $opts = go 'p:h'
9
+ $opts = go 'b:p:h', defaults: { ?b => '127.0.0.1', ?p => 8888 }
10
10
 
11
11
  if $opts[?h]
12
12
  puts <<~USAGE
@@ -15,12 +15,14 @@ if $opts[?h]
15
15
  Usage: #{File.basename($0)} [OPTIONS] [DIR]
16
16
 
17
17
  Options:
18
- -p PORT Specify port number (default: 8888)
19
- -h Show this help message
18
+ -b ADDRESS Address to bind to (default: "127.0.0.1")
19
+ -p PORT Specify port number (default: 8888)
20
+ -h Show this help message
20
21
 
21
22
  Examples:
22
- #{File.basename($0)} # Serve current directory on port 8888
23
- #{File.basename($0)} -p 3000 # Serve on port 3000
23
+ #{File.basename($0)} # Serve current directory on 127.0.0.1:8888
24
+ #{File.basename($0)} -b 0.0.0.0 # Serve on 0.0.0.0:3000
25
+ #{File.basename($0)} -p 3000 # Serve on 127.0.0.1:3000
24
26
  #{File.basename($0)} /path/to/dir # Serve specific directory
25
27
 
26
28
  Note: If no directory is specified, serves the current working directory.
@@ -28,11 +30,13 @@ if $opts[?h]
28
30
  exit
29
31
  end
30
32
 
31
- port = ($opts[?p] || 8888).to_i
33
+ address = $opts[?b]
34
+ port = $opts[?p].to_i
32
35
  s = WEBrick::HTTPServer.new(
36
+ BindAddress: address,
33
37
  Port: port,
34
38
  DocumentRoot: ARGV.shift || Dir.pwd
35
39
  )
36
40
  trap('INT') { s.shutdown }
37
- puts "You have been served: http://localhost:#{port}/"
41
+ puts "You have been served: http://#{address}:#{port}/"
38
42
  s.start
data/bin/yaml_check CHANGED
@@ -24,6 +24,8 @@
24
24
  # DEBUG=1 ./yaml_check data.yaml
25
25
  #
26
26
 
27
+ require 'yaml'
28
+
27
29
  format = -> s {
28
30
  if /^\((?<f>[^)]+)\):\ (?<m>.*?) at line (?<l>\d+) column (?<c>\d+)/ =~ s
29
31
  [ f, l, c, m ] * ?:
@@ -2,6 +2,21 @@ require 'pathname'
2
2
  require 'stringio'
3
3
 
4
4
  module Utils
5
+ # A configuration directory manager that handles path resolution and file
6
+ # operations within a specified directory structure.
7
+ #
8
+ # This class provides functionality for managing configuration directories by
9
+ # deriving paths based on a root directory and name, and offering methods to
10
+ # read files with optional default values and block handling. It supports
11
+ # environment variable-based root path resolution and uses Pathname for
12
+ # robust path manipulation.
13
+ #
14
+ # @example
15
+ # config_dir = Utils::ConfigDir.new('myapp')
16
+ # config_dir.to_s # => returns the string representation of the configuration directory path
17
+ # config_dir.join('config.txt') # => returns a Pathname object for the joined path
18
+ # config_dir.read('settings.rb') # => reads and returns the content of 'settings.rb' or nil if not found
19
+ # config_dir.read('missing.txt', default: 'default content') # => returns 'default content' if file is missing
5
20
  class ConfigDir
6
21
  # Initializes a new ConfigDir instance with the specified name and optional
7
22
  # root path or environment variable.
@@ -1,5 +1,11 @@
1
1
  require 'tins'
2
2
 
3
+ # Configuration file manager for Utils library.
4
+ #
5
+ # This class provides functionality for loading, parsing, and managing
6
+ # configuration settings from multiple sources. It supports DSL-style
7
+ # configuration blocks and integrates with various utility components to
8
+ # provide centralized configuration management.
3
9
  class Utils::ConfigFile
4
10
  class << self
5
11
  attr_accessor :config_file_paths
@@ -12,6 +18,12 @@ class Utils::ConfigFile
12
18
 
13
19
  include DSLKit::Interpreter
14
20
 
21
+ # Error raised when configuration file parsing fails.
22
+ #
23
+ # This exception is specifically designed to be thrown when issues occur
24
+ # during the parsing or processing of configuration files within the Utils
25
+ # library. It inherits from StandardError, making it a standard Ruby
26
+ # exception that can be caught and handled appropriately by calling code.
15
27
  class ConfigFileError < StandardError; end
16
28
 
17
29
  # The initialize method sets up a new instance of the class.
@@ -76,6 +88,12 @@ class Utils::ConfigFile
76
88
  self
77
89
  end
78
90
 
91
+ # Base class for defining configuration blocks with DSL accessors.
92
+ #
93
+ # This class provides a foundation for creating configuration classes that
94
+ # support dynamic attribute definition through DSL-style accessor methods. It
95
+ # includes functionality for registering configuration settings and
96
+ # generating Ruby code representations of the configuration state.
79
97
  class BlockConfig
80
98
  class << self
81
99
  # The inherited method extends the module with DSL accessor functionality
@@ -158,11 +176,17 @@ class Utils::ConfigFile
158
176
  end
159
177
  end
160
178
 
179
+ # A configuration class for test execution settings.
180
+ #
181
+ # This class manages the configuration options related to running tests,
182
+ # specifically supporting different test frameworks and defining which
183
+ # directories should be included in test discovery and execution.
161
184
  class Probe < BlockConfig
162
185
  # The config method sets up a configuration option for the test framework.
163
186
  #
164
187
  # This method defines a configuration parameter that specifies which test
165
- # framework should be used, allowing for flexible test execution environments.
188
+ # framework should be used, allowing for flexible test execution
189
+ # environments.
166
190
  #
167
191
  # @param name [ Symbol ] the name of the configuration option
168
192
  # @param value [ Object ] the value to set for the configuration option
@@ -221,6 +245,13 @@ class Utils::ConfigFile
221
245
  @probe ||= Probe.new
222
246
  end
223
247
 
248
+ # A configuration class for file system operations.
249
+ #
250
+ # This class manages the configuration settings for searching and discovering
251
+ # files and directories while filtering out unwanted entries based on
252
+ # configured patterns. It provides functionality to define which directories
253
+ # should be pruned and which files should be skipped during file system
254
+ # operations.
224
255
  class FileFinder < BlockConfig
225
256
  # The prune? method checks if a basename matches any of the configured
226
257
  # prune directories.
@@ -254,6 +285,13 @@ class Utils::ConfigFile
254
285
  end
255
286
  end
256
287
 
288
+ # A configuration class for search operations.
289
+ #
290
+ # This class manages the configuration settings for searching files and
291
+ # directories while filtering out unwanted entries based on configured
292
+ # patterns. It inherits from FileFinder and provides functionality to define
293
+ # which directories should be pruned and which files should be skipped during
294
+ # search processes.
257
295
  class Search < FileFinder
258
296
  # The prune_dirs method configures the pattern for identifying directories
259
297
  # to be pruned during file system operations.
@@ -299,6 +337,12 @@ class Utils::ConfigFile
299
337
  @search ||= Search.new
300
338
  end
301
339
 
340
+ # A configuration class for file discovery operations.
341
+ #
342
+ # This class manages the configuration settings for discovering files and directories
343
+ # while filtering out unwanted entries based on configured patterns. It inherits from
344
+ # FileFinder and provides functionality to define which directories should be pruned
345
+ # and which files should be skipped during discovery processes.
302
346
  class Discover < FileFinder
303
347
  # The prune_dirs method configures the pattern for identifying directories
304
348
  # to be pruned during file system operations.
@@ -361,49 +405,61 @@ class Utils::ConfigFile
361
405
  @discover ||= Discover.new
362
406
  end
363
407
 
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
374
- config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\z/
408
+ # A configuration class for code indexing operations.
409
+ #
410
+ # This class manages the configuration settings for generating code indexes
411
+ # like ctags and cscope. It provides functionality to define which paths
412
+ # should be indexed and what file formats should be generated for each
413
+ # indexing tool.
414
+ #
415
+ # @example
416
+ # indexer = Utils::ConfigFile.new.code_indexer do |config|
417
+ # config.paths = %w[ lib spec ]
418
+ # config.formats = { 'ctags' => 'tags', 'cscope' => 'cscope.out' }
419
+ # end
420
+ #
421
+ # The paths config configures the directories to be included in the index
422
+ # generation process.
423
+ #
424
+ # The formats config configures the output file formats for different indexing
425
+ # tools and the output filenames.
426
+ class CodeIndexer < BlockConfig
427
+ config :verbose, false
375
428
 
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
386
- config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
429
+ config :paths, %w[ bin lib spec tests ]
430
+
431
+ config :formats, {
432
+ 'ctags' => 'tags',
433
+ 'cscope' => 'cscope.out',
434
+ }
387
435
  end
388
436
 
389
- # The scope method initializes and returns a Scope object.
437
+ # The code_indexer method manages and returns a CodeIndexer configuration
438
+ # instance.
390
439
  #
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.
440
+ # This method provides access to a CodeIndexer object that handles configuration
441
+ # for generating code indexes such as ctags and cscope files. It ensures that only
442
+ # one CodeIndexer instance is created per object by storing it in an instance variable.
443
+ # When a block is provided, it initializes the CodeIndexer with custom settings;
444
+ # otherwise, it returns a default CodeIndexer instance.
395
445
  #
396
- # @param block [ Proc ] optional block to pass to the Scope constructor
446
+ # @param block [ Proc ] optional block to configure the CodeIndexer object
397
447
  #
398
- # @return [ Utils::Scope ] a Scope object configured with the provided block
399
- # or default settings
400
- def scope(&block)
448
+ # @return [ Utils::ConfigFile::CodeIndexer ] a CodeIndexer configuration instance
449
+ # configured either by the block or with default settings
450
+ def code_indexer(&block)
401
451
  if block
402
- @scope = Scope.new(&block)
452
+ @code_indexer = CodeIndexer.new(&block)
403
453
  end
404
- @scope ||= Scope.new
454
+ @code_indexer ||= CodeIndexer.new
405
455
  end
406
456
 
457
+ # A configuration class for whitespace handling operations.
458
+ #
459
+ # This class manages the configuration options related to removing or modifying
460
+ # trailing whitespace in files. It provides functionality to define patterns for
461
+ # pruning directories and skipping specific files during whitespace processing,
462
+ # ensuring that only relevant files are affected by space-stripping operations.
407
463
  class StripSpaces < FileFinder
408
464
  # The prune_dirs method configures the pattern for directory names that
409
465
  # should be pruned.
@@ -448,6 +504,12 @@ class Utils::ConfigFile
448
504
  @strip_spaces ||= StripSpaces.new
449
505
  end
450
506
 
507
+ # SSH tunnel configuration manager
508
+ #
509
+ # Provides functionality for configuring and managing SSH tunnels with support for
510
+ # different terminal multiplexers like tmux and screen. Allows setting up tunnel
511
+ # specifications with local and remote address/port combinations, handling
512
+ # environment variables, and managing copy/paste functionality for tunnel sessions.
451
513
  class SshTunnel < BlockConfig
452
514
  # The terminal_multiplexer method configures the terminal multiplexer
453
515
  # setting.
@@ -472,8 +534,6 @@ class Utils::ConfigFile
472
534
 
473
535
  # The initialize method sets up the instance by calling the superclass
474
536
  # constructor and assigning the terminal multiplexer configuration.
475
- #
476
- # @param terminal_multiplexer [ Object ] the terminal multiplexer to be assigned
477
537
  def initialize
478
538
  super
479
539
  self.terminal_multiplexer = terminal_multiplexer
@@ -540,6 +600,12 @@ class Utils::ConfigFile
540
600
  end
541
601
  end
542
602
 
603
+ # Manages the copy/paste functionality configuration for SSH tunnels.
604
+ #
605
+ # This class handles the setup and configuration of copy/paste capabilities
606
+ # within SSH tunnel sessions, allowing users to define network addresses,
607
+ # ports, and other parameters needed for establishing and managing
608
+ # copy/paste connections through SSH tunnels.
543
609
  class CopyPaste < BlockConfig
544
610
  # The bind_address method configures the network address to which the
545
611
  # server will bind for incoming connections.
@@ -614,6 +680,17 @@ class Utils::ConfigFile
614
680
  self.config_settings << :copy_paste
615
681
  end
616
682
 
683
+ # The ssh_tunnel method provides access to an SSH tunnel configuration instance.
684
+ #
685
+ # This method returns the existing SSH tunnel configuration object if one has
686
+ # already been created, or initializes and returns a new SSH tunnel
687
+ # configuration instance if no instance exists. If a block is provided, it
688
+ # will be passed to the SSH tunnel configuration constructor when creating a
689
+ # new instance.
690
+ #
691
+ # @param block [ Proc ] optional block to configure the SSH tunnel object
692
+ #
693
+ # @return [ Utils::ConfigFile::SshTunnel ] an SSH tunnel configuration instance
617
694
  def ssh_tunnel(&block)
618
695
  if block
619
696
  @ssh_tunnel = SshTunnel.new(&block)
@@ -621,6 +698,12 @@ class Utils::ConfigFile
621
698
  @ssh_tunnel ||= SshTunnel.new
622
699
  end
623
700
 
701
+ # A configuration class for editor settings.
702
+ #
703
+ # This class manages the configuration options related to editing operations,
704
+ # specifically focusing on Vim editor integration. It provides functionality
705
+ # to configure the path to the Vim executable and default arguments used when
706
+ # invoking the editor.
624
707
  class Edit < BlockConfig
625
708
  # The vim_path method determines the path to the vim executable.
626
709
  #
@@ -650,6 +733,12 @@ class Utils::ConfigFile
650
733
  @edit ||= Edit.new
651
734
  end
652
735
 
736
+ # A configuration class for file classification settings.
737
+ #
738
+ # This class manages the configuration options related to classifying files
739
+ # by type or category. It provides functionality to define path shifting
740
+ # behavior and prefix handling for determining how file paths should be
741
+ # categorized during classification operations.
653
742
  class Classify < BlockConfig
654
743
  # The shift_path_by_default method configuration accessor
655
744
  #
@@ -687,6 +776,12 @@ class Utils::ConfigFile
687
776
  @classify ||= Classify.new
688
777
  end
689
778
 
779
+ # A configuration class for directory synchronization settings.
780
+ #
781
+ # This class manages the configuration options related to synchronizing
782
+ # directories using rsync. It provides functionality to define patterns for
783
+ # skipping certain paths during synchronization operations, making it easy to
784
+ # exclude temporary, cache, or version control files from being synced.
690
785
  class SyncDir < BlockConfig
691
786
  # The skip_path method configures a regular expression pattern for skipping
692
787
  # paths.
@@ -730,6 +825,33 @@ class Utils::ConfigFile
730
825
  @sync_dir ||= SyncDir.new
731
826
  end
732
827
 
828
+ # A configuration class for code comment settings.
829
+ #
830
+ # This class manages the configuration options related to generating YARD
831
+ # documentation for Ruby source code. It provides access to glob patterns
832
+ # that define which files should be considered when generating code comments.
833
+ class CodeComment < BlockConfig
834
+ dsl_accessor :code_globs, 'lib/**/*.rb', 'spec/**/*.rb', 'tests/**/*rb'
835
+ end
836
+
837
+ # The code_comment method provides access to a CodeComment configuration
838
+ # instance.
839
+ #
840
+ # This method returns the existing CodeComment instance if one has already
841
+ # been created, or initializes and returns a new CodeComment instance if no
842
+ # instance exists. If a block is provided, it will be passed to the
843
+ # CodeComment constructor when creating a new instance.
844
+ #
845
+ # @param block [ Proc ] optional block to configure the CodeComment object
846
+ #
847
+ # @return [ Utils::ConfigFile::CodeComment ] a CodeComment configuration instance
848
+ def code_comment(&block)
849
+ if block
850
+ @code_comment = CodeComment.new(&block)
851
+ end
852
+ @code_comment ||= CodeComment.new
853
+ end
854
+
733
855
  # The to_ruby method generates a Ruby configuration string by collecting
734
856
  # configuration data from various components and combining them into a
735
857
  # single formatted output.
data/lib/utils/editor.rb CHANGED
@@ -3,6 +3,19 @@ require 'rbconfig'
3
3
  require 'pstree'
4
4
 
5
5
  module Utils
6
+ # An editor interface for interacting with Vim server instances.
7
+ #
8
+ # This class provides functionality for managing Vim editor sessions through
9
+ # server connections, enabling features like remote file editing, window
10
+ # management, and server state monitoring. It handles communication with
11
+ # running Vim instances and supports various configuration options for
12
+ # customizing the editing experience.
13
+ #
14
+ # @example
15
+ # editor = Utils::Editor.new
16
+ # editor.edit('file.rb')
17
+ # editor.activate
18
+ # editor.stop
6
19
  class Editor
7
20
  # The initialize method sets up a new editor instance with default
8
21
  # configuration.
@@ -11,7 +24,8 @@ module Utils
11
24
  # flag, pause duration, and server name. It also loads the configuration
12
25
  # file and assigns the edit configuration section to the instance.
13
26
  #
14
- # @param block [ Proc ] optional block to be executed after initialization
27
+ # @yield |editor| optional block to be executed after initialization with
28
+ # self as argument.
15
29
  #
16
30
  # @return [ Utils::Editor ] a new editor instance configured with default settings
17
31
  def initialize
@@ -41,10 +55,14 @@ module Utils
41
55
  name.upcase
42
56
  end
43
57
 
44
- # The pause_duration method gets or sets the pause duration value.
58
+ # The pause_duration method provides access to the duration value used for
59
+ # pausing operations.
45
60
  #
46
- # @return [ Integer ] the current pause duration value
47
- # @param value [ Integer ] the new pause duration value to set
61
+ # This method returns the current value of the pause duration attribute,
62
+ # which controls how long certain operations should wait or pause between
63
+ # actions.
64
+ #
65
+ # @return [ Integer, Float ] the current pause duration value in seconds
48
66
  attr_accessor :pause_duration
49
67
 
50
68
  # The wait method gets the wait status.
data/lib/utils/finder.rb CHANGED
@@ -4,6 +4,18 @@ require 'digest/md5'
4
4
  require 'fileutils'
5
5
  require 'mize'
6
6
 
7
+ # A class for finding and searching files with configurable patterns and
8
+ # filters.
9
+ #
10
+ # This class provides functionality for traversing file systems to locate files
11
+ # based on various criteria including file extensions, directory pruning, and
12
+ # pattern matching. It supports both indexed and direct search approaches to
13
+ # optimize performance when dealing with large codebases or frequently accessed
14
+ # file sets.
15
+ #
16
+ # @example
17
+ # finder = Utils::Finder.new(args: { l: true }, roots: ['.'])
18
+ # finder.search
7
19
  class Utils::Finder
8
20
  include Tins::Find
9
21
  include Utils::Patterns
data/lib/utils/grepper.rb CHANGED
@@ -1,10 +1,27 @@
1
1
  require 'term/ansicolor'
2
2
 
3
+ # A class for searching and matching text patterns within files.
4
+ #
5
+ # This class provides functionality to search through file systems for content
6
+ # matching specified patterns, with support for various output formats and
7
+ # filtering options. It handles directory pruning, file skipping, and different
8
+ # types of pattern matching including regular expressions and fuzzy matching.
9
+ #
10
+ # @example
11
+ # grepper = Utils::Grepper.new(args: { l: true }, roots: ['.'])
12
+ # grepper.search
3
13
  class Utils::Grepper
4
14
  include Tins::Find
5
15
  include Utils::Patterns
6
16
  include Term::ANSIColor
7
17
 
18
+ # A queue implementation with size limitation.
19
+ #
20
+ # @example queue = Utils::Grepper::Queue.new(5) queue << "item1" queue <<
21
+ # "item2" # ... queue.data # => [ "item1", "item2", ... ]
22
+ #
23
+ # The Queue class provides a fixed-size buffer for storing objects. When the
24
+ # maximum size is exceeded, the oldest item is automatically removed.
8
25
  class Queue
9
26
  # The initialize method sets up a new instance with the specified maximum
10
27
  # size and empty data array.
data/lib/utils/irb.rb CHANGED
@@ -9,7 +9,19 @@ $editor = Utils::Editor.new
9
9
  $pager = ENV['PAGER'] || 'less -r'
10
10
 
11
11
  module Utils
12
+ # A module that extends Ruby's core classes with additional utility methods
13
+ # for interactive development.
14
+ #
15
+ # Provides enhanced functionality for IRB sessions through method extensions
16
+ # on Object, String, and Regexp classes. Includes features like improved
17
+ # pattern matching, shell command integration, file I/O operations,
18
+ # performance measurement tools, and developer productivity enhancements.
12
19
  module IRB
20
+ # A module that extends Regexp functionality with additional pattern
21
+ # matching and display capabilities.
22
+ #
23
+ # Provides enhanced regexp operations including match highlighting and
24
+ # shell command integration.
13
25
  module Shell
14
26
  require 'fileutils'
15
27
  include FileUtils
@@ -223,6 +235,12 @@ module Utils
223
235
  end.compact.sort!
224
236
  end
225
237
 
238
+ # Base class for wrapping objects with descriptive metadata.
239
+ #
240
+ # This class provides a foundation for creating wrapper objects that
241
+ # associate descriptive information with underlying objects. It handles
242
+ # name conversion and provides common methods for accessing and comparing
243
+ # wrapped objects.
226
244
  class WrapperBase
227
245
  include Comparable
228
246
 
@@ -293,6 +311,15 @@ module Utils
293
311
  end
294
312
  end
295
313
 
314
+ # A wrapper class for Ruby method objects that provides enhanced
315
+ # introspection and display capabilities.
316
+ #
317
+ # This class extends WrapperBase to create specialized wrappers for Ruby
318
+ # method objects, offering detailed information about methods including
319
+ # their source location, arity, and owner. It facilitates interactive
320
+ # exploration of Ruby methods in environments like IRB by providing
321
+ # structured access to method metadata and enabling sorting and
322
+ # comparison operations based on method descriptions.
296
323
  class MethodWrapper < WrapperBase
297
324
  # The initialize method sets up a new instance with the specified
298
325
  # object, method name, and module flag.
@@ -356,6 +383,15 @@ module Utils
356
383
  end
357
384
  end
358
385
 
386
+ # A wrapper class for Ruby constant objects that provides enhanced
387
+ # introspection and display capabilities.
388
+ #
389
+ # This class extends WrapperBase to create specialized wrappers for Ruby
390
+ # constant objects, offering detailed information about constants
391
+ # including their names and associated classes. It facilitates
392
+ # interactive exploration of Ruby constants in environments like IRB by
393
+ # providing structured access to constant metadata and enabling sorting
394
+ # and comparison operations based on constant descriptions.
359
395
  class ConstantWrapper < WrapperBase
360
396
  # The initialize method sets up a new instance with the provided object
361
397
  # and name.
@@ -667,6 +703,15 @@ module Utils
667
703
  end
668
704
  end
669
705
 
706
+ # A module that extends Regexp functionality with additional pattern
707
+ # matching and display capabilities.
708
+ #
709
+ # Provides enhanced regexp operations including match highlighting and
710
+ # shell command integration.
711
+ #
712
+ # @example
713
+ # /pattern/ # => regular expression object
714
+ # /pattern/.show_match("text") # => highlighted text match
670
715
  module Regexp
671
716
  # The show_match method evaluates a string against the receiver pattern
672
717
  # and highlights matching portions.
@@ -691,6 +736,11 @@ module Utils
691
736
  end
692
737
  end
693
738
 
739
+ # A module that extends String with additional utility methods for shell
740
+ # command piping and file writing operations.
741
+ #
742
+ # Provides convenient methods for executing shell commands on string
743
+ # content and securely writing strings to files.
694
744
  module String
695
745
  # The | method executes a shell command and returns its output.
696
746
  #
@@ -1,4 +1,12 @@
1
1
  module Utils
2
+ # A class for analyzing and retrieving git blame information for specific
3
+ # lines of code.
4
+ #
5
+ # This class provides functionality to initialize with a file path and line
6
+ # number, and then perform git blame operations to obtain information about
7
+ # when and by whom that specific line was last modified. It serves as a
8
+ # utility for developers to quickly access historical context for individual
9
+ # lines of code within their projects.
2
10
  class LineBlamer
3
11
  # Initializes a new LineBlamer instance to analyze source code line
4
12
  # information.
data/lib/utils/md5.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  require 'digest/md5'
2
2
 
3
3
  module Utils
4
+ # MD5 module for computing MD5 hash digests of files.
5
+ #
6
+ # This module provides functionality for calculating MD5 hash digests of
7
+ # files using the Digest::MD5 library. It offers a convenient interface for
8
+ # computing hashes while handling file reading in chunks to optimize memory
9
+ # usage during the hashing process.
4
10
  module MD5
5
11
  class << self
6
12
  # The buffer_size accessor method provides read and write access to the
@@ -1,5 +1,19 @@
1
1
  module Utils
2
+ # A module that provides pattern matching functionality for file searching
3
+ # and text processing.
4
+ #
5
+ # It includes classes for different types of pattern matching including fuzzy
6
+ # matching and regular expression matching.
2
7
  module Patterns
8
+
9
+ # Base class for pattern matching implementations.
10
+ #
11
+ # This class serves as the foundation for various pattern matching
12
+ # strategies, providing common functionality for initializing patterns with
13
+ # character set filtering and case sensitivity options. It handles the core
14
+ # configuration and delegates specific matching behavior to subclasses.
15
+ #
16
+ # @abstract
3
17
  class Pattern
4
18
  # Initializes a new Pattern instance with the specified options.
5
19
  #
@@ -46,6 +60,19 @@ module Utils
46
60
  end
47
61
  end
48
62
 
63
+ # A fuzzy pattern matcher that performs partial string matching while
64
+ # preserving character order.
65
+ #
66
+ # This class implements a pattern matching strategy that allows for
67
+ # flexible matching of strings where the characters of the search pattern
68
+ # appear in sequence within the target string, but not necessarily
69
+ # consecutively. It is particularly useful for finding text patterns with
70
+ # potential typos or
71
+ # when only partial information about the target is available.
72
+ #
73
+ # @example
74
+ # fuzzy_pattern = FuzzyPattern.new(pattern: 'abc')
75
+ # fuzzy_pattern.match('a1b2c3') # => matches because 'a', 'b', and 'c' appear in order
49
76
  class FuzzyPattern < Pattern
50
77
  # Initializes a fuzzy pattern matcher by processing the pattern string
51
78
  # and compiling it into a regular expression.
@@ -70,6 +97,18 @@ module Utils
70
97
  end
71
98
  end
72
99
 
100
+ # A regular expression pattern matcher that performs exact string matching
101
+ # with optional case sensitivity.
102
+ #
103
+ # This class extends the base Pattern class to provide functionality for
104
+ # creating and using regular expression patterns. It compiles the provided
105
+ # pattern into a Regexp object that can be used for matching operations
106
+ # throughout the application. The pattern matching behavior is influenced
107
+ # by the case sensitivity configuration inherited from the parent class.
108
+ #
109
+ # @example
110
+ # regexp_pattern = RegexpPattern.new(pattern: 'foo', icase: true)
111
+ # regexp_pattern.match('FOO') # => matches because case insensitive
73
112
  class RegexpPattern < Pattern
74
113
  # Initializes a regular expression pattern matcher with the specified
75
114
  # options.
@@ -2,6 +2,12 @@ require 'unix_socks'
2
2
  require 'term/ansicolor'
3
3
 
4
4
  module Utils
5
+ # A process job representation for execution within the probe server system.
6
+ #
7
+ # This class encapsulates the information and behavior associated with a
8
+ # single executable task that can be enqueued and processed by a ProbeServer.
9
+ # It holds command arguments, manages execution status, and provides
10
+ # mechanisms for serialization and display of job information.
5
11
  class ProcessJob
6
12
  include Term::ANSIColor
7
13
 
@@ -125,7 +131,19 @@ module Utils
125
131
  end
126
132
  end
127
133
 
134
+ # A client for interacting with the probe server through Unix domain sockets.
135
+ #
136
+ # This class provides an interface for enqueueing process jobs and managing
137
+ # environment variables on a remote probe server. It uses Unix domain sockets
138
+ # to communicate with the server, enabling distributed task execution and
139
+ # configuration management.
128
140
  class ProbeClient
141
+ # A proxy class for managing environment variables through a probe server communication channel.
142
+ #
143
+ # This class provides a wrapper around the ENV object that allows setting and retrieving
144
+ # environment variables while logging these operations through the probe server.
145
+ # It intercepts assignments and lookups to provide visibility into environment modifications
146
+ # during probe server operations.
129
147
  class EnvProxy
130
148
  # The initialize method sets up a new instance with the provided server
131
149
  # object.
@@ -208,6 +226,13 @@ module Utils
208
226
  end
209
227
  end
210
228
 
229
+ # A probe server for managing and executing process jobs through Unix domain
230
+ # sockets.
231
+ #
232
+ # This class provides a mechanism for enqueueing and running process jobs in
233
+ # a distributed manner, using Unix domain sockets for communication. It
234
+ # maintains a queue of jobs, tracks their execution status, and provides an
235
+ # interactive interface for managing the server.
211
236
  class ProbeServer
212
237
  include Term::ANSIColor
213
238
 
@@ -276,13 +301,13 @@ module Utils
276
301
 
277
302
  annotate :shortcut
278
303
 
304
+ doc 'Display this help.'
305
+ shortcut :h
279
306
  # The help method displays a formatted list of available commands and their
280
307
  # descriptions.
281
308
  #
282
309
  # This method organizes and presents the documented commands along with their
283
310
  # shortcuts and descriptions in a formatted table layout for easy reference.
284
- doc 'Display this help.'
285
- shortcut :h
286
311
  def help
287
312
  docs = doc_annotations.sort_by(&:first)
288
313
  docs_size = docs.map { |a| a.first.size }.max
@@ -295,6 +320,8 @@ module Utils
295
320
  }
296
321
  end
297
322
 
323
+ doc 'Enqueue a new job with the argument array <args>.'
324
+ shortcut :e
298
325
  # The job_enqueue method adds a new process job to the execution queue.
299
326
  #
300
327
  # This method creates a process job instance with the provided arguments
@@ -302,8 +329,6 @@ module Utils
302
329
  # about the enqueued job through output messaging.
303
330
  #
304
331
  # @param args [ Array ] the command arguments to be executed by the process job
305
- doc 'Enqueue a new job with the argument array <args>.'
306
- shortcut :e
307
332
  def job_enqueue(args)
308
333
  job = ProcessJob.new(args:, probe_server: self)
309
334
  output_message " → #{job.inspect} enqueued.", type: :info
@@ -311,17 +336,19 @@ module Utils
311
336
  end
312
337
  alias enqueue job_enqueue
313
338
 
339
+ doc 'Quit the server.'
340
+ shortcut :q
314
341
  # The shutdown method terminates the probe server process immediately.
315
342
  #
316
343
  # This method outputs a warning message indicating that the server is being
317
344
  # shut down forcefully and then exits the program with status code 23.
318
- doc 'Quit the server.'
319
- shortcut :q
320
345
  def shutdown
321
346
  output_message "Server was shutdown down manually!", type: :info
322
347
  exit 23
323
348
  end
324
349
 
350
+ doc 'Repeat the job with <job_id> or the last, it will be assigned a new id, though.'
351
+ shortcut :r
325
352
  # The job_repeat method re-executes a previously run job from the history.
326
353
  #
327
354
  # This method takes a job identifier and attempts to find the corresponding
@@ -334,8 +361,6 @@ module Utils
334
361
  #
335
362
  # @return [ TrueClass, FalseClass ] true if the job was found and re-enqueued,
336
363
  # false otherwise
337
- doc 'Repeat the job with <job_id> or the last, it will be assigned a new id, though.'
338
- shortcut :r
339
364
  def job_repeat(job_id = @history.last)
340
365
  ProcessJob === job_id and job_id = job_id.id
341
366
  if old_job = @history.find { |job| job.id == job_id }
@@ -346,17 +371,18 @@ module Utils
346
371
  end
347
372
  end
348
373
 
374
+ doc 'List the history of run jobs.'
375
+ shortcut :l
349
376
  # The history_list method displays the list of previously executed jobs
350
377
  # from the server's history.
351
378
  #
352
379
  # This method outputs all completed jobs that have been processed by the probe server,
353
380
  # showing their identifiers and command arguments for review.
354
- doc 'List the history of run jobs.'
355
- shortcut :l
356
381
  def history_list
357
382
  output_message @history
358
383
  end
359
384
 
385
+ doc 'Clear the history of run jobs.'
360
386
  # The history_clear method clears all entries from the server's execution
361
387
  # history.
362
388
  #
@@ -365,12 +391,18 @@ module Utils
365
391
  # probe server.
366
392
  #
367
393
  # @return [ TrueClass ] always returns true after clearing the history
368
- doc 'Clear the history of run jobs.'
369
394
  def history_clear
370
395
  @history = []
371
396
  true
372
397
  end
373
398
 
399
+ # A wrapper class for environment variable management that logs operations.
400
+ #
401
+ # This class provides a transparent interface for accessing and modifying
402
+ # environment variables while recording these interactions. It delegates all
403
+ # method calls to an underlying object (typically ENV) but intercepts assignments
404
+ # to log the changes, enabling tracking of environment modifications during
405
+ # probe server operations.
374
406
  class LogWrapper < BasicObject
375
407
  # The initialize method sets up a new instance with the provided server
376
408
  # object and object.
@@ -1,4 +1,19 @@
1
1
  module Utils
2
+ # A class that represents an SSH tunnel specification for configuring network
3
+ # connections.
4
+ #
5
+ # This class parses and stores the configuration details for SSH tunnels,
6
+ # including local and remote address/port combinations. It provides methods
7
+ # to validate the specification, convert it to string or array
8
+ # representations, and access individual components of the tunnel
9
+ # configuration.
10
+ #
11
+ # @example
12
+ # spec = Utils::SshTunnelSpecification.new('localhost:8080:remote.host:22')
13
+ # spec.local_addr # => 'localhost'
14
+ # spec.local_port # => 8080
15
+ # spec.remote_addr # => 'remote.host'
16
+ # spec.remote_port # => 22
2
17
  class SshTunnelSpecification
3
18
  # Initializes a new SshTunnelSpecification instance by parsing the provided
4
19
  # specification string.
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.73.1'
3
+ VERSION = '0.75.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -1,5 +1,23 @@
1
1
  module Utils
2
+ # Extension module for adding source location functionality to objects.
3
+ #
4
+ # This module provides enhanced source location capabilities by extending
5
+ # objects with methods that can determine file paths and line numbers
6
+ # associated with method definitions, class references, or file-based
7
+ # locations. It supports parsing of various input formats including file:line
8
+ # syntax, class.method patterns, and provides convenient accessors for
9
+ # filename, line number, and range information through the source_location
10
+ # method.
2
11
  module Xt
12
+ # Extension module for adding source location functionality to objects.
13
+ #
14
+ # This module provides enhanced source location capabilities by extending
15
+ # objects with methods that can determine file paths and line numbers
16
+ # associated with method definitions, class references, or file-based
17
+ # locations. It supports parsing of various input formats including
18
+ # file:line syntax, class.method patterns, and provides convenient
19
+ # accessors for filename, line number, and range information through the
20
+ # source_location method.
3
21
  module SourceLocationExtension
4
22
  # Regular expression to match Ruby class method signatures
5
23
  # Matches patterns like "ClassName#method" or "ClassName.method"
data/lib/utils.rb CHANGED
@@ -1,5 +1,11 @@
1
1
  require 'tins/xt'
2
2
 
3
+ # The main Utils module serves as the primary namespace for the developer
4
+ # productivity command-line utilities gem.
5
+
6
+ # This module provides the core functionality and organization for the Utils
7
+ # library, which delivers a curated collection of command-line tools designed
8
+ # to streamline software development workflows and automate repetitive tasks.
3
9
  module Utils
4
10
  require 'utils/version'
5
11
  require 'utils/md5'
data/utils.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.73.1 ruby lib
2
+ # stub: utils 0.75.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "utils".freeze
6
- s.version = "0.73.1".freeze
6
+ s.version = "0.75.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -11,9 +11,9 @@ Gem::Specification.new do |s|
11
11
  s.date = "1980-01-02"
12
12
  s.description = "This ruby gem provides some useful command line utilities".freeze
13
13
  s.email = "flori@ping.de".freeze
14
- s.executables = ["ascii7".freeze, "blameline".freeze, "changes".freeze, "classify".freeze, "code_comment".freeze, "commit_message".freeze, "create_cstags".freeze, "create_tags".freeze, "discover".freeze, "edit".freeze, "edit_wait".freeze, "enum".freeze, "git-empty".freeze, "git-versions".freeze, "json_check".freeze, "long_lines".freeze, "myex".freeze, "on_change".freeze, "path".freeze, "print_method".freeze, "probe".freeze, "rainbow".freeze, "rd2md".freeze, "search".freeze, "sedit".freeze, "serve".freeze, "ssh-tunnel".freeze, "strip_spaces".freeze, "sync_dir".freeze, "untest".freeze, "utils-utilsrc".freeze, "vcf2alias".freeze, "yaml_check".freeze]
14
+ s.executables = ["ascii7".freeze, "blameline".freeze, "changes".freeze, "classify".freeze, "code_comment".freeze, "code_indexer".freeze, "commit_message".freeze, "discover".freeze, "edit".freeze, "edit_wait".freeze, "enum".freeze, "git-empty".freeze, "git-versions".freeze, "json_check".freeze, "long_lines".freeze, "myex".freeze, "on_change".freeze, "path".freeze, "print_method".freeze, "probe".freeze, "rainbow".freeze, "rd2md".freeze, "search".freeze, "sedit".freeze, "serve".freeze, "ssh-tunnel".freeze, "strip_spaces".freeze, "sync_dir".freeze, "untest".freeze, "utils-utilsrc".freeze, "vcf2alias".freeze, "yaml_check".freeze]
15
15
  s.extra_rdoc_files = ["README.md".freeze, "lib/utils.rb".freeze, "lib/utils/config_dir.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze]
16
- s.files = [".github/dependabot.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, ".utilsrc".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/changes".freeze, "bin/classify".freeze, "bin/code_comment".freeze, "bin/commit_message".freeze, "bin/create_cstags".freeze, "bin/create_tags".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/git-empty".freeze, "bin/git-versions".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/myex".freeze, "bin/on_change".freeze, "bin/path".freeze, "bin/print_method".freeze, "bin/probe".freeze, "bin/rainbow".freeze, "bin/rd2md".freeze, "bin/search".freeze, "bin/sedit".freeze, "bin/serve".freeze, "bin/ssh-tunnel".freeze, "bin/strip_spaces".freeze, "bin/sync_dir".freeze, "bin/untest".freeze, "bin/utils-utilsrc".freeze, "bin/vcf2alias".freeze, "bin/yaml_check".freeze, "lib/utils.rb".freeze, "lib/utils/config_dir.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze, "tests/test_helper.rb".freeze, "tests/utils_test.rb".freeze, "utils.gemspec".freeze]
16
+ s.files = [".github/dependabot.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, ".utilsrc".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/changes".freeze, "bin/classify".freeze, "bin/code_comment".freeze, "bin/code_indexer".freeze, "bin/commit_message".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/git-empty".freeze, "bin/git-versions".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/myex".freeze, "bin/on_change".freeze, "bin/path".freeze, "bin/print_method".freeze, "bin/probe".freeze, "bin/rainbow".freeze, "bin/rd2md".freeze, "bin/search".freeze, "bin/sedit".freeze, "bin/serve".freeze, "bin/ssh-tunnel".freeze, "bin/strip_spaces".freeze, "bin/sync_dir".freeze, "bin/untest".freeze, "bin/utils-utilsrc".freeze, "bin/vcf2alias".freeze, "bin/yaml_check".freeze, "lib/utils.rb".freeze, "lib/utils/config_dir.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze, "tests/test_helper.rb".freeze, "tests/utils_test.rb".freeze, "utils.gemspec".freeze]
17
17
  s.homepage = "http://github.com/flori/utils".freeze
18
18
  s.licenses = ["GPL-2.0".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "Utils - Some useful command line utilities".freeze, "--main".freeze, "README.md".freeze]
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.specification_version = 4
25
25
 
26
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.0".freeze])
26
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.2".freeze])
27
27
  s.add_development_dependency(%q<test-unit>.freeze, [">= 0".freeze])
28
28
  s.add_runtime_dependency(%q<unix_socks>.freeze, [">= 0".freeze])
29
29
  s.add_runtime_dependency(%q<webrick>.freeze, [">= 0".freeze])
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  s.add_runtime_dependency(%q<ollama-ruby>.freeze, ["~> 1.6".freeze])
38
38
  s.add_runtime_dependency(%q<kramdown-ansi>.freeze, ["~> 0.1".freeze])
39
39
  s.add_runtime_dependency(%q<figlet>.freeze, ["~> 1.0".freeze])
40
+ s.add_runtime_dependency(%q<starscope>.freeze, [">= 0".freeze])
40
41
  s.add_runtime_dependency(%q<context_spook>.freeze, ["~> 0.2".freeze])
41
42
  s.add_runtime_dependency(%q<simplecov>.freeze, [">= 0".freeze])
42
43
  s.add_runtime_dependency(%q<debug>.freeze, [">= 0".freeze])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.73.1
4
+ version: 0.75.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '2.0'
18
+ version: '2.2'
19
19
  type: :development
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '2.0'
25
+ version: '2.2'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: test-unit
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -205,6 +205,20 @@ dependencies:
205
205
  - - "~>"
206
206
  - !ruby/object:Gem::Version
207
207
  version: '1.0'
208
+ - !ruby/object:Gem::Dependency
209
+ name: starscope
210
+ requirement: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ type: :runtime
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
208
222
  - !ruby/object:Gem::Dependency
209
223
  name: context_spook
210
224
  requirement: !ruby/object:Gem::Requirement
@@ -255,9 +269,8 @@ executables:
255
269
  - changes
256
270
  - classify
257
271
  - code_comment
272
+ - code_indexer
258
273
  - commit_message
259
- - create_cstags
260
- - create_tags
261
274
  - discover
262
275
  - edit
263
276
  - edit_wait
@@ -314,9 +327,8 @@ files:
314
327
  - bin/changes
315
328
  - bin/classify
316
329
  - bin/code_comment
330
+ - bin/code_indexer
317
331
  - bin/commit_message
318
- - bin/create_cstags
319
- - bin/create_tags
320
332
  - bin/discover
321
333
  - bin/edit
322
334
  - bin/edit_wait
data/bin/create_cstags DELETED
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Create cscope database for project files
4
- #
5
- # Usage:
6
- # create_cstags # Generate cscope.out database in current directory
7
- #
8
- # This script generates a cscope database (cscope.out) by collecting all
9
- # project files and building an index for efficient cross-reference searching.
10
- # It uses bundle paths and project roots to determine which files to include.
11
- #
12
- # Requires:
13
- # - cscope command-line tool
14
- #
15
- # The script will:
16
- # 1. Collect all files from project roots (including bundle paths)
17
- # 2. Generate cscope.out database with cross-references
18
- # 3. Show progress using infobar visualization
19
- # 4. Report the size of the created database
20
-
21
- require 'utils'
22
- require 'infobar'
23
-
24
- config = Utils::ConfigFile.new
25
- config.configure_from_paths
26
-
27
- roots = %w[ . ] + `bundle list --paths`.lines.map(&:chomp)
28
-
29
- IO.popen('cscope 2>/dev/null -R -b -i - -f cscope.out', 'w') do |scope|
30
- finder = Utils::Finder.new(
31
- pattern: '',
32
- roots: roots,
33
- config: config,
34
- )
35
- finder.search.paths.with_infobar(label: 'Collecting files') do |path|
36
- scope.puts path
37
- +infobar
38
- end
39
-
40
- infobar.newline
41
- Infobar.busy(label: 'Creating cstags', frames: :braille7) do
42
- scope.close
43
- end
44
- end
45
-
46
- if megabytes = File.size('cscope.out').to_f / 1024 ** 2 rescue nil
47
- infobar.puts 'Created %.3fM of cstags.' % megabytes
48
- end
data/bin/create_tags DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Creates ctags index for Ruby project including bundled gems
4
- #
5
- # This script generates a tags file that enables code navigation in editors
6
- # like Vim. It automatically includes:
7
- # - Current directory (.)
8
- # - All gem paths from bundle list
9
- # - Excludes pkg directory to avoid vendor code
10
- #
11
- # Usage: Run directly from project root
12
-
13
- require 'infobar'
14
-
15
- paths = %w[ . ] + `bundle list --paths`.lines.map(&:chomp)
16
- cmd = %w[ ctags --recurse=yes --exclude=pkg --languages=Ruby,C ] + paths
17
- Infobar.busy(label: 'Creating tags', frames: :braille7) { system(*cmd) }
18
- if megabytes = File.size('tags').to_f / 1024 ** 2 rescue nil
19
- infobar.puts 'Created %.3fM of tags.' % megabytes
20
- end