power_stencil 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) 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 +194 -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-architecture.svg +151 -0
  17. data/doc/images/power-stencil-entity-build.svg +481 -0
  18. data/doc/images/power-stencil-entity-creation.svg +375 -0
  19. data/doc/images/power-stencil-project-overview.svg +2534 -0
  20. data/doc/images/power-stencil-simple-flow.svg +265 -0
  21. data/doc/plugins.md +169 -0
  22. data/doc/templates.md +332 -0
  23. data/etc/base_commands_definition.yml +259 -0
  24. data/etc/meta_templates/plugin_seed/etc/command_line.yaml +12 -0
  25. data/etc/meta_templates/plugin_seed/etc/plugin_config.yaml +4 -0
  26. data/etc/meta_templates/plugin_seed/etc/templates/.git_keep +0 -0
  27. data/etc/meta_templates/plugin_seed/lib/{entity}.rb.erb +34 -0
  28. data/etc/meta_templates/plugin_seed/lib/{entity}/entity_definitions/{entity}_entity.rb.erb +11 -0
  29. data/etc/meta_templates/plugin_seed/lib/{entity}/plugin_helper.rb.erb +17 -0
  30. data/etc/meta_templates/plugin_seed/lib/{entity}/version.rb.erb +3 -0
  31. data/etc/meta_templates/plugin_seed/lib/{entity}/{entity}_processor.rb.erb +19 -0
  32. data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +36 -0
  33. data/etc/power_stencil.yaml +92 -0
  34. data/etc/templates/plugin_definition/.gitignore +11 -0
  35. data/etc/templates/plugin_definition/.rspec +3 -0
  36. data/etc/templates/plugin_definition/.travis.yml +5 -0
  37. data/etc/templates/plugin_definition/CODE_OF_CONDUCT.md +74 -0
  38. data/etc/templates/plugin_definition/Gemfile +6 -0
  39. data/etc/templates/plugin_definition/LICENSE.txt +21 -0
  40. data/etc/templates/plugin_definition/README.md +43 -0
  41. data/etc/templates/plugin_definition/Rakefile +6 -0
  42. data/etc/templates/plugin_definition/bin/console +14 -0
  43. data/etc/templates/plugin_definition/bin/setup +8 -0
  44. data/etc/templates/plugin_definition/etc/command_line.yaml +12 -0
  45. data/etc/templates/plugin_definition/etc/plugin_config.yaml +4 -0
  46. data/etc/templates/plugin_definition/etc/templates/.git_keep +1 -0
  47. data/etc/templates/plugin_definition/lib/{entity}.rb.erb +34 -0
  48. data/etc/templates/plugin_definition/lib/{entity}/entity_definitions/{entity}_entity.rb.erb +11 -0
  49. data/etc/templates/plugin_definition/lib/{entity}/plugin_helper.rb.erb +17 -0
  50. data/etc/templates/plugin_definition/lib/{entity}/version.rb.erb +3 -0
  51. data/etc/templates/plugin_definition/lib/{entity}/{entity}_processor.rb.erb +19 -0
  52. data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +36 -0
  53. data/etc/templates/plugin_definition/spec/spec_helper.rb +14 -0
  54. data/etc/templates/plugin_definition/spec/{entity}_spec.rb +9 -0
  55. data/etc/templates/project/.copy_ignore +2 -0
  56. data/etc/templates/project/.gitignore.erb +6 -0
  57. data/etc/templates/project/.ps_project/entities/.gitkeep +0 -0
  58. data/etc/templates/project/.ps_project/entities/README.md +11 -0
  59. data/etc/templates/project/.ps_project/entity_definitions/.gitkeep +0 -0
  60. data/etc/templates/project/.ps_project/entity_definitions/README.md +15 -0
  61. data/etc/templates/project/.ps_project/personal-config.yaml +8 -0
  62. data/etc/templates/project/.ps_project/plugins/.gitkeep +0 -0
  63. data/etc/templates/project/.ps_project/templates-templates/.gitkeep +0 -0
  64. data/etc/templates/project/.ps_project/templates-templates/README.md +13 -0
  65. data/etc/templates/project/.ps_project/user_entities/.gitkeep +0 -0
  66. data/etc/templates/project/.ps_project/user_entities/README.md +12 -0
  67. data/etc/templates/project/.ps_project/versioned-config.yaml +6 -0
  68. data/etc/templates/simple_exec/main.sh +4 -0
  69. data/exe/power_stencil +28 -0
  70. data/lib/power_stencil.rb +53 -0
  71. data/lib/power_stencil/command_processors/build.rb +43 -0
  72. data/lib/power_stencil/command_processors/check.rb +35 -0
  73. data/lib/power_stencil/command_processors/create.rb +70 -0
  74. data/lib/power_stencil/command_processors/delete.rb +38 -0
  75. data/lib/power_stencil/command_processors/edit.rb +35 -0
  76. data/lib/power_stencil/command_processors/entity_helper.rb +105 -0
  77. data/lib/power_stencil/command_processors/get.rb +22 -0
  78. data/lib/power_stencil/command_processors/info.rb +41 -0
  79. data/lib/power_stencil/command_processors/init.rb +47 -0
  80. data/lib/power_stencil/command_processors/new_plugin.rb +31 -0
  81. data/lib/power_stencil/command_processors/root.rb +27 -0
  82. data/lib/power_stencil/command_processors/shell.rb +37 -0
  83. data/lib/power_stencil/command_processors/trace_helper.rb +20 -0
  84. data/lib/power_stencil/dsl/base.rb +24 -0
  85. data/lib/power_stencil/dsl/entities.rb +46 -0
  86. data/lib/power_stencil/dsl/plugin_generation.rb +17 -0
  87. data/lib/power_stencil/engine/base.rb +50 -0
  88. data/lib/power_stencil/engine/build_handling.rb +77 -0
  89. data/lib/power_stencil/engine/directory_processor.rb +111 -0
  90. data/lib/power_stencil/engine/entities_definitions.rb +42 -0
  91. data/lib/power_stencil/engine/entities_handling.rb +76 -0
  92. data/lib/power_stencil/engine/entity_engine.rb +20 -0
  93. data/lib/power_stencil/engine/init_engine.rb +18 -0
  94. data/lib/power_stencil/engine/project_engine.rb +75 -0
  95. data/lib/power_stencil/engine/renderers/erb.rb +21 -0
  96. data/lib/power_stencil/error.rb +20 -0
  97. data/lib/power_stencil/initializer.rb +87 -0
  98. data/lib/power_stencil/plugins/base.rb +54 -0
  99. data/lib/power_stencil/plugins/capabilities.rb +30 -0
  100. data/lib/power_stencil/plugins/command_line.rb +27 -0
  101. data/lib/power_stencil/plugins/config.rb +32 -0
  102. data/lib/power_stencil/plugins/dependencies.rb +32 -0
  103. data/lib/power_stencil/plugins/gem.rb +57 -0
  104. data/lib/power_stencil/plugins/require.rb +77 -0
  105. data/lib/power_stencil/plugins/templates.rb +21 -0
  106. data/lib/power_stencil/project/base.rb +79 -0
  107. data/lib/power_stencil/project/config.rb +54 -0
  108. data/lib/power_stencil/project/create.rb +30 -0
  109. data/lib/power_stencil/project/info.rb +72 -0
  110. data/lib/power_stencil/project/paths.rb +119 -0
  111. data/lib/power_stencil/project/plugins.rb +89 -0
  112. data/lib/power_stencil/project/proxy.rb +13 -0
  113. data/lib/power_stencil/project/templates.rb +56 -0
  114. data/lib/power_stencil/project/versioning.rb +29 -0
  115. data/lib/power_stencil/system_entity_definitions/all.rb +14 -0
  116. data/lib/power_stencil/system_entity_definitions/buildable.rb +23 -0
  117. data/lib/power_stencil/system_entity_definitions/entity_override.rb +8 -0
  118. data/lib/power_stencil/system_entity_definitions/entity_project_common.rb +33 -0
  119. data/lib/power_stencil/system_entity_definitions/has_associated_files.rb +13 -0
  120. data/lib/power_stencil/system_entity_definitions/non_persistent.rb +14 -0
  121. data/lib/power_stencil/system_entity_definitions/plugin.rb +17 -0
  122. data/lib/power_stencil/system_entity_definitions/process_descriptor.rb +15 -0
  123. data/lib/power_stencil/system_entity_definitions/project_config.rb +24 -0
  124. data/lib/power_stencil/system_entity_definitions/project_entity.rb +16 -0
  125. data/lib/power_stencil/system_entity_definitions/simple_exec.rb +47 -0
  126. data/lib/power_stencil/utils/directory_processor.rb +54 -0
  127. data/lib/power_stencil/utils/file_edit.rb +87 -0
  128. data/lib/power_stencil/utils/file_helper.rb +56 -0
  129. data/lib/power_stencil/utils/gem_utils.rb +13 -0
  130. data/lib/power_stencil/utils/secure_require.rb +26 -0
  131. data/lib/power_stencil/utils/semantic_version.rb +128 -0
  132. data/lib/power_stencil/version.rb +3 -0
  133. data/power_stencil.gemspec +32 -0
  134. metadata +287 -0
@@ -0,0 +1,111 @@
1
+ require 'fileutils'
2
+ require 'erb'
3
+
4
+ module PowerStencil
5
+ module Engine
6
+
7
+ module DirectoryProcessor
8
+
9
+ include PowerStencil::Utils::DirectoryProcessor
10
+
11
+ def render_source(source_dir, destination_dir, overwrite_files: false, main_entry_point: nil)
12
+ compiled_universe = root_universe.compile scenario: config[:scenario]
13
+ puts_and_logs 'Entities analysis completed.'
14
+
15
+ logger.info 'Generating target...'
16
+ setup_files_not_to_render source_dir
17
+ setup_files_not_to_rename source_dir
18
+ process_directory source: source_dir,
19
+ destination: destination_dir,
20
+ ignore_files_pattern: config[:ignore_filename_for_files_to_skip] do |src_file, dest_file|
21
+ dest_file = detemplatized_file_name(dest_file, main_entry_point) unless main_entry_point.nil?
22
+ if File.directory? src_file
23
+ check_or_build_target_directory dest_file
24
+ next
25
+ else
26
+ process_file src_file, dest_file,
27
+ compiled_universe,
28
+ overwrite_files: overwrite_files,
29
+ main_entry_point: main_entry_point
30
+ end
31
+ end
32
+ ensure
33
+ @rendering_context = nil
34
+ @files_not_to_render = nil
35
+ end
36
+
37
+ private
38
+
39
+ def detemplatized_file_name(filename, replacement_text)
40
+ replacement_text = replacement_text.tr '- /', '___'
41
+ filename.gsub '{entity}', replacement_text
42
+ end
43
+
44
+ attr_reader :files_not_to_render, :files_not_to_rename
45
+
46
+ def setup_files_not_to_render(source_dir)
47
+ @files_not_to_render = DirGlobIgnore::IgnoreFileLists.new source_dir
48
+ files_not_to_render.ignore_file_name = config[:ignore_filename_for_files_to_copy]
49
+ files_not_to_render.load_ignore_files
50
+ end
51
+
52
+ def setup_files_not_to_rename(source_dir)
53
+ @files_not_to_rename = DirGlobIgnore::IgnoreFileLists.new source_dir
54
+ files_not_to_rename.ignore_file_name = config[:ignore_filename_for_files_to_rename]
55
+ files_not_to_rename.load_ignore_files
56
+ end
57
+
58
+ def process_file(src_file, dest_file, universe, overwrite_files: false, main_entry_point: nil)
59
+ unless files_not_to_rename.ignore_file? src_file
60
+ config[:file_renaming_patterns].each do |regexp_str, replacement|
61
+ regexp = Regexp.new regexp_str
62
+ next if (dest_file =~ regexp).nil?
63
+ dest_file = dest_file.gsub regexp, replacement
64
+ break
65
+ end
66
+ end
67
+ if File.exist? dest_file
68
+ unless overwrite_files
69
+ logger.info "Skipping file '#{dest_file}'..."
70
+ return
71
+ end
72
+ end
73
+ check_or_build_target_directory File.dirname dest_file
74
+ source_mode = File.stat(src_file).mode
75
+ File.open(dest_file, 'w') do |f|
76
+ if files_not_to_render.ignore_file? src_file
77
+ logger.debug "Copying file '#{src_file}' to '#{dest_file}' (ignored for substitutions)."
78
+ f.write File.read src_file
79
+ else
80
+ logger.debug "Rendering file '#{src_file}' to '#{dest_file}'."
81
+ f.write render_template(src_file, universe, main_entry_point: main_entry_point)
82
+ end
83
+ end
84
+ File.chmod source_mode, dest_file
85
+ end
86
+
87
+
88
+ def check_or_build_target_directory(dir)
89
+ FileUtils.mkpath dir
90
+ end
91
+
92
+ def render_template(source, universe, main_entry_point: nil)
93
+ config[:templating_engines_map].each do |engine_name, file_pattern|
94
+ unless (source =~ /#{file_pattern}/).nil?
95
+ templating_engine_method_name = "render_#{engine_name}_template".to_sym
96
+ unless private_methods.include? templating_engine_method_name
97
+ raise PowerStencil::Error, "File '#{source}' is supposed to be rendered using '#{engine_name}', but seems not to be supported !"
98
+ end
99
+ context = running_context universe, main_entry_point: main_entry_point
100
+ return send templating_engine_method_name, source, context
101
+ end
102
+ end
103
+ logger.warn "File '#{source}' was supposed to be processed but there is no template engine defined ! Applying simple copy."
104
+ File.read source
105
+ end
106
+
107
+
108
+ end
109
+
110
+ end
111
+ end
@@ -0,0 +1,42 @@
1
+ module PowerStencil
2
+ module Engine
3
+
4
+ module EntitiesDefinition
5
+
6
+ SYSTEM_ENTITY_DEFINITION_ENTRY_POINT = 'power_stencil/system_entity_definitions/all'.freeze
7
+
8
+ include PowerStencil::Utils::SecureRequire
9
+
10
+ def require_definition_files(files_or_dirs)
11
+ required_files = []
12
+ files_or_dirs.each do |file_or_dir|
13
+ if File.directory? file_or_dir and File.readable? file_or_dir
14
+ Dir.entries(file_or_dir).grep(/\.rb$/).each do |file|
15
+ required_files << File.join(file_or_dir, file)
16
+ end
17
+ next
18
+ end
19
+ if File.file? file_or_dir and File.readable? file_or_dir
20
+ required_files << file_or_dir
21
+ next
22
+ end
23
+ # This is a ruby library or there is something wrong
24
+ securely_require file_or_dir
25
+ # unless securely_require file_or_dir
26
+ # logger.warn "While trying to load definition files, found that '#{file_or_dir}' has a problem. Ignored..."
27
+ # end
28
+ end
29
+ required_files.sort!.each {|file| securely_require file, fail_on_error: true}
30
+ required_files
31
+ end
32
+
33
+ private
34
+
35
+ def load_system_entities_definition
36
+ require_definition_files [SYSTEM_ENTITY_DEFINITION_ENTRY_POINT]
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,76 @@
1
+ module PowerStencil
2
+ module Engine
3
+
4
+ module EntitiesHandling
5
+
6
+ include Climatic::Utils::Input
7
+
8
+ def self.all_types
9
+ entities_base_type = UniverseCompiler::Entity::Base
10
+
11
+ klasses = ObjectSpace.each_object(Class).select do |klass|
12
+ klass < entities_base_type and not klass.singleton_class?
13
+ end
14
+ types = klasses.map &:entity_type
15
+
16
+ types.zip(klasses).to_h.reject do |t, k|
17
+ t.to_s.include? '/'
18
+ end
19
+ end
20
+
21
+ def available_entities_hash(force_rescan: false)
22
+ if force_rescan
23
+ available_entity_types force_rescan: true
24
+ end
25
+ @available_entities_hash
26
+ end
27
+
28
+ def available_entity_types(force_rescan: false)
29
+ if force_rescan
30
+ @available_entities_hash = PowerStencil::Engine::EntitiesHandling.all_types
31
+ else
32
+ @available_entities_hash ||= PowerStencil::Engine::EntitiesHandling.all_types
33
+ end
34
+ @available_entities_hash.keys
35
+ end
36
+
37
+ def entity(type, name, universe)
38
+ universe.get_entity type, name
39
+ end
40
+
41
+ def entities(universe, criterion: nil, value: nil, &filter_block)
42
+ universe.get_entities criterion: criterion, value: value, &filter_block
43
+ end
44
+
45
+ def delete_entity(work_universe, type, name, delete_files: false)
46
+ entity_to_delete = work_universe.get_entity type, name
47
+ get_user_confirmation prompt: "Are you sure you want delete '#{[type, name].join '/'}' ?" do
48
+ entity_to_delete.delete force_files_deletion: delete_files
49
+ entity_to_delete.universe = nil
50
+ entity_to_delete
51
+ end
52
+ end
53
+
54
+ def new_entity(work_universe, type, fields: {}, user: false)
55
+ logger.debug "Trying to create a new entity in '#{work_universe.name}'"
56
+ unless available_entity_types.include? type.to_sym
57
+ raise PowerStencil::Error, "Unknown entity type: '#{type}'"
58
+ end
59
+ fields[:name] = fields[:name].to_s
60
+ res = @available_entities_hash[type.to_sym].new fields: fields, universe: work_universe
61
+ logger.debug "Created new '#{type}': \n#{fields.to_yaml}"
62
+ work_universe.add res
63
+ if work_universe == PowerStencil.project.engine.root_universe
64
+ res.source_uri = user ? PowerStencil.project.user_entity_path(res) : PowerStencil.project.project_entity_path(res)
65
+ else
66
+ PowerStencil.logger.warn "Creating entity, but you won't be able to save it in compiled mode !"
67
+ end
68
+ res
69
+ end
70
+
71
+
72
+
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,20 @@
1
+ require 'power_stencil/engine/project_engine'
2
+
3
+ module PowerStencil
4
+ module Engine
5
+
6
+ class EntityEngine < PowerStencil::Engine::Base
7
+
8
+ UNIVERSE_BASENAME = 'Entities directory creation'.freeze
9
+
10
+ def initialize(universe = UniverseCompiler::Universe::Base.new(unique_name))
11
+ super
12
+ load_system_entities
13
+ end
14
+
15
+
16
+ end
17
+
18
+
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ require 'power_stencil/engine/base'
2
+
3
+ module PowerStencil
4
+ module Engine
5
+
6
+ class InitEngine < PowerStencil::Engine::Base
7
+
8
+ def initialize
9
+ super
10
+ root_universe.name = 'Project initialization universe'
11
+ load_system_entities_definition
12
+ load_system_entities
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,75 @@
1
+ require 'power_stencil/engine/base'
2
+ require 'power_stencil/engine/entities_handling'
3
+ require 'power_stencil/engine/build_handling'
4
+
5
+ module PowerStencil
6
+ module Engine
7
+
8
+ class ProjectEngine < PowerStencil::Engine::Base
9
+
10
+ include PowerStencil::Engine::EntitiesHandling
11
+ include PowerStencil::Engine::BuildHandling
12
+
13
+ attr_reader :project
14
+
15
+ def initialize(project)
16
+ super()
17
+ @project = project
18
+ load_system_entities_definition
19
+ load_plugins_entities_definition
20
+ load_project_entities_definition
21
+ load_entities
22
+ end
23
+
24
+ protected
25
+
26
+ def load_project_entities_definition
27
+ dir = project.project_entity_definitions_path
28
+ if Dir.exist? dir and File.readable? dir
29
+ logger.info 'Loading project specific entity definitions.'
30
+ $LOAD_PATH << dir
31
+ require_definition_files [dir]
32
+ end
33
+ end
34
+
35
+ def load_plugins_entities_definition
36
+ project.plugins.each do |plugin_name, plugin|
37
+ if plugin.capabilities[:entity_definitions]
38
+ logger.info "Loading entity definitions for plugin '#{plugin_name}'."
39
+ plugin.plugin_module.send PowerStencil::Plugins::Require::SETUP_ENTITY_DEFINITIONS_CALLBACK
40
+ end
41
+ end
42
+ end
43
+
44
+ def load_entities
45
+ root_universe.clear
46
+ load_system_entities
47
+ load_project_entities
48
+ load_user_entities
49
+ end
50
+
51
+ private
52
+
53
+ def load_project_entities
54
+ logger.debug 'Loading project entities - NOT IMPLEMENTED'
55
+ root_universe.import project.project_entities_path, stop_on_error: false do |new_entity|
56
+ process_entity new_entity
57
+ end
58
+ end
59
+
60
+ def load_user_entities
61
+ logger.debug 'Loading user entities - NOT IMPLEMENTED'
62
+ root_universe.import project.user_entities_path, stop_on_error: false do |new_entity|
63
+ process_entity new_entity
64
+ end
65
+ end
66
+
67
+ def process_entity(entity)
68
+ logger.debug "New entity: '#{entity.name}' (#{entity.type})"
69
+ end
70
+
71
+
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,21 @@
1
+ module PowerStencil
2
+ module Engine
3
+ module Renderers
4
+
5
+ module Erb
6
+
7
+ private
8
+
9
+ def render_erb_template(source, context)
10
+ logger.debug "Using ERB to render file '#{source}'"
11
+ ERB.new(File.read(source), nil, '-').result(context)
12
+ rescue => e
13
+ logger.debug PowerStencil::Error.report_error(e)
14
+ raise PowerStencil::Error, "Error rendering '#{source}': '#{e.message}'"
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ module PowerStencil
2
+ class Error < StandardError
3
+
4
+ DEFAULT_EXIT_CODE = 127
5
+
6
+ def exit_code=(val)
7
+ raise PowerStencil::Error, 'Invalid exit code !' unless val.is_a? Fixnum
8
+ @exit_code = val
9
+ end
10
+
11
+ def exit_code
12
+ @exit_code ||= DEFAULT_EXIT_CODE
13
+ end
14
+
15
+ def self.report_error(e)
16
+ "#{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}"
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,87 @@
1
+ require 'yaml'
2
+
3
+ module PowerStencil
4
+
5
+ module Initializer
6
+
7
+ BASE_COMMANDS_DEFINITION_FILE = 'base_commands_definition.yml'.freeze
8
+
9
+ include Climatic::Proxy
10
+
11
+ def bootstrap(cmd_line_args = ARGV.dup)
12
+ setup_climatic cmd_line_args
13
+ logger.debug 'Starting PowerStencil initialization...'
14
+ setup_system_processors
15
+ setup_universe_compiler_logger
16
+ # @project = try_to_load_project fail_on_error: false
17
+ begin
18
+ project.setup_templates_for_entities # unless project.nil?
19
+ rescue => e
20
+ logger.debug PowerStencil::Error.report_error e
21
+ end
22
+ logger.debug 'PowerStencil initialization complete'
23
+ end
24
+
25
+ def project
26
+ @project ||= try_to_load_project
27
+ end
28
+
29
+ private
30
+
31
+ include PowerStencil::Utils::FileHelper
32
+
33
+ def try_to_load_project(fail_on_error: true)
34
+ PowerStencil::Project::Base.instantiate_from_config config
35
+
36
+ end
37
+
38
+ def setup_system_processors
39
+ logger.debug 'Registering system processors'
40
+ {
41
+ '' => PowerStencil::CommandProcessors::Root,
42
+ init: PowerStencil::CommandProcessors::Init,
43
+ info: PowerStencil::CommandProcessors::Info,
44
+ get: PowerStencil::CommandProcessors::Get,
45
+ check: PowerStencil::CommandProcessors::Check,
46
+ create: PowerStencil::CommandProcessors::Create,
47
+ edit: PowerStencil::CommandProcessors::Edit,
48
+ delete: PowerStencil::CommandProcessors::Delete,
49
+ shell: PowerStencil::CommandProcessors::Shell,
50
+ :'new-plugin' => PowerStencil::CommandProcessors::NewPlugin,
51
+ build: PowerStencil::CommandProcessors::Build
52
+ }.each do |command_name, processor|
53
+ command_line_manager.register_processor command_line_manager.command_by_alias(command_name),
54
+ processor.new
55
+ end
56
+ end
57
+
58
+ def setup_climatic(cmd_line_args)
59
+ mngr = Climatic::ConfigLayers::CommandLineLayer.build_command_line_manager base_commands_definition_file
60
+ Climatic.bootstrap cmd_line_args: cmd_line_args, command_manager: mngr
61
+ begin
62
+ # Fix command line layer priority to allow a bigger number of plugins
63
+ config.command_line_layer.priority = 999
64
+ config.command_line_layer.reload
65
+ config.include_gem_layer_for :power_stencil
66
+ rescue Slop::UnknownOption => e
67
+ # Forget those errors. Will be caught later.
68
+ end
69
+
70
+ end
71
+
72
+ def setup_universe_compiler_logger
73
+ UniverseCompiler.logger = Climatic.logger
74
+ end
75
+
76
+ def base_commands_definition_file
77
+ File.join gempath, 'etc', BASE_COMMANDS_DEFINITION_FILE
78
+ end
79
+
80
+ def gempath
81
+ Climatic::ConfigLayers::ExecutableGemLayer.executable_gem_config_root
82
+ end
83
+
84
+
85
+ end
86
+
87
+ end