utils 0.83.1 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +2 -1
- data/bin/probe +15 -9
- data/lib/utils/config_file.rb +8 -14
- data/lib/utils/irb.rb +57 -31
- data/lib/utils/probe/probe_client.rb +11 -8
- data/lib/utils/probe/probe_server.rb +2 -2
- data/lib/utils/probe/server_handling.rb +10 -15
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +4 -3
- metadata +18 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fd913953f77f177caac61d9a98e615eaba79f5aad327b892a8728d510443b3f
|
|
4
|
+
data.tar.gz: d8f2937862ac26cffa7a4d3244155354b33e587d0fc6cecacedbf6539845bbf4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc3e00dd0c01f36a2835f74c490f2b35cb8d64b7d4197d49d7c3ae09e247ea3d6067483d34facbdc40c19018516e7a368ddfeb4a38e26efc6d8cf460a8785e4a
|
|
7
|
+
data.tar.gz: 566f70210d3ff85d8798cc2876371e49c86d2ec959fa11f76a6ecc6e546819953878fcabc53e210de8c1b024dab9d61863f86f5c415fcb02551fe0f79420b8de
|
data/Rakefile
CHANGED
|
@@ -26,7 +26,8 @@ GemHadar do
|
|
|
26
26
|
dependency 'pstree', '~> 0.3'
|
|
27
27
|
dependency 'infobar', '~> 0.8'
|
|
28
28
|
dependency 'mize', '~> 0.6'
|
|
29
|
-
dependency '
|
|
29
|
+
dependency 'amatch', '~> 0.6'
|
|
30
|
+
dependency 'search_ui', '>= 0.0.9'
|
|
30
31
|
dependency 'all_images', '~> 0.5.0'
|
|
31
32
|
dependency 'ollama-ruby', '~> 1.6'
|
|
32
33
|
dependency 'kramdown-ansi', '~> 0.1'
|
data/bin/probe
CHANGED
|
@@ -33,6 +33,7 @@ def usage
|
|
|
33
33
|
|
|
34
34
|
-n TESTNAME run the test TESTNAME in file FILENAME
|
|
35
35
|
-t FRAMEWORK use test framework FRAMEWORK (rspec, test-unit or cucumber)
|
|
36
|
+
-s SERVER_URL tcp/unix URL to connect to
|
|
36
37
|
-c start probe as a client
|
|
37
38
|
-C FOO[=BAR] set/get env variable on probe server
|
|
38
39
|
-l start probe as a server
|
|
@@ -72,6 +73,17 @@ def find_cmd(*cmds, on_fail: -> *cmds { fail "no #{cmds * '|'} command found" })
|
|
|
72
73
|
cmds.map { |c| `which #{c}`.full?(:chomp) }.compact.first or on_fail.(*cmds)
|
|
73
74
|
end
|
|
74
75
|
|
|
76
|
+
# The server_url method retrieves the configured server URL for probe operations.
|
|
77
|
+
#
|
|
78
|
+
# This method checks if a server URL has been specified via command-line
|
|
79
|
+
# options and returns it if available. Otherwise, it falls back to the server
|
|
80
|
+
# URL configured in the probe settings.
|
|
81
|
+
#
|
|
82
|
+
# @return [ String ] the server URL for probe operations
|
|
83
|
+
def server_url
|
|
84
|
+
$opts[?s] || $config.probe.server_url
|
|
85
|
+
end
|
|
86
|
+
|
|
75
87
|
# The start_server method initializes and begins operation of a probe server.
|
|
76
88
|
#
|
|
77
89
|
# This method configures the environment for server operation by setting the
|
|
@@ -79,10 +91,7 @@ end
|
|
|
79
91
|
# probe server instance to handle incoming requests and process jobs.
|
|
80
92
|
def start_server
|
|
81
93
|
Thread.abort_on_exception = $DEBUG
|
|
82
|
-
ProbeServer.new(
|
|
83
|
-
server_type: $config.probe.server_type,
|
|
84
|
-
port: $config.probe.tcp_server_port
|
|
85
|
-
).start
|
|
94
|
+
ProbeServer.new(server_url:).start
|
|
86
95
|
end
|
|
87
96
|
|
|
88
97
|
# The connect_server method establishes a connection to a probe server and
|
|
@@ -93,10 +102,7 @@ end
|
|
|
93
102
|
# It also enqueues jobs for execution on the probe server when specified.
|
|
94
103
|
#
|
|
95
104
|
def connect_server
|
|
96
|
-
probe_client = ProbeClient.new(
|
|
97
|
-
server_type: $config.probe.server_type,
|
|
98
|
-
port: $config.probe.tcp_server_port
|
|
99
|
-
)
|
|
105
|
+
probe_client = ProbeClient.new(server_url:)
|
|
100
106
|
if setting = $opts[?C]
|
|
101
107
|
case setting
|
|
102
108
|
when /\A([^=]+)=([^=]+)\z/
|
|
@@ -125,7 +131,7 @@ if i = ARGV.index('--')
|
|
|
125
131
|
else
|
|
126
132
|
$args = ARGV.dup
|
|
127
133
|
end
|
|
128
|
-
$opts = go 'lct:n:C:h', $args
|
|
134
|
+
$opts = go 'lct:n:C:s:h', $args
|
|
129
135
|
$opts[?h] and usage
|
|
130
136
|
|
|
131
137
|
case
|
data/lib/utils/config_file.rb
CHANGED
|
@@ -224,22 +224,16 @@ class Utils::ConfigFile
|
|
|
224
224
|
# @param dirs [ Array<String> ] the array of directory names to include
|
|
225
225
|
config :include_dirs, %w[lib test tests ext spec]
|
|
226
226
|
|
|
227
|
-
# The
|
|
227
|
+
# The server_url method configures the URL for the probe server
|
|
228
|
+
# communication.
|
|
228
229
|
#
|
|
229
|
-
# This method sets up the server
|
|
230
|
-
#
|
|
231
|
-
#
|
|
230
|
+
# This method sets up a DSL accessor for the probe server URL, providing a
|
|
231
|
+
# default value that uses a Unix domain socket located in the current
|
|
232
|
+
# working directory.
|
|
232
233
|
#
|
|
233
|
-
# @return [
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
# The tcp_server_port method configures the TCP server port setting.
|
|
237
|
-
#
|
|
238
|
-
# This method sets up a configuration option that specifies the port number
|
|
239
|
-
# to be used for TCP server operations.
|
|
240
|
-
#
|
|
241
|
-
# @param value [ Integer ] the TCP server port number to use
|
|
242
|
-
config :tcp_server_port, 59999
|
|
234
|
+
# @return [ String ] the configured probe server URL including the default
|
|
235
|
+
# socket path
|
|
236
|
+
dsl_accessor :server_url, "unix://#{Pathname.pwd + 'probe.socket'}"
|
|
243
237
|
|
|
244
238
|
# The include_dirs_argument method constructs a colon-separated string from
|
|
245
239
|
# include directories.
|
data/lib/utils/irb.rb
CHANGED
|
@@ -4,6 +4,9 @@ require 'tempfile'
|
|
|
4
4
|
require 'pp'
|
|
5
5
|
require 'shellwords'
|
|
6
6
|
require 'utils'
|
|
7
|
+
require 'fileutils'
|
|
8
|
+
require 'amatch'
|
|
9
|
+
require 'search_ui'
|
|
7
10
|
require_maybe 'ap'
|
|
8
11
|
|
|
9
12
|
$editor = Utils::Editor.new
|
|
@@ -24,7 +27,7 @@ module Utils
|
|
|
24
27
|
# Provides enhanced regexp operations including match highlighting and
|
|
25
28
|
# shell command integration.
|
|
26
29
|
module Shell
|
|
27
|
-
|
|
30
|
+
include SearchUI
|
|
28
31
|
include FileUtils
|
|
29
32
|
include Tins::Find
|
|
30
33
|
|
|
@@ -672,36 +675,59 @@ module Utils
|
|
|
672
675
|
end
|
|
673
676
|
end
|
|
674
677
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
678
|
+
# The irb_load! method loads Ruby files by their names into the current
|
|
679
|
+
# environment through an interactive selection interface.
|
|
680
|
+
#
|
|
681
|
+
# This method takes a glob pattern and finds matching Ruby files, then
|
|
682
|
+
# presents an interactive search interface for selecting which file to load.
|
|
683
|
+
# It ensures that each file is loaded only once by tracking loaded files
|
|
684
|
+
# using their paths. The method outputs messages to standard error
|
|
685
|
+
# indicating which file has been successfully loaded.
|
|
686
|
+
#
|
|
687
|
+
# @param glob [String] the glob pattern to search for Ruby files (defaults to
|
|
688
|
+
# ENV['UTILS_IRB_LOAD_GLOB'] or 'lib/**/*.rb')
|
|
689
|
+
#
|
|
690
|
+
# @return [Boolean] true if a file was successfully loaded, false if no file
|
|
691
|
+
# was selected or loaded
|
|
692
|
+
#
|
|
693
|
+
# @example
|
|
694
|
+
# # Load a file interactively with default glob pattern
|
|
695
|
+
# irb_load!
|
|
696
|
+
#
|
|
697
|
+
# # Load files matching a custom pattern
|
|
698
|
+
# irb_load!('app/models/**/*.rb')
|
|
699
|
+
#
|
|
700
|
+
# # Set environment variable for default pattern
|
|
701
|
+
# ENV['UTILS_IRB_LOAD_GLOB'] = 'lib/**/*.rb'
|
|
702
|
+
# irb_load!
|
|
703
|
+
#
|
|
704
|
+
# @note This method uses fuzzy matching to help find files when typing
|
|
705
|
+
# partial names. It respects the terminal height to limit the number of
|
|
706
|
+
# displayed results.
|
|
707
|
+
#
|
|
708
|
+
# @see SearchUI for the interactive search interface implementation
|
|
709
|
+
# @see Amatch::PairDistance for the fuzzy matching algorithm
|
|
710
|
+
def irb_load!(glob = ENV.fetch('UTILS_IRB_LOAD_GLOB', 'lib/**/*.rb'))
|
|
711
|
+
files = Dir.glob(glob)
|
|
712
|
+
found = Search.new(
|
|
713
|
+
match: -> answer {
|
|
714
|
+
matcher = Amatch::PairDistance.new(answer.downcase)
|
|
715
|
+
matches = files.map { |n| [ n, -matcher.similar(n.downcase) ] }.
|
|
716
|
+
sort.select { _2 < 0 }.sort_by(&:last).map(&:first)
|
|
717
|
+
matches.empty? and matches = files
|
|
718
|
+
matches.first(Tins::Terminal.lines - 1)
|
|
719
|
+
},
|
|
720
|
+
query: -> _answer, matches, selector {
|
|
721
|
+
matches.each_with_index.
|
|
722
|
+
map { |m, i| i == selector ? "→ " + Search.on_blue(m) : " " + m } * ?\n
|
|
723
|
+
},
|
|
724
|
+
found: -> _answer, matches, selector {
|
|
725
|
+
matches[selector]
|
|
726
|
+
},
|
|
727
|
+
output: STDOUT
|
|
728
|
+
).start
|
|
729
|
+
found or return false
|
|
730
|
+
load found
|
|
705
731
|
end
|
|
706
732
|
|
|
707
733
|
# The irb_server method provides access to an IRB server instance for
|
|
@@ -57,15 +57,18 @@ module Utils::Probe
|
|
|
57
57
|
|
|
58
58
|
# The initialize method sets up a new probe server instance.
|
|
59
59
|
#
|
|
60
|
-
# This method creates and configures
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
60
|
+
# This method creates and configures the core components of the probe
|
|
61
|
+
# server, including initializing the Unix domain socket server for
|
|
62
|
+
# communication, setting up the job queue for processing tasks, and
|
|
63
|
+
# preparing the history tracking for completed jobs.
|
|
64
64
|
#
|
|
65
|
-
# @
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
# @param server_url [ String ] the URL to be used for the probe server
|
|
66
|
+
# communication
|
|
67
|
+
#
|
|
68
|
+
# @return [ Utils::ProbeServer ] a new probe server instance configured
|
|
69
|
+
# with the specified socket name and runtime directory
|
|
70
|
+
def initialize(server_url:)
|
|
71
|
+
@server = create_server(server_url)
|
|
69
72
|
end
|
|
70
73
|
|
|
71
74
|
# The env method provides access to environment variable management through
|
|
@@ -19,8 +19,8 @@ module Utils::Probe
|
|
|
19
19
|
#
|
|
20
20
|
# @return [ Utils::ProbeServer ] a new probe server instance configured
|
|
21
21
|
# with the specified socket name and runtime directory
|
|
22
|
-
def initialize(
|
|
23
|
-
@server = create_server(
|
|
22
|
+
def initialize(server_url:)
|
|
23
|
+
@server = create_server(server_url)
|
|
24
24
|
@history = [].freeze
|
|
25
25
|
@jobs_queue = Queue.new
|
|
26
26
|
@current_job_id = 0
|
|
@@ -8,25 +8,20 @@ module Utils::Probe
|
|
|
8
8
|
# creation and management within the Utils library.
|
|
9
9
|
module ServerHandling
|
|
10
10
|
# The create_server method initializes and returns a socket server instance
|
|
11
|
-
# based on the specified server
|
|
11
|
+
# based on the specified server URL configuration
|
|
12
12
|
#
|
|
13
|
-
# This method
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
13
|
+
# This method acts as a factory for creating socket server objects,
|
|
14
|
+
# delegating to the UnixSocks.from_url method to construct either a TCP
|
|
15
|
+
# socket server or a domain socket server depending on the URL scheme
|
|
16
|
+
# provided
|
|
17
17
|
#
|
|
18
|
-
# @param
|
|
19
|
-
#
|
|
18
|
+
# @param server_url [ String ] the URL specifying the socket server
|
|
19
|
+
# configuration
|
|
20
20
|
#
|
|
21
21
|
# @return [ UnixSocks::TCPSocketServer, UnixSocks::DomainSocketServer ] a
|
|
22
|
-
# new socket server instance
|
|
23
|
-
def create_server(
|
|
24
|
-
|
|
25
|
-
when :tcp
|
|
26
|
-
UnixSocks::TCPSocketServer.new(port:)
|
|
27
|
-
else
|
|
28
|
-
UnixSocks::DomainSocketServer.new(socket_name: 'probe.sock', runtime_dir: Dir.pwd)
|
|
29
|
-
end
|
|
22
|
+
# new socket server instance configured according to the URL specification
|
|
23
|
+
def create_server(server_url)
|
|
24
|
+
UnixSocks.from_url(server_url)
|
|
30
25
|
end
|
|
31
26
|
end
|
|
32
27
|
end
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: utils 0.
|
|
2
|
+
# stub: utils 0.85.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "utils".freeze
|
|
6
|
-
s.version = "0.
|
|
6
|
+
s.version = "0.85.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]
|
|
@@ -31,7 +31,8 @@ Gem::Specification.new do |s|
|
|
|
31
31
|
s.add_runtime_dependency(%q<pstree>.freeze, ["~> 0.3".freeze])
|
|
32
32
|
s.add_runtime_dependency(%q<infobar>.freeze, ["~> 0.8".freeze])
|
|
33
33
|
s.add_runtime_dependency(%q<mize>.freeze, ["~> 0.6".freeze])
|
|
34
|
-
s.add_runtime_dependency(%q<
|
|
34
|
+
s.add_runtime_dependency(%q<amatch>.freeze, ["~> 0.6".freeze])
|
|
35
|
+
s.add_runtime_dependency(%q<search_ui>.freeze, [">= 0.0.9".freeze])
|
|
35
36
|
s.add_runtime_dependency(%q<all_images>.freeze, ["~> 0.5.0".freeze])
|
|
36
37
|
s.add_runtime_dependency(%q<ollama-ruby>.freeze, ["~> 1.6".freeze])
|
|
37
38
|
s.add_runtime_dependency(%q<kramdown-ansi>.freeze, ["~> 0.1".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.
|
|
4
|
+
version: 0.85.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -122,19 +122,33 @@ dependencies:
|
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
123
|
version: '0.6'
|
|
124
124
|
- !ruby/object:Gem::Dependency
|
|
125
|
-
name:
|
|
125
|
+
name: amatch
|
|
126
126
|
requirement: !ruby/object:Gem::Requirement
|
|
127
127
|
requirements:
|
|
128
128
|
- - "~>"
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: '0.
|
|
130
|
+
version: '0.6'
|
|
131
131
|
type: :runtime
|
|
132
132
|
prerelease: false
|
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
134
134
|
requirements:
|
|
135
135
|
- - "~>"
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '0.
|
|
137
|
+
version: '0.6'
|
|
138
|
+
- !ruby/object:Gem::Dependency
|
|
139
|
+
name: search_ui
|
|
140
|
+
requirement: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: 0.0.9
|
|
145
|
+
type: :runtime
|
|
146
|
+
prerelease: false
|
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
148
|
+
requirements:
|
|
149
|
+
- - ">="
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: 0.0.9
|
|
138
152
|
- !ruby/object:Gem::Dependency
|
|
139
153
|
name: all_images
|
|
140
154
|
requirement: !ruby/object:Gem::Requirement
|