wait_for_it 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wait_for_it.rb +23 -5
- data/lib/wait_for_it/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aa914a00bde5498f75359ef60be2a0fd753e02a
|
4
|
+
data.tar.gz: 3caea633a9fb12579741134d22f6480befc590a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 060c24f2de3a404f149e9b8427e09c4258d8af54f35d5031fe073c2e56967432401c2d2319d28e10f8f6226868e9f10d469734fa291181713a953dc70eda7c60
|
7
|
+
data.tar.gz: 65e0e622acbab6de54cc33a460ec538043b8b2f240142eaa7cdf0b4e8da9d0abaac58c5cc78e1ba01588679b408af1a1a0d0100b4430a04e9c13c34cd8dfe39c
|
data/lib/wait_for_it.rb
CHANGED
@@ -94,6 +94,10 @@ class WaitForIt
|
|
94
94
|
cleanup
|
95
95
|
end
|
96
96
|
end
|
97
|
+
|
98
|
+
rescue WaitForItTimeoutError => e
|
99
|
+
cleanup
|
100
|
+
raise e
|
97
101
|
end
|
98
102
|
|
99
103
|
attr_reader :timeout, :log
|
@@ -140,11 +144,23 @@ class WaitForIt
|
|
140
144
|
# Kills the process and removes temporary files
|
141
145
|
def cleanup
|
142
146
|
shutdown
|
143
|
-
|
144
|
-
|
147
|
+
close_log
|
148
|
+
unlink_log
|
145
149
|
end
|
146
150
|
|
147
151
|
private
|
152
|
+
|
153
|
+
def close_log
|
154
|
+
@tmp_file.close if @tmp_file
|
155
|
+
end
|
156
|
+
|
157
|
+
def unlink_log
|
158
|
+
@log.unlink if @log
|
159
|
+
rescue Errno::ENOENT
|
160
|
+
# File already unlinked
|
161
|
+
end
|
162
|
+
|
163
|
+
|
148
164
|
def set_log
|
149
165
|
@tmp_file = Tempfile.new(["wait_for_it", ".log"])
|
150
166
|
log_file = Pathname.new(@tmp_file)
|
@@ -153,9 +169,11 @@ private
|
|
153
169
|
end
|
154
170
|
|
155
171
|
def spawn(command, redirection, env_hash = {})
|
156
|
-
env
|
157
|
-
|
158
|
-
|
172
|
+
env = {}
|
173
|
+
env_hash.each {|k, v| env[k.to_s] = v.to_s }
|
174
|
+
|
175
|
+
# Must exec so when we kill the PID it kills the child process
|
176
|
+
@pid = Process.spawn(env, "exec #{ command } #{ redirection } #{ log }")
|
159
177
|
end
|
160
178
|
|
161
179
|
def convert_to_regex(input)
|
data/lib/wait_for_it/version.rb
CHANGED