omq-cli 0.15.2 → 0.15.3

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: f6f38a5924268358a3b48021d597248a341e3590ea36a13fc9ee8cc078d2a826
4
- data.tar.gz: fc3e4b1b13cb85b9e492f6f75e4a6409e5fe2357ee1806bd68abe27954117e41
3
+ metadata.gz: 5b503b668b3427210a067278ba175bbda172e98ccf19df42f4dcf4cc84cd1dd4
4
+ data.tar.gz: 9861f0dd910a0ca723b97043996a8c5e47c2222efd77321f8f1e43efdc872818
5
5
  SHA512:
6
- metadata.gz: c8b10c0dc4aa93ab2676c8df93cc62026fd08b17cc76d2cb3da73059e0fba443263e9200a9eb65835bd7985bf48e5409fd04dabd0574cbe1b5c1735e14ce0c88
7
- data.tar.gz: 7899ea0cbfac91674f8bc750cd31faf957bcb9f6b9996261d606d6859322b7c74fdbc2311f3d7dc9ec72355add2f9734f1493d36a4eb86af3bffb6eed110a874
6
+ metadata.gz: 82972297897d9ea36f3a10ecad3372b476ae935e9b4d20ff312f23db5ecee438b52b0a443d814048f4dab8d5e5243e927509a994917b4926058d80c3f314188b
7
+ data.tar.gz: cbca40c66d0061a3d51782e3b1cf001aad9d44596f2b9203a7d6837c087049227565456f07646de7e2788d827ce91a1ba5290fa7c8792f103475b867ee663c28
data/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.3 — 2026-04-16
4
+
5
+ ### Changed
6
+
7
+ - **Cache decoded `--data` input.** `read_inline_data` and
8
+ `ParallelWorker#compute_reply` now memoize the decoded result
9
+ instead of re-decoding the same literal on every iteration.
10
+
11
+ ## Unreleased
12
+
13
+ ### Added
14
+
15
+ - **REQ generator mode (`-E`/`-e` with no stdin).** `omq req` now
16
+ produces each request from the send-eval alone when no `-d`/`-f`
17
+ is given and stdin is not piped, matching the existing PUSH/PUB
18
+ behaviour. Bounded by `-n` or paced by `-i` like the other
19
+ generator-capable runners.
20
+
21
+ ### Tests
22
+
23
+ - **System tests for REQ and PUB `-E` generator mode.** REQ fires
24
+ `-E'"foo"' -n 3` against a REP running `-e '|(a)| a.upcase' -n 3`
25
+ and verifies three `FOO` replies round-trip. PUB fires
26
+ `-E'"tick"' -i 0.05 -n 3` against a SUB and verifies three `tick`
27
+ frames are received.
28
+ - **System tests split into themed files under `test/system/`.** The
29
+ monolithic `test/system_test.sh` is replaced by 12 standalone files
30
+ (req_rep, push_pull, pub_sub, router_dealer, format, compression,
31
+ interval, transport, script, validation, pipe, parallel) sharing
32
+ `support.sh` helpers. `run_all.sh` chains them; each file also runs
33
+ standalone. `rake test:system` now invokes `run_all.sh`.
34
+
3
35
  ## 0.15.2 — 2026-04-15
4
36
 
5
37
  ### Fixed
@@ -422,7 +422,7 @@ module OMQ
422
422
 
423
423
  def read_inline_data
424
424
  if config.data
425
- @fmt.decode(config.data + "\n")
425
+ @inline_data ||= @fmt.decode(config.data + "\n")
426
426
  else
427
427
  @file_data ||= (config.file == "-" ? $stdin.read : File.read(config.file)).chomp
428
428
  @fmt.decode(@file_data + "\n")
@@ -28,6 +28,7 @@ module OMQ
28
28
  expr, begin_body, end_body = extract_blocks(src)
29
29
  @begin_proc = eval("proc { #{begin_body} }") if begin_body
30
30
  @end_proc = eval("proc { #{end_body} }") if end_body
31
+
31
32
  if expr && !expr.strip.empty?
32
33
  @eval_proc = eval("proc { #{expr} }")
33
34
  end
@@ -85,6 +86,7 @@ module OMQ
85
86
  begin_proc = eval("proc { #{begin_body} }") if begin_body
86
87
  end_proc = eval("proc { #{end_body} }") if end_body
87
88
  eval_proc = nil
89
+
88
90
  if expr && !expr.strip.empty?
89
91
  eval_proc = eval("proc { #{expr} }")
90
92
  end
@@ -100,12 +102,12 @@ module OMQ
100
102
  # (Ractors cannot call back into instance state).
101
103
  #
102
104
  def self.extract_block(expr, keyword)
103
- start = expr.index(/#{keyword}\s*\{/)
104
- return [expr, nil] unless start
105
+ start = expr.index(/#{keyword}\s*\{/) or return [expr, nil]
105
106
 
106
107
  i = expr.index("{", start)
107
108
  depth = 1
108
109
  j = i + 1
110
+
109
111
  while j < expr.length && depth > 0
110
112
  case expr[j]
111
113
  when "{"
@@ -113,6 +115,7 @@ module OMQ
113
115
  when "}"
114
116
  depth -= 1
115
117
  end
118
+
116
119
  j += 1
117
120
  end
118
121
 
@@ -157,7 +157,7 @@ module OMQ
157
157
  elsif @config.echo
158
158
  parts
159
159
  elsif @config.data
160
- @fmt.decode(@config.data + "\n")
160
+ @inline_data ||= @fmt.decode(@config.data + "\n")
161
161
  else
162
162
  parts
163
163
  end
@@ -10,19 +10,27 @@ module OMQ
10
10
  def run_loop(task)
11
11
  n = config.count
12
12
  i = 0
13
- sleep(config.delay) if config.delay
13
+
14
+ sleep config.delay if config.delay
15
+ generator = @send_eval_proc && !config.data && !config.file && !stdin_ready?
16
+
14
17
  loop do
15
- parts = read_next
16
- break unless parts
17
- parts = eval_send_expr(parts)
18
+ if generator
19
+ parts = eval_send_expr(nil)
20
+ else
21
+ parts = read_next
22
+ break unless parts
23
+ parts = eval_send_expr(parts)
24
+ end
25
+
18
26
  next unless parts
27
+
19
28
  send_msg(parts)
20
- reply = recv_msg
21
- break if reply.nil?
29
+ reply = recv_msg or break
22
30
  output(eval_recv_expr(reply))
23
31
  i += 1
24
32
  break if n && n > 0 && i >= n
25
- break if !config.interval && (config.data || config.file)
33
+ break if !config.interval && (generator || config.data || config.file) && !(n && n > 0)
26
34
  wait_for_interval if config.interval
27
35
  end
28
36
  end
@@ -38,7 +46,11 @@ module OMQ
38
46
  # Runner for REP sockets (synchronous request-reply server).
39
47
  class RepRunner < BaseRunner
40
48
  def call(task)
41
- config.parallel ? run_parallel_workers(:REP) : super
49
+ if config.parallel
50
+ run_parallel_workers(:REP)
51
+ else
52
+ super
53
+ end
42
54
  end
43
55
 
44
56
 
@@ -48,9 +60,9 @@ module OMQ
48
60
  def run_loop(task)
49
61
  n = config.count
50
62
  i = 0
63
+
51
64
  loop do
52
- msg = recv_msg
53
- break if msg.nil?
65
+ msg = recv_msg or break
54
66
  break unless handle_rep_request(msg)
55
67
  i += 1
56
68
  break if n && n > 0 && i >= n
@@ -61,6 +73,7 @@ module OMQ
61
73
  def handle_rep_request(msg)
62
74
  if config.recv_expr || @recv_eval_proc
63
75
  reply = eval_recv_expr(msg)
76
+
64
77
  unless reply.equal?(SENT)
65
78
  output(reply)
66
79
  send_msg(reply || [""])
@@ -76,6 +89,7 @@ module OMQ
76
89
  else
77
90
  abort "REP needs a reply source: --echo, --data, --file, -e, or stdin pipe"
78
91
  end
92
+
79
93
  true
80
94
  end
81
95
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OMQ
4
4
  module CLI
5
- VERSION = "0.15.2"
5
+ VERSION = "0.15.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omq-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger