power_stencil 0.9.6 → 0.9.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: fa24834795adfb76db8e36bc7bd3ac199be9a3e4
4
- data.tar.gz: ecec159f500c0f333d4cb7252a11be862dffed44
3
+ metadata.gz: 4ab7d833b0c353a7f1a1d1cd240bd89b7e1d6920
4
+ data.tar.gz: 61a22b0e88f7fe4072f241619174a231407e52e5
5
5
  SHA512:
6
- metadata.gz: 4d564ec96787b00c3628bc9bba61f0b55f46e538f2726ec28684f6256d07f67952dce7d5207c6c190d6717c9b5bd389d95b160cecee0ab72200351222f017d3d
7
- data.tar.gz: 368d8b0a6f9a91688218a9594b1c90cd5ef35caddb2e01b1fb93abae44ec4a70ca64386f5504d37b968174dfe163eaccc14bd9867532e1e6420ffd55cd932457
6
+ metadata.gz: 5754fd517225f6b0f17100e9129a7eb55b1be226cffeec5f69b4f16fbc26755d7911137d7cfef9d7a408d12cd0aceff13bcda261e707a622574b853e41f8c8a8
7
+ data.tar.gz: 26ffefc937dd522b7c8834f31d4d2a06fc3800e6576a4f5512878396956ddf49f25723bad7ea24ab0458b75493554ec1a711a4e58bc9ba2dc9d394d3c3a647ee
data/lib/power_stencil.rb CHANGED
@@ -21,6 +21,7 @@ require 'power_stencil/utils/gem_utils'
21
21
  require 'power_stencil/utils/file_edit'
22
22
  require 'power_stencil/utils/graphviz'
23
23
  require 'power_stencil/utils/completion'
24
+ require 'power_stencil/utils/entity_helper'
24
25
 
25
26
  require 'climatic/script/unimplemented_processor'
26
27
  require 'power_stencil/project/proxy'
@@ -19,15 +19,19 @@ module PowerStencil
19
19
  if md = property_def.match(/^\s*(?<prop_name>[^:=]+)\s*[:=]\s*(?<prop_val>.*)\s*$/)
20
20
  property_value = md['prop_val']
21
21
  logger.debug "Using extra properties from command line '#{md['prop_name']}' = '#{property_value}'"
22
- if pmd = property_value.match(/^\s*!entity\s+(?<entity_type>[^\/]+)\/(?<entity_name>.*)\s*$/)
23
- type = pmd['entity_type'].to_sym
24
- name = pmd['entity_name']
25
- referenced_entity = project.engine.entity(type, name)
26
- property_value = referenced_entity.to_reference unless referenced_entity.nil?
27
- puts_and_logs "Could not find entity '#{type.to_s}/#{name}' !", logs_as: :error, check_verbose: false if referenced_entity.nil?
22
+ if pd = property_value.match(/^\s*!entity\s+(?<entity_id>.+)\s*$/)
23
+ property_value = pd['entity_id']
24
+ esr = PowerStencil::Utils::EntityHelper::EntitySearchReference.from_string property_value
25
+ if esr
26
+ type, name = esr.to_a
27
+ referenced_entity = project.engine.entity(type, name)
28
+ property_value = referenced_entity.to_reference unless referenced_entity.nil?
29
+ puts_and_logs "Could not find entity '#{type.to_s}/#{name}' !", logs_as: :error, check_verbose: false if referenced_entity.nil?
30
+ end
28
31
  end
29
-
30
32
  entity_as_hash[md['prop_name'].to_sym] = property_value
33
+
34
+
31
35
  else
32
36
  raise PowerStencil::Error, "Invalid command line property definition: '#{property_def}'"
33
37
  end
@@ -3,11 +3,7 @@ module PowerStencil
3
3
 
4
4
  module EntityHelper
5
5
 
6
- EntitySearchReference = Struct.new(:type, :name) do
7
- def as_path
8
- [type, name].map(&:to_s).join '/'
9
- end
10
- end
6
+ include PowerStencil::Utils::EntityHelper
11
7
 
12
8
  def describe_entity_types(entity_types)
13
9
  report = {}
@@ -132,9 +128,9 @@ module PowerStencil
132
128
  criteria = stack
133
129
  else
134
130
  stack.each do |param|
135
- if md = param.match(/^\s*(?<type>[^\/]+)\/(?<name>.+)\s*$/)
136
- next_entity_reference.type = md[:type].to_sym
137
- next_entity_reference.name = md[:name]
131
+ esr = EntitySearchReference.from_string param
132
+ if esr
133
+ esr.fill next_entity_reference
138
134
  else
139
135
  if next_entity_reference.type.nil? or next_entity_reference.type.empty?
140
136
  next_entity_reference.type = param.to_sym
@@ -19,9 +19,9 @@ module PowerStencil
19
19
 
20
20
  def entity(type_or_path, name = nil)
21
21
  type, name = if name.nil?
22
- md = type_or_path.match /^(?<type>[^\/]+)\/(?<name>.*)$/
23
- if md
24
- [md['type'].to_sym, md['name']]
22
+ esr = PowerStencil::Utils::EntityHelper::EntitySearchReference.from_string type_or_path
23
+ if esr
24
+ esr.to_a
25
25
  else
26
26
  raise PowerStencil::Error, "Invalid entity id: '#{type_or_path}'"
27
27
  end
@@ -56,7 +56,7 @@ module PowerStencil
56
56
  end
57
57
 
58
58
  def apply_plugins_dsl_definition(context)
59
- project.plugins.each do |_, plugin|
59
+ project.plugins_sorted_by_dependency.each do |plugin|
60
60
  plugin.apply_extra_dsl context
61
61
  end
62
62
  end
@@ -17,12 +17,12 @@ 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
+ project fail_on_error: false
21
21
  logger.debug 'PowerStencil initialization complete'
22
22
  end
23
23
 
24
- def project
25
- @project ||= try_to_load_project
24
+ def project(fail_on_error: true)
25
+ @project ||= try_to_load_project fail_on_error: fail_on_error
26
26
  end
27
27
 
28
28
  private
@@ -67,7 +67,7 @@ module PowerStencil
67
67
  attr_reader :project
68
68
 
69
69
  def setup_plugin
70
- load_capabilities
70
+ determine_capabilities
71
71
  load_plugin_specific_config
72
72
  load_yaml_command_definition
73
73
  end
@@ -19,7 +19,7 @@ module PowerStencil
19
19
 
20
20
  private
21
21
 
22
- def load_capabilities
22
+ def determine_capabilities
23
23
  yaml_file = plugin_capabilities_definition_file
24
24
  unless File.exists? yaml_file and File.file? yaml_file and File.readable? yaml_file
25
25
  raise PowerStencil::Error, "Plugin '#{self.name}' has no definition file !"
@@ -0,0 +1,35 @@
1
+ module PowerStencil
2
+ module Utils
3
+
4
+ module EntityHelper
5
+
6
+ EntitySearchReference = Struct.new(:type, :name) do
7
+
8
+ def self.from_string(string)
9
+ if md = string.match(/^\s*(?<type>[^\/]+)\/\s*(?<name>.+)\s*$/)
10
+ return new md[:type].to_sym, md[:name]
11
+ end
12
+
13
+ false
14
+ end
15
+
16
+ def as_path
17
+ to_a.map(&:to_s).join '/'
18
+ end
19
+
20
+ def to_a
21
+ [type, name]
22
+ end
23
+
24
+ def fill(something)
25
+ something.type = type
26
+ something.name = name
27
+ end
28
+
29
+ end
30
+
31
+
32
+ end
33
+
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module PowerStencil
2
- VERSION = '0.9.6'.freeze
2
+ VERSION = '0.9.7'.freeze
3
3
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'climatic', '~> 0.2.35'
29
29
  spec.add_dependency 'dir_glob_ignore', '~> 0.3'
30
- spec.add_dependency 'universe_compiler', '~> 0.5.5'
30
+ spec.add_dependency 'universe_compiler', '~> 0.5.6'
31
31
  spec.add_dependency 'pry'
32
32
  spec.add_dependency 'git' , '~> 1.5.0'
33
33
  spec.add_dependency 'haml', '~> 5.1.2'
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.9.6
4
+ version: 0.9.7
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-19 00:00:00.000000000 Z
11
+ date: 2019-11-20 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.5
89
+ version: 0.5.6
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.5
96
+ version: 0.5.6
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -310,6 +310,7 @@ files:
310
310
  - lib/power_stencil/utils/completion.rb
311
311
  - lib/power_stencil/utils/dependency_solver.rb
312
312
  - lib/power_stencil/utils/directory_processor.rb
313
+ - lib/power_stencil/utils/entity_helper.rb
313
314
  - lib/power_stencil/utils/file_edit.rb
314
315
  - lib/power_stencil/utils/file_helper.rb
315
316
  - lib/power_stencil/utils/gem_utils.rb
@@ -328,7 +329,7 @@ metadata:
328
329
  documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
329
330
  source_code_uri: https://gitlab.com/tools4devops/power_stencil
330
331
  homepage_uri: https://powerstencil.brizone.org/
331
- post_install_message: "\nThank you for installing PowerStencil 0.9.6 !\nFrom the command
332
+ post_install_message: "\nThank you for installing PowerStencil 0.9.7 !\nFrom the command
332
333
  line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
333
334
  \ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
334
335
  \ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel