pups 1.3.0 → 1.4.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: 3a3b8f3717bb917e039d84ec656835ce1c4b213d481de705244bb15fa58e8f1a
4
- data.tar.gz: f104c2f76abccafc9705c08a1619dd1a0351ad91a19ddf5c29cb4f9bc283a91d
3
+ metadata.gz: c44dd2f8d1c107d585ee7c21a15dfb4061f6dafd78a07f8f937e416fc2f267ee
4
+ data.tar.gz: 99dc03350563acc46ae7df3566bf647db604572b31b8b46d46579acba6a9b880
5
5
  SHA512:
6
- metadata.gz: de7bd31e09e421f3a2ff172199694cc19e757a4be8fde50188cde889f8ca788c15f9733d354ad6ee0b8ef6551f804bdf470ab8175059a5b66be05d9c73cadf5f
7
- data.tar.gz: 8b704e22e578e48870733a8c3925afff1dc7773cf17fe5a5c9182fa1a464fc2ca97c80a0bed174393e54ff5f2e3071d9c4abb2eee8086c07a9c96da0c44267b1
6
+ metadata.gz: fdac187b13809df0c9b6c6dc34d74b17e2c360dcdf84e9f60a01a9f9d57f813a618a2ab99689a65a4998cf38e6ae98e01504aac9224bf81b5096a415dda0973f
7
+ data.tar.gz: 1668338d3b167b277cfcb09c063f7489101cfc4470e2b00d5c1d36d46fd0e8eb4e8149a33ab0ff11780f50060c9efee3f948fa203785da596ea74329356d1e0d
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 1.4.0 - 01-07-2026
2
+
3
+ - Stream command output directly to stdout instead of buffering
4
+
1
5
  1.3.0 - 07-08-2025
2
6
 
3
7
  - Add --params option
@@ -111,17 +111,24 @@ module Pups
111
111
  return pid
112
112
  end
113
113
 
114
- IO.popen(command, "w+") do |f|
115
- if stdin
116
- # need a way to get stdout without blocking
117
- Pups.log.info(stdin)
118
- f.write stdin
119
- f.close
120
- else
121
- Pups.log.info(f.readlines.join)
122
- end
114
+ opts = { out: $stdout, err: $stderr }
115
+
116
+ if stdin
117
+ reader, writer = IO.pipe
118
+ opts[:in] = reader
119
+ end
120
+
121
+ pid = Process.spawn(command, opts)
122
+
123
+ if stdin
124
+ reader.close
125
+ Pups.log.info(stdin)
126
+ writer.write(stdin)
127
+ writer.close
123
128
  end
124
129
 
130
+ Process.wait(pid)
131
+
125
132
  unless $CHILD_STATUS == 0
126
133
  err =
127
134
  Pups::ExecError.new(
data/lib/pups/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pups
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  end
@@ -98,5 +98,44 @@ module Pups
98
98
 
99
99
  assert_raises(Errno::ECHILD) { Process.waitpid(pid, Process::WNOHANG) }
100
100
  end
101
+
102
+ def test_stdout_streaming
103
+ # Starts a long-running process that outputs immediately
104
+ # and then watches a file before quitting.
105
+ # If stdout is properly streamed, we should see the output
106
+ # immediately rather than waiting for the process to end.
107
+
108
+ signal_file = Tempfile.new("signal")
109
+ signal_path = signal_file.path
110
+ signal_file.close
111
+
112
+ reader, writer = IO.pipe
113
+ original_stdout = $stdout.dup
114
+
115
+ $stdout.reopen(writer)
116
+
117
+ cmd = ExecCommand.new({})
118
+ cmd.add("echo 'streamed output'; while [ ! -s #{signal_path} ]; do sleep 0.1; done")
119
+
120
+ thread = Thread.new { cmd.run }
121
+
122
+ # Wait for output - if streaming works, it appears immediately
123
+ # If buffered, it would never appear since command loops until signaled
124
+ ready = IO.select([reader], nil, nil, 2)
125
+ assert ready, "Output should be available before command completes"
126
+
127
+ output = reader.read_nonblock(1000)
128
+ assert_includes(output, "streamed output")
129
+ ensure
130
+ $stdout.reopen(original_stdout) if original_stdout
131
+
132
+ writer&.close
133
+ reader&.close
134
+
135
+ File.write(signal_path, "done")
136
+ signal_file&.unlink
137
+
138
+ thread.join(2)
139
+ end
101
140
  end
102
141
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pups
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-09 00:00:00.000000000 Z
11
+ date: 2026-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler