utils 0.81.0 → 0.82.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: 6f4a74cb28195b08e8c1105b16b40a4d79189c4e8a5396a1f2df3deba71ed9d4
4
- data.tar.gz: 4d01dc2e96f809e5ed338f875f87e90468721b190bb79856aa854830a4b413bf
3
+ metadata.gz: 3e7a6c6bc8c38c84587412e072fa0ddee7e9e854a61eb50b4caded051d1388b7
4
+ data.tar.gz: b6e695b2b379c591a0a402cf638e062d8ae84f516684bb72e8a7a6e4e71e3c66
5
5
  SHA512:
6
- metadata.gz: 12e0c3edbef1d6ce684ea79bb80ac0379f5962626d07cc574906df58bd2158225c4732982850c6adefd0dbb4cd7347eff58f7f3422537bb96da57ac5f62ec5bd
7
- data.tar.gz: cd3eddebabc474a530dfca7427bda4dffbbf377a09bf8b891d6c8ef51c2fc2aa033c625254ea88854d0b3b8e83207e59097276ccf06840c461c23fd872929995
6
+ metadata.gz: e3ac01c79b99a587b32f633dc5ec7d7df26688bdbf5ce24886a8c62f2dd8d13b2db518eeaed4912340b432fcbeee02ffac547ade62d3b7e44e846d3e3c79e089
7
+ data.tar.gz: 8e39fda010cb4a33cfbc00e390ddf750ffa57d4e39396eed007b489b04a67c1d8be8d3f0ef73930e9f9e9ba4bf714ed27fcea1c9cf3caecb6cc749afb856352c
data/bin/code_comment CHANGED
@@ -184,7 +184,7 @@ end
184
184
  filename_linenumber = ARGV.shift or fail "require file_name as second argument"
185
185
  $config = Utils::ConfigFile.new
186
186
  $config.configure_from_paths
187
- $config_dir = Utils::ConfigDir.new('code_comment', env_var: 'XDG_CONFIG_HOME')
187
+ $config_dir = Utils::ConfigDir.new('code_comment', env_var: 'XDG_CONFIG_HOME')
188
188
  base_url = ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST')
189
189
  model = ENV.fetch('OLLAMA_MODEL', 'llama3.1')
190
190
  construct, construct_type = fetch_construct(filename_linenumber)
data/bin/probe CHANGED
@@ -14,6 +14,7 @@
14
14
 
15
15
  require 'utils'
16
16
  include Utils
17
+ include Utils::Probe
17
18
  include Tins::GO
18
19
  require 'shellwords'
19
20
 
@@ -78,7 +79,7 @@ end
78
79
  # probe server instance to handle incoming requests and process jobs.
79
80
  def start_server
80
81
  Thread.abort_on_exception = $DEBUG
81
- Utils::ProbeServer.new(
82
+ ProbeServer.new(
82
83
  server_type: $config.probe.server_type,
83
84
  port: $config.probe.tcp_server_port
84
85
  ).start
@@ -92,7 +93,7 @@ end
92
93
  # It also enqueues jobs for execution on the probe server when specified.
93
94
  #
94
95
  def connect_server
95
- probe_client = Utils::ProbeClient.new(
96
+ probe_client = ProbeClient.new(
96
97
  server_type: $config.probe.server_type,
97
98
  port: $config.probe.tcp_server_port
98
99
  )
data/lib/utils/irb.rb CHANGED
@@ -2,6 +2,7 @@ require 'irb/completion'
2
2
  require 'enumerator'
3
3
  require 'tempfile'
4
4
  require 'pp'
5
+ require 'shellwords'
5
6
  require 'utils'
6
7
  require_maybe 'ap'
7
8
 
@@ -83,6 +84,48 @@ module Utils
83
84
  ri(*patterns, doc: 'yri')
84
85
  end
85
86
 
87
+ # The ai method interacts with an Ollama chat service to process queries
88
+ # and optionally return responses.
89
+ #
90
+ # This method constructs command-line arguments for the ollama_chat_send
91
+ # utility based on the provided options, executes the command with the
92
+ # query as input, and returns the response if requested.
93
+ #
94
+ # @param query [ String ] the input query to send to the Ollama chat
95
+ # service
96
+ # @param command [ TrueClass, FalseClass ] whether to treat the query as
97
+ # a command
98
+ # @param respond [ TrueClass, FalseClass ] whether to capture and return
99
+ # the response from the service
100
+ # @param parse [ TrueClass, FalseClass ] whether to parse the response
101
+ # @param dir [ String ] the directory to use for the operation
102
+ #
103
+ # @return [ String, nil ] the response from the Ollama chat service if
104
+ # respond is true, otherwise nil
105
+ def ai(query, command: false, respond: false, parse: false, dir: ?.)
106
+ dir = File.expand_path(dir)
107
+ args = {
108
+ ?r => respond,
109
+ ?t => command,
110
+ ?p => parse,
111
+ ?d => dir,
112
+ }
113
+ args = args.map { |k, v|
114
+ v == false and next
115
+ v == true ? "-#{k}" : [ "-#{k}", v.to_s ]
116
+ }.flatten.compact
117
+ args.unshift 'ollama_chat_send'
118
+ response = nil
119
+ IO.popen(Shellwords.join(args), 'r+') do |io|
120
+ io.write query
121
+ io.close_write
122
+ if respond
123
+ response = io.read
124
+ end
125
+ end
126
+ response
127
+ end
128
+
86
129
  # The irb_open method opens a URL or executes a block to capture output
87
130
  # and open it.
88
131
  #
@@ -0,0 +1,98 @@
1
+ module Utils::Probe
2
+ # A client for interacting with the probe server through Unix domain sockets.
3
+ #
4
+ # This class provides an interface for enqueueing process jobs and managing
5
+ # environment variables on a remote probe server. It uses Unix domain sockets
6
+ # to communicate with the server, enabling distributed task execution and
7
+ # configuration management.
8
+ class ProbeClient
9
+ include ServerHandling
10
+
11
+ # A proxy class for managing environment variables through a probe server communication channel.
12
+ #
13
+ # This class provides a wrapper around the ENV object that allows setting and retrieving
14
+ # environment variables while logging these operations through the probe server.
15
+ # It intercepts assignments and lookups to provide visibility into environment modifications
16
+ # during probe server operations.
17
+ class EnvProxy
18
+ # The initialize method sets up a new instance with the provided server
19
+ # object.
20
+ #
21
+ # @param server [ UnixSocks::Server ] the server object to be assigned
22
+ # to the instance variable
23
+ def initialize(server)
24
+ @server = server
25
+ end
26
+
27
+ # The []= method sets an environment variable value through the probe server.
28
+ #
29
+ # This method transmits a request to the probe server to set the specified
30
+ # environment variable key to the given value, then returns the updated
31
+ # environment value from the server's response.
32
+ #
33
+ # @param key [ String ] the environment variable key to set
34
+ # @param value [ String ] the value to assign to the environment variable
35
+ #
36
+ # @return [ String ] the updated environment variable value returned by the server
37
+ def []=(key, value)
38
+ response = @server.transmit_with_response(type: 'set_env', key:, value:)
39
+ response.env
40
+ end
41
+
42
+ # The [] method retrieves the value of an environment variable from the probe server.
43
+ #
44
+ # This method sends a request to the probe server to fetch the current value of the specified
45
+ # environment variable key and returns the corresponding value.
46
+ #
47
+ # @param key [ String ] the environment variable key to retrieve
48
+ #
49
+ # @return [ String ] the value of the specified environment variable
50
+ def [](key)
51
+ response = @server.transmit_with_response(type: 'get_env', key:)
52
+ response.env
53
+ end
54
+
55
+ attr_reader :env
56
+ end
57
+
58
+ # The initialize method sets up a new probe server instance.
59
+ #
60
+ # This method creates and configures a Unix domain socket server for
61
+ # handling probe jobs and communication. It initializes the server with a
62
+ # specific socket name and runtime directory, preparing it to listen for
63
+ # incoming connections and process jobs.
64
+ #
65
+ # @return [ Utils::ProbeServer ] a new probe server instance configured with
66
+ # the specified socket name and runtime directory
67
+ def initialize(server_type: :unix, port: 6666)
68
+ @server = create_server(server_type, port)
69
+ end
70
+
71
+ # The env method provides access to environment variable management through
72
+ # a proxy object.
73
+ #
74
+ # This method returns an EnvProxy instance that allows for setting and
75
+ # retrieving environment variables via the probe server communication
76
+ # channel.
77
+ #
78
+ # @return [ Utils::ProbeServer::EnvProxy ] a proxy object for environment
79
+ # variable operations
80
+ def env
81
+ EnvProxy.new(@server)
82
+ end
83
+
84
+ # The enqueue method submits a new process job to the probe server for
85
+ # execution.
86
+ #
87
+ # This method transmits a process job request to the underlying Unix domain
88
+ # socket server, which then adds the job to the processing queue. The job
89
+ # includes the specified command arguments that will be executed by the
90
+ # probe server.
91
+ #
92
+ # @param args [ Array ] the command arguments to be executed by the process
93
+ # job
94
+ def enqueue(args)
95
+ @server.transmit({ type: 'process_job', args: })
96
+ end
97
+ end
98
+ end
@@ -1,264 +1,4 @@
1
- require 'unix_socks'
2
- require 'term/ansicolor'
3
-
4
- module Utils
5
- # A module that provides server handling functionality for creating and
6
- # managing socket servers.
7
- #
8
- # This module encapsulates the logic for initializing different types of
9
- # socket servers based on the specified server type, supporting both TCP and
10
- # domain socket configurations. It provides a centralized approach to server
11
- # creation and management within the Utils library.
12
- module ServerHandling
13
- # The create_server method initializes and returns a socket server instance
14
- # based on the specified server type.
15
- #
16
- # This method creates either a TCP socket server or a domain socket server
17
- # depending on the server type parameter. It configures the server with the
18
- # appropriate parameters including port number for TCP servers or socket
19
- # name and runtime directory for domain sockets.
20
- #
21
- # @param server_type [ Symbol ] the type of socket server to create, either :tcp or another value for domain socket
22
- # @param port [ Integer ] the port number to use for TCP socket server creation
23
- #
24
- # @return [ UnixSocks::TCPSocketServer, UnixSocks::DomainSocketServer ] a
25
- # new socket server instance of the specified type
26
- def create_server(server_type, port)
27
- case server_type
28
- when :tcp
29
- UnixSocks::TCPSocketServer.new(port:)
30
- else
31
- UnixSocks::DomainSocketServer.new(socket_name: 'probe.sock', runtime_dir: Dir.pwd)
32
- end
33
- end
34
- end
35
-
36
- # A process job representation for execution within the probe server system.
37
- #
38
- # This class encapsulates the information and behavior associated with a
39
- # single executable task that can be enqueued and processed by a ProbeServer.
40
- # It holds command arguments, manages execution status, and provides
41
- # mechanisms for serialization and display of job information.
42
- class ProcessJob
43
- include Term::ANSIColor
44
-
45
- # Initializes a new ProcessJob instance with the specified arguments and
46
- # optional probe server.
47
- #
48
- # This method creates a process job object that can be enqueued for
49
- # execution by a probe server. It assigns a unique job ID from the probe
50
- # server if provided and stores the command arguments as an array.
51
- #
52
- # @param args [ Array ] the command arguments to be executed by the job
53
- # @param probe_server [ Utils::ProbeServer, nil ] the probe server instance
54
- # to use for generating job IDs
55
- #
56
- # @return [ Utils::ProcessJob ] a new ProcessJob instance configured with
57
- # the provided arguments and server reference
58
- def initialize(args:, probe_server: nil)
59
- @id = probe_server&.next_job_id
60
- @args = Array(args)
61
- end
62
-
63
- # Returns the unique identifier of the process job.
64
- #
65
- # @return [ Integer ] the job ID
66
- attr_reader :id
67
-
68
- # The args reader method provides access to the arguments stored in the
69
- # instance.
70
- #
71
- # @return [ Array ] the array of arguments
72
- attr_reader :args
73
-
74
- # The ok method sets the success status of the process job.
75
- #
76
- # @param value [ TrueClass, FalseClass, nil ] the success status to set
77
- attr_writer :ok
78
-
79
- # Returns the type identifier for the process job.
80
- #
81
- # This method provides a constant string value that identifies the object
82
- # as a process job within the probe server system, facilitating type-based
83
- # dispatch and handling.
84
- #
85
- # @return [ String ] the string 'process_job' indicating the object's type
86
- def type
87
- 'process_job'
88
- end
89
-
90
- # The ok method returns a character representation of the job's success
91
- # status.
92
- #
93
- # This method provides a visual indicator of whether a process job has
94
- # succeeded, failed, or is still in progress. It returns 'y' for successful
95
- # jobs, 'n' for failed jobs, and '…' for jobs that are currently running or
96
- # pending.
97
- #
98
- # @return [ String ] 'y' if the job succeeded, 'n' if it failed, or '…' if
99
- # the status is unknown
100
- def ok
101
- case @ok
102
- when false then 'n'
103
- when true then 'y'
104
- else '…'
105
- end
106
- end
107
-
108
- # The ok_colorize method applies color formatting to a string based on the
109
- # success status.
110
- #
111
- # This method returns the input string wrapped with color codes to indicate
112
- # whether the associated process job succeeded, failed, or is in progress.
113
- # Successful jobs are highlighted in green, failed jobs in red, and pending
114
- # jobs are returned without any color formatting.
115
- #
116
- # @param string [ String ] the string to be colorized
117
- #
118
- # @return [ String ] the colorized string or the original string if status is unknown
119
- def ok_colorize(string)
120
- case @ok
121
- when false then white { on_red { string } }
122
- when true then black { on_green { string } }
123
- else string
124
- end
125
- end
126
-
127
- # The inspect method generates a colorized string representation of the
128
- # process job.
129
- #
130
- # This method creates a formatted string that includes the job's unique
131
- # identifier and its command arguments, with the status indicator
132
- # color-coded based on whether the job succeeded, failed, or is pending.
133
- #
134
- # @return [ String ] a formatted string representation of the process job
135
- # including its ID, arguments, and color-coded status indicator
136
- def inspect
137
- ok_colorize("#{id} #{args.map { |a| a.include?(' ') ? a.inspect : a } * ' '}")
138
- end
139
-
140
- alias to_s inspect
141
-
142
- # The as_json method converts the process job object into a
143
- # JSON-serializable hash.
144
- #
145
- # This method creates and returns a hash representation of the process job,
146
- # containing its type, unique identifier, and command arguments.
147
- #
148
- # @return [ Hash ] a hash containing the type, id, and args of the process job
149
- def as_json(*)
150
- { type:, id:, args:, }
151
- end
152
-
153
- # The to_json method converts the object to a JSON string representation.
154
- #
155
- # This method delegates to the as_json method to generate a hash representation
156
- # of the object, then converts that hash to a JSON string using the
157
- # standard JSON library's to_json method.
158
- #
159
- # @return [ String ] a JSON string representation of the object
160
- def to_json(*)
161
- as_json.to_json(*)
162
- end
163
- end
164
-
165
- # A client for interacting with the probe server through Unix domain sockets.
166
- #
167
- # This class provides an interface for enqueueing process jobs and managing
168
- # environment variables on a remote probe server. It uses Unix domain sockets
169
- # to communicate with the server, enabling distributed task execution and
170
- # configuration management.
171
- class ProbeClient
172
- include ServerHandling
173
-
174
- # A proxy class for managing environment variables through a probe server communication channel.
175
- #
176
- # This class provides a wrapper around the ENV object that allows setting and retrieving
177
- # environment variables while logging these operations through the probe server.
178
- # It intercepts assignments and lookups to provide visibility into environment modifications
179
- # during probe server operations.
180
- class EnvProxy
181
- # The initialize method sets up a new instance with the provided server
182
- # object.
183
- #
184
- # @param server [ UnixSocks::Server ] the server object to be assigned
185
- # to the instance variable
186
- def initialize(server)
187
- @server = server
188
- end
189
-
190
- # The []= method sets an environment variable value through the probe server.
191
- #
192
- # This method transmits a request to the probe server to set the specified
193
- # environment variable key to the given value, then returns the updated
194
- # environment value from the server's response.
195
- #
196
- # @param key [ String ] the environment variable key to set
197
- # @param value [ String ] the value to assign to the environment variable
198
- #
199
- # @return [ String ] the updated environment variable value returned by the server
200
- def []=(key, value)
201
- response = @server.transmit_with_response(type: 'set_env', key:, value:)
202
- response.env
203
- end
204
-
205
- # The [] method retrieves the value of an environment variable from the probe server.
206
- #
207
- # This method sends a request to the probe server to fetch the current value of the specified
208
- # environment variable key and returns the corresponding value.
209
- #
210
- # @param key [ String ] the environment variable key to retrieve
211
- #
212
- # @return [ String ] the value of the specified environment variable
213
- def [](key)
214
- response = @server.transmit_with_response(type: 'get_env', key:)
215
- response.env
216
- end
217
-
218
- attr_reader :env
219
- end
220
-
221
- # The initialize method sets up a new probe server instance.
222
- #
223
- # This method creates and configures a Unix domain socket server for
224
- # handling probe jobs and communication. It initializes the server with a
225
- # specific socket name and runtime directory, preparing it to listen for
226
- # incoming connections and process jobs.
227
- #
228
- # @return [ Utils::ProbeServer ] a new probe server instance configured with
229
- # the specified socket name and runtime directory
230
- def initialize(server_type: :unix, port: 6666)
231
- @server = create_server(server_type, port)
232
- end
233
-
234
- # The env method provides access to environment variable management through
235
- # a proxy object.
236
- #
237
- # This method returns an EnvProxy instance that allows for setting and
238
- # retrieving environment variables via the probe server communication
239
- # channel.
240
- #
241
- # @return [ Utils::ProbeServer::EnvProxy ] a proxy object for environment
242
- # variable operations
243
- def env
244
- EnvProxy.new(@server)
245
- end
246
-
247
- # The enqueue method submits a new process job to the probe server for
248
- # execution.
249
- #
250
- # This method transmits a process job request to the underlying Unix domain
251
- # socket server, which then adds the job to the processing queue. The job
252
- # includes the specified command arguments that will be executed by the
253
- # probe server.
254
- #
255
- # @param args [ Array ] the command arguments to be executed by the process
256
- # job
257
- def enqueue(args)
258
- @server.transmit({ type: 'process_job', args: })
259
- end
260
- end
261
-
1
+ module Utils::Probe
262
2
  # A probe server for managing and executing process jobs through Unix domain
263
3
  # sockets.
264
4
  #
@@ -267,7 +7,7 @@ module Utils
267
7
  # maintains a queue of jobs, tracks their execution status, and provides an
268
8
  # interactive interface for managing the server.
269
9
  class ProbeServer
270
- include ServerHandling
10
+ include Utils::Probe::ServerHandling
271
11
  include Term::ANSIColor
272
12
 
273
13
  # The initialize method sets up a new probe server instance.
@@ -0,0 +1,130 @@
1
+ module Utils::Probe
2
+ # A process job representation for execution within the probe server system.
3
+ #
4
+ # This class encapsulates the information and behavior associated with a
5
+ # single executable task that can be enqueued and processed by a ProbeServer.
6
+ # It holds command arguments, manages execution status, and provides
7
+ # mechanisms for serialization and display of job information.
8
+ class ProcessJob
9
+ include Term::ANSIColor
10
+
11
+ # Initializes a new ProcessJob instance with the specified arguments and
12
+ # optional probe server.
13
+ #
14
+ # This method creates a process job object that can be enqueued for
15
+ # execution by a probe server. It assigns a unique job ID from the probe
16
+ # server if provided and stores the command arguments as an array.
17
+ #
18
+ # @param args [ Array ] the command arguments to be executed by the job
19
+ # @param probe_server [ Utils::ProbeServer, nil ] the probe server instance
20
+ # to use for generating job IDs
21
+ #
22
+ # @return [ Utils::ProcessJob ] a new ProcessJob instance configured with
23
+ # the provided arguments and server reference
24
+ def initialize(args:, probe_server: nil)
25
+ @id = probe_server&.next_job_id
26
+ @args = Array(args)
27
+ end
28
+
29
+ # Returns the unique identifier of the process job.
30
+ #
31
+ # @return [ Integer ] the job ID
32
+ attr_reader :id
33
+
34
+ # The args reader method provides access to the arguments stored in the
35
+ # instance.
36
+ #
37
+ # @return [ Array ] the array of arguments
38
+ attr_reader :args
39
+
40
+ # The ok method sets the success status of the process job.
41
+ #
42
+ # @param value [ TrueClass, FalseClass, nil ] the success status to set
43
+ attr_writer :ok
44
+
45
+ # Returns the type identifier for the process job.
46
+ #
47
+ # This method provides a constant string value that identifies the object
48
+ # as a process job within the probe server system, facilitating type-based
49
+ # dispatch and handling.
50
+ #
51
+ # @return [ String ] the string 'process_job' indicating the object's type
52
+ def type
53
+ 'process_job'
54
+ end
55
+
56
+ # The ok method returns a character representation of the job's success
57
+ # status.
58
+ #
59
+ # This method provides a visual indicator of whether a process job has
60
+ # succeeded, failed, or is still in progress. It returns 'y' for successful
61
+ # jobs, 'n' for failed jobs, and '…' for jobs that are currently running or
62
+ # pending.
63
+ #
64
+ # @return [ String ] 'y' if the job succeeded, 'n' if it failed, or '…' if
65
+ # the status is unknown
66
+ def ok
67
+ case @ok
68
+ when false then 'n'
69
+ when true then 'y'
70
+ else '…'
71
+ end
72
+ end
73
+
74
+ # The ok_colorize method applies color formatting to a string based on the
75
+ # success status.
76
+ #
77
+ # This method returns the input string wrapped with color codes to indicate
78
+ # whether the associated process job succeeded, failed, or is in progress.
79
+ # Successful jobs are highlighted in green, failed jobs in red, and pending
80
+ # jobs are returned without any color formatting.
81
+ #
82
+ # @param string [ String ] the string to be colorized
83
+ #
84
+ # @return [ String ] the colorized string or the original string if status is unknown
85
+ def ok_colorize(string)
86
+ case @ok
87
+ when false then white { on_red { string } }
88
+ when true then black { on_green { string } }
89
+ else string
90
+ end
91
+ end
92
+
93
+ # The inspect method generates a colorized string representation of the
94
+ # process job.
95
+ #
96
+ # This method creates a formatted string that includes the job's unique
97
+ # identifier and its command arguments, with the status indicator
98
+ # color-coded based on whether the job succeeded, failed, or is pending.
99
+ #
100
+ # @return [ String ] a formatted string representation of the process job
101
+ # including its ID, arguments, and color-coded status indicator
102
+ def inspect
103
+ ok_colorize("#{id} #{args.map { |a| a.include?(' ') ? a.inspect : a } * ' '}")
104
+ end
105
+
106
+ alias to_s inspect
107
+
108
+ # The as_json method converts the process job object into a
109
+ # JSON-serializable hash.
110
+ #
111
+ # This method creates and returns a hash representation of the process job,
112
+ # containing its type, unique identifier, and command arguments.
113
+ #
114
+ # @return [ Hash ] a hash containing the type, id, and args of the process job
115
+ def as_json(*)
116
+ { type:, id:, args:, }
117
+ end
118
+
119
+ # The to_json method converts the object to a JSON string representation.
120
+ #
121
+ # This method delegates to the as_json method to generate a hash representation
122
+ # of the object, then converts that hash to a JSON string using the
123
+ # standard JSON library's to_json method.
124
+ #
125
+ # @return [ String ] a JSON string representation of the object
126
+ def to_json(*)
127
+ as_json.to_json(*)
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,32 @@
1
+ module Utils::Probe
2
+ # A module that provides server handling functionality for creating and
3
+ # managing socket servers.
4
+ #
5
+ # This module encapsulates the logic for initializing different types of
6
+ # socket servers based on the specified server type, supporting both TCP and
7
+ # domain socket configurations. It provides a centralized approach to server
8
+ # creation and management within the Utils library.
9
+ module ServerHandling
10
+ # The create_server method initializes and returns a socket server instance
11
+ # based on the specified server type.
12
+ #
13
+ # This method creates either a TCP socket server or a domain socket server
14
+ # depending on the server type parameter. It configures the server with the
15
+ # appropriate parameters including port number for TCP servers or socket
16
+ # name and runtime directory for domain sockets.
17
+ #
18
+ # @param server_type [ Symbol ] the type of socket server to create, either :tcp or another value for domain socket
19
+ # @param port [ Integer ] the port number to use for TCP socket server creation
20
+ #
21
+ # @return [ UnixSocks::TCPSocketServer, UnixSocks::DomainSocketServer ] a
22
+ # new socket server instance of the specified type
23
+ def create_server(server_type, port)
24
+ case server_type
25
+ when :tcp
26
+ UnixSocks::TCPSocketServer.new(port:)
27
+ else
28
+ UnixSocks::DomainSocketServer.new(socket_name: 'probe.sock', runtime_dir: Dir.pwd)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ # A module that provides probe server functionality for managing and executing
2
+ # process jobs through Unix domain sockets.
3
+ #
4
+ # This module encapsulates the core components for creating and interacting
5
+ # with probe servers that can enqueue and run process jobs in a distributed
6
+ # manner.
7
+ #
8
+ # The module includes classes for handling server communication, managing
9
+ # process jobs, and providing client interfaces for interacting with probe
10
+ # servers.
11
+ #
12
+ # It supports both TCP and Unix domain socket configurations for server
13
+ # communication and provides mechanisms for environment variable management and
14
+ # job execution tracking.
15
+ module Utils::Probe
16
+ end
17
+
18
+ require 'unix_socks'
19
+ require 'term/ansicolor'
20
+ require 'utils/probe/server_handling'
21
+ require 'utils/probe/process_job'
22
+ require 'utils/probe/probe_server'
23
+ require 'utils/probe/probe_client'
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.81.0'
3
+ VERSION = '0.82.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:
data/lib/utils.rb CHANGED
@@ -14,7 +14,7 @@ module Utils
14
14
  require 'utils/editor'
15
15
  require 'utils/finder'
16
16
  require 'utils/grepper'
17
- require 'utils/probe_server'
17
+ require 'utils/probe'
18
18
  require 'utils/ssh_tunnel_specification'
19
19
  require 'utils/line_blamer'
20
20
  require 'utils/config_dir'
data/utils.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.81.0 ruby lib
2
+ # stub: utils 0.82.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "utils".freeze
6
- s.version = "0.81.0".freeze
6
+ s.version = "0.82.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]
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.description = "This ruby gem provides some useful command line utilities".freeze
13
13
  s.email = "flori@ping.de".freeze
14
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
- 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 = ["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]
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.rb".freeze, "lib/utils/probe/probe_client.rb".freeze, "lib/utils/probe/probe_server.rb".freeze, "lib/utils/probe/process_job.rb".freeze, "lib/utils/probe/server_handling.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 = ["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.rb".freeze, "lib/utils/probe/probe_client.rb".freeze, "lib/utils/probe/probe_server.rb".freeze, "lib/utils/probe/process_job.rb".freeze, "lib/utils/probe/server_handling.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]
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.81.0
4
+ version: 0.82.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -310,7 +310,11 @@ extra_rdoc_files:
310
310
  - lib/utils/line_formatter.rb
311
311
  - lib/utils/md5.rb
312
312
  - lib/utils/patterns.rb
313
- - lib/utils/probe_server.rb
313
+ - lib/utils/probe.rb
314
+ - lib/utils/probe/probe_client.rb
315
+ - lib/utils/probe/probe_server.rb
316
+ - lib/utils/probe/process_job.rb
317
+ - lib/utils/probe/server_handling.rb
314
318
  - lib/utils/ssh_tunnel_specification.rb
315
319
  - lib/utils/version.rb
316
320
  - lib/utils/xt/source_location_extension.rb
@@ -362,7 +366,11 @@ files:
362
366
  - lib/utils/line_formatter.rb
363
367
  - lib/utils/md5.rb
364
368
  - lib/utils/patterns.rb
365
- - lib/utils/probe_server.rb
369
+ - lib/utils/probe.rb
370
+ - lib/utils/probe/probe_client.rb
371
+ - lib/utils/probe/probe_server.rb
372
+ - lib/utils/probe/process_job.rb
373
+ - lib/utils/probe/server_handling.rb
366
374
  - lib/utils/ssh_tunnel_specification.rb
367
375
  - lib/utils/version.rb
368
376
  - lib/utils/xt/source_location_extension.rb