power_stencil 0.4.22 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/plugins.md +269 -18
- data/etc/meta_templates/plugin_seed/etc/command_line.yaml +1 -1
- data/etc/meta_templates/plugin_seed/etc/plugin_capabilities.yaml +33 -0
- data/etc/meta_templates/plugin_seed/etc/templates/{entity}_entity/.copy_ignore +2 -0
- data/etc/meta_templates/plugin_seed/etc/templates/{entity}_entity/.subst_ignore +1 -0
- data/etc/meta_templates/plugin_seed/etc/templates/{entity}_entity/message.txt +7 -0
- data/etc/meta_templates/plugin_seed/lib/{entity}.rb.erb +9 -24
- data/etc/meta_templates/plugin_seed/lib/{entity}/dsl/{entity}_dsl.rb.erb +9 -0
- data/etc/meta_templates/plugin_seed/lib/{entity}/entity_definitions/{entity}_entity.rb.erb +2 -0
- data/etc/meta_templates/plugin_seed/lib/{entity}/{entity}_processor.rb.erb +4 -1
- data/etc/templates/plugin_definition/.travis.yml +1 -1
- data/etc/templates/plugin_definition/CODE_OF_CONDUCT.md +1 -1
- data/etc/templates/plugin_definition/etc/command_line.yaml +1 -1
- data/etc/templates/plugin_definition/etc/plugin_capabilities.yaml +33 -0
- data/etc/templates/plugin_definition/etc/plugin_config.yaml +1 -1
- data/etc/templates/plugin_definition/etc/templates/{entity}_entity/.copy_ignore +2 -0
- data/etc/templates/plugin_definition/etc/templates/{entity}_entity/.subst_ignore +1 -0
- data/etc/templates/plugin_definition/etc/templates/{entity}_entity/message.txt +7 -0
- data/etc/templates/plugin_definition/lib/{entity}.rb.erb +9 -24
- data/etc/templates/plugin_definition/lib/{entity}/dsl/{entity}_dsl.rb.erb +9 -0
- data/etc/templates/plugin_definition/lib/{entity}/entity_definitions/{entity}_entity.rb.erb +2 -0
- data/etc/templates/plugin_definition/lib/{entity}/{entity}_processor.rb.erb +4 -1
- data/lib/power_stencil/command_processors/info.rb +0 -3
- data/lib/power_stencil/dsl/plugin_generation.rb +9 -0
- data/lib/power_stencil/engine/build_handling.rb +12 -7
- data/lib/power_stencil/engine/project_engine.rb +13 -9
- data/lib/power_stencil/plugins/base.rb +20 -5
- data/lib/power_stencil/plugins/build.rb +17 -0
- data/lib/power_stencil/plugins/capabilities.rb +24 -15
- data/lib/power_stencil/plugins/command_line.rb +13 -1
- data/lib/power_stencil/plugins/config.rb +11 -15
- data/lib/power_stencil/plugins/dsl.rb +17 -0
- data/lib/power_stencil/plugins/entity_definitions.rb +17 -0
- data/lib/power_stencil/plugins/require.rb +1 -31
- data/lib/power_stencil/plugins/templates.rb +10 -8
- data/lib/power_stencil/plugins/type.rb +13 -0
- data/lib/power_stencil/project/config.rb +2 -2
- data/lib/power_stencil/project/paths.rb +3 -0
- data/lib/power_stencil/project/plugins.rb +3 -14
- data/lib/power_stencil/utils/secure_require.rb +1 -1
- data/lib/power_stencil/version.rb +1 -1
- metadata +21 -9
- data/lib/power_stencil/plugins/dependencies.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925c1cdc265fdddbe244699558bfe8e89bdf28a7
|
4
|
+
data.tar.gz: 66b36b54757cc3593ce06d9da5c608485839b2bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e253fbedf2d8a29458168238a7b55dc8eb46a2f7c84b2f61cbed7653fc0a6e795f17c47ddf5cd8b4aa7a1a5ba389d3a86c36d55e5b18552350fd73399be4edc8
|
7
|
+
data.tar.gz: cfc7fc77bcbb74cab625c3b8bca40b9502943701e12509810eb41945f2390f7a7f528a1e8f6cec6be84434b55ae64b71ef0a39691fe7e4425b8403fc0a617390
|
data/doc/plugins.md
CHANGED
@@ -10,6 +10,12 @@ Plugins
|
|
10
10
|
- [Enhance `power_stencil` command line](#enhance-power_stencil-command-line)
|
11
11
|
- [What are plugins ?](#what-are-plugins-)
|
12
12
|
- [Creating plugin local to the project](#creating-plugin-local-to-the-project)
|
13
|
+
- [Plugin creation](#plugin-creation)
|
14
|
+
- [Adding new subcommands to `PowerStencil`](#adding-new-subcommands-to-powerstencil)
|
15
|
+
- [Providing entity types and templates](#providing-entity-types-and-templates)
|
16
|
+
- [Providing custom build process](#providing-custom-build-process)
|
17
|
+
- [Plugin capabilities and structure](#plugin-capabilities-and-structure)
|
18
|
+
- [Conclusion](#conclusion)
|
13
19
|
|
14
20
|
<!-- /TOC -->
|
15
21
|
[:back:][Documentation root]
|
@@ -49,7 +55,9 @@ The normal process would be to begin with a plugin within the project and once y
|
|
49
55
|
|
50
56
|
# Creating plugin local to the project
|
51
57
|
|
52
|
-
|
58
|
+
## Plugin creation
|
59
|
+
|
60
|
+
There is a command provided for that, that will create a whole plugin skeleton.
|
53
61
|
|
54
62
|
```shell
|
55
63
|
$ power_stencil plugin --create myplugin
|
@@ -81,17 +89,16 @@ So what was the impact on the project.
|
|
81
89
|
If you do a `power_stencil info` you see a new part appeared in the report
|
82
90
|
|
83
91
|
```
|
92
|
+
|
84
93
|
--------------------------------------------------------------------------------
|
85
94
|
Plugins:
|
86
95
|
--> Plugin 'myplugin' has following capabilities:
|
96
|
+
- config: true
|
87
97
|
- command_line: true
|
88
|
-
- local_config: true
|
89
98
|
- processors: true
|
90
|
-
- build:
|
99
|
+
- build: true
|
91
100
|
- dsl: false
|
92
101
|
- entity_definitions: true
|
93
|
-
- code: true
|
94
|
-
- version: true
|
95
102
|
- templates: true
|
96
103
|
```
|
97
104
|
Each of the lines correspond to what is called a _plugin capability_.
|
@@ -111,20 +118,19 @@ Or with the capabilities information:
|
|
111
118
|
|
112
119
|
```
|
113
120
|
1 plugin found to be used in this project.
|
114
|
-
- myplugin (in '/tmp/
|
121
|
+
- myplugin (in '/tmp/demo/.ps_project/plugins/myplugin/lib/myplugin.rb')
|
122
|
+
config: true
|
115
123
|
command_line: true
|
116
|
-
local_config: true
|
117
124
|
processors: true
|
118
|
-
build:
|
125
|
+
build: true
|
119
126
|
dsl: false
|
120
127
|
entity_definitions: true
|
121
|
-
code: true
|
122
|
-
version: true
|
123
128
|
templates: true
|
124
129
|
```
|
125
|
-
|
126
130
|
|
127
|
-
|
131
|
+
## Adding new subcommands to `PowerStencil`
|
132
|
+
|
133
|
+
Obviously by default the plugin does nothing very useful, yet it defined some placeholders and demo entity type. For example in the output here above it says `command_line: true`. What could it mean ?
|
128
134
|
|
129
135
|
Let's try to see to help:
|
130
136
|
|
@@ -167,15 +173,260 @@ Let's try it:
|
|
167
173
|
|
168
174
|
```shell
|
169
175
|
$ power_stencil myplugin
|
170
|
-
MYPLUGIN PLUGIN WAZ HERE
|
176
|
+
MYPLUGIN PLUGIN WAZ HERE !!
|
177
|
+
```
|
178
|
+
|
179
|
+
Wow it worked ! Useless, but worked ! But it's a good demo on how to create your own subcommands in `PowerStencil`.
|
180
|
+
|
181
|
+
## Providing entity types and templates
|
182
|
+
|
183
|
+
Of course you can provide new entity types and templates templates within plugin. The plugin created contains a demo entity type which brings its own template template (and even a custom build, but we will see that in next paragraph).
|
184
|
+
|
185
|
+
You can see in the output of `power_stencil info` (in _availaible entity types_) that a new entity type has been added to the project by the plugin: `myplugin_entity`
|
186
|
+
|
187
|
+
```
|
188
|
+
- Type 'myplugin_entity' --> Myplugin::EntityDefinitions::MypluginEntity (template-template path: '/tmp/demo/.ps_project/plugins/myplugin/etc/templates/myplugin_entity')
|
189
|
+
```
|
190
|
+
and you can see as well that it provides a template template.
|
191
|
+
|
192
|
+
So let's create a new entity of this type...
|
193
|
+
|
194
|
+
```
|
195
|
+
$ power_stencil create myplugin_entity/test -v
|
196
|
+
Creating new entity 'myplugin_entity/test'
|
197
|
+
Entities analysis completed.
|
198
|
+
Created 'myplugin_entity/test'
|
199
|
+
```
|
200
|
+
We can check the directory `myplugin_entity/test`, but actually a new entity has been created and provided some templates.
|
201
|
+
|
202
|
+
we can check using `power_stencil check myplugin_entity/test`:
|
203
|
+
|
204
|
+
```
|
205
|
+
$ power_stencil check myplugin_entity/test
|
206
|
+
'myplugin_entity/test':
|
207
|
+
- Storage path : '/tmp/demo/.ps_project/entities/myplugin_entity/test.yaml'
|
208
|
+
- Templates path : '/tmp/demo/myplugin_entity/test'
|
209
|
+
- Status : Valid
|
210
|
+
- Buildable : true
|
211
|
+
```
|
212
|
+
So it used the template templates to generate templates in `myplugin_entity/test`
|
213
|
+
|
214
|
+
So far so good, we can provide entity types and templates from a plugin... :+1:
|
215
|
+
|
216
|
+
## Providing custom build process
|
217
|
+
|
218
|
+
As we can see in the previous output of `power_stencil check myplugin_entity/test`, the entity is said to be `buildable`. But to demonstrate the possiblity to define custom builds within a plugin this entity is defined to be buildable by the plugin, meaning that after the templates are rendered, the plugin is involved to perform some post process actions. How is it achieved ?
|
219
|
+
|
220
|
+
First lets have a look at the entity type definition for `myplugin_entity`. `power_stencil info` shows that the class of the entity type is `Myplugin::EntityDefinitions::MypluginEntity` and we can find it in `.ps_project/plugins/myplugin/lib/myplugin/entity_definitions/myplugin_entity.rb`:
|
221
|
+
|
222
|
+
```ruby
|
223
|
+
module Myplugin
|
224
|
+
module EntityDefinitions
|
225
|
+
|
226
|
+
class MypluginEntity < PowerStencil::SystemEntityDefinitions::ProjectEntity
|
227
|
+
|
228
|
+
entity_type :myplugin_entity
|
229
|
+
|
230
|
+
buildable_by :myplugin
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
end
|
236
|
+
```
|
237
|
+
|
238
|
+
Here we see a standard entity type definition how we already saw previously except that instead of the standard `buildable` directive, we find a `buildable_by :myplugin` directive. This is simply saying that the build for this entity type is delegated to the plugin `myplugin`.
|
239
|
+
|
240
|
+
**:information_source: Entity types provided by plugins do not have to be built necessarily by the plugin they belong to !** Here the idea is just demonstrate the possibility to create custom builds.
|
241
|
+
|
242
|
+
|
243
|
+
As a reminder the build process is the following:
|
244
|
+
|
245
|
+
![simple-flow-image]
|
246
|
+
|
247
|
+
When we talk about custom builds we actually talk about the last step. The core `PowerStencil` engine provides only one `buildable` entity which is the `simple_exec` entity type. And its [post-process] action was simply to call the script (main.sh) it generated.
|
248
|
+
|
249
|
+
Here to demonstrate the possibility to create a custom build, the post-process action will simply display the template attached to `myplugin_entity` entity type.
|
250
|
+
|
251
|
+
If we have a look in `myplugin_entity/test` we see it contains a template named `message.txt`, and its content is:
|
252
|
+
|
253
|
+
```erb
|
254
|
+
|
255
|
+
This message has been generated on the <%= Time.now %>
|
256
|
+
This is an example of what you can do, and how much PowerStencil is customizable !
|
257
|
+
|
258
|
+
This text is the result of a full build process of the entity '<%= build_target.as_path %>' by the plugin '<%= build_target.buildable_by %>'.
|
259
|
+
|
260
|
+
```
|
261
|
+
Ok, knowing that, let's finally build the `myplugin_entity/test` we created in the previous paragraph:
|
262
|
+
|
263
|
+
```
|
264
|
+
$ power_stencil build myplugin_entity/test
|
265
|
+
|
266
|
+
This message has been generated on the 2019-10-24 18:37:46 +0200
|
267
|
+
This is an example of what you can do, and how much PowerStencil is customizable !
|
268
|
+
|
269
|
+
This text is the result of a full build process of the entity 'myplugin_entity/test' by the plugin 'myplugin'.
|
270
|
+
|
271
|
+
- 'myplugin_entity/test' has been correctly built
|
171
272
|
```
|
172
273
|
|
173
|
-
|
274
|
+
The last line is actually displayed by the build process, but see above that building the entity resulted in displaying the result of the _detemplatization_ ... So a post process actually occurred. Where does it come from ?
|
174
275
|
|
276
|
+
We can find that in the main file of the plugin: `.ps_project/plugins/myplugin/lib/myplugin.rb`:
|
175
277
|
|
176
|
-
|
278
|
+
```ruby
|
279
|
+
require 'myplugin/version'
|
280
|
+
require 'myplugin/plugin_helper'
|
281
|
+
require 'myplugin/myplugin_processor'
|
282
|
+
require 'myplugin/dsl/myplugin_dsl'
|
177
283
|
|
178
|
-
|
284
|
+
module Myplugin
|
285
|
+
|
286
|
+
def self.post_build_hook(built_entity, generated_files_path)
|
287
|
+
# This is an example of what you could do after files are generated, ie pretty much anything...
|
288
|
+
case built_entity.type
|
289
|
+
when :myplugin_entity
|
290
|
+
generated_file = File.join generated_files_path, 'message.txt'
|
291
|
+
puts File.readlines(generated_file)
|
292
|
+
else
|
293
|
+
raise PowerStencil::Error, 'Plugin myplugin doesnt know how handle the build of a myplugin_entity entity type !'
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|
298
|
+
```
|
299
|
+
|
300
|
+
This is pretty self explanatory. It contains only one method named `self.post_build_hook` and it receives as parameter:
|
301
|
+
|
302
|
+
* The entity you are building.
|
303
|
+
* The path to where the templates have been _detemplatized_.
|
304
|
+
|
305
|
+
:information_source: So it's really easy to implement whatever you want there and use information from both the entity itself and the generated files to implement something as complew as you want.
|
306
|
+
|
307
|
+
Here the code simply reads the generated `message.txt` file and displays it...
|
308
|
+
|
309
|
+
# Plugin capabilities and structure
|
310
|
+
|
311
|
+
So the `power_stencil plugin --create` generated a fully working plugin, implementing all the features (actually for the time being only custom dsl is not yet implemented) you could define in a template.
|
312
|
+
|
313
|
+
The generated plugin has the structure of a legit ruby gem, and this is not by chance, this is to prepare the fact that you may want to create a stand-alone plugin gem that you you may want to re-use in different projects.
|
314
|
+
|
315
|
+
But this is not mandatory. Actually the only mandatory file for a plugin to be valid is the file `etc/plugin_capabilities.yaml` in the plugin directory. This file declares what the plugin is able to do. For the `myplugin` we just created it contains:
|
316
|
+
|
317
|
+
```yaml
|
318
|
+
---
|
319
|
+
# This file defines the capabilities exposed by the plugin. This file is mandatory
|
320
|
+
# for a plugin to be considered as valid.
|
321
|
+
|
322
|
+
# Define the main module of the plugin. In this module you can define the build method
|
323
|
+
# if the plugin exposes a build (actually a post build hook occurring after the files
|
324
|
+
# are "detemplatized")
|
325
|
+
:plugin_module: Myplugin
|
326
|
+
|
327
|
+
# In the processors defined in the hereunder hash you map a subcommand with the processor
|
328
|
+
# that will handle it. A plugin can define as many subcommands as needed, or none...
|
329
|
+
# Hash keys should match sub-commands declared in the `command_line.yaml` file and processor
|
330
|
+
# classes should expose an `execute` method.
|
331
|
+
:processors:
|
332
|
+
myplugin: Myplugin::Processor
|
333
|
+
|
334
|
+
# This is the name of the method called after the files are detemplatized. This method has
|
335
|
+
# to be a module method in the `plugin_module` module.
|
336
|
+
:build: post_build_hook
|
337
|
+
|
338
|
+
# If a dsl module is declared it will be injected in the DSL available in the shell or templates
|
339
|
+
:dsl: null
|
340
|
+
|
341
|
+
# These are the files (array) defining entity types. These files should not be already
|
342
|
+
# required by the plugin as they will be required by the framework when needed.
|
343
|
+
:entity_definitions:
|
344
|
+
- myplugin/entity_definitions/myplugin_entity
|
345
|
+
|
346
|
+
# A list of root directories where you can find templates in directories named from the
|
347
|
+
# entity types they are attached to.
|
348
|
+
:templates:
|
349
|
+
- etc/templates
|
350
|
+
```
|
351
|
+
|
352
|
+
As it is quite self-documented, I won't too much elaborate on the meaning of each of the fields. But actually a plugin can actually provide ... nothing.
|
353
|
+
|
354
|
+
Let's create a plugin fully manually instead of using the `power_stencil plugin --create`. From the root of the project, let's create the directory:
|
355
|
+
|
356
|
+
$ mkdir -p .ps_project/plugins/minimal/etc
|
357
|
+
|
358
|
+
(of course the command to create the directory may be different on your system). Then here let's create a `plugin_capabilities.yaml` file with the following content:
|
359
|
+
|
360
|
+
```yaml
|
361
|
+
---
|
362
|
+
:plugin_module: null
|
363
|
+
:processors: null
|
364
|
+
:build: null
|
365
|
+
:dsl: null
|
366
|
+
:entity_definitions: null
|
367
|
+
:templates: null
|
368
|
+
```
|
369
|
+
|
370
|
+
Bam ! We just created a more than useless yet valid plugin ! You can check that in the output of `power_stencil info`:
|
371
|
+
|
372
|
+
```
|
373
|
+
--> Plugin 'minimal' has following capabilities:
|
374
|
+
- config: false
|
375
|
+
- command_line: false
|
376
|
+
- processors: false
|
377
|
+
- build: false
|
378
|
+
- dsl: false
|
379
|
+
- entity_definitions: false
|
380
|
+
- templates: false
|
381
|
+
```
|
382
|
+
|
383
|
+
All the code you may write has to be within the `lib` subdirectory, so let's create it:
|
384
|
+
|
385
|
+
$ mkdir -p .ps_project/plugins/minimal/lib
|
386
|
+
|
387
|
+
And create there a file named `minimal_entity.rb` with the following content:
|
388
|
+
|
389
|
+
```ruby
|
390
|
+
class Minimal < PowerStencil::SystemEntityDefinitions::ProjectEntity
|
391
|
+
entity_type :minimal
|
392
|
+
end
|
393
|
+
```
|
394
|
+
|
395
|
+
Then modify the `plugin_capabilities.yaml` file with the following content:
|
396
|
+
|
397
|
+
```yaml
|
398
|
+
---
|
399
|
+
:plugin_module: null
|
400
|
+
:processors: null
|
401
|
+
:build: null
|
402
|
+
:dsl: null
|
403
|
+
:entity_definitions:
|
404
|
+
- minimal_entity.rb
|
405
|
+
:templates: null
|
406
|
+
```
|
407
|
+
|
408
|
+
_Et voilà_, we have a plugin just providing new entity type, and it is fully working. We can create a new entity of this type:
|
409
|
+
|
410
|
+
```
|
411
|
+
$ power_stencil create minimal/test
|
412
|
+
Created 'minimal/test'
|
413
|
+
|
414
|
+
$ power_stencil get minimal/test
|
415
|
+
---
|
416
|
+
MinimalPlugin::Minimal:
|
417
|
+
:type: :minimal
|
418
|
+
:fields:
|
419
|
+
:name: test
|
420
|
+
```
|
421
|
+
|
422
|
+
All of this to demonstrate that a plugin can be almost anything, even something very minimalistic, but nevertheless you should keep on using the `power_stencil plugin --create` command and benefit from the structure it brings, as well as the possibility to become a stand-alone plugin gem...
|
423
|
+
|
424
|
+
|
425
|
+
# Conclusion
|
426
|
+
|
427
|
+
The documentation for plugins is not fully complete, so you are encouraged to read the code. Some official plugins are under development, and the documentation will be improved along their development...
|
428
|
+
|
429
|
+
**: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.** Yet now _local_ plugins are almost in their final stage. Gem plugins will soon be released and then `PowerStencil` will turn 1.0.0.
|
179
430
|
|
180
431
|
|
181
432
|
[:back:][Documentation root]
|
@@ -186,12 +437,12 @@ The documentation for plugins is not yet done, so you are encouraged to read the
|
|
186
437
|
[entities]: entities.md "Entities in PowerStencil"
|
187
438
|
[builds]: builds.md "Builds in PowerStencil"
|
188
439
|
[templates]: templates.md "Templates in PowerStencil"
|
189
|
-
|
440
|
+
[post-process]: builds.md#post-process-actions "post-process actions in builds"
|
190
441
|
|
191
442
|
<!-- Code links -->
|
192
443
|
|
193
444
|
|
194
445
|
<!-- Illustrations -->
|
195
|
-
|
446
|
+
[simple-flow-image]: images/power-stencil-simple-flow.svg
|
196
447
|
|
197
448
|
<!-- External links -->
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
# This file defines the capabilities exposed by the plugin. This file is mandatory
|
3
|
+
# for a plugin to be considered as valid.
|
4
|
+
|
5
|
+
# Define the main module of the plugin. In this module you can define the build method
|
6
|
+
# if the plugin exposes a build (actually a post build hook occurring after the files
|
7
|
+
# are "detemplatized")
|
8
|
+
:plugin_module: <%= plugin_module_name %>
|
9
|
+
|
10
|
+
# In the processors defined in the hereunder hash you map a subcommand with the processor
|
11
|
+
# that will handle it. A plugin can define as many subcommands as needed, or none...
|
12
|
+
# Hash keys should match sub-commands declared in the `command_line.yaml` file and processor
|
13
|
+
# classes should expose an `execute` method.
|
14
|
+
:processors:
|
15
|
+
<%= plugin_name %>: <%= plugin_module_name %>::Processor
|
16
|
+
|
17
|
+
# This is the name of the method called after the files are detemplatized. This method has
|
18
|
+
# to be a module method in the `plugin_module` module.
|
19
|
+
:build: post_build_hook
|
20
|
+
|
21
|
+
# If a dsl module is declared it will be injected in the DSL available in the shell or templates
|
22
|
+
:dsl: null
|
23
|
+
|
24
|
+
# These are the files (array) defining entity types. These files should not be already
|
25
|
+
# required by the plugin as they will be required by the framework when needed.
|
26
|
+
:entity_definitions:
|
27
|
+
- <%= plugin_name %>/entity_definitions/<%= plugin_name %>_entity
|
28
|
+
|
29
|
+
# A list of root directories where you can find templates in directories named from the
|
30
|
+
# entity types they are attached to.
|
31
|
+
:templates:
|
32
|
+
- etc/templates
|
33
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
**
|
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
This message has been generated on the <%= erb_insert 'Time.now' %>
|
3
|
+
This is an example of what you can do, and how much PowerStencil is customizable ! Check the plugin generated code and
|
4
|
+
taylor it to your needs...
|
5
|
+
|
6
|
+
This text is the result of a full build process of the entity '<%= erb_insert 'build_target.as_path' %>' by the plugin '<%= erb_insert 'build_target.buildable_by' %>'.
|
7
|
+
|
@@ -1,34 +1,19 @@
|
|
1
1
|
require '<%= plugin_name %>/version'
|
2
2
|
require '<%= plugin_name %>/plugin_helper'
|
3
3
|
require '<%= plugin_name %>/<%= plugin_name %>_processor'
|
4
|
+
require '<%= plugin_name %>/dsl/<%= plugin_name %>_dsl'
|
4
5
|
|
5
6
|
module <%= plugin_module_name %>
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.setup_entity_definitions
|
18
|
-
PowerStencil.logger.info 'Setting up <%= main_entry_point %> plugin entities'
|
19
|
-
securely_require '<%= plugin_name %>/entity_definitions/<%= plugin_name %>_entity', fail_on_error: true
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.setup_plugin_templates
|
23
|
-
Dir.entries(plugin_templates_path).reject { |e| %w(. ..).include? e }.each do |entry|
|
24
|
-
template_path = File.join(plugin_templates_path, entry)
|
25
|
-
if Dir.exist? template_path
|
26
|
-
PowerStencil.project.register_template_path_for_type entry.to_sym, template_path
|
27
|
-
end
|
8
|
+
def self.post_build_hook(built_entity, generated_files_path)
|
9
|
+
# This is an example of what you could do after files are generated, ie pretty much anything...
|
10
|
+
case built_entity.type
|
11
|
+
when :<%= plugin_name %>_entity
|
12
|
+
generated_file = File.join generated_files_path, 'message.txt'
|
13
|
+
puts File.readlines(generated_file)
|
14
|
+
else
|
15
|
+
raise PowerStencil::Error, 'Plugin <%= plugin_name %> doesnt know how handle the build of a <%= plugin_name %>_entity entity type !'
|
28
16
|
end
|
29
17
|
end
|
30
18
|
|
31
19
|
end
|
32
|
-
|
33
|
-
# All plugins have to be in the PowerStencil::Plugin namespace !
|
34
|
-
PowerStencil::Plugin::<%= plugin_module_name %> = <%= plugin_module_name %>
|