frontkick 0.5.4 → 0.5.5
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +16 -1
- data/example/popen2e.rb +4 -0
- data/example/redirect.rb +5 -0
- data/experiment/redirect_child.rb +7 -0
- data/lib/frontkick/command.rb +45 -24
- data/lib/frontkick/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15b843028a22925691e8f1746f64512fcc4b5e41
|
4
|
+
data.tar.gz: 365e8d2f64e51103895af090c1ea5ef14cd66fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1f32da4df783699687b209a3475f47f07dcf4b973090784a3601dc00ae2f07893300c08eb51b88e9c0df68b69b8987468dabb34a71c310631547a07c5838ec
|
7
|
+
data.tar.gz: 5e870eb23d7ccaba8655134131fac61f3653f8ac98bf1f16b0b30e68558474dfec6e28bfb5d16c611cb0537695836aa8acea5ba131b19b87912dcb7655f607f8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -70,12 +70,18 @@ ruby
|
|
70
70
|
└─ echo
|
71
71
|
```
|
72
72
|
|
73
|
-
NOTE: This interface is different with Kernel.spawn or Open3.popen3.
|
73
|
+
NOTE: This interface is different with Kernel.spawn or Open3.popen3, but similar to IO.popen. Kernel.spawn or Open3.popen3 works with no shell if multiple arguments are given:
|
74
74
|
|
75
75
|
```
|
76
76
|
spawn('echo', '*')
|
77
77
|
```
|
78
78
|
|
79
|
+
IO.popen works with no shell if an array argument is given:
|
80
|
+
|
81
|
+
```
|
82
|
+
IO.popen(['echo', '*'])
|
83
|
+
```
|
84
|
+
|
79
85
|
### Environment Variables
|
80
86
|
|
81
87
|
You can pass environment variables as a hash for the 1st argument as [spawn](https://ruby-doc.org/core-2.4.0/Kernel.html#method-i-spawn).
|
@@ -133,6 +139,15 @@ Frontkick.exec(["ls /something_not_found"], :out => out, :err => err)
|
|
133
139
|
|
134
140
|
You can also give IO objects. In this case, result.stdout, and result.stderr are the given IO objects.
|
135
141
|
|
142
|
+
### Popen2e Option (Get stdout and stderr together)
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
result = Frontkick.exec("echo foo; ls /something_not_found", :popen2e => true)
|
146
|
+
puts result.output #=>
|
147
|
+
foo
|
148
|
+
ls: /something_not_found: No such file or directory
|
149
|
+
```
|
150
|
+
|
136
151
|
### Popen3 Options (such as :chdir)
|
137
152
|
|
138
153
|
Other options such as :chdir are treated as options of `Open3.#popen3`.
|
data/example/popen2e.rb
ADDED
data/example/redirect.rb
ADDED
data/lib/frontkick/command.rb
CHANGED
@@ -55,32 +55,52 @@ module Frontkick
|
|
55
55
|
begin
|
56
56
|
::Timeout.timeout(opts[:timeout], Frontkick::TimeoutLocal) do # nil is for no timeout
|
57
57
|
duration = Benchmark.realtime do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
if opts[:popen2e]
|
59
|
+
stdin, stdout, wait_thr = Open3.popen2e(env, *cmd_array, popen3_opts)
|
60
|
+
out_thr = Thread.new {
|
61
|
+
begin
|
62
|
+
while true
|
63
|
+
out.write stdout.readpartial(4096)
|
64
|
+
end
|
65
|
+
rescue EOFError
|
63
66
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
}
|
68
|
+
stdin.close
|
69
|
+
pid = wait_thr.pid
|
70
|
+
|
71
|
+
yield(wait_thr) if block_given?
|
72
|
+
|
73
|
+
out_thr.join
|
74
|
+
exit_code = wait_thr.value.exitstatus
|
75
|
+
process_wait(pid)
|
76
|
+
else
|
77
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3(env, *cmd_array, popen3_opts)
|
78
|
+
out_thr = Thread.new {
|
79
|
+
begin
|
80
|
+
while true
|
81
|
+
out.write stdout.readpartial(4096)
|
82
|
+
end
|
83
|
+
rescue EOFError
|
84
|
+
end
|
85
|
+
}
|
86
|
+
err_thr = Thread.new {
|
87
|
+
begin
|
88
|
+
while true
|
89
|
+
err.write stderr.readpartial(4096)
|
90
|
+
end
|
91
|
+
rescue EOFError
|
71
92
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
process_wait(pid)
|
93
|
+
}
|
94
|
+
stdin.close
|
95
|
+
pid = wait_thr.pid
|
96
|
+
|
97
|
+
yield(wait_thr) if block_given?
|
98
|
+
|
99
|
+
out_thr.join
|
100
|
+
err_thr.join
|
101
|
+
exit_code = wait_thr.value.exitstatus
|
102
|
+
process_wait(pid)
|
103
|
+
end
|
84
104
|
end
|
85
105
|
end
|
86
106
|
rescue Frontkick::TimeoutLocal => e
|
@@ -121,6 +141,7 @@ module Frontkick
|
|
121
141
|
o.delete(:timeout)
|
122
142
|
o.delete(:out)
|
123
143
|
o.delete(:err)
|
144
|
+
o.delete(:popen2e)
|
124
145
|
}
|
125
146
|
end
|
126
147
|
|
data/lib/frontkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frontkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -70,7 +70,9 @@ files:
|
|
70
70
|
- example/dry_run.rb
|
71
71
|
- example/env.rb
|
72
72
|
- example/kill_child.rb
|
73
|
+
- example/popen2e.rb
|
73
74
|
- example/popen3_options.rb
|
75
|
+
- example/redirect.rb
|
74
76
|
- example/redirect_without_shell.rb
|
75
77
|
- example/run.rb
|
76
78
|
- experiment/capture3_no_deadlock.rb
|
@@ -78,6 +80,7 @@ files:
|
|
78
80
|
- experiment/cat_64k.rb
|
79
81
|
- experiment/popen3_deadlock.rb
|
80
82
|
- experiment/popen3_no_deadlock.rb
|
83
|
+
- experiment/redirect_child.rb
|
81
84
|
- frontkick.gemspec
|
82
85
|
- lib/frontkick.rb
|
83
86
|
- lib/frontkick/command.rb
|
@@ -104,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
107
|
version: '0'
|
105
108
|
requirements: []
|
106
109
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.5.1
|
108
111
|
signing_key:
|
109
112
|
specification_version: 4
|
110
113
|
summary: Execute a command simply!
|