power_stencil 0.8.5 → 0.8.10

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: 5e85fced3b94ed8e71fa62e9aa7927e3326261c0
4
- data.tar.gz: 45b93aeca4d3fda35ed2041517b78db4d19fe3a7
3
+ metadata.gz: 5c5b1fcf4935b7c66ff6f969180ff79d034c2895
4
+ data.tar.gz: 098a44fc1907977f33e078d285f92540d98291dd
5
5
  SHA512:
6
- metadata.gz: 58666884718c08bfc17995f9d3056089a8e83c80b43bb47ba980eee2fab43a3c1ad5cfc6898db31cfed75661580066e47dc2ff4365edc159ced210841e1bab77
7
- data.tar.gz: 3336919a1a5f71c37f536cf56e23fd54d24aeff8977be611ff054afde39d70498929009d6adee80a155ef0eb0b5c40584c2882e65a1bd875464029cbb39af2c5
6
+ metadata.gz: 60cc2f0ee6884afed9b18e2163ea4e2c9695e5ae05886b542e7fa1a437dd369672e2c133742ed0d18a79761ab8a20a70d1bbb3178a6790eda43d23c58ca6c8b6
7
+ data.tar.gz: c7645e56558aa929f61282539b9badc472c7f1376b3ec39194ea3f9c33695fd1c7b8245cc0e71aafbb2ff522bff3cc40c72b1b277d17f5e70333a98a05409084
@@ -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
 
@@ -24,11 +24,11 @@ module PowerStencil
24
24
 
25
25
  def modifications_valid?(modified_path, original_entity)
26
26
  test_entity = UniverseCompiler::Entity::Persistence.load modified_path
27
- test_entity.valid?
28
- rescue => e
29
- logger.debug PowerStencil::Error.report_error(e)
30
- logger.debug "Modifications applied to '#{original_entity.as_path}' are invalid !"
31
- false
27
+ test_universe = project.engine.root_universe.dup
28
+ duplicated_entity = test_universe.get_entity *(original_entity.to_composite_key)
29
+ test_universe.replace duplicated_entity, test_entity
30
+ test_entity.resolve_fields_references!
31
+ test_entity.valid? raise_error: true
32
32
  end
33
33
 
34
34
  end
@@ -14,7 +14,7 @@ module PowerStencil
14
14
 
15
15
  def execute
16
16
  setup_project_path
17
- log_startup_context
17
+ log_startup_context
18
18
  puts_and_logs "Creating new project structure in '#{config[:'project-path']}'", check_verbose: false
19
19
  PowerStencil::Project::Base.create_project_tree config[:'project-path']
20
20
  puts_and_logs 'Done.', check_verbose: false
@@ -17,6 +17,7 @@ module PowerStencil
17
17
  logger.debug 'Starting PowerStencil initialization...'
18
18
  setup_system_processors
19
19
  setup_universe_compiler_logger
20
+ try_to_load_project fail_on_error: false
20
21
  logger.debug 'PowerStencil initialization complete'
21
22
  end
22
23
 
@@ -29,7 +30,12 @@ module PowerStencil
29
30
  include PowerStencil::Utils::FileHelper
30
31
 
31
32
  def try_to_load_project(fail_on_error: true)
32
- PowerStencil::Project::Base.instantiate_from_config config
33
+ begin
34
+ PowerStencil::Project::Base.instantiate_from_config config
35
+ rescue => e
36
+ raise e if fail_on_error
37
+ end
38
+
33
39
  end
34
40
 
35
41
  def setup_system_processors
@@ -73,7 +73,6 @@ module PowerStencil
73
73
  logger.debug PowerStencil::Error.report_error(e)
74
74
  logger.warn 'This project is not managed by git'
75
75
  # Ensure Git will not be further used
76
- config[:'no-git'] = true
77
76
  @git = nil
78
77
  end
79
78
 
@@ -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
@@ -76,6 +76,7 @@ module PowerStencil
76
76
  def analyze_semantic_version(semantic_version)
77
77
  case semantic_version
78
78
  when String
79
+ semantic_version = '0.0.0' if semantic_version.empty?
79
80
  version_string_to_hash semantic_version
80
81
  when SemanticVersion
81
82
  semantic_version.to_hash
@@ -85,6 +86,8 @@ module PowerStencil
85
86
  raise_analysis_error semantic_version unless semantic_version[level].is_a? Fixnum
86
87
  end
87
88
  semantic_version.dup
89
+ when NilClass
90
+ version_string_to_hash '0.0.0'
88
91
  else
89
92
  raise_analysis_error semantic_version
90
93
  end
@@ -1,3 +1,3 @@
1
1
  module PowerStencil
2
- VERSION = '0.8.5'.freeze
2
+ VERSION = '0.8.10'.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.1'
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_stencil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Briais
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-04 00:00:00.000000000 Z
11
+ date: 2019-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.5.1
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.1
96
+ version: 0.5.5
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -299,12 +299,13 @@ 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.5 !\nFrom the command
303
- line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
304
- \ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
305
- \ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
306
- free to report issues: https://gitlab.com/tools4devops/power_stencil/issues\n\nType
307
- 'power_stencil adm --zsh-completion' to install auto-completion for zsh.\n\n "
302
+ post_install_message: "\nThank you for installing PowerStencil 0.8.10 !\nFrom the
303
+ command line you can run `power_stencil --help`\nIf your shell is not completing
304
+ the command:\n If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial
305
+ Website : https://powerstencil.brizone.org/\nFull documentation here :
306
+ https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel free to
307
+ report issues: https://gitlab.com/tools4devops/power_stencil/issues\n\nType 'power_stencil
308
+ adm --zsh-completion' to install auto-completion for zsh.\n\n "
308
309
  rdoc_options: []
309
310
  require_paths:
310
311
  - lib