specinfra 2.83.2 → 2.83.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb64f982a1db9c07f65e29062f40f76d2dbd06cc
4
- data.tar.gz: 6e35fcccef10ee85f2798d5cd55dd35415a97007
3
+ metadata.gz: 58cbd695ca792e709adf09757a8b98c9a8ae232e
4
+ data.tar.gz: 6456b8a3ec20b871fec8f2f9213047168ffb2f9d
5
5
  SHA512:
6
- metadata.gz: 667d26731d168fd905f3235f135bb7cf12098908b4114e3a7b2938518e5fb2e2574a12ae9f85006856a1ced27e708070d144f1e7ec299160482daadd9b91c247
7
- data.tar.gz: cfe99453702b4169825605f8c98fba7bd7cbf35331df9fc142ee824acafb433a9c71800104e95446b8fa080b6797617bddf7d8629b1fb22fe24f78f9e48f36ae
6
+ metadata.gz: e4e9801b8d4bf4c504f43e3356240523970e58818f85c0647ed4a2dc2b7e701af323619d270150a0aef349d15dd9f66c3c898d4b0f83ef893d9d078e3593e578
7
+ data.tar.gz: 2d3b11cdf49a821746666230da0980377aaff8e3061e458fdfa76bfc4e5b1ed8d5eba8c19bc886988733f288c436549f7788670216676805cd2c26836e24602f
@@ -17,7 +17,7 @@ module Specinfra
17
17
  @base_image = get_or_pull_image(image)
18
18
 
19
19
  create_and_start_container
20
- ObjectSpace.define_finalizer(self, proc { cleanup_container })
20
+ ObjectSpace.define_finalizer(self, self.class.__send__(:finalizer_for, @container))
21
21
  elsif container = get_config(:docker_container)
22
22
  @container = ::Docker::Container.get(container)
23
23
  else
@@ -25,6 +25,25 @@ module Specinfra
25
25
  end
26
26
  end
27
27
 
28
+ class << self
29
+ protected
30
+
31
+ # Get a finalizer for given container.
32
+ #
33
+ # @param [::Docker::Container, nil] container
34
+ #
35
+ # @return [Proc]
36
+ def finalizer_for(container)
37
+ proc do
38
+ # noinspection RubyNilAnalysis
39
+ unless container.nil?
40
+ container.stop
41
+ container.delete
42
+ end
43
+ end
44
+ end
45
+ end
46
+
28
47
  def run_command(cmd, opts={})
29
48
  cmd = build_command(cmd)
30
49
  run_pre_command(opts)
@@ -77,8 +96,7 @@ module Specinfra
77
96
  end
78
97
 
79
98
  def cleanup_container
80
- @container.stop
81
- @container.delete
99
+ self.class.__send__(:finalizer_for, @container).call
82
100
  end
83
101
 
84
102
  def current_image
@@ -30,7 +30,7 @@ class Specinfra::Command::Linux::Base::Inventory < Specinfra::Command::Base::Inv
30
30
 
31
31
  def get_block_device
32
32
  block_device_dirs = '/sys/block/*/{size,removable,device/{model,rev,state,timeout,vendor},queue/rotational}'
33
- "for f in $(ls #{block_device_dirs}); do echo -e \"${f}\t$(cat ${f})\"; done"
33
+ %Q[bash -c 'for f in $(ls #{block_device_dirs}); do echo -e "${f}\t$(cat ${f})"; done']
34
34
  end
35
35
 
36
36
  def get_system_product_name
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.83.2"
2
+ VERSION = "2.83.4"
3
3
  end
@@ -16,5 +16,5 @@ end
16
16
 
17
17
  describe get_command(:get_inventory_block_device) do
18
18
  block_device_dirs = '/sys/block/*/{size,removable,device/{model,rev,state,timeout,vendor},queue/rotational}'
19
- it { should eq "for f in $(ls #{block_device_dirs}); do echo -e \"${f}\t$(cat ${f})\"; done" }
19
+ it { should eq %Q[bash -c 'for f in $(ls #{block_device_dirs}); do echo -e "${f}\t$(cat ${f})"; done'] }
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.83.2
4
+ version: 2.83.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-31 00:00:00.000000000 Z
11
+ date: 2022-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp