power_stencil 0.8.6 → 0.8.7

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: f12907b8b2e2bd5ff7e94f6f1c75241604cfef84
4
- data.tar.gz: 66f1296b1df2d83e1f52625f8056d5ec46d17114
3
+ metadata.gz: a11e9c5260e1929526cc1555923592f3a3fd5041
4
+ data.tar.gz: 39c54949b912a3cf6aa298207f59cd2d3a4c58ee
5
5
  SHA512:
6
- metadata.gz: 9c9968f5c422ec59ee0c4a33f184bca64b1501d879b7cc085a0b52a23a13afeeac25d487b373b0fb6d0999e958476962278fbb445aaf44834035623962857c93
7
- data.tar.gz: 03bee415e4a53424a12df0aee9e611eea282fef903a4374b7877bf5befd3fa9b7890429430d22765d1836bfbbbe4ddababe1833d7221699fa2f5242b89d244f9
6
+ metadata.gz: b71ba2925c1f7c09ad2db22bb56d90b4b293114405bc03aac08b583fc9ddb991ca804425ef095ecf7ff548963c87d025912de4d348507de7972e13726983eb46
7
+ data.tar.gz: 9dc5cc390ea7f3adfa2d25893773b5a67c42a6b0be88e17bc3ed9de28e14fce009df8b913382d3dad35557df0a4132b2c2241553eda495a7435563af99ab5015
@@ -51,17 +51,20 @@ module PowerStencil
51
51
 
52
52
  def modifications_valid?(modified_path, original_entity)
53
53
  test_entity = UniverseCompiler::Entity::Persistence.load modified_path
54
- test_entity.valid?
55
- rescue => e
56
- logger.debug PowerStencil::Error.report_error(e)
57
- logger.debug "Modifications applied to '#{original_entity.as_path}' are invalid !"
58
- false
54
+ test_universe = project.engine.root_universe.dup
55
+ duplicated_entity = test_universe.get_entity *(original_entity.to_composite_key)
56
+ test_universe.replace duplicated_entity, test_entity
57
+ test_entity.resolve_fields_references!
58
+ test_entity.valid? raise_error: true
59
59
  end
60
60
 
61
61
  def edit_before_save(entity)
62
- securely_edit_entity entity do |modified_path, _|
62
+ modified_entity = securely_edit_entity entity do |modified_path, _|
63
63
  modifications_valid? modified_path, entity
64
64
  end
65
+ project.engine.root_universe.replace entity, modified_entity
66
+ modified_entity.resolve_fields_references!
67
+ modified_entity
65
68
  end
66
69
 
67
70
 
@@ -28,11 +28,7 @@ module PowerStencil
28
28
  duplicated_entity = test_universe.get_entity *(original_entity.to_composite_key)
29
29
  test_universe.replace duplicated_entity, test_entity
30
30
  test_entity.resolve_fields_references!
31
- test_entity.valid?
32
- rescue => e
33
- logger.debug PowerStencil::Error.report_error(e)
34
- logger.debug "Modifications applied to '#{original_entity.as_path}' are invalid !"
35
- false
31
+ test_entity.valid? raise_error: true
36
32
  end
37
33
 
38
34
  end
@@ -55,22 +55,29 @@ module PowerStencil
55
55
  begin
56
56
  FileUtils.copy file, tmp_file_path if retry_count == 1
57
57
  edit_file tmp_file_path
58
- if block_given?
59
- unless modifications_validation_block.call tmp_file_path, file
60
- raise PowerStencil::Error, "Your modifications to '#{file}' are invalid !"
61
- end
62
- end
58
+ modifications_validation_block.call(tmp_file_path, file) if block_given?
63
59
  FileUtils.copy tmp_file_path, file
64
60
  logger.info "File '#{file}' updated successfully."
65
61
  file
66
62
  rescue StandardError => e
63
+ remaining_attempts = nb_max_edit_retries - retry_count
67
64
  retry_count += 1
65
+ msg = "Changes invalid: '#{e.message}'."
66
+ if remaining_attempts > 0
67
+ msg << " #{remaining_attempts} remaining attempt"
68
+ if remaining_attempts == 1
69
+ msg << '.'
70
+ else
71
+ msg << 's.'
72
+ end
73
+ end
74
+ puts_and_logs msg, logs_as: :error, check_verbose: false
68
75
  if retry_count > nb_max_edit_retries
69
- logger.error "Your modifications are kept in '#{LAST_EDITED_FILE}' as it was invalid !"
70
76
  begin
71
77
  FileUtils.copy tmp_file_path, LAST_EDITED_FILE
78
+ puts_and_logs "Your modifications were kept in '#{LAST_EDITED_FILE}' as it was invalid !", logs_as: :error, check_verbose: false
72
79
  rescue => ue
73
- logger.error 'Cannot keep your modifications !'
80
+ logger.error 'Ooops, something strange happened while saving your modifications. Cannot keep your modifications !'
74
81
  logger.debug PowerStencil::Error.report_error(ue)
75
82
  end
76
83
  else
@@ -1,3 +1,3 @@
1
1
  module PowerStencil
2
- VERSION = '0.8.6'.freeze
2
+ VERSION = '0.8.7'.freeze
3
3
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'climatic', '~> 0.2.32'
29
29
  spec.add_dependency 'dir_glob_ignore', '~> 0.3'
30
- spec.add_dependency 'universe_compiler', '~> 0.5.3'
30
+ spec.add_dependency 'universe_compiler', '~> 0.5.5'
31
31
  spec.add_dependency 'pry'
32
32
  spec.add_dependency 'git' , '~> 1.5.0'
33
33
 
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.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Briais
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.5.3
89
+ version: 0.5.5
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.5.3
96
+ version: 0.5.5
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -299,7 +299,7 @@ metadata:
299
299
  documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
300
300
  source_code_uri: https://gitlab.com/tools4devops/power_stencil
301
301
  homepage_uri: https://powerstencil.brizone.org/
302
- post_install_message: "\nThank you for installing PowerStencil 0.8.6 !\nFrom the command
302
+ post_install_message: "\nThank you for installing PowerStencil 0.8.7 !\nFrom the command
303
303
  line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
304
304
  \ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
305
305
  \ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel