power_stencil 0.4.13 → 0.4.14

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: fca238f33a9bf3e40e4bd67f206222a9948aec3b
4
- data.tar.gz: a37bc631b2dd484ce178e92fad3e111d2ae71baf
3
+ metadata.gz: c21fb1598bf2a0f87a28225e7293c6316a535866
4
+ data.tar.gz: 382b7da148e144199820f554044b6dbd6bc1748a
5
5
  SHA512:
6
- metadata.gz: 56677a6eca4255ee646b98f5dfb719130f2d83cf50a63b3060fca00780f17a998087c96c11d5b94f2f12e1a375884ef322fd62abb6a95132a15a77a79ad6935f
7
- data.tar.gz: ab78a10d95e5ee949a4044d733c381cc38707da75f02bb494e1a6705c5420f86a52cab285062849163a6b7c60a3e7500e6bf76cd2c80a7cada67d666d14b0b4d
6
+ metadata.gz: 04a4b1171e4a606261f28a1b1187009385f1507b5d21fcb91a9b561bdde33afb7516875921b161ee35662ccc4195f7e642acabc4c566a2db3d6d43f765a25cce
7
+ data.tar.gz: 346b28711b2da3ef615fc8da3f46b26dfe078924cb8012c35d8e789d517d2d9e1a77cbb6feb399a380f8d14bcc877c5d724470c7cc8b0594ea2612a257e85ca7
@@ -25,14 +25,21 @@ module PowerStencil
25
25
  def securely_edit_entity(entity, &modifications_validation_block)
26
26
  initial_uri = entity.source_uri
27
27
  modified_entity = nil
28
- Tempfile.create(["#{entity.type.to_s}_#{entity.name.to_s}", '.yaml']) do |tmpfile|
28
+ tmpfile = Tempfile.create(["#{entity.type.to_s}_#{entity.name.to_s}", '.yaml'])
29
+ tmpfile_path = tmpfile.path
30
+ begin
29
31
  tmpfile.puts entity.to_yaml
30
32
  tmpfile.flush
31
- securely_edit_file(tmpfile, &modifications_validation_block)
32
- modified_entity = UniverseCompiler::Entity::Persistence.load tmpfile
33
- modified_entity.source_uri = initial_uri
33
+ ensure
34
+ tmpfile.close
34
35
  end
36
+ securely_edit_file(tmpfile_path, &modifications_validation_block)
37
+ modified_entity = UniverseCompiler::Entity::Persistence.load tmpfile_path
38
+ modified_entity.source_uri = initial_uri
35
39
  return modified_entity
40
+ ensure
41
+ tmpfile.close
42
+ File.unlink tmpfile
36
43
  end
37
44
 
38
45
  def securely_edit_file(file, &modifications_validation_block)
@@ -41,7 +48,9 @@ module PowerStencil
41
48
  end
42
49
  ext = File.extname file
43
50
  base = File.basename file, ext
44
- tmp_file_path = Tempfile.new([base, ext]).path
51
+ tmp_file = Tempfile.create([base, ext])
52
+ tmp_file_path = tmp_file.path
53
+ tmp_file.close
45
54
  retry_count = 1
46
55
  begin
47
56
  FileUtils.copy file, tmp_file_path if retry_count == 1
@@ -1,3 +1,3 @@
1
1
  module PowerStencil
2
- VERSION = '0.4.13'.freeze
2
+ VERSION = '0.4.14'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_stencil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.13
4
+ version: 0.4.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Briais
@@ -259,7 +259,7 @@ metadata:
259
259
  documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
260
260
  source_code_uri: https://gitlab.com/tools4devops/power_stencil
261
261
  homepage_uri: https://powerstencil.brizone.org/
262
- post_install_message: "\nThank you for installing PowerStencil 0.4.13 !\nFrom the
262
+ post_install_message: "\nThank you for installing PowerStencil 0.4.14 !\nFrom the
263
263
  command line you can run `power_stencil --help`\nIf your shell is not completing
264
264
  the command:\n If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial
265
265
  Website : https://powerstencil.brizone.org/\nFull documentation here :