power_stencil 0.4.6 → 0.4.11

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: cf42bb3aa3fce0dcef410238959e9394cc65f0ff
4
- data.tar.gz: 7de48ededf8571e15521a0b24e4b38ea2371e56e
3
+ metadata.gz: 94f31697927b7c398f3479e6119e5ec7b9ada878
4
+ data.tar.gz: 1aa4ee24ce33bb0d056a471cde643d85c804b369
5
5
  SHA512:
6
- metadata.gz: 2740f61ea898b2996ad83818de653ad63ac5a737afa0a41bc18351a5b745d0ce3d27d46813572f283e290b576babecf64df6be36ec8159abfa178054260c872d
7
- data.tar.gz: 710d575d1ca588505ca2c4cd58d60f55c7b530a6466634f26751906a0ab86735343e9f483b3e07c757033d3d85a97d88e0b75463648ba27eeab82c9872d85877
6
+ metadata.gz: 903b071f3761253f8dcb766bd1d340a494115f6a5483d5346872488074c023ebf9b1fd573510f64fbfa53abddcdcdd944ac8ea778d528188748d6be7f6af6cfe
7
+ data.tar.gz: 6df31360e4f082f1a45e80120d49057da5222e3f8466a02c71bafe31e39b6047a9223e5eb793c0c50b5b88d4802105cdbeaac86e750d000539b067f6768aa980
@@ -0,0 +1,9 @@
1
+ image: "ruby:2.3"
2
+
3
+ before_script:
4
+ - gem install bundler --no-document
5
+ - bundle install --jobs $(nproc) "${FLAGS[@]}"
6
+
7
+ rspec:
8
+ script:
9
+ - bundle exec rspec
data/README.md CHANGED
@@ -1,18 +1,27 @@
1
1
  PowerStencil
2
2
  ============
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/power_stencil.svg)](https://rubygems.org/gems/power_stencil) [![Pipeline status](https://gitlab.com/tools4devops/power_stencil/badges/master/pipeline.svg)](https://gitlab.com/tools4devops/power_stencil/commits/master)
5
+
4
6
  `Power Stencil` is the Swiss-army knife templating workflow for developers and ops.
5
7
 
8
+ See [official website][PowerStencil site].
9
+
10
+
6
11
  <!-- TOC -->
7
12
 
8
13
  - [Overview](#overview)
9
- - [Pfff, yet another templating engine...](#pfff-yet-another-templating-engine)
14
+ - [Pfff, yet another templating engine...?](#pfff-yet-another-templating-engine)
10
15
  - [Installation](#installation)
11
16
  - [Usage](#usage)
12
17
  - [Help](#help)
13
18
  - [Creating a `PowerStencil` project](#creating-a-powerstencil-project)
14
19
  - [`PowerStencil` project structure](#powerstencil-project-structure)
15
20
  - [Getting started](#getting-started)
21
+ - [Entities](#entities)
22
+ - [Templates](#templates)
23
+ - [Builds](#builds)
24
+ - [Plugins](#plugins)
16
25
  - [Project status](#project-status)
17
26
  - [Contributing](#contributing)
18
27
  - [License](#license)
@@ -24,7 +33,7 @@ PowerStencil
24
33
 
25
34
  `PowerStencil` proposes a radical approach on how to manage your shared configuration.
26
35
 
27
- **Configuration** is one of the most complex things to maintain, and anyone who participated in a large scale piece of software or documentation knows how complex it is to maintain, **keep consistent and avoid duplication** on the long run across the various projects that may share this configuration.
36
+ **Configuration** is one of the most complex things to maintain, and anyone who participated in a large scale piece of software, be it for code, tools configuration or even documentation, knows how complex it is to maintain, **keep consistent and avoid duplication** on the long run, across the various projects that may share this configuration.
28
37
 
29
38
  From a very high level point of view, the workfow `PowerStencil` proposes looks like:
30
39
 
@@ -32,39 +41,49 @@ From a very high level point of view, the workfow `PowerStencil` proposes looks
32
41
 
33
42
  `PowerStencil` provides **development and operations friendly workflows to fully manage the maintenance of a complex shared config** in order to generate anything you may want like _documentation_, _static sites_, _code_, _configuration_ for multiple tools..., while **avoiding duplication, and manage it like code** !
34
43
 
35
- It is a common pattern to introduce a database to manage shared configuration for CI/CD processes, and it is a very bad idea (see [F.A.Q.]) because it implies extra tooling, and specific developments that de-facto become single point of failure at the heart of your development process. Why would you do that when something as versatile and ubiquitous as Git exists that will integrate smoothly within your existing development and operations workflows, builds, CI/CD processes, while benefiting from all the goodness provided by Git, like branches, decentralization, versioning, tags, code reviews, traceability, simplified fallbacks etc... ?
44
+ It is a common pattern to introduce a database to manage shared configuration for CI/CD processes, and it is a very bad idea (see [F.A.Q.][DB in F.A.Q.]) because it implies extra tooling, and specific developments that de-facto become single point of failure at the heart of your development process. Why would you do that when something as versatile and ubiquitous as Git exists that will integrate smoothly within your existing development and operations workflows, builds, CI/CD processes, while benefiting from all the goodness provided by Git, like branches, decentralization, versioning, tags, code reviews, traceability, simplified fallbacks etc... ?
36
45
 
37
46
  A `PowerStencil` project is composed of a data repository and a pretty standard templating flow to generate whatever is needed by your project or organization and **with `PowerStencil` everything is maintained in a git repository**: data, templates, specific code **without sacrificing on data integrity and relational features**. No more config loss, no more change applied without a full lineage.
38
47
 
39
- **:information_source: With `PowerStencil` data can either be managed as documents to edit (Yaml) or code !!**. Use the best method depending on what you are doing.
48
+ **:information_source: With `PowerStencil` data can either be managed as documents to edit (Yaml) or fully as code within a powerful shell !!**. Choose the method that fits the most to what you are doing.
40
49
 
41
50
  The `PowerStencil` gem provides the `power_stencil` executable which is a pluggable CLI to:
42
51
 
43
- - Manage the project data
44
- - Manage templates
45
- - Manage builds
46
- - Create and manipulate plugins
52
+ - Manage your project **relational-integrity-checked data** in a versioned, git diff friendly yet flexible format.
53
+ - Visualize your **data relations with graphviz**. Customize generated graphs easily.
54
+ - Easily **manage templates** to generate whatever your project/organization requires.
55
+ - Define builds that you can easily **embed in your CI/CD process** or use them standalone.
56
+ - Propose mechanism to temporarily override some data to test changes impact without polluting the official repository data.
57
+ - Ensure **re-usability** with a versatile extension mechanism, including plugins.
58
+
59
+ # Pfff, yet another templating engine...?
60
+
61
+ **Actually `PowerStencil` is _not_ a templating engine**. It uses already existing and proven templating engines.
62
+
63
+ Currently it uses [ERB], which is a pretty standard and very well known engine in the [Ruby] world and especially for people who already used the [Rails] framework. Virtually any templating engine existing in the Ruby ecosystem could be integrated in the `PowerStencil` framework next to [ERB] (as `PowerStencil` already comes with a mechanism to select a templating engine regarding some criteria like file extension, path etc...).
47
64
 
48
- # Pfff, yet another templating engine...
65
+ This will probably be the case in a future release, at least to integrate the [Haml] templating engine in order to ease the generation of XML-like files, still you obviously already can do it with [ERB].
49
66
 
50
- **Actually `PowerStencil` is _not_ a templating engine** per se. Instead it uses already existing and proven templating engines.
51
- Currently it uses [ERB], which is pretty standard in [Ruby] world, but this is not hardcoded and any templating engine could be used (in parallel, meaning different templating engines can be used automatically depending on what you actually want to generate), even if only [ERB] is implemented for the time-being, `PowerStencil` is modular from ground-up and at least a second implementation for [Haml] templating engine is planned to ease generation of XML-like files, still currently you can do it with [ERB]. See the [templates] section for more information about templates in `PowerStencil`.
67
+ So `PowerStencil` is definitely not a templating it is actually much more than that.
52
68
 
53
- No, the real value of `PowerStencil` is not really in its templating capabilities even if very powerful, but in the development flow it proposes around this templating mechanism for both development and/or operations teams, in the way you organize and trace the data which is the real asset, and in the way you can easily extend it to fit the particular needs of a project or organization.
54
69
 
55
70
  # Installation
56
71
 
57
- You need a working install of the [Ruby] language (>= 2.2).
72
+ You need a working install of the [Ruby] language (>= 2.3).
58
73
 
59
- You can install the `PowerStencil` gem by issuing the usual:
74
+ Then you can install the `PowerStencil` gem by issuing the usual:
60
75
 
61
76
  $ gem install power_stencil
62
77
 
78
+ If you want to create graphviz graphs, you probably may want to install it for your system. If you are using an _apt-based_ system like Ubuntu or Debian it may probably be as simple as:
79
+
80
+ $ sudo apt install graphviz
81
+
63
82
  # Usage
64
83
 
65
84
  ## Help
66
85
 
67
- The `power_stencil` CLI provides a contextual help. You can start by:
86
+ The `power_stencil` CLI provides a contextual help. You can begin with:
68
87
 
69
88
  $ power_stencil --help
70
89
 
@@ -109,13 +128,13 @@ The program uses the standard paradigm of sub-commands (à-la-git), and each can
109
128
 
110
129
  ## Creating a `PowerStencil` project
111
130
 
112
- To create a new project, use the `init` sub-command. It works as you would expect. If you run it in an existing directory it will create the project here but you can specify the directory where you want the project to be created (the path will be created provided you have the rights on the filesystem):
131
+ To create a new project, use the `init` sub-command. It works as you would expect. If you run it in an existing directory it will create the project here but you can specify the directory where you want the project to be created (the path will be created provided you have enough rights on the filesystem):
113
132
 
114
133
  $ power_stencil init /where/you/want/your/project
115
134
 
116
135
  Once the project created, if you are anywhere within the project tree, you don't need to specify the project path anymore (if needed, any `power_stencil` sub-command supports a `--project-path` option). If you're used to the Git command line, it works the same way, and you should not feel in uncharted territory...
117
136
 
118
- :information_source: The rest of this documentation will assume you are at the root of this created project.
137
+ **:information_source: The rest of this documentation will assume you are at the root of this created project.**
119
138
 
120
139
  **:information_source: Of course, once you've been creating a new project, you should version it with Git:**
121
140
 
@@ -144,38 +163,47 @@ The structure of a brand new `PowerStencil` project is the following:
144
163
  │   └── README.md
145
164
  └── versioned-config.yaml
146
165
  ```
147
- New directories will appear once you start some [builds] or when you will define [templates], but this is the initial state.
148
166
 
149
- Not all the files in this directory should be versioned, and this the reason why there is a preconfigured `.gitignore` at the root of the project. It is prefilled so that unless you want to specifically avoid a file to be versioned, you don't need any action regarding `PowerStencil` project files.
167
+ Other directories will appear once you start working with the project, perform some [builds] or when you will define [templates], but this is the initial state.
168
+
169
+ Not all the files in this directory should be versioned, and this the reason why there is a preconfigured `.gitignore` at the root of the project. It is prefilled so that unless you want to specifically avoid a file to be versioned, you don't need to worry regarding `PowerStencil` project files. **By default everything that must be versioned actually is and everything that shouldn't isn't**.
150
170
 
151
- The project has two distinct config files. Keep the official project config in the `.ps_project/versioned-config.yaml` which, as its name suggest will be versioned. But any developer who wants to temporarily override some configuration should do it in the `.ps_project/personal-config.yaml` which is not be versioned. The content defined in the latter overrides the content of the official one. This is a clean way for anyone who wants to test something to safely do it locally without the risk to pollute the central repo.
171
+ The project has two distinct config files.
152
172
 
153
- There is the same mechanism between `.ps_project/entities` and `.ps_project/user_entities`, but as opposed to the two aforementioned config files you should not edit anything directly there, but instead interact using the CLI. More information on how to manage entities [here][entities].
173
+ - Keep the official project config in the `.ps_project/versioned-config.yaml` which, as its name suggest, will be git versioned.
174
+ - But any developer who wants to temporarily override some configuration should do it in the `.ps_project/personal-config.yaml`, which is not to be versioned. The content defined in the latter will override the content of the versioned one.
154
175
 
155
- The `plugins` directory can optionally contain project specific plugins. Plugins are a great way to extend `PowerStencil` for the needs of a project or organization. See the [plugins] documentation.
176
+ **This is a clean way for anyone who wants to test something to safely do it locally without the risk to pollute the central repo.**
177
+
178
+ There is the same mechanism between `.ps_project/entities` (where the project data is stored and which is versioned) and `.ps_project/user_entities` (where local data is stored and not versioned), but as opposed to the two aforementioned config files, you should not edit anything directly there, but instead use the CLI or the shell. More information on how to manage entities [here][entities].
179
+
180
+ The `plugins` directory can optionally contain project specific plugins. Plugins are a great way to extend `PowerStencil` for the needs of a project or organization.
156
181
 
157
182
  ## Getting started
158
183
 
159
- The core of the system is the `entity`, so you should start by having a look at what entities are, how they are easily managed using the `PowerStencil` CLI and shell.
184
+ See the four following topics as a kind of tutorial on `PowerStencil`. You should read them in order, as each of them assumes you already read the previous one.
185
+
186
+ ### Entities
160
187
 
161
- > :arrow_forward: [Entities]
188
+ The **core of the system** is the **[entity][entities]**, so you should start by having a look at what entities are, how they are easily managed using the `PowerStencil` CLI and shell.
162
189
 
163
- Then it is important to understand how to use entities within `templates`. Templates are the way to generate something (doc, code, descriptors, sites, whatever...) from the data that the entities represent.
190
+ ### Templates
164
191
 
165
- > :arrow_forward: [Templates]
192
+ Then it is important to understand how to use entities within **[templates]**. Templates are the way to **generate whatever you need** (doc, code, descriptors, sites, whatever...) from the data that the entities represent.
166
193
 
167
- The mechanism that combines entities and templates is called a `build`. A build is always attached to an entity (you build something). The result of a build is a set of files. Optionally an action can be triggered after the files are generated (could be as simple as calling a script that has been generated).
194
+ ### Builds
168
195
 
169
- > :arrow_forward: [Builds]
196
+ The mechanism that **combines entities and templates** is called a **[build][builds]**. A build is always attached to an entity (you build something). The result of a build is a set of files. Optionally an action can be triggered after the files are generated (could be as simple as calling a script that has been generated).
170
197
 
171
- `PowerStencil` could stop there, and you would be able to do whatever you want, but there is a whole world beyond. `Plugins` provide a way to completely extend `PowerStencil`, further control relations between entities, implement complex post-build actions, add CLI sub-commands and options. Plugins can be local to the project or coming in the form of standard Ruby Gems ! The icing on the cake...
198
+ ### Plugins
172
199
 
173
- > :arrow_forward: [Plugins]
200
+ `PowerStencil` could stop there, and you would be able to do whatever you want, but there is a whole world beyond. **[Plugins]** provide a way to completely **extend `PowerStencil` and ease cross-projects share and re-usability**, further control relations between entities, implement complex post-build actions, add CLI sub-commands and options.
201
+ Plugins can be local to the project or coming in the form of standard Ruby Gems ! The icing on the cake...
174
202
 
175
- And course, you may:
203
+ <br>
204
+ <br>
176
205
 
177
- - Read the [F.A.Q.]
178
- - See some real world [example use cases].
206
+ And course, you may want to **read the [F.A.Q.]**
179
207
 
180
208
  # Project status
181
209
 
@@ -203,6 +231,7 @@ Everyone interacting in the PowerStencil project’s codebases, issue trackers,
203
231
  [example use cases]: doc/example_use_cases.md "Example uses cases using PowerStencil"
204
232
  [F.A.Q.]: doc/faq.md "PowerStencil F.A.Q."
205
233
  [status in the F.A.Q.]: doc/faq.md#what-is-the-status-of-powerstencil- "PowerStencil project status"
234
+ [DB in F.A.Q.]: doc/faq.md#why-is-a-real-database-a-bad-idea-as-configuration-store-for-cicd- "Databases in build processes"
206
235
  [code of conduct]: CODE_OF_CONDUCT.md
207
236
 
208
237
  <!-- Code links -->
@@ -216,3 +245,5 @@ Everyone interacting in the PowerStencil project’s codebases, issue trackers,
216
245
  [ERB]: https://ruby-doc.org/stdlib-2.6.3/libdoc/erb/rdoc/ERB.html "Quick ERB description"
217
246
  [Haml]: http://haml.info/ "The templating engine for XML-like documents"
218
247
  [Ruby]: https://www.ruby-lang.org "The powerful Ruby language"
248
+ [Rails]: https://rubyonrails.org/ "The Ruby on Rails framework"
249
+ [PowerStencil site]: https://powerstencil.brizone.org "Official PowerStencil website"
@@ -16,6 +16,7 @@ Builds
16
16
 
17
17
  # Overview of the build process
18
18
 
19
+ **:warning: You should have already read the documentation about [templates], before reading this.**
19
20
 
20
21
  You build a [buildable] entity by issuing `power_stencil build <entity_type>/<entity_name>`. If you try to build an entity which is not buildable, the process fail with an error message.
21
22
 
@@ -115,7 +116,7 @@ You may have noticed from the output of `power_stencil info` that there is a typ
115
116
 
116
117
  This is a very specific type of entity linked to the compilation process.
117
118
 
118
- The goal of this specific entity is to provide a mechanism to override some of the properties of other entities in the scope of a _build scenario_. This is really a feature turned towards testing possibilities, by it for developers or ops, and as such generally `entity_override` are often created as [local entities] (although they really could be created as standard versioned entities).
119
+ The goal of this specific entity is to provide a mechanism to override some of the properties of other entities in the scope of a _build scenario_. This is really a feature turned towards testing possibilities, be it for developers or ops, and as such generally `entity_override` are often created as [local entities] (although they really could be created as standard versioned entities).
119
120
 
120
121
  Let's create our first override:
121
122
 
@@ -10,7 +10,7 @@ Entities
10
10
  - [Loose schema entities](#loose-schema-entities)
11
11
  - [Manipulating entities](#manipulating-entities)
12
12
  - [Checking entities](#checking-entities)
13
- - [Querying entities](#querying-entities)
13
+ - [Querying and graphing entities](#querying-and-graphing-entities)
14
14
  - [Creating entities](#creating-entities)
15
15
  - [Versioned entities](#versioned-entities)
16
16
  - [Local (unversioned) entities](#local-unversioned-entities)
@@ -25,14 +25,16 @@ Entities
25
25
  - [entity_type](#entity_type)
26
26
  - [auto_named_entity_type](#auto_named_entity_type)
27
27
  - [field](#field)
28
- - [has_one](#has_one)
29
- - [has_many](#has_many)
30
- - [is_array](#is_array)
31
- - [is_hash](#is_hash)
32
- - [not_null](#not_null)
33
- - [not_empty](#not_empty)
34
- - [should_match](#should_match)
35
- - [class_name](#class_name)
28
+ - [Integrity constraints](#integrity-constraints)
29
+ - [is_array](#is_array)
30
+ - [is_hash](#is_hash)
31
+ - [not_null](#not_null)
32
+ - [not_empty](#not_empty)
33
+ - [should_match](#should_match)
34
+ - [class_name](#class_name)
35
+ - [Relational constraints](#relational-constraints)
36
+ - [has_one](#has_one)
37
+ - [has_many](#has_many)
36
38
  - [buildable and buildable_by](#buildable-and-buildable_by)
37
39
  - [Module you could include in your entity types](#module-you-could-include-in-your-entity-types)
38
40
  - [Adding functional code](#adding-functional-code)
@@ -224,7 +226,7 @@ RAW ENTITIES
224
226
  - Buildable : false
225
227
  ```
226
228
 
227
- ## Querying entities
229
+ ## Querying and graphing entities
228
230
 
229
231
  The command to query entities from the repository is `power_stencil get`, and it works basically like the `power_stencil check` command.
230
232
 
@@ -612,116 +614,11 @@ PowerStencil DSL> e.fields['another_field']
612
614
  - The `name` field that we already saw and which is mandatory.
613
615
  - The `description` field which is optional, and which is pretty self-explanatory.
614
616
 
615
- ### has_one
616
617
 
617
- This property may look familiar to users of [ActiveRecord], it introduces the concept of relationship between entities.
618
-
619
- ```ruby
620
- class MyCustomEntity < PowerStencil::SystemEntityDefinitions::ProjectEntity
621
- entity_type :custom_entity
622
-
623
- has_one :custom_entity, name: :parent
624
- end
625
- ```
618
+ ### Integrity constraints
626
619
 
627
- ```ruby
628
- PowerStencil DSL> e = new_custom_entity name: :test_entity
629
- => #<MyCustomEntity:47215552142260 composite_key=[:custom_entity, "test_entity"], @universe='Project entities (1566478203.584915)'>
630
- PowerStencil DSL> p = new_custom_entity name: :foo
631
- => #<MyCustomEntity:47215551934000 composite_key=[:custom_entity, "foo"], @universe='Project entities (1566478203.584915)'>
632
- PowerStencil DSL> e.parent = p
633
- => #<MyCustomEntity:47215551934000 composite_key=[:custom_entity, "foo"], @universe='Project entities (1566478203.584915)'>
634
- PowerStencil DSL> e.fields
635
- => {:name=>"test_entity", :parent=>#<MyCustomEntity:47215551934000 composite_key=[:custom_entity, "foo"], @universe='Project entities (1566478203.584915)'>}
636
- PowerStencil DSL> p.save=> #<MyCustomEntity:47215551934000 composite_key=[:custom_entity, "foo"], @universe='Project entities (1566478203.584915)'>
637
- PowerStencil DSL> e.save
638
- => #<MyCustomEntity:47215552142260 composite_key=[:custom_entity, "test_entity"], @universe='Project entities (1566478203.584915)'>
639
- PowerStencil DSL> exit
640
- ```
641
-
642
- Which translates at persistence level as:
643
-
644
- ```shell
645
- $ power_stencil get custom_entity/test_entity --raw
646
- --- !ruby/object:MyCustomEntity
647
- :name: test_entity
648
- :parent: !psref
649
- type: :custom_entity
650
- name: foo
651
- ```
652
- Here we are referencing an entity of the same type, but of course you can reference any type of entity. Using `has_one` will enforce the type of data you reference. Let's try to mess-up:
653
-
654
- ```ruby
655
- PowerStencil DSL> e.parent = :bar
656
- => :bar
657
- PowerStencil DSL> e.fields
658
- => {:name=>"test_entity", :parent=>:bar}
659
- PowerStencil DSL> e.valid?
660
- => false
661
- PowerStencil DSL> e.valid? raise_error: true
662
- UniverseCompiler::Error: Invalid entity '[:custom_entity, "test_entity"]' for fields parent !
663
- from /opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/universe_compiler-0.2.7/lib/universe_compiler/utils/error_propagation.rb:10:in `false_or_raise'
664
- PowerStencil DSL> e.save
665
- UniverseCompiler::Error: Invalid entity '[:custom_entity, "test_entity"]' for fields parent !
666
- from /opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/universe_compiler-0.2.7/lib/universe_compiler/utils/error_propagation.rb:10:in `false_or_raise'
667
- ```
668
- So you see that if we try to set parent with something wrong, the accessor seems to accept, you can even see the `#fields` Hash updated. But as soon as you try to save to entity, or if you use the `#valid?` method, it complains about the type... Cool.
669
-
670
- :information_source: The `name` property of the `has_one` directive is optional. If not present the field will be named from the entity_type referenced instead...
671
620
 
672
- **:warning: See more advanced features, like reverse methods in the [universe_compiler advanced relations documentation].**
673
-
674
- ### has_many
675
-
676
- Once you know the `has_one` directive, you should not be surprised by the `has_many` directive...
677
-
678
- ```ruby
679
- class MyCustomEntity < PowerStencil::SystemEntityDefinitions::ProjectEntity
680
- entity_type :custom_entity
681
-
682
- has_many :base_entity, name: :sub_properties
683
- end
684
- ```
685
-
686
- ```ruby
687
- PowerStencil DSL> e = new_custom_entity name: :test_entity
688
- => #<MyCustomEntity:47312117001560 composite_key=[:custom_entity, "test_entity"], @universe='Project entities (1566482056.789871)'>
689
- PowerStencil DSL> sub_prop1 = new_base_entity name: :prop1
690
- => #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116793880 composite_key=[:base_entity, "prop1"], @universe='Project entities (1566482056.789871)'>
691
- PowerStencil DSL> e.sub_properties << sub_prop1
692
- => [#<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116793880 composite_key=[:base_entity, "prop1"], @universe='Project entities (1566482056.789871)'>]
693
- PowerStencil DSL> sub_prop2 = new_base_entity name: :prop2
694
- => #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116175620 composite_key=[:base_entity, "prop2"], @universe='Project entities (1566482056.789871)'>
695
- PowerStencil DSL> e.sub_properties << sub_prop2
696
- => [#<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116793880 composite_key=[:base_entity, "prop1"], @universe='Project entities (1566482056.789871)'>,
697
- #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116175620 composite_key=[:base_entity, "prop2"], @universe='Project entities (1566482056.789871)'>]
698
- PowerStencil DSL> sub_prop1.save
699
- => #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116793880 composite_key=[:base_entity, "prop1"], @universe='Project entities (1566482056.789871)'>
700
- PowerStencil DSL> sub_prop2.save
701
- => #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116175620 composite_key=[:base_entity, "prop2"], @universe='Project entities (1566482056.789871)'>
702
- PowerStencil DSL> e.save
703
- => #<MyCustomEntity:47312117001560 composite_key=[:custom_entity, "test_entity"], @universe='Project entities (1566482056.789871)'>
704
- PowerStencil DSL> exit
705
- ```
706
-
707
- Which translates at persistence level as:
708
-
709
- ```shell
710
- --- !ruby/object:MyCustomEntity
711
- :sub_properties:
712
- - !psref
713
- type: :base_entity
714
- name: prop1
715
- - !psref
716
- type: :base_entity
717
- name: prop2
718
- :name: test_entity
719
- ```
720
- Nice !
721
-
722
- **:warning: See more advanced features, like reverse methods in the [universe_compiler advanced relations documentation].**
723
-
724
- ### is_array
621
+ #### is_array
725
622
 
726
623
  You can define a field as being an array:
727
624
 
@@ -745,7 +642,7 @@ PowerStencil DSL> e.fields
745
642
 
746
643
  :information_source: Please note the two syntaxes are equivalent.
747
644
 
748
- ### is_hash
645
+ #### is_hash
749
646
 
750
647
  You can define a field as being an array:
751
648
 
@@ -769,7 +666,7 @@ PowerStencil DSL> e.fields
769
666
 
770
667
  :information_source: Please note the two syntaxes are equivalent.
771
668
 
772
- ### not_null
669
+ #### not_null
773
670
 
774
671
  I guess you start getting used to what happens:
775
672
 
@@ -804,7 +701,7 @@ PowerStencil DSL> e.valid?
804
701
  ```
805
702
  Nothing very surprising there. Please note an empty string is not a null value...
806
703
 
807
- ### not_empty
704
+ #### not_empty
808
705
 
809
706
  This directive will adapt depending on the field type
810
707
 
@@ -847,7 +744,7 @@ Pretty simple nope ?
847
744
 
848
745
  :information_source: `has_one` does not support `not_empty` but support `not_null`, and the opposite for `has_many`...
849
746
 
850
- ### should_match
747
+ #### should_match
851
748
 
852
749
  `should_match` will perform a validation of the content regarding a regular expression or a string. It should work on strings or symbols:
853
750
 
@@ -888,7 +785,7 @@ PowerStencil DSL> e.valid? raise_error: true
888
785
 
889
786
  :warning: As you can see there, unless specified as `not_null` or `not_empty`, the `should_match` validation will not be performed ! Pretty normal if you think about it...
890
787
 
891
- ### class_name
788
+ #### class_name
892
789
 
893
790
  ```ruby
894
791
  class MyCustomEntity < PowerStencil::SystemEntityDefinitions::ProjectEntity
@@ -917,6 +814,119 @@ PowerStencil DSL> e.valid? raise_error: true
917
814
 
918
815
  :warning: Use this one with caution, as it does not test anything regarding inheritance...
919
816
 
817
+
818
+ ### Relational constraints
819
+
820
+ #### has_one
821
+
822
+ This property may look familiar to users of [ActiveRecord], it introduces the concept of relationship between entities.
823
+
824
+ ```ruby
825
+ class MyCustomEntity < PowerStencil::SystemEntityDefinitions::ProjectEntity
826
+ entity_type :custom_entity
827
+
828
+ has_one :custom_entity, name: :parent
829
+ end
830
+ ```
831
+
832
+ ```ruby
833
+ PowerStencil DSL> e = new_custom_entity name: :test_entity
834
+ => #<MyCustomEntity:47215552142260 composite_key=[:custom_entity, "test_entity"], @universe='Project entities (1566478203.584915)'>
835
+ PowerStencil DSL> p = new_custom_entity name: :foo
836
+ => #<MyCustomEntity:47215551934000 composite_key=[:custom_entity, "foo"], @universe='Project entities (1566478203.584915)'>
837
+ PowerStencil DSL> e.parent = p
838
+ => #<MyCustomEntity:47215551934000 composite_key=[:custom_entity, "foo"], @universe='Project entities (1566478203.584915)'>
839
+ PowerStencil DSL> e.fields
840
+ => {:name=>"test_entity", :parent=>#<MyCustomEntity:47215551934000 composite_key=[:custom_entity, "foo"], @universe='Project entities (1566478203.584915)'>}
841
+ PowerStencil DSL> p.save=> #<MyCustomEntity:47215551934000 composite_key=[:custom_entity, "foo"], @universe='Project entities (1566478203.584915)'>
842
+ PowerStencil DSL> e.save
843
+ => #<MyCustomEntity:47215552142260 composite_key=[:custom_entity, "test_entity"], @universe='Project entities (1566478203.584915)'>
844
+ PowerStencil DSL> exit
845
+ ```
846
+
847
+ Which translates at persistence level as:
848
+
849
+ ```shell
850
+ $ power_stencil get custom_entity/test_entity --raw
851
+ --- !ruby/object:MyCustomEntity
852
+ :name: test_entity
853
+ :parent: !psref
854
+ type: :custom_entity
855
+ name: foo
856
+ ```
857
+ Here we are referencing an entity of the same type, but of course you can reference any type of entity. Using `has_one` will enforce the type of data you reference. Let's try to mess-up:
858
+
859
+ ```ruby
860
+ PowerStencil DSL> e.parent = :bar
861
+ => :bar
862
+ PowerStencil DSL> e.fields
863
+ => {:name=>"test_entity", :parent=>:bar}
864
+ PowerStencil DSL> e.valid?
865
+ => false
866
+ PowerStencil DSL> e.valid? raise_error: true
867
+ UniverseCompiler::Error: Invalid entity '[:custom_entity, "test_entity"]' for fields parent !
868
+ from /opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/universe_compiler-0.2.7/lib/universe_compiler/utils/error_propagation.rb:10:in `false_or_raise'
869
+ PowerStencil DSL> e.save
870
+ UniverseCompiler::Error: Invalid entity '[:custom_entity, "test_entity"]' for fields parent !
871
+ from /opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/universe_compiler-0.2.7/lib/universe_compiler/utils/error_propagation.rb:10:in `false_or_raise'
872
+ ```
873
+ So you see that if we try to set parent with something wrong, the accessor seems to accept, you can even see the `#fields` Hash updated. But as soon as you try to save to entity, or if you use the `#valid?` method, it complains about the type... Cool.
874
+
875
+ :information_source: The `name` property of the `has_one` directive is optional. If not present the field will be named from the entity_type referenced instead...
876
+
877
+ **:information_source: See more advanced features, like the very powerful reverse methods in the [`universe_compiler` advanced relations documentation].** [universe_compiler] is the Gem that manages entities under the hood, but it is much lower level than `PowerStencil`, so unless you are really interested in what happens under the hood, you should not really care about it. Yet you should definitely check what the `with_reverse_method` and `unique` options do to the `has_one` directive.
878
+
879
+ #### has_many
880
+
881
+ Once you know the `has_one` directive, you should not be surprised by the `has_many` directive...
882
+
883
+ ```ruby
884
+ class MyCustomEntity < PowerStencil::SystemEntityDefinitions::ProjectEntity
885
+ entity_type :custom_entity
886
+
887
+ has_many :base_entity, name: :sub_properties
888
+ end
889
+ ```
890
+
891
+ ```ruby
892
+ PowerStencil DSL> e = new_custom_entity name: :test_entity
893
+ => #<MyCustomEntity:47312117001560 composite_key=[:custom_entity, "test_entity"], @universe='Project entities (1566482056.789871)'>
894
+ PowerStencil DSL> sub_prop1 = new_base_entity name: :prop1
895
+ => #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116793880 composite_key=[:base_entity, "prop1"], @universe='Project entities (1566482056.789871)'>
896
+ PowerStencil DSL> e.sub_properties << sub_prop1
897
+ => [#<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116793880 composite_key=[:base_entity, "prop1"], @universe='Project entities (1566482056.789871)'>]
898
+ PowerStencil DSL> sub_prop2 = new_base_entity name: :prop2
899
+ => #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116175620 composite_key=[:base_entity, "prop2"], @universe='Project entities (1566482056.789871)'>
900
+ PowerStencil DSL> e.sub_properties << sub_prop2
901
+ => [#<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116793880 composite_key=[:base_entity, "prop1"], @universe='Project entities (1566482056.789871)'>,
902
+ #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116175620 composite_key=[:base_entity, "prop2"], @universe='Project entities (1566482056.789871)'>]
903
+ PowerStencil DSL> sub_prop1.save
904
+ => #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116793880 composite_key=[:base_entity, "prop1"], @universe='Project entities (1566482056.789871)'>
905
+ PowerStencil DSL> sub_prop2.save
906
+ => #<PowerStencil::SystemEntityDefinitions::ProjectEntity:47312116175620 composite_key=[:base_entity, "prop2"], @universe='Project entities (1566482056.789871)'>
907
+ PowerStencil DSL> e.save
908
+ => #<MyCustomEntity:47312117001560 composite_key=[:custom_entity, "test_entity"], @universe='Project entities (1566482056.789871)'>
909
+ PowerStencil DSL> exit
910
+ ```
911
+
912
+ Which translates at persistence level as:
913
+
914
+ ```shell
915
+ --- !ruby/object:MyCustomEntity
916
+ :sub_properties:
917
+ - !psref
918
+ type: :base_entity
919
+ name: prop1
920
+ - !psref
921
+ type: :base_entity
922
+ name: prop2
923
+ :name: test_entity
924
+ ```
925
+ Nice !
926
+
927
+ **:information_source: See more advanced features, like the very powerful reverse methods in the [`universe_compiler` advanced relations documentation].** [universe_compiler] is the Gem that manages entities under the hood, but it is much lower level than `PowerStencil`, so unless you are really interested in what happens under the hood, you should not really care about it. Yet you should definitely check what the `with_reverse_method` and `unique` options do to the `has_many` directive.
928
+
929
+
920
930
  ### buildable and buildable_by
921
931
 
922
932
  One of the most important directives !
@@ -973,5 +983,5 @@ Now you know an entity type is just a regular Ruby class. As such you could add
973
983
  [ActiveRecord]: https://guides.rubyonrails.org/active_record_basics.html "The ultimate ORM"
974
984
  [Ruby On Rails]: https://rubyonrails.org/ "One of the best Web framework"
975
985
  [universe_compiler]: https://gitlab.com/tools4devops/universe_compiler "The underlying engine to manage entities and compilation !"
976
- [universe_compiler advanced relations documentation]: https://gitlab.com/tools4devops/universe_compiler#advanced-relations "Advanced relational features"
986
+ [`universe_compiler` advanced relations documentation]: https://gitlab.com/tools4devops/universe_compiler#advanced-relations "Advanced relational features"
977
987
  [Graphviz]: (https://www.graphviz.org/) "Graph Visualization Software"
@@ -17,6 +17,7 @@ Example use cases
17
17
  Considering the genericity of the `PowerStencil` framework, it is a bit difficult to define a strict scope for its usage. It's a bit like wondering what you could do with a programming language.
18
18
 
19
19
  Neverthless, I will give two short ideas that should open you mind to things you could do with it.
20
+ Plugins are currently in development around these topics, and may come pretty soon.
20
21
 
21
22
 
22
23
  # Managing machines, routers, firewalls...
@@ -29,6 +30,8 @@ You could define machines, interfaces, networks as [entities] and having [templa
29
30
 
30
31
  And of course, changes are tracked using Git, providing easy fallback for something as critical as your network config.
31
32
 
33
+ An official plugin is under development for this.
34
+
32
35
  # Deploying Snaps, Docker containers, VMs
33
36
 
34
37
  If you manage a containerized infrastructure, you probably noticed how often you need to have the same information duplicated from your application builds, Snaps, Docker containers or VM definitions (names, ports, entry-points...)
data/doc/faq.md CHANGED
@@ -70,16 +70,18 @@ Regarding Windows, I stopped using spywareOS years ago so I can't really tell yo
70
70
 
71
71
  # What is the status of `PowerStencil` ?
72
72
 
73
- Although `PowerStencil` is still under development, **it can already be safely used**.
73
+ `PowerStencil` is still under development, yet **it can already be safely used**.
74
74
 
75
75
  Regarding `PowerStencil` core:
76
76
 
77
77
  - The part that may evolve the most is the plugin part (including documentation which is not really in par with the rest...), but it should not break anything developed now.
78
- - New system entity types may appear.
78
+ - New system entity types may appear.
79
+ - The functional documentation is evolving.
80
+ - There is almost no technical/architectural documentation yet. Read the code...
79
81
 
80
82
  Anyway `PowerStencil` follows the semantic versioning pattern and if incompatible changes arise it may be reflected in the version.
81
83
 
82
- There are already some plugins in the pipe, especially around contenerization topics.
84
+ There are already some plugins in the pipe. See [example use cases], to get an idea of the first official plugins to come.
83
85
 
84
86
  :information_source: Of course, `PowerStencil` is new software and it is expected to evolve with the needs of its users...
85
87
 
@@ -94,6 +96,7 @@ There are already some plugins in the pipe, especially around contenerization to
94
96
  [entities]: entities.md "Entities in PowerStencil"
95
97
  [plugins]: plugins.md "Plugins in PowerStencil"
96
98
  [overrides]: builds.md#overriding-entities-and-build-scenarii "Overriding data locally"
99
+ [example use cases]: example_use_cases.md "Example uses cases using PowerStencil"
97
100
 
98
101
 
99
102
  <!-- Code links -->
@@ -68,9 +68,9 @@
68
68
  borderopacity="1.0"
69
69
  inkscape:pageopacity="0.0"
70
70
  inkscape:pageshadow="2"
71
- inkscape:zoom="0.7"
72
- inkscape:cx="641.18508"
73
- inkscape:cy="2.7826171"
71
+ inkscape:zoom="0.98994949"
72
+ inkscape:cx="651.7638"
73
+ inkscape:cy="23.641026"
74
74
  inkscape:document-units="mm"
75
75
  inkscape:current-layer="layer1"
76
76
  showgrid="false"
@@ -129,7 +129,7 @@
129
129
  inkscape:path-effect="#path-effect1081"
130
130
  inkscape:original-d="m -20.579753,67.932995 c 104.23538,-2.64e-4 208.470493,-2.64e-4 312.705333,0" />
131
131
  <g
132
- id="g948">
132
+ id="g870">
133
133
  <rect
134
134
  ry="1.3100638"
135
135
  y="59.92662"
@@ -140,27 +140,26 @@
140
140
  style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a7c2db;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.48427609;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
141
141
  <text
142
142
  id="text819"
143
- y="66.31649"
144
- x="10.098216"
143
+ y="66.765266"
144
+ x="9.4663115"
145
145
  style="font-style:normal;font-weight:normal;font-size:4.63020849px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
146
146
  xml:space="preserve"><tspan
147
- id="tspan821"
148
- style="stroke-width:0.26458332px"
149
- y="66.31649"
150
- x="10.098216"
151
- sodipodi:role="line">Project </tspan><tspan
152
147
  id="tspan865"
153
148
  style="stroke-width:0.26458332px"
154
- y="72.104248"
155
- x="10.098216"
156
- sodipodi:role="line">Templates &amp; Data</tspan></text>
149
+ y="66.765266"
150
+ x="9.4663115"
151
+ sodipodi:role="line">Project Templates </tspan><tspan
152
+ id="tspan864"
153
+ style="stroke-width:0.26458332px"
154
+ y="72.553024"
155
+ x="9.4663115"
156
+ sodipodi:role="line">&amp; Structured Data</tspan></text>
157
157
  </g>
158
158
  <g
159
- id="g954"
160
- transform="translate(-2.9812257e-6,-0.76938629)">
159
+ id="g880">
161
160
  <rect
162
161
  ry="1.3100638"
163
- y="60.696007"
162
+ y="59.92662"
164
163
  x="81.007019"
165
164
  height="16.012749"
166
165
  width="55.700253"
@@ -168,18 +167,18 @@
168
167
  style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a7c2db;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.48427609;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
169
168
  <text
170
169
  id="text819-2"
171
- y="67.085876"
170
+ y="66.31649"
172
171
  x="82.828049"
173
172
  style="font-style:normal;font-weight:normal;font-size:4.63020849px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
174
173
  xml:space="preserve"><tspan
175
174
  id="tspan821-7"
176
175
  style="stroke-width:0.26458332px"
177
- y="67.085876"
176
+ y="66.31649"
178
177
  x="82.828049"
179
178
  sodipodi:role="line">PowerStencil</tspan><tspan
180
179
  id="tspan861"
181
180
  style="stroke-width:0.26458332px"
182
- y="72.873634"
181
+ y="72.104248"
183
182
  x="82.828049"
184
183
  sodipodi:role="line">Core actions &amp; Plugins</tspan></text>
185
184
  </g>
@@ -44,7 +44,7 @@ The normal process would be to begin with a plugin within the project and once y
44
44
  - Plugins local to the project are automatically taken in account.
45
45
  - To use plugins provided as Gems you have to set the `:plugins:` array property in the `.ps_project/versioned-config.yaml`
46
46
 
47
- :warning: Plugins provided as standalone Gems are not thoroughly tested, for the time being you may use plugins local to the project.
47
+ :warning: Plugins provided as standalone Gems are not thoroughly tested, for the time being, you may use plugins local to the project.
48
48
 
49
49
 
50
50
  # Creating plugin local to the project
@@ -145,9 +145,9 @@ MYPLUGIN PLUGIN WAZ HERE
145
145
  Wow it worked ! Useless, but worked !
146
146
 
147
147
 
148
- The documentation for plugins is not yet done, so you are encouraged to read the code, the capabilities (in the output of `power_stencil info`) give you an idea of what plugins can do.
148
+ The documentation for plugins is not yet done, so you are encouraged to read the code, the `capabilities` (in the output of `power_stencil info`) give you an idea of what plugins can do. Some official plugins are under development, and the documentation will be improved along their development...
149
149
 
150
- :warning: As opposed to the rest of `PowerStencil`, the functionnality is nevertheless not completely frozen.
150
+ **:warning: As opposed to the rest of `PowerStencil`, the functionnality is nevertheless not completely frozen. This will be the case once `PowerStencil` turns 1.0.0.**
151
151
 
152
152
 
153
153
  [:back:][Documentation root]
@@ -19,15 +19,21 @@ Templates
19
19
 
20
20
  # Templates overview
21
21
 
22
- Templates are the key feature of `PowerStencil` (hence the name). Templates are what will use the [entities] you carefully crafted in order to produce something during the [build][builds] process.
22
+ **:warning: You should have already read the documentation about [entities], before reading this.**
23
23
 
24
- Currently the underlying engine is [ERB].
24
+ Template is a key feature of `PowerStencil` (hence the name). In templates you define how you will use the [entities] you carefully crafted in order to produce something during a [build][builds] process.
25
25
 
26
- When an entity type has some templates associated and you create an entity, it will create a directory `<entity_type>/<entity_name>` where you will fond those templates.
26
+ The default templating engine being [ERB], your templates should be written using the [ERB] syntax, like most templates are written in the [Ruby On Rails] framework. This is basically some [Ruby] inside some ERB tags.
27
+
28
+ Templates are always associated to some [buildable entities][buildable].
29
+
30
+ When a [buildable entity][buildable] has some templates associated, they will be located in a directory `<entity_type>/<entity_name>/`. For some entity types, when you will create a new entity of this type, some default templates will be created in that directory (this is the case of the `simple_exec` entity type as you will see in the next paragraph). This is what is called `templates-templates`.
31
+
32
+ In this document, you will learn how to create your own templates, as well as your own templates-templates.
27
33
 
28
34
  # Templates discovery with `simple_exec` entity type
29
35
 
30
- In the basic entity types, the only one having templates is the `simple_exec` entity type. So let's try with it:
36
+ In the basic entity types, the only one providing default templates is the `simple_exec` entity type. So let's try with it:
31
37
 
32
38
  ```shell
33
39
  $ power_stencil create simple_exec/demo_templates
@@ -41,9 +47,9 @@ RAW ENTITIES
41
47
  - Status : Valid
42
48
  - Buildable : true
43
49
  ```
44
- As you can see the output of `power_stencil check` shows more information than entities we already created. First we see that this entity is `buildable`, and we'll detail that in the [builds] document, but for the moment what we will focus on the `Templates path` information.
50
+ As you can see the output of `power_stencil check` shows more information than entities we created so far. First we see that this entity is `buildable`, and we'll detail that in the [builds] document, but for the moment what we will focus on the `Templates path` information.
45
51
 
46
- And it's true if we have a look in the `simple_exec/demo_templates` from the root of the project, a file appeared there:
52
+ And it's true if we have a look in the `simple_exec/demo_templates/` directory from the root of the project, a file appeared there:
47
53
 
48
54
  ```shell
49
55
  $ ls -l simple_exec/demo_templates
@@ -138,7 +144,7 @@ Here are the main methods:
138
144
  - `entity(type, name)` will return any entity from the repository. The method is self-explanatory, this is the most generic way to access any entity of the repository.
139
145
  - `entities(criterion: nil, value: nil, &filter_block)` which is a more generic entities query method where `criterion` can be `:by_name` or `:by_type` and that will return an array (that you can potentially filter using the `filter_block`).
140
146
  - `build_target` will return the entity that you are currently building.
141
- - `project_config` is a shortcut to the project entity. You could actually retrieve it using the `entity(type, name)` method.
147
+ - `project_config` is a shortcut to the project entity. You could actually retrieve it using the `entity(:project_config, 'Project Config')` method.
142
148
 
143
149
  And of course you have access like in `power_stencil shell` to any class brought by `PowerStencil`, you could create entities there, destroy some, **but you should not do it**, as it would be very weird to do that during the process of detemplating !
144
150
 
@@ -21,10 +21,18 @@ module PowerStencil
21
21
  h = entity.to_hash
22
22
  entity.class.fields_constraints.each do |field_name, constraints|
23
23
  next unless constraints[:reverse_method]
24
+
24
25
  reverse_method_conf = constraints[:reverse_method]
25
26
  val = entity.send(reverse_method_conf[:actual_method])
26
27
  node = h[entity.class.name][:dynamic_data] ||= {}
27
- node[reverse_method_conf[:actual_method]] = val.as_path unless val.nil?
28
+ next if val.nil?
29
+ next if val.is_a? Array and val.empty?
30
+
31
+ node[reverse_method_conf[:actual_method]] = if val.is_a? Array
32
+ val.map &:as_path
33
+ else
34
+ val.as_path
35
+ end
28
36
  end
29
37
  puts h.to_yaml
30
38
  end
@@ -14,10 +14,6 @@ module PowerStencil
14
14
  @universe = universe
15
15
  end
16
16
 
17
- def project_config
18
- project.config
19
- end
20
-
21
17
  end
22
18
 
23
19
  end
@@ -13,6 +13,10 @@ module PowerStencil
13
13
  e.nil? ? entity(type.to_sym, name) : e
14
14
  end
15
15
 
16
+ def project_config
17
+ entity :project_config, 'Project Config'
18
+ end
19
+
16
20
  def entity(type_or_path, name = nil)
17
21
  type, name = if name.nil?
18
22
  md = type_or_path.match /^(?<type>[^\/]+)\/(?<name>.*)$/
@@ -5,7 +5,7 @@ module PowerStencil
5
5
 
6
6
  module Gem
7
7
 
8
- NO_DOC = %w(--no-ri --no-rdoc).freeze
8
+ NO_DOC = %w(--no-document).freeze
9
9
 
10
10
  def gem_locally_installed?(plugin_name, plugin_requirements)
11
11
  get_spec(plugin_name, plugin_requirements).nil? ? false : true
@@ -1,3 +1,3 @@
1
1
  module PowerStencil
2
- VERSION = '0.4.6'.freeze
2
+ VERSION = '0.4.11'.freeze
3
3
  end
@@ -6,12 +6,12 @@ require 'power_stencil/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'power_stencil'
8
8
  spec.version = PowerStencil::VERSION
9
- spec.authors = ['Laurent B.']
10
- spec.email = ['lbnetid+rb@gmail.com']
9
+ spec.authors = ['Laurent Briais']
10
+ spec.email = ['powerstencil-contact@brizone.org']
11
11
 
12
12
  spec.summary = %q{PowerStencil is the Swiss-army knife templating workflow for developers and ops.}
13
13
  spec.description = %q{PowerStencil is the Swiss-army knife templating workflow for developers and ops.}
14
- spec.homepage = 'https://gitlab.com/tools4devops/power_stencil'
14
+ spec.homepage = ''
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -27,9 +27,17 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'climatic', '~> 0.2.29'
29
29
  spec.add_dependency 'dir_glob_ignore', '~> 0.3'
30
- spec.add_dependency 'universe_compiler', '~> 0.4.2'
30
+ spec.add_dependency 'universe_compiler', '~> 0.4.3'
31
31
  spec.add_dependency 'pry'
32
32
 
33
+ source_code_uri = 'https://gitlab.com/tools4devops/power_stencil'
34
+
35
+ spec.metadata = {
36
+ "bug_tracker_uri" => "#{source_code_uri}/issues",
37
+ "documentation_uri" => "#{source_code_uri}/blob/master/README.md",
38
+ "source_code_uri" => source_code_uri
39
+ }
40
+
33
41
  spec.post_install_message = %Q{
34
42
  Thank you for installing PowerStencil #{PowerStencil::VERSION} !
35
43
  From the command line you can run `power_stencil --help`
@@ -37,7 +45,7 @@ If your shell is not completing the command:
37
45
  If you use rbenv: `rbenv rehash`
38
46
  If you use zsh : `rehash`
39
47
 
40
- Full documentation here : #{spec.homepage}/blob/master/README.md
41
- Feel free to report issues: #{spec.homepage}/issues
48
+ Full documentation here : #{spec.metadata['source_code_uri']}/blob/master/README.md
49
+ Feel free to report issues: #{spec.metadata['source_code_uri']}/issues
42
50
  }
43
51
  end
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.4.6
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
- - Laurent B.
7
+ - Laurent Briais
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-17 00:00:00.000000000 Z
11
+ date: 2019-09-28 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.4.2
89
+ version: 0.4.3
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.4.2
96
+ version: 0.4.3
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -111,13 +111,14 @@ dependencies:
111
111
  description: PowerStencil is the Swiss-army knife templating workflow for developers
112
112
  and ops.
113
113
  email:
114
- - lbnetid+rb@gmail.com
114
+ - powerstencil-contact@brizone.org
115
115
  executables:
116
116
  - power_stencil
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
120
  - ".gitignore"
121
+ - ".gitlab-ci.yml"
121
122
  - ".rspec"
122
123
  - ".travis.yml"
123
124
  - CODE_OF_CONDUCT.md
@@ -249,14 +250,17 @@ files:
249
250
  - lib/power_stencil/utils/semantic_version.rb
250
251
  - lib/power_stencil/version.rb
251
252
  - power_stencil.gemspec
252
- homepage: https://gitlab.com/tools4devops/power_stencil
253
+ homepage: ''
253
254
  licenses:
254
255
  - MIT
255
- metadata: {}
256
- post_install_message: "\nThank you for installing PowerStencil 0.4.6 !\nFrom the command
257
- line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
258
- \ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nFull documentation
259
- here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
256
+ metadata:
257
+ bug_tracker_uri: https://gitlab.com/tools4devops/power_stencil/issues
258
+ documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
259
+ source_code_uri: https://gitlab.com/tools4devops/power_stencil
260
+ post_install_message: "\nThank you for installing PowerStencil 0.4.11 !\nFrom the
261
+ command line you can run `power_stencil --help`\nIf your shell is not completing
262
+ the command:\n If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nFull
263
+ documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
260
264
  free to report issues: https://gitlab.com/tools4devops/power_stencil/issues\n "
261
265
  rdoc_options: []
262
266
  require_paths: