power_stencil 0.6.1 → 0.7.2

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +2 -0
  3. data/README.md +3 -7
  4. data/doc/builds.md +10 -1
  5. data/doc/entities.md +59 -50
  6. data/doc/images/power-stencil-entity-creation.svg +247 -114
  7. data/doc/plugins.md +1 -0
  8. data/doc/templates.md +23 -18
  9. data/etc/base_commands_definition.yml +14 -0
  10. data/etc/power_stencil.yaml +7 -1
  11. data/etc/templates/project/.zzzgitignore.erb +8 -3
  12. data/lib/power_stencil.rb +1 -0
  13. data/lib/power_stencil/command_processors/build.rb +15 -2
  14. data/lib/power_stencil/command_processors/check.rb +12 -0
  15. data/lib/power_stencil/command_processors/create.rb +6 -5
  16. data/lib/power_stencil/command_processors/delete.rb +23 -15
  17. data/lib/power_stencil/command_processors/edit.rb +4 -2
  18. data/lib/power_stencil/command_processors/plugin.rb +21 -6
  19. data/lib/power_stencil/command_processors/shell.rb +10 -3
  20. data/lib/power_stencil/dsl/entities.rb +0 -16
  21. data/lib/power_stencil/engine/entities_definitions.rb +16 -7
  22. data/lib/power_stencil/engine/entities_handling.rb +1 -1
  23. data/lib/power_stencil/engine/project_engine.rb +6 -10
  24. data/lib/power_stencil/initializer.rb +4 -7
  25. data/lib/power_stencil/plugins/entity_definitions.rb +15 -0
  26. data/lib/power_stencil/plugins/require.rb +1 -0
  27. data/lib/power_stencil/plugins/templates.rb +3 -3
  28. data/lib/power_stencil/project/base.rb +24 -9
  29. data/lib/power_stencil/project/create.rb +23 -2
  30. data/lib/power_stencil/project/git.rb +75 -0
  31. data/lib/power_stencil/project/info.rb +14 -1
  32. data/lib/power_stencil/project/paths.rb +22 -6
  33. data/lib/power_stencil/project/plugins.rb +1 -1
  34. data/lib/power_stencil/project/templates.rb +15 -22
  35. data/lib/power_stencil/system_entity_definitions/all.rb +2 -1
  36. data/lib/power_stencil/system_entity_definitions/buildable.rb +1 -1
  37. data/lib/power_stencil/system_entity_definitions/entity_override.rb +6 -0
  38. data/lib/power_stencil/system_entity_definitions/entity_project_common.rb +13 -5
  39. data/lib/power_stencil/system_entity_definitions/{has_associated_files.rb → entity_templates.rb} +2 -2
  40. data/lib/power_stencil/system_entity_definitions/project_config.rb +1 -1
  41. data/lib/power_stencil/system_entity_definitions/project_entity.rb +7 -0
  42. data/lib/power_stencil/system_entity_definitions/simple_exec.rb +3 -3
  43. data/lib/power_stencil/system_entity_definitions/source_provider.rb +15 -0
  44. data/lib/power_stencil/version.rb +1 -1
  45. data/power_stencil.gemspec +1 -0
  46. metadata +20 -4
@@ -11,7 +11,7 @@ module PowerStencil
11
11
  raise PowerStencil::Error, "Plugin '#{plugin_name}' already exists !" if plugins.keys.include? plugin_name
12
12
  raise PowerStencil::Error, "Invalid plugin name '#{plugin_name}'" if (plugin_name.underscore =~ /^[_[:lower:]][_[:alnum:]]*$/).nil?
13
13
  entity_engine.dsl = PowerStencil::Dsl::PluginGeneration
14
- entity_engine.render_source entity_type_templates[:plugin_definition],
14
+ entity_engine.render_source entity_type_templates_templates[:plugin_definition],
15
15
  new_plugin_path,
16
16
  overwrite_files: overwrite_files,
17
17
  main_entry_point: plugin_name
@@ -3,48 +3,41 @@ module PowerStencil
3
3
 
4
4
  module Templates
5
5
 
6
- def setup_templates_for_entities
7
- plugins.each do |plugin_name, plugin|
8
- logger.debug "Checking if plugin '#{plugin_name}' declares some templates..."
9
- plugin.register_plugin_templates
10
- end
11
- end
12
-
13
- def entity_type_templates
14
- @entity_type_templates ||= {}
6
+ def entity_type_templates_templates
7
+ @entity_type_templates_templates ||= {}
15
8
  end
16
9
 
17
- def register_template_path_for_type(entity_type, path)
18
- if entity_type_templates.include? entity_type
19
- logger.warn "There is already a template-template path registered for entity type '#{entity_type}': '#{entity_type_templates[entity_type]}'."
10
+ def register_template_template_path_for_type(entity_type, path)
11
+ if entity_type_templates_templates.include? entity_type
12
+ logger.warn "There is already a template-template path registered for entity type '#{entity_type}': '#{entity_type_templates_templates[entity_type]}'."
20
13
  end
21
14
  raise PowerStencil::Error, "There is no template in path: '#{path}'" unless Dir.exist? path and File.readable? path
22
15
  raise PowerStencil::Error, "Trying to register a template for non existing type '#{entity_type}'" unless engine.available_entity_types.include? entity_type
23
16
  logger.debug "Registering '#{path}' as template for type '#{entity_type}'."
24
- entity_type_templates[entity_type] = path
17
+ entity_type_templates_templates[entity_type] = path
25
18
  end
26
19
 
27
- def generate_entity_dir_for_entity(entity, force: false)
28
- unless entity_type_templates[entity.type].nil?
20
+ def generate_template_dir_for_entity(entity, force: false)
21
+ unless entity_type_templates_templates[entity.type].nil?
29
22
  logger.debug "Generating entity dir for entity '#{entity.as_path}'"
30
- target_path = File.join project_root, entity.type.to_s, entity.name.to_s
31
- render_entity_template_in entity, target_path, force: force
23
+ target_path = entity.templates_path
24
+ render_entity_template_template_in entity, target_path, force: force
32
25
  end
33
26
  end
34
27
 
35
- def delete_entity_dir_for_entity(entity, force: false)
28
+ def delete_template_dir_for_entity(entity, force: false)
36
29
  return unless force
37
- unless entity_type_templates[entity.type].nil?
30
+ unless entity_type_templates_templates[entity.type].nil?
38
31
  logger.debug "Deleting entity files for entity '#{entity.as_path}'"
39
- target_path = File.join project_root, entity.type.to_s, entity.name.to_s
32
+ target_path = entity.templates_path
40
33
  FileUtils.rmtree target_path unless target_path.nil? or target_path.empty?
41
34
  end
42
35
  end
43
36
 
44
37
  private
45
38
 
46
- def render_entity_template_in(entity, entity_dir_path, force: false)
47
- entity_engine.render_source entity_type_templates[entity.type],
39
+ def render_entity_template_template_in(entity, entity_dir_path, force: false)
40
+ entity_engine.render_source entity_type_templates_templates[entity.type],
48
41
  entity_dir_path,
49
42
  overwrite_files: force,
50
43
  main_entry_point: entity.name
@@ -2,7 +2,8 @@
2
2
  # So it is safe to declare files in the order you need.
3
3
 
4
4
  require 'power_stencil/system_entity_definitions/non_persistent'
5
- require 'power_stencil/system_entity_definitions/has_associated_files'
5
+ require 'power_stencil/system_entity_definitions/entity_templates'
6
+ require 'power_stencil/system_entity_definitions/source_provider'
6
7
  require 'power_stencil/system_entity_definitions/buildable'
7
8
  require 'power_stencil/system_entity_definitions/entity_project_common'
8
9
 
@@ -10,7 +10,7 @@ module PowerStencil
10
10
  def buildable_by(plugin_name = nil)
11
11
  return @build_plugin_name if plugin_name.nil?
12
12
  @build_plugin_name = plugin_name
13
- self.include PowerStencil::SystemEntityDefinitions::HasAssociatedFiles
13
+ self.include PowerStencil::SystemEntityDefinitions::EntityTemplates
14
14
  end
15
15
 
16
16
  def buildable?
@@ -1,8 +1,14 @@
1
1
  class UniverseCompiler::Entity::Override
2
2
 
3
+ extend PowerStencil::SystemEntityDefinitions::SourceProvider
3
4
  extend PowerStencil::SystemEntityDefinitions::Buildable
4
5
  include PowerStencil::SystemEntityDefinitions::EntityProjectCommon
5
6
 
6
7
  field :description
7
8
 
9
+ def initialize(fields: {}, universe: nil, user: false)
10
+ @is_versioned_entity = not(user)
11
+ super(fields: fields, universe: universe)
12
+ end
13
+
8
14
  end
@@ -3,17 +3,25 @@ module PowerStencil
3
3
 
4
4
  module EntityProjectCommon
5
5
 
6
- def save(uri = source_uri, raise_error: true, force_save: false, force_files_generation: false )
6
+ def is_versioned_entity?
7
+ @is_versioned_entity
8
+ end
9
+
10
+ def is_user_entity?
11
+ not(@is_versioned_entity)
12
+ end
13
+
14
+ def save(uri = source_uri, raise_error: true, force_save: false, force_files_generation: false )
7
15
  super(source_uri, raise_error: raise_error, force_save: force_save)
8
- unless PowerStencil.project.entity_type_templates[type].nil?
9
- PowerStencil.project.generate_entity_dir_for_entity self, force: force_files_generation
16
+ unless PowerStencil.project.entity_type_templates_templates[type].nil?
17
+ PowerStencil.project.generate_template_dir_for_entity self, force: force_files_generation
10
18
  end
11
19
  self
12
20
  end
13
21
 
14
22
  def delete(force_files_deletion: false)
15
- unless PowerStencil.project.entity_type_templates[type].nil?
16
- PowerStencil.project.delete_entity_dir_for_entity self, force: force_files_deletion
23
+ unless PowerStencil.project.entity_type_templates_templates[type].nil?
24
+ PowerStencil.project.delete_template_dir_for_entity self, force: force_files_deletion
17
25
  end
18
26
  super()
19
27
  self
@@ -1,10 +1,10 @@
1
1
  module PowerStencil
2
2
  module SystemEntityDefinitions
3
3
 
4
- module HasAssociatedFiles
4
+ module EntityTemplates
5
5
 
6
6
  def templates_path
7
- File.join PowerStencil.project.project_root, type.to_s, name
7
+ PowerStencil.project.entity_template_path self
8
8
  end
9
9
 
10
10
  end
@@ -11,7 +11,7 @@ module PowerStencil
11
11
 
12
12
  field_reader :simulate, :debug
13
13
 
14
- def initialize(fields: {}, universe: nil)
14
+ def initialize(fields: {}, universe: nil, user: false)
15
15
  super
16
16
  self.name = 'Project Config'
17
17
  end
@@ -3,6 +3,7 @@ module PowerStencil
3
3
 
4
4
  class ProjectEntity < UniverseCompiler::Entity::Base
5
5
 
6
+ extend PowerStencil::SystemEntityDefinitions::SourceProvider
6
7
  extend PowerStencil::SystemEntityDefinitions::Buildable
7
8
  include PowerStencil::SystemEntityDefinitions::EntityProjectCommon
8
9
 
@@ -10,6 +11,12 @@ module PowerStencil
10
11
 
11
12
  field :description
12
13
 
14
+ def initialize(fields: {}, universe: nil, user: false)
15
+ @is_versioned_entity = not(user)
16
+ super(fields: fields, universe: universe)
17
+ end
18
+
19
+
13
20
  end
14
21
 
15
22
  end
@@ -3,13 +3,13 @@ module PowerStencil
3
3
 
4
4
  class SimpleExec < PowerStencil::SystemEntityDefinitions::ProjectEntity
5
5
 
6
- include PowerStencil::SystemEntityDefinitions::HasAssociatedFiles
6
+ include PowerStencil::SystemEntityDefinitions::EntityTemplates
7
7
 
8
8
  DOC = 'Describes a simple process to be called after source files have been rendered'.freeze
9
9
 
10
10
  entity_type :simple_exec
11
11
 
12
- buildable_by ''
12
+ buildable
13
13
 
14
14
  has_one :process_descriptor, name: :post_process
15
15
  not_null :post_process
@@ -20,7 +20,7 @@ module PowerStencil
20
20
  self.post_process = PowerStencil.project.engine.new_entity universe, :process_descriptor, fields: {
21
21
  name: "simple_exec_#{name}.process",
22
22
  process: './main.sh'
23
- }
23
+ }, user: is_user_entity?
24
24
  end
25
25
  end
26
26
  super(raise_error: raise_error)
@@ -0,0 +1,15 @@
1
+ module PowerStencil
2
+ module SystemEntityDefinitions
3
+
4
+ module SourceProvider
5
+
6
+ DEFAULT_PROVIDER = PowerStencil
7
+
8
+ def entity_type_source_provider
9
+ @entity_type_source_provider ||= DEFAULT_PROVIDER
10
+ end
11
+
12
+ end
13
+
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module PowerStencil
2
- VERSION = '0.6.1'.freeze
2
+ VERSION = '0.7.2'.freeze
3
3
  end
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'dir_glob_ignore', '~> 0.3'
30
30
  spec.add_dependency 'universe_compiler', '~> 0.5.1'
31
31
  spec.add_dependency 'pry'
32
+ spec.add_dependency 'git' , '~> 1.5.0'
32
33
 
33
34
  source_code_uri = 'https://gitlab.com/tools4devops/power_stencil'
34
35
 
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.6.1
4
+ version: 0.7.2
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-10-27 00:00:00.000000000 Z
11
+ date: 2019-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: git
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.5.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.5.0
111
125
  description: PowerStencil is the Swiss-army knife templating workflow for developers
112
126
  and ops.
113
127
  email:
@@ -240,6 +254,7 @@ files:
240
254
  - lib/power_stencil/project/base.rb
241
255
  - lib/power_stencil/project/config.rb
242
256
  - lib/power_stencil/project/create.rb
257
+ - lib/power_stencil/project/git.rb
243
258
  - lib/power_stencil/project/info.rb
244
259
  - lib/power_stencil/project/paths.rb
245
260
  - lib/power_stencil/project/plugins.rb
@@ -250,13 +265,14 @@ files:
250
265
  - lib/power_stencil/system_entity_definitions/buildable.rb
251
266
  - lib/power_stencil/system_entity_definitions/entity_override.rb
252
267
  - lib/power_stencil/system_entity_definitions/entity_project_common.rb
253
- - lib/power_stencil/system_entity_definitions/has_associated_files.rb
268
+ - lib/power_stencil/system_entity_definitions/entity_templates.rb
254
269
  - lib/power_stencil/system_entity_definitions/non_persistent.rb
255
270
  - lib/power_stencil/system_entity_definitions/plugin.rb
256
271
  - lib/power_stencil/system_entity_definitions/process_descriptor.rb
257
272
  - lib/power_stencil/system_entity_definitions/project_config.rb
258
273
  - lib/power_stencil/system_entity_definitions/project_entity.rb
259
274
  - lib/power_stencil/system_entity_definitions/simple_exec.rb
275
+ - lib/power_stencil/system_entity_definitions/source_provider.rb
260
276
  - lib/power_stencil/utils/directory_processor.rb
261
277
  - lib/power_stencil/utils/file_edit.rb
262
278
  - lib/power_stencil/utils/file_helper.rb
@@ -275,7 +291,7 @@ metadata:
275
291
  documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
276
292
  source_code_uri: https://gitlab.com/tools4devops/power_stencil
277
293
  homepage_uri: https://powerstencil.brizone.org/
278
- post_install_message: "\nThank you for installing PowerStencil 0.6.1 !\nFrom the command
294
+ post_install_message: "\nThank you for installing PowerStencil 0.7.2 !\nFrom the command
279
295
  line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
280
296
  \ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
281
297
  \ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel