wait_for_it 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: d0f834a28065f71917777d4683074b39c94a23da
4
- data.tar.gz: 6d9c2443ce1c46e603da9d8e7a34bbaea979a06a
3
+ metadata.gz: 1aa914a00bde5498f75359ef60be2a0fd753e02a
4
+ data.tar.gz: 3caea633a9fb12579741134d22f6480befc590a2
5
5
  SHA512:
6
- metadata.gz: abfdd59d18cb4747bb284c5edd0342fc59ccdb623ab61d6bc0920e1259adfa5ba86bf7324848836170f3f27bfc729dfe2648daa2b82d054cb17483aeedf96ee7
7
- data.tar.gz: 5d8f53f05f3ff7f186089c3260c29445bfc012cace2195cc3566092c85ba2e34915d9d58f1c826983847fc41769870aca7c216a4cf4a1c69150313adee77bd6f
6
+ metadata.gz: 060c24f2de3a404f149e9b8427e09c4258d8af54f35d5031fe073c2e56967432401c2d2319d28e10f8f6226868e9f10d469734fa291181713a953dc70eda7c60
7
+ data.tar.gz: 65e0e622acbab6de54cc33a460ec538043b8b2f240142eaa7cdf0b4e8da9d0abaac58c5cc78e1ba01588679b408af1a1a0d0100b4430a04e9c13c34cd8dfe39c
@@ -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
- @tmp_file.close
144
- @log.unlink
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 = env_hash.map {|key, value| "#{ key.to_s.shellescape }=#{ value.to_s.shellescape }" }.join(" ")
157
- command = "/usr/bin/env #{ env } bash -c #{ command.shellescape } #{ redirection } #{ log }"
158
- @pid = Process.spawn("#{ command }")
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)
@@ -1,3 +1,3 @@
1
1
  class WaitForIt
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wait_for_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - schneems