power_stencil 0.3.1

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.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +198 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/bin/update_plugin_template +79 -0
  13. data/doc/builds.md +267 -0
  14. data/doc/entities.md +964 -0
  15. data/doc/example_use_cases.md +59 -0
  16. data/doc/images/power-stencil-entity-build.svg +481 -0
  17. data/doc/images/power-stencil-entity-creation.svg +375 -0
  18. data/doc/images/power-stencil-simple-flow.svg +265 -0
  19. data/doc/plugins.md +169 -0
  20. data/doc/templates.md +333 -0
  21. data/etc/base_commands_definition.yml +259 -0
  22. data/etc/meta_templates/plugin_seed/etc/command_line.yaml +12 -0
  23. data/etc/meta_templates/plugin_seed/etc/plugin_config.yaml +4 -0
  24. data/etc/meta_templates/plugin_seed/etc/templates/.git_keep +0 -0
  25. data/etc/meta_templates/plugin_seed/lib/{entity}.rb.erb +34 -0
  26. data/etc/meta_templates/plugin_seed/lib/{entity}/entity_definitions/{entity}_entity.rb.erb +11 -0
  27. data/etc/meta_templates/plugin_seed/lib/{entity}/plugin_helper.rb.erb +17 -0
  28. data/etc/meta_templates/plugin_seed/lib/{entity}/version.rb.erb +3 -0
  29. data/etc/meta_templates/plugin_seed/lib/{entity}/{entity}_processor.rb.erb +19 -0
  30. data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +36 -0
  31. data/etc/power_stencil.yaml +92 -0
  32. data/etc/templates/plugin_definition/.gitignore +11 -0
  33. data/etc/templates/plugin_definition/.rspec +3 -0
  34. data/etc/templates/plugin_definition/.travis.yml +5 -0
  35. data/etc/templates/plugin_definition/CODE_OF_CONDUCT.md +74 -0
  36. data/etc/templates/plugin_definition/Gemfile +6 -0
  37. data/etc/templates/plugin_definition/LICENSE.txt +21 -0
  38. data/etc/templates/plugin_definition/README.md +43 -0
  39. data/etc/templates/plugin_definition/Rakefile +6 -0
  40. data/etc/templates/plugin_definition/bin/console +14 -0
  41. data/etc/templates/plugin_definition/bin/setup +8 -0
  42. data/etc/templates/plugin_definition/etc/command_line.yaml +12 -0
  43. data/etc/templates/plugin_definition/etc/plugin_config.yaml +4 -0
  44. data/etc/templates/plugin_definition/etc/templates/.git_keep +1 -0
  45. data/etc/templates/plugin_definition/lib/{entity}.rb.erb +34 -0
  46. data/etc/templates/plugin_definition/lib/{entity}/entity_definitions/{entity}_entity.rb.erb +11 -0
  47. data/etc/templates/plugin_definition/lib/{entity}/plugin_helper.rb.erb +17 -0
  48. data/etc/templates/plugin_definition/lib/{entity}/version.rb.erb +3 -0
  49. data/etc/templates/plugin_definition/lib/{entity}/{entity}_processor.rb.erb +19 -0
  50. data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +36 -0
  51. data/etc/templates/plugin_definition/spec/spec_helper.rb +14 -0
  52. data/etc/templates/plugin_definition/spec/{entity}_spec.rb +9 -0
  53. data/etc/templates/project/.copy_ignore +2 -0
  54. data/etc/templates/project/.gitignore.erb +6 -0
  55. data/etc/templates/project/.ps_project/entities/.gitkeep +0 -0
  56. data/etc/templates/project/.ps_project/entities/README.md +11 -0
  57. data/etc/templates/project/.ps_project/entity_definitions/.gitkeep +0 -0
  58. data/etc/templates/project/.ps_project/entity_definitions/README.md +15 -0
  59. data/etc/templates/project/.ps_project/personal-config.yaml +8 -0
  60. data/etc/templates/project/.ps_project/plugins/.gitkeep +0 -0
  61. data/etc/templates/project/.ps_project/templates-templates/.gitkeep +0 -0
  62. data/etc/templates/project/.ps_project/templates-templates/README.md +13 -0
  63. data/etc/templates/project/.ps_project/user_entities/.gitkeep +0 -0
  64. data/etc/templates/project/.ps_project/user_entities/README.md +12 -0
  65. data/etc/templates/project/.ps_project/versioned-config.yaml +6 -0
  66. data/etc/templates/simple_exec/main.sh +4 -0
  67. data/exe/power_stencil +28 -0
  68. data/lib/power_stencil.rb +53 -0
  69. data/lib/power_stencil/command_processors/build.rb +43 -0
  70. data/lib/power_stencil/command_processors/check.rb +35 -0
  71. data/lib/power_stencil/command_processors/create.rb +70 -0
  72. data/lib/power_stencil/command_processors/delete.rb +38 -0
  73. data/lib/power_stencil/command_processors/edit.rb +35 -0
  74. data/lib/power_stencil/command_processors/entity_helper.rb +105 -0
  75. data/lib/power_stencil/command_processors/get.rb +22 -0
  76. data/lib/power_stencil/command_processors/info.rb +41 -0
  77. data/lib/power_stencil/command_processors/init.rb +47 -0
  78. data/lib/power_stencil/command_processors/new_plugin.rb +31 -0
  79. data/lib/power_stencil/command_processors/root.rb +27 -0
  80. data/lib/power_stencil/command_processors/shell.rb +37 -0
  81. data/lib/power_stencil/command_processors/trace_helper.rb +20 -0
  82. data/lib/power_stencil/dsl/base.rb +24 -0
  83. data/lib/power_stencil/dsl/entities.rb +46 -0
  84. data/lib/power_stencil/dsl/plugin_generation.rb +17 -0
  85. data/lib/power_stencil/engine/base.rb +50 -0
  86. data/lib/power_stencil/engine/build_handling.rb +77 -0
  87. data/lib/power_stencil/engine/directory_processor.rb +111 -0
  88. data/lib/power_stencil/engine/entities_definitions.rb +42 -0
  89. data/lib/power_stencil/engine/entities_handling.rb +76 -0
  90. data/lib/power_stencil/engine/entity_engine.rb +20 -0
  91. data/lib/power_stencil/engine/init_engine.rb +18 -0
  92. data/lib/power_stencil/engine/project_engine.rb +75 -0
  93. data/lib/power_stencil/engine/renderers/erb.rb +21 -0
  94. data/lib/power_stencil/error.rb +20 -0
  95. data/lib/power_stencil/initializer.rb +87 -0
  96. data/lib/power_stencil/plugins/base.rb +54 -0
  97. data/lib/power_stencil/plugins/capabilities.rb +30 -0
  98. data/lib/power_stencil/plugins/command_line.rb +27 -0
  99. data/lib/power_stencil/plugins/config.rb +32 -0
  100. data/lib/power_stencil/plugins/dependencies.rb +32 -0
  101. data/lib/power_stencil/plugins/gem.rb +57 -0
  102. data/lib/power_stencil/plugins/require.rb +77 -0
  103. data/lib/power_stencil/plugins/templates.rb +21 -0
  104. data/lib/power_stencil/project/base.rb +79 -0
  105. data/lib/power_stencil/project/config.rb +54 -0
  106. data/lib/power_stencil/project/create.rb +30 -0
  107. data/lib/power_stencil/project/info.rb +72 -0
  108. data/lib/power_stencil/project/paths.rb +119 -0
  109. data/lib/power_stencil/project/plugins.rb +89 -0
  110. data/lib/power_stencil/project/proxy.rb +13 -0
  111. data/lib/power_stencil/project/templates.rb +56 -0
  112. data/lib/power_stencil/project/versioning.rb +29 -0
  113. data/lib/power_stencil/system_entity_definitions/all.rb +14 -0
  114. data/lib/power_stencil/system_entity_definitions/buildable.rb +23 -0
  115. data/lib/power_stencil/system_entity_definitions/entity_override.rb +8 -0
  116. data/lib/power_stencil/system_entity_definitions/entity_project_common.rb +33 -0
  117. data/lib/power_stencil/system_entity_definitions/has_associated_files.rb +13 -0
  118. data/lib/power_stencil/system_entity_definitions/non_persistent.rb +14 -0
  119. data/lib/power_stencil/system_entity_definitions/plugin.rb +17 -0
  120. data/lib/power_stencil/system_entity_definitions/process_descriptor.rb +15 -0
  121. data/lib/power_stencil/system_entity_definitions/project_config.rb +24 -0
  122. data/lib/power_stencil/system_entity_definitions/project_entity.rb +16 -0
  123. data/lib/power_stencil/system_entity_definitions/simple_exec.rb +47 -0
  124. data/lib/power_stencil/utils/directory_processor.rb +54 -0
  125. data/lib/power_stencil/utils/file_edit.rb +87 -0
  126. data/lib/power_stencil/utils/file_helper.rb +56 -0
  127. data/lib/power_stencil/utils/gem_utils.rb +13 -0
  128. data/lib/power_stencil/utils/secure_require.rb +26 -0
  129. data/lib/power_stencil/utils/semantic_version.rb +128 -0
  130. data/lib/power_stencil/version.rb +3 -0
  131. data/power_stencil.gemspec +32 -0
  132. metadata +287 -0
@@ -0,0 +1,54 @@
1
+ require 'power_stencil/plugins/dependencies'
2
+ require 'power_stencil/plugins/config'
3
+ require 'power_stencil/plugins/command_line'
4
+ require 'power_stencil/plugins/templates'
5
+ require 'power_stencil/plugins/require'
6
+ require 'power_stencil/plugins/capabilities'
7
+ require 'power_stencil/plugins/gem'
8
+
9
+ module PowerStencil
10
+
11
+ module Plugins
12
+
13
+ class Base
14
+
15
+ extend PowerStencil::Plugins::Gem
16
+
17
+ include Climatic::Proxy
18
+ include PowerStencil::Plugins::Dependencies
19
+ include PowerStencil::Plugins::Config
20
+ include PowerStencil::Plugins::CommandLine
21
+ include PowerStencil::Plugins::Require
22
+ include PowerStencil::Plugins::Capabilities
23
+ include PowerStencil::Plugins::Templates
24
+
25
+ attr_reader :name, :version, :entry_point_path
26
+
27
+ def initialize(name, project)
28
+ @name = name
29
+ @project = project
30
+ @version = PowerStencil::Utils::SemanticVersion.new '0.0.0-not-specified'
31
+ logger.debug "Loading plugin '#{name}'..."
32
+ setup_plugin
33
+ logger.info "Plugin '#{name}' successfully available"
34
+ logger.debug "Plugin '#{name}' has following capabilities: #{capabilities.inspect}"
35
+ end
36
+
37
+ def path
38
+ project.project_plugin_path(name)
39
+ end
40
+
41
+ private
42
+
43
+ attr_reader :project
44
+
45
+ def setup_plugin
46
+ require_entry_point
47
+ load_plugin_specific_config
48
+ load_yaml_command_definition
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,30 @@
1
+ module PowerStencil
2
+ module Plugins
3
+
4
+ module Capabilities
5
+
6
+ DEFAULT_CAPABILITIES = {
7
+ command_line: false,
8
+ local_config: false,
9
+ processors: false,
10
+ build: false,
11
+ dsl: false,
12
+ entity_definitions: false,
13
+ code: false,
14
+ version: false,
15
+ templates: false
16
+ }.freeze
17
+
18
+ def capabilities
19
+ @capabilities ||= DEFAULT_CAPABILITIES.dup
20
+ end
21
+
22
+ def valid?
23
+ capabilities.keys.each {|cap_name| return true if capabilities[cap_name]}
24
+ false
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,27 @@
1
+ module PowerStencil
2
+ module Plugins
3
+
4
+ module CommandLine
5
+
6
+ attr_reader :plugin_command_line_modifier
7
+
8
+ private
9
+
10
+ def load_yaml_command_definition
11
+ yaml_file = project.plugin_commands_line_definition_file name
12
+ if File.exists? yaml_file and File.file? yaml_file and File.readable? yaml_file
13
+ logger.info "Adding extra command line definition for '#{name}' plugin..."
14
+ @plugin_command_line_modifier = project.yaml_file_to_hash yaml_file
15
+ command_line_manager.contribute_to_definition @plugin_command_line_modifier, layer_name: "Plugin: #{name}"
16
+ capabilities[:command_line] = true
17
+ else
18
+ logger.debug "There is no extra command line definition provided by plugin '#{name}'."
19
+ end
20
+ rescue => e
21
+ logger.debug PowerStencil::Error.report_error(e)
22
+ logger.warn "Could not load yaml file '#{yaml_file}' because '#{e.message}'"
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ module PowerStencil
2
+ module Plugins
3
+
4
+ module Config
5
+
6
+ attr_reader :plugin_specific_config
7
+
8
+ def has_plugin_specific_config?
9
+ yaml_file = project.plugin_config_specific_file(name)
10
+ if File.exists? yaml_file and File.file? yaml_file and File.readable? yaml_file
11
+ logger.info "Found plugin specific config to global config from '#{name}' plugin..."
12
+ return true
13
+ end
14
+ logger.debug "There is no extra command line definition provided by plugin '#{name}'."
15
+ false
16
+ end
17
+
18
+ def load_plugin_specific_config
19
+ yaml_file = project.plugin_config_specific_file(name)
20
+ if has_plugin_specific_config?
21
+ project.add_plugin_config(name)
22
+ capabilities[:local_config] = true
23
+ end
24
+ rescue => e
25
+ logger.debug PowerStencil::Error.report_error(e)
26
+ logger.warn "Could not load yaml file '#{yaml_file}' because '#{e.message}'"
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module PowerStencil
2
+ module Plugins
3
+
4
+ module Dependencies
5
+
6
+ def has_dependencies?
7
+ not declared_dependencies.empty?
8
+ end
9
+
10
+ def declared_dependencies
11
+ if plugin_module.constants.include? :REQUIRED_PLUGINS
12
+ plugin_module::REQUIRED_PLUGINS
13
+ else
14
+ []
15
+ end
16
+ end
17
+
18
+ def check_plugin_dependencies
19
+ logger.info "Checking plugin '#{name}' dependencies !"
20
+ declared_dependencies.each do |dependency|
21
+ logger.debug "Checking dependency of plugin '#{name}' to plugin '#{dependency}'"
22
+ unless project.plugins.keys.include? dependency.to_s
23
+ raise PowerStencil::Error, "Unmatched dependency '#{dependency}' for plugin '#{name}' !"
24
+ end
25
+ end
26
+ logger.debug "Dependencies for plugin '#{name}' are Ok."
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,57 @@
1
+ require 'rubygems/commands/install_command'
2
+
3
+ module PowerStencil
4
+ module Plugins
5
+
6
+ module Gem
7
+
8
+ NO_DOC = %w(--no-ri --no-rdoc).freeze
9
+
10
+ def gem_locally_installed?(plugin_name, plugin_requirements)
11
+ get_spec(plugin_name, plugin_requirements).nil? ? false : true
12
+ end
13
+
14
+
15
+ def install_gem(plugin_name, plugin_requirements)
16
+ cmd = ::Gem::Commands::InstallCommand.new
17
+ opts = [plugin_name]
18
+ opts << plugin_requirements unless plugin_requirements.empty?
19
+ opts.concat NO_DOC
20
+ cmd.handle_options opts
21
+ PowerStencil.logger.debug "Installing plugin '#{plugin_name}'..."
22
+ cmd.execute
23
+ PowerStencil.logger.debug "Plugin '#{plugin_name}' successfully installed."
24
+ rescue ::Gem::SystemExitException => e
25
+ PowerStencil.logger.warn PowerStencil::Error.report_error(e)
26
+ end
27
+
28
+
29
+
30
+ private
31
+
32
+ def get_spec(plugin_name, plugin_requirements)
33
+ candidates = ::Gem::Specification.find_all_by_name plugin_name
34
+ if candidates.empty?
35
+ PowerStencil.logger.debug "Could not find required plugin '#{plugin_name}'"
36
+ return nil
37
+ end
38
+
39
+ req = if plugin_requirements.nil? or plugin_requirements.empty?
40
+ ::Gem::Requirement::DefaultRequirement
41
+ else
42
+ ::Gem::Requirement.create plugin_requirements
43
+ end
44
+
45
+ selected = candidates.select {|candidate| req.satisfied_by? candidate.version}.sort {|a, b| a.version <=> b.version}
46
+ if candidates.empty?
47
+ PowerStencil.logger.debug "Could not find required plugin '#{plugin_name}'"
48
+ return nil
49
+ end
50
+ selected.last
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,77 @@
1
+ module PowerStencil
2
+ module Plugins
3
+
4
+ module Require
5
+
6
+ PLUGINS_NAMESPACE = PowerStencil::Plugin
7
+ SETUP_PROCESSOR_CALLBACK = :setup_processors
8
+ SETUP_DSL_CALLBACK = :setup_dsl
9
+ SETUP_ENTITY_DEFINITIONS_CALLBACK = :setup_entity_definitions
10
+ POST_BUILD_HOOK = :post_build_hook
11
+
12
+ include PowerStencil::Utils::SecureRequire
13
+ include PowerStencil::Utils::GemUtils
14
+
15
+ def plugin_module
16
+ if PLUGINS_NAMESPACE.constants.include? module_short_name
17
+ PLUGINS_NAMESPACE.const_get module_short_name
18
+ else
19
+ module_name = if respond_to? :name
20
+ name.nil? ? 'Unknown' : module_short_name
21
+ else
22
+ __DIR__
23
+ end
24
+ raise PowerStencil::Error, "Invalid plugin '#{module_name}'"
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def module_short_name
31
+ name.split(/[-_]+/).map(&:capitalize).join.to_sym
32
+ end
33
+
34
+ def require_entry_point
35
+ if is_available_gem? name
36
+ logger.debug "Plugin '#{name}' is actually a Ruby Gem."
37
+ raise "Plugin (#{name}) provided as a Ruby gem is not yet supported !"
38
+ else
39
+ @entry_point_path = File.join project.project_plugin_path(name), 'lib', "#{name.underscore}.rb"
40
+ logger.debug "Plugin '#{name}' is provided locally: '#{entry_point_path}'"
41
+ plugin_root_path = File.dirname(entry_point_path)
42
+ begin
43
+ $LOAD_PATH << plugin_root_path
44
+ securely_require entry_point_path do
45
+ check_plugin_module_capabilities
46
+ end
47
+ rescue LoadError => e
48
+ logger.warn "As plugin '#{name}' code is invalid, removing '#{plugin_root_path}' from LOAD_PATH"
49
+ $LOAD_PATH.delete plugin_root_path
50
+ end
51
+
52
+ end
53
+ end
54
+
55
+ def check_plugin_module_capabilities
56
+ unless plugin_module.nil?
57
+ capabilities[:code] = true
58
+ setup_version
59
+ end
60
+ capabilities[:processors] = plugin_module.respond_to? SETUP_PROCESSOR_CALLBACK
61
+ capabilities[:dsl] = plugin_module.respond_to? SETUP_DSL_CALLBACK
62
+ capabilities[:entity_definitions] = plugin_module.respond_to? SETUP_ENTITY_DEFINITIONS_CALLBACK
63
+ capabilities[:build] = plugin_module.respond_to? POST_BUILD_HOOK
64
+ end
65
+
66
+ def setup_version
67
+ @version = PowerStencil::Utils::SemanticVersion.new plugin_module::VERSION
68
+ capabilities[:version] = true
69
+ logger.debug "Plugin '#{name}' is in version: #{version}"
70
+ rescue
71
+ logger.warn "No version specified for plugin '#{name}'."
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+ end
@@ -0,0 +1,21 @@
1
+ module PowerStencil
2
+ module Plugins
3
+
4
+ module Templates
5
+
6
+ SETUP_PLUGIN_TEMPLATES = :setup_plugin_templates
7
+
8
+ def register_plugin_templates
9
+ if plugin_module.respond_to? SETUP_PLUGIN_TEMPLATES
10
+ logger.debug "Plugin '#{name}' declares to have template(s)."
11
+ capabilities[:templates] = true
12
+ plugin_module.send SETUP_PLUGIN_TEMPLATES
13
+ else
14
+ logger.debug "Plugin '#{name}' declares to have no template."
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,79 @@
1
+ require 'power_stencil/project/paths'
2
+ require 'power_stencil/project/create'
3
+ require 'power_stencil/project/config'
4
+ require 'power_stencil/project/versioning'
5
+ require 'power_stencil/project/info'
6
+ require 'power_stencil/project/templates'
7
+ require 'power_stencil/project/plugins'
8
+
9
+ require 'power_stencil/engine/project_engine'
10
+ require 'power_stencil/engine/entity_engine'
11
+
12
+ module PowerStencil
13
+ module Project
14
+
15
+ class Base
16
+
17
+ class << self
18
+
19
+ def instantiate_from_config(config)
20
+ path = config[:'project-path'] || Dir.pwd
21
+ new search_from_path: path
22
+ end
23
+
24
+ end
25
+
26
+ include Climatic::Proxy
27
+ include PowerStencil::Project::Paths
28
+ include PowerStencil::Project::Config
29
+ include PowerStencil::Project::Versioning
30
+ include PowerStencil::Project::Templates
31
+ include PowerStencil::Project::Plugins
32
+ include PowerStencil::Project::Info
33
+ extend PowerStencil::Project::Create
34
+
35
+ attr_reader :engine, :entity_engine
36
+
37
+ def initialize(search_from_path: Dir.pwd)
38
+ initialize_paths search_from_path
39
+ load_project_specific_config
40
+ check_project_version
41
+ bootstrap_plugins
42
+ build_engines
43
+ register_system_templates
44
+ register_project_templates
45
+ end
46
+
47
+ private
48
+
49
+ def register_project_templates
50
+ dir = project_templates_path
51
+ if Dir.exist? dir and File.readable? dir
52
+ logger.info 'Registering project specific templates.'
53
+ Dir.entries(dir).each do |potential_entity_type|
54
+ next if potential_entity_type.match /^\./
55
+ template_dir = File.join(dir, potential_entity_type)
56
+ next unless File.directory? template_dir
57
+ register_template_path_for_type potential_entity_type.to_sym, template_dir
58
+ end
59
+ end
60
+ end
61
+
62
+ def register_system_templates
63
+ logger.debug 'Registering system templates'
64
+ %i(plugin_definition simple_exec).each do |template_name|
65
+ template_path = template_path template_name
66
+ register_template_path_for_type template_name, template_path
67
+ end
68
+ end
69
+
70
+
71
+ def build_engines
72
+ @engine = PowerStencil::Engine::ProjectEngine.new self
73
+ @entity_engine = PowerStencil::Engine::EntityEngine.new
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end
@@ -0,0 +1,54 @@
1
+ module PowerStencil
2
+ module Project
3
+
4
+ module Config
5
+
6
+ include PowerStencil::Project::Paths
7
+
8
+ attr_reader :plugin_priority_count
9
+
10
+ def load_project_specific_config
11
+ # Optional config files should have less priority than the command line layer
12
+ add_optional_config_layer project_versioned_config_file, 'versioned project config file', 70
13
+ add_optional_config_layer project_personal_config_file, 'personal project config file', 900
14
+ end
15
+
16
+ def add_plugin_config(plugin_name)
17
+ yaml_file = plugin_config_specific_file plugin_name
18
+ priority = if priority.nil?
19
+ 200
20
+ else
21
+ plugin_priority_count + 1
22
+ end
23
+
24
+ add_optional_config_layer yaml_file, "'#{plugin_name}' plugin specific config", priority
25
+ @plugin_priority_count ||= 0
26
+ @plugin_priority_count += 1
27
+ end
28
+
29
+ private
30
+
31
+ def add_optional_config_layer(yaml_file, layer_name, layer_priority)
32
+ if File.readable? yaml_file
33
+ logger.debug "Loading #{layer_name}: '#{yaml_file}'..."
34
+ begin
35
+ new_config_layer = SuperStack::Layer.new.load yaml_file
36
+ new_config_layer.name = layer_name
37
+ new_config_layer.priority = layer_priority
38
+ config << new_config_layer
39
+ new_config_layer
40
+ rescue => e
41
+ logger.error "The #{layer_name} '#{yaml_file}' is invalid and has been ignored !"
42
+ logger.debug PowerStencil::Error.report_error(e)
43
+ false
44
+ end
45
+ else
46
+ logger.debug "No #{layer_name} found."
47
+ false
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end