Skip to content

Commit 98793d9

Browse files
committed
Support environment argument
1 parent 8e38140 commit 98793d9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

stdlib/open3/0/open3.rbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
# Options](rdoc-ref:Process@Execution+Options).
4949
#
5050
module Open3
51+
type env = Hash[String, String]
52+
5153
# <!--
5254
# rdoc-file=lib/open3.rb
5355
# - Open3.capture2([env, ] command_line, options = {}) -> [stdout_s, status]
@@ -144,6 +146,7 @@ module Open3
144146
# # => ["hello world\n", #<Process::Status: pid 2326299 exit 0>]
145147
#
146148
def self?.capture2: (*String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
149+
| (env, *String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
147150

148151
# <!--
149152
# rdoc-file=lib/open3.rb
@@ -241,4 +244,5 @@ module Open3
241244
# # => ["hello world\n", #<Process::Status: pid 2371894 exit 0>]
242245
#
243246
def self?.capture2e: (*String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
247+
| (env, *String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
244248
end

test/stdlib/Open3_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def test_capture2
1313
Open3, :capture2, 'echo "Foo"', binmode: true
1414
assert_send_type "(*::String, stdin_data: ::String) -> [ ::String, ::Process::Status ]",
1515
Open3, :capture2, "#{RUBY_EXECUTABLE} -e 'puts STDIN.read'", stdin_data: 'Foo'
16+
assert_send_type "(::Hash[::String, ::String], *::String) -> [ ::String, ::Process::Status ]",
17+
Open3, :capture2, { 'FOO' => 'BAR' }, "echo $FOO"
1618
end
1719

1820
def test_capture2e
@@ -22,6 +24,8 @@ def test_capture2e
2224
Open3, :capture2e, 'echo "Foo"', binmode: true
2325
assert_send_type "(*::String, stdin_data: ::String) -> [ ::String, ::Process::Status ]",
2426
Open3, :capture2e, "#{RUBY_EXECUTABLE} -e 'puts STDIN.read'", stdin_data: 'Foo'
27+
assert_send_type "(::Hash[::String, ::String], *::String) -> [ ::String, ::Process::Status ]",
28+
Open3, :capture2e, { 'FOO' => 'BAR' }, "echo $FOO"
2529
end
2630
end
2731

0 commit comments

Comments
 (0)