utils 0.84.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dda5615db1b6e0a3ceb342ec83ca1d2a9db169f45f4c0207daec1ba456e6456
4
- data.tar.gz: 90a9bc8dd0937badb77c947d9e98abae918b6098cee076cff40868021727905d
3
+ metadata.gz: 3fd913953f77f177caac61d9a98e615eaba79f5aad327b892a8728d510443b3f
4
+ data.tar.gz: d8f2937862ac26cffa7a4d3244155354b33e587d0fc6cecacedbf6539845bbf4
5
5
  SHA512:
6
- metadata.gz: '08cb02b22c75148956266066e107e8ea2e1b90162479df973ba010b7c2edf6d339240e8cbc7f5c4957eb249b56cde34f17216aa24b70bcc162fd8c05775d8c52'
7
- data.tar.gz: fe9c4966eb16d5ee1344626789232c939653841af8f7ecd132d5b1cf0ab96f953e2019e3d0e9238dc93442d1ec90b9dc9f87a2d8886d51b803a2bd2cce70e29c
6
+ metadata.gz: cc3e00dd0c01f36a2835f74c490f2b35cb8d64b7d4197d49d7c3ae09e247ea3d6067483d34facbdc40c19018516e7a368ddfeb4a38e26efc6d8cf460a8785e4a
7
+ data.tar.gz: 566f70210d3ff85d8798cc2876371e49c86d2ec959fa11f76a6ecc6e546819953878fcabc53e210de8c1b024dab9d61863f86f5c415fcb02551fe0f79420b8de
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
@@ -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 server_type method configures the type of server to be used.
227
+ # The server_url method configures the URL for the probe server
228
+ # communication.
228
229
  #
229
- # This method sets up the server type configuration option, which
230
- # determines the underlying server implementation to be utilized, this is
231
- # either :unix for UNIX domain sockets or :tcp for TCP Sockets.
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 [ Symbol ] returns the server type configured
234
- config :server_type, :unix
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.
@@ -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 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.
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
- # @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)
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(server_type: :unix, port: 6666)
23
- @server = create_server(server_type, port)
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 type.
11
+ # based on the specified server URL configuration
12
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.
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 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
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 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
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
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.84.0'
3
+ VERSION = '0.85.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/utils.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.84.0 ruby lib
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.84.0".freeze
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]
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.84.0
4
+ version: 0.85.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank