helm-cli 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/helm-cli.rb +78 -5
- data/lib/helm-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df943c745733500ec8e3fe4f4625d93f0177e0a4d990b179b0a9dd97dcceea4d
|
4
|
+
data.tar.gz: cfc72f57fbc9bfc4024b56b7dd7f68a3d2f81afe8b37a355b3025e1d9984b3d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 612a1959c9b722180fb4014910f081652154ed2ba267d1e121f9a423716ff6237495e67e6434d1fd3f71e5f564fa719337013ca7495178198977e02ee0d09a18
|
7
|
+
data.tar.gz: 37b29e9f4f293278a0e17ae149104aad929d4ddffa658c9ac95c87876ec66286af0873d64c107ac22ff95b5162b30f1a995e653cbb4fec05d923dacce3f3e5a8
|
data/CHANGELOG.md
CHANGED
data/lib/helm-cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helm-rb'
|
2
|
+
require 'open3'
|
2
3
|
|
3
4
|
class HelmCLI
|
4
5
|
class HelmError < StandardError; end
|
@@ -79,6 +80,33 @@ class HelmCLI
|
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
83
|
+
def with_pipes(out = STDOUT, err = STDERR)
|
84
|
+
previous_stdout = self.stdout
|
85
|
+
previous_stderr = self.stderr
|
86
|
+
self.stdout = out
|
87
|
+
self.stderr = err
|
88
|
+
yield
|
89
|
+
ensure
|
90
|
+
self.stdout = previous_stdout
|
91
|
+
self.stderr = previous_stderr
|
92
|
+
end
|
93
|
+
|
94
|
+
def stdout
|
95
|
+
Thread.current[stdout_key] || STDOUT
|
96
|
+
end
|
97
|
+
|
98
|
+
def stdout=(new_stdout)
|
99
|
+
Thread.current[stdout_key] = new_stdout
|
100
|
+
end
|
101
|
+
|
102
|
+
def stderr
|
103
|
+
Thread.current[stderr_key] || STDERR
|
104
|
+
end
|
105
|
+
|
106
|
+
def stderr=(new_stderr)
|
107
|
+
Thread.current[stderr_key] = new_stderr
|
108
|
+
end
|
109
|
+
|
82
110
|
private
|
83
111
|
|
84
112
|
def base_cmd
|
@@ -87,15 +115,52 @@ class HelmCLI
|
|
87
115
|
|
88
116
|
def backticks(cmd)
|
89
117
|
cmd_s = cmd.join(' ')
|
90
|
-
|
91
|
-
|
118
|
+
result = StringIO.new
|
119
|
+
|
120
|
+
Open3.popen3(cmd_s) do |p_stdin, p_stdout, p_stderr, wait_thread|
|
121
|
+
Thread.new do
|
122
|
+
begin
|
123
|
+
p_stdout.each { |line| result.puts(line) }
|
124
|
+
rescue IOError
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
Thread.new(stderr) do |t_stderr|
|
129
|
+
begin
|
130
|
+
p_stderr.each { |line| t_stderr.puts(line) }
|
131
|
+
rescue IOError
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
p_stdin.close
|
136
|
+
self.last_status = wait_thread.value
|
137
|
+
wait_thread.join
|
92
138
|
end
|
139
|
+
|
140
|
+
result.string
|
93
141
|
end
|
94
142
|
|
95
143
|
def systemm(cmd)
|
96
144
|
cmd_s = cmd.join(' ')
|
97
|
-
|
98
|
-
|
145
|
+
|
146
|
+
Open3.popen3(cmd_s) do |p_stdin, p_stdout, p_stderr, wait_thread|
|
147
|
+
Thread.new(stdout) do |t_stdout|
|
148
|
+
begin
|
149
|
+
p_stdout.each { |line| t_stdout.puts(line) }
|
150
|
+
rescue IOError
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
Thread.new(stderr) do |t_stderr|
|
155
|
+
begin
|
156
|
+
p_stderr.each { |line| t_stderr.puts(line) }\
|
157
|
+
rescue IOError
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
p_stdin.close
|
162
|
+
self.last_status = wait_thread.value
|
163
|
+
wait_thread.join
|
99
164
|
end
|
100
165
|
end
|
101
166
|
|
@@ -104,6 +169,14 @@ class HelmCLI
|
|
104
169
|
end
|
105
170
|
|
106
171
|
def status_key
|
107
|
-
:
|
172
|
+
:helm_cli_last_status
|
173
|
+
end
|
174
|
+
|
175
|
+
def stdout_key
|
176
|
+
:helm_cli_stdout
|
177
|
+
end
|
178
|
+
|
179
|
+
def stderr_key
|
180
|
+
:helm_cli_stderr
|
108
181
|
end
|
109
182
|
end
|
data/lib/helm-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helm-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: helm-rb
|