power_stencil 0.8.11 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -15
  3. data/doc/faq.md +4 -7
  4. data/doc/git_integration.md +38 -12
  5. data/etc/meta_templates/plugin_seed/README.md +133 -0
  6. data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +20 -5
  7. data/etc/meta_templates/plugin_seed/spec/project_helper.rb +50 -0
  8. data/etc/meta_templates/plugin_seed/spec/spec_helper.rb +16 -0
  9. data/etc/meta_templates/plugin_seed/spec/{entity}_spec.rb +30 -0
  10. data/etc/power_stencil.yaml +6 -1
  11. data/etc/templates/plugin_definition/README.md +110 -20
  12. data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +20 -5
  13. data/etc/templates/plugin_definition/spec/project_helper.rb +50 -0
  14. data/etc/templates/plugin_definition/spec/spec_helper.rb +4 -2
  15. data/etc/templates/plugin_definition/spec/{entity}_spec.rb +24 -3
  16. data/etc/templates/zsh_command_line_completion/_power_stencil.sh.erb +18 -8
  17. data/lib/power_stencil.rb +4 -0
  18. data/lib/power_stencil/command_processors/adm.rb +29 -1
  19. data/lib/power_stencil/command_processors/create.rb +1 -1
  20. data/lib/power_stencil/dsl/completion.rb +37 -0
  21. data/lib/power_stencil/dsl/plugin_generation.rb +4 -0
  22. data/lib/power_stencil/engine/base.rb +2 -0
  23. data/lib/power_stencil/engine/build_handling.rb +5 -0
  24. data/lib/power_stencil/engine/directory_processor.rb +20 -1
  25. data/lib/power_stencil/engine/entities_handling.rb +2 -2
  26. data/lib/power_stencil/engine/renderers/haml.rb +21 -0
  27. data/lib/power_stencil/initializer.rb +6 -1
  28. data/lib/power_stencil/plugins/command_line.rb +3 -1
  29. data/lib/power_stencil/project/completion.rb +3 -5
  30. data/lib/power_stencil/ultra_command_line/command_line_manager.rb +35 -0
  31. data/lib/power_stencil/ultra_command_line/option_definition.rb +5 -0
  32. data/lib/power_stencil/ultra_command_line/providers_manager.rb +21 -0
  33. data/lib/power_stencil/ultra_command_line/sub_command.rb +12 -0
  34. data/lib/power_stencil/utils/completion.rb +19 -9
  35. data/lib/power_stencil/version.rb +1 -1
  36. data/power_stencil.gemspec +2 -1
  37. metadata +34 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df94a3acebefba79cac4230615727310af33352c
4
- data.tar.gz: d9c23c0e8b153af072e533d6e170b412e9bcccdd
3
+ metadata.gz: f8ef665f1ce87e962192d7725c2dbd851759bc00
4
+ data.tar.gz: 65d6b440a419dddc9a3f0c46c2b7c80db9d78d90
5
5
  SHA512:
6
- metadata.gz: ef6af6b335756c7120575eba283887e704371a90032ae24c60f12915ddf43cebdb2205eb58c445b36a374d6255c114150bb816576ef3ded5304ef4227198e43c
7
- data.tar.gz: 60b5625ba00c9fa20176f584d32b8c405b9dbf41a93b29d1d24b4bf453cd75d133c74b41e3620d1fef80beb6a44009ba8755c3a2dbdcd1834167b3dc42538131
6
+ metadata.gz: 8e39368e94c8710dba97db574916017d9a30ce45468d5674787daef4f2ad915af8dba03235d60988a2f887a96020f151dabccd160b32baef0d4421a576339284
7
+ data.tar.gz: 7a7ba9f93020d3d92954ef997d46d5724ff11e79deec6270e1a283009faf00df56762435532aa8762dbad93ea062af4931b21fb76941fa04ec59cc0b141de69d
data/README.md CHANGED
@@ -15,10 +15,10 @@ See [official website][PowerStencil site].
15
15
  - [Installation](#installation)
16
16
  - [Usage](#usage)
17
17
  - [Help](#help)
18
- - [Command line auto-completion](#command-line-auto-completion)
19
- - [Creating a `PowerStencil` project](#creating-a-powerstencil-project)
20
- - [`PowerStencil` project structure](#powerstencil-project-structure)
21
18
  - [Getting started](#getting-started)
19
+ - [Creating a `PowerStencil` project](#creating-a-powerstencil-project)
20
+ - [`PowerStencil` project structure overview](#powerstencil-project-structure-overview)
21
+ - [Command line auto-completion](#command-line-auto-completion)
22
22
  - [Entities](#entities)
23
23
  - [Templates](#templates)
24
24
  - [Builds](#builds)
@@ -62,11 +62,12 @@ The `PowerStencil` gem provides the `power_stencil` executable which is a plugga
62
62
 
63
63
  **Actually `PowerStencil` is _not_ a templating engine**. It uses already existing and proven templating engines.
64
64
 
65
- 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...).
65
+ `PowerStenil` currently embeds two templating engines:
66
66
 
67
- 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].
67
+ * **[ERB] is the default**. This is a pretty standard and very well known engine in the [Ruby] world and especially for people who already used the [Rails] framework. This is a generic templating engine which can handle any use-case. Each template will be processed by default using the [ERB] engine.
68
+ * When it comes to generate mark-up documents like XML or HTML, many people prefer to use [Haml], as it designed towards generating these kinds of documents and tends to end-up with much clearer templates. Any template whose names ends by `.haml` will be processed by the [Haml] engine by default instead of [ERB].
68
69
 
69
- So `PowerStencil` is definitely not a templating it is actually much more than that.
70
+ So `PowerStencil` is definitely not a templating engine, it is actually much more than that. It is a framework to manage your templates, design the relational data you can use in your templates, manage the versioning, define the way you build things etc... Read this documentation (and especially the [getting started](#getting-started) section which is a tutorial in itself).
70
71
 
71
72
 
72
73
  # Installation
@@ -134,17 +135,16 @@ The program uses the standard paradigm of sub-commands (à-la-git), and each can
134
135
 
135
136
  [Plugins] may bring extra subcommands and/or options, so depending on the project you are working in, the output of `--help` may differ...
136
137
 
137
- ## Command line auto-completion
138
138
 
139
- `PowerStencil` comes with a command-line auto-completion feature for `zsh`. It is not yet available for `bash`.
140
139
 
141
- You can install it by running:
142
140
 
143
- $ power_stencil adm --zsh-completion
144
141
 
145
- It provides a very useful auto-completion for sub-commands, options as well as parameters...
142
+ ## Getting started
143
+
144
+ See the 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.
146
145
 
147
- ## Creating a `PowerStencil` project
146
+
147
+ ### Creating a `PowerStencil` project
148
148
 
149
149
  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):
150
150
 
@@ -156,7 +156,7 @@ Once the project created, if you are anywhere within the project tree, you don't
156
156
 
157
157
  **:information_source: If you have `git` installed on your system, **the repository of the newly created project has been automatically turned into a git repository. And any action done through the `power_stencil` command-line will be automatically tracked by `git`**. Only things you will do outside of the `power_stencil` command-line (adding or modifying templates, creating or modifying entity types... any manual action) will require a user action to make `git` take it in account. You can completely de-activate this behaviour if you want to fully manage things by yourself by adding `:no-git: true` in the `.ps_project/versioned-config.yaml`, yet there is no good reason for that... Unless you know what you are doing, you should keep the default settings. See [Git integration] for further information.
158
158
 
159
- ## `PowerStencil` project structure
159
+ ### `PowerStencil` project structure overview
160
160
 
161
161
  The structure of a brand new `PowerStencil` project is the following:
162
162
 
@@ -191,9 +191,21 @@ There is the same mechanism between `.ps_project/entities` (where the project da
191
191
 
192
192
  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.
193
193
 
194
- ## Getting started
194
+ ### Command line auto-completion
195
+
196
+ `PowerStencil` comes with a powerful command-line auto-completion feature for `zsh`. (It is not yet available for `bash`).
197
+
198
+ You can install it by running:
199
+
200
+ $ power_stencil adm --zsh-completion
201
+
202
+ It provides a very useful auto-completion for sub-commands, options as well as options parameters...
203
+
204
+ `PowerStencil` uses a _two-stages_ auto-completion mechanism:
205
+
206
+ * Project independent completion is generated in `~/.zsh/completion/_power_stencil`, whereas completion related to new commands or options, coming from plugins used in a project, is generated (and versioned) within the project itself, in `.ps_project/.zsh_project_completion`.
195
207
 
196
- 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.
208
+ * Meaning that if you want to benefit from the "_full_" completion from within a project you may have to re-run `power_stencil add --zsh-completion` from within any project where you use extra plugins, in order to generate that `.ps_project/.zsh_project_completion` file. If you don't, it is not a big deal, but then you will only have access to the "_generic_" completion, ie completion not taking in account any of the extra commands or options you are using in this project brought by plugins you may use...
197
209
 
198
210
  ### Entities
199
211
 
data/doc/faq.md CHANGED
@@ -72,12 +72,13 @@ I had the opportunity to have access to a Windows VM and tested `PowerStencil`.
72
72
 
73
73
  # What is the status of `PowerStencil` ?
74
74
 
75
- `PowerStencil` is still under development, yet **it can already be safely used**.
75
+ `PowerStencil` is still considered under development until version `1.0.0` is released, yet **it can already be safely used**, event for production.
76
+
77
+ **Since it entered the `0.9.x` version, no new feature should be added**. That branch will be used for statibilisation and anything released there should only be related to bugfixes, and plugin developement. As a bunch of official plugins should be released along with the version `1.0.0`.
76
78
 
77
79
  Regarding `PowerStencil` core:
78
80
 
79
- - 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.
80
- - New system entity types may appear.
81
+ - The plugin related features may still evole a bit along with first official plugins development, but since both local and gems plugins are supported no big change may arise in the architecture.
81
82
  - The functional documentation is evolving.
82
83
  - There is almost no technical/architectural documentation yet. Read the code...
83
84
 
@@ -85,10 +86,6 @@ Anyway `PowerStencil` follows the semantic versioning pattern and if incompatibl
85
86
 
86
87
  There are already some plugins in the pipe. See [example use cases], to get an idea of the first official plugins to come.
87
88
 
88
- :information_source: Of course, `PowerStencil` is new software and it is expected to evolve with the needs of its users...
89
-
90
-
91
-
92
89
 
93
90
  [:back:][Documentation root]
94
91
  <!-- End of Document -->
@@ -13,6 +13,7 @@ Git integration
13
13
  - [Deleting an entity](#deleting-an-entity)
14
14
  - [`PowerStencil` shell session](#powerstencil-shell-session)
15
15
  - [Plugin creation](#plugin-creation)
16
+ - [(Re)Generating `zsh` command line completion for the project](#regenerating-zsh-command-line-completion-for-the-project)
16
17
  - [Manual actions](#manual-actions)
17
18
 
18
19
  <!-- /TOC -->
@@ -36,18 +37,19 @@ Here is a summary:
36
37
 
37
38
  | `PowerStencil` sub-command | Status |
38
39
  |----------------------------|:------:|
39
- |init | creates a project
40
- |info | read-only
41
- |plugin | creates a plugin
42
- |get | read-only
43
- |shell | do anything
44
- |adm | read-only
45
- |check | read-only
46
- |create | creates entities
47
- |edit | modifies entities
48
- |delete | deletes entities
49
- |describe | read-only
50
- |build | read-only
40
+ |`init` | creates a project
41
+ |`info` | read-only
42
+ |`plugin` | creates a plugin
43
+ |`get` | read-only
44
+ |`shell` | do anything
45
+ |`adm --zsh-completion` | generates zsh command-line completion
46
+ |`check` | read-only
47
+ |`create` | creates entities
48
+ |`edit` | modifies entities
49
+ |`delete` | deletes entities
50
+ |`describe` | read-only
51
+ |`build` | read-only
52
+
51
53
 
52
54
  On top this we could add some other actions, you can obviously perform manually within the repository, like:
53
55
 
@@ -306,6 +308,30 @@ Date: Sun Nov 3 19:42:11 2019 +0100
306
308
  Cool ! Nevertheless, plugins may be one of the things you may want to track a bit differently. For example as git sub-modules, to keep a separated git history, and ease future re-useability of the plugin you are developing.
307
309
  So it's up to you and `PowerStencil` provides an easy way to keep your plugin out of your project repo. Same as for `power_stencil init`, `power_stencil plugin --create` supports the `--no-git` option...
308
310
 
311
+ ## (Re)Generating `zsh` command line completion for the project
312
+
313
+ If you generate the zsh command line completion file for the project by doing, from within the project:
314
+
315
+ $ power_stencil adm --zsh-completion
316
+
317
+ You will then generate a file that contains project-specific zsh completion directives: `.ps_project/.zsh_project_completion`.
318
+
319
+ That file is versioned too, because its content depends on the plugins (local or as gems) that you actually use in this project. **If you add a new plugin or modify the way local ones handle the command-line, you should then regenerate it**, by re-running that command if you want the completion to fully take in account your changes.
320
+
321
+ It is tracked like that:
322
+ ```
323
+ $ git log -1 --summary
324
+ commit 0c7bedb7249654873882c56bb15172c528511cff
325
+ Author: Joe <joe@outerspace.org>
326
+ Date: Sun Nov 10 11:21:10 2019 +0100
327
+
328
+ Adding project specific zsh completion file: '.ps_project/.zsh_project_completion'.
329
+
330
+ create mode 100644 .ps_project/.zsh_project_completion
331
+ ```
332
+
333
+
334
+
309
335
  # Manual actions
310
336
 
311
337
  Ok, so far we have a pretty nice git history:
@@ -0,0 +1,133 @@
1
+ <% gem_name = "psplugin_#{ plugin_name}" -%>
2
+ <%= plugin_title_name %>
3
+ <%= '=' * plugin_title_name.size %>
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/<%= gem_name %>.svg)](https://rubygems.org/gems/<%= gem_name %>) [![Pipeline status](https://gitlab.com/tools4devops/psplugins/<%= gem_name %>/badges/master/pipeline.svg)](https://gitlab.com/tools4devops/psplugins/<%= gem_name %>/commits/master)
6
+
7
+ [PowerStencil] is the Swiss-army knife templating workflow for developers and ops.
8
+
9
+ `<%= plugin_title_name %>` is a [PowerStencil] plugin.
10
+
11
+ See [official website][PowerStencil site].
12
+
13
+
14
+ <!-- TOC -->
15
+
16
+ - [What is a PowerStencil plugin ?](#what-is-a-powerstencil-plugin-)
17
+ - [Using this plugin in your `PowerStencil` projects](#using-this-plugin-in-your-powerstencil-projects)
18
+ - [Goal of this plugin](#goal-of-this-plugin)
19
+ - [Plugin dependencies](#plugin-dependencies)
20
+ - [Standard gems dependencies](#standard-gems-dependencies)
21
+ - [Dependency to other plugins](#dependency-to-other-plugins)
22
+ - [Plugin capabilities](#plugin-capabilities)
23
+ - [Config](#config)
24
+ - [Subcommands and options](#subcommands-and-options)
25
+ - [Post-build actions](#post-build-actions)
26
+ - [DSL in templates and in `power_stencil shell`](#dsl-in-templates-and-in-power_stencil-shell)
27
+ - [Entity types](#entity-types)
28
+ - [Templates-templates](#templates-templates)
29
+ - [Contributing](#contributing)
30
+ - [License](#license)
31
+ - [Code of Conduct](#code-of-conduct)
32
+
33
+ <!-- /TOC -->
34
+
35
+ # What is a PowerStencil plugin ?
36
+
37
+ A `PowerStencil` plugin can be used in the context of a `PowerStencil` project and bring extra features to a standard project.
38
+
39
+ If you don't know what `PowerStencil` is made for, you may read [the documentation][PowerStencil] first.
40
+
41
+ Features provided by a plugin can be:
42
+
43
+ * Extra config.
44
+ * Extra subcommands or options added to the `power_stencil` command-line.
45
+ * Extra post-build actions.
46
+ * Extra DSL methods available in templates and in `power_stencil shell`.
47
+ * Extra entity types.
48
+ * Extra templates-templates.
49
+
50
+ # Using this plugin in your `PowerStencil` projects
51
+
52
+ To use this plugin within your `PowerStencil` project, you need to:
53
+
54
+ * be within a `PowerStencil` project :wink:.
55
+ * declare this plugin in the project configuration (from the root of your project in the `.ps_project/versioned-config.yaml` file).
56
+
57
+ In this yaml configuration file, you just have to add a new entry in the `:project_plugins` array or simply create it if it is not yet existing:
58
+
59
+ ```yaml
60
+ :project_plugins:
61
+ - <%= gem_name %>
62
+ ```
63
+ If this plugin is not already present on your machine, you may have to download it:
64
+
65
+ $ power_stencil plugin --install
66
+
67
+ And then you may see information about the plugin by running:
68
+
69
+ * `power_stencil info` in the plugins section.
70
+ * `power_stencil plugin --list -v`
71
+
72
+ # Goal of this plugin
73
+
74
+ # Plugin dependencies
75
+
76
+ ## Standard gems dependencies
77
+
78
+ Standard dependencies are declared normally in the _gemspec file_. They are automatically installed when installing the plugin with `power_stencil plugin --install`.
79
+
80
+ ## Dependency to other plugins
81
+
82
+ For development purpose, dependency to other plugins are declared in the _gemspec file_ as _development dependency_.
83
+
84
+ But within a project, dependencies have to be added to the `:project_plugins` array in the project configuration file (`.ps_project/versioned-config.yaml`).
85
+
86
+
87
+ # Plugin capabilities
88
+
89
+ This plugin provides the following features:
90
+
91
+ ## Config
92
+
93
+ ## Subcommands and options
94
+
95
+ ## Post-build actions
96
+
97
+ ## DSL in templates and in `power_stencil shell`
98
+
99
+ ## Entity types
100
+
101
+ ## Templates-templates
102
+
103
+ # Contributing
104
+
105
+ Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/tools4devops/psplugins/<%= plugin_name %>/issues. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
106
+
107
+ ## License
108
+
109
+ The gem is available as open source under the terms of the [MIT License].
110
+
111
+ ## Code of Conduct
112
+
113
+ Everyone interacting in the PowerStencil project’s codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct].
114
+
115
+ <!-- End of Document -->
116
+
117
+ <!-- Pages -->
118
+ [code of conduct]: CODE_OF_CONDUCT.md
119
+
120
+ <!-- Code links -->
121
+
122
+ <!-- Illustrations -->
123
+ [simple-flow-image]: doc/images/power-stencil-simple-flow.svg
124
+
125
+ <!-- External links -->
126
+ [MIT License]: http://opensource.org/licenses/MIT "The MIT license"
127
+ [ERB]: https://ruby-doc.org/stdlib-2.6.3/libdoc/erb/rdoc/ERB.html "Quick ERB description"
128
+ [Haml]: http://haml.info/ "The templating engine for XML-like documents"
129
+ [Ruby]: https://www.ruby-lang.org "The powerful Ruby language"
130
+ [Rails]: https://rubyonrails.org/ "The Ruby on Rails framework"
131
+ [PowerStencil site]: https://powerstencil.brizone.org "Official PowerStencil website"
132
+ [PowerStencil]: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md "PowerStencil documentation"
133
+ [PowerStencil plugins]: https://gitlab.com/tools4devops/power_stencil/blob/master/doc/plugins.md "PowerStencil plugins documentation"
@@ -12,13 +12,27 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{<%= plugin_name %> is a plugin for the PowerStencil framework.}
13
13
  spec.description = %q{TODO: Write a longer description or delete this line.}
14
14
  spec.homepage = "TODO: Put your gem's website or public repo URL here."
15
- spec.license = "MIT"
15
+ spec.license = 'MIT'
16
16
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ # Change this and following metadata if you don't want your plugin to be an "official" PowerStencil plugin.
18
+ # ie deployed to https://gitlab.com/tools4devops/psplugins
19
+ source_code_uri = 'https://gitlab.com/tools4devops/psplugins/<%= plugin_name %>'
20
+
21
+ # Gem metadata
19
22
  if spec.respond_to?(:metadata)
23
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
24
+ # to allow pushing to a single host or delete this line to allow pushing to any host.
20
25
  spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
- # This metadata is mandatory for PowerStencil !!
26
+
27
+ # Nice link to your home page on rubygems.org
28
+ spec.metadata['homepage_uri'] = spec.homepage
29
+
30
+ # You have to probably change this if you don't deploy to gitlab
31
+ spec.metadata['bug_tracker_uri'] = "#{source_code_uri}/issues"
32
+ spec.metadata['documentation_uri'] = "#{source_code_uri}/blob/master/README.md"
33
+ spec.metadata['source_code_uri'] = source_code_uri
34
+
35
+ # This metadata is mandatory for a PowerStencil plugin !!
22
36
  spec.metadata['plugin_name'] = '<%= plugin_name %>'
23
37
  else
24
38
  raise 'RubyGems 2.0 or newer is required to protect against public gem pushes and PowerStencil plugin mechanism !'
@@ -31,8 +45,9 @@ Gem::Specification.new do |spec|
31
45
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
46
  spec.require_paths = ['lib']
33
47
 
34
- spec.add_development_dependency 'bundler', '~> 2.0.2'
48
+ spec.add_development_dependency 'bundler'
35
49
  spec.add_development_dependency 'rake', '~> 10.0'
36
50
  spec.add_development_dependency 'rspec', '~> 3.0'
37
51
  spec.add_development_dependency 'power_stencil', "~> <%= PowerStencil::VERSION %>"
52
+
38
53
  end
@@ -0,0 +1,50 @@
1
+ module PowerStencilTests
2
+
3
+ module Project
4
+
5
+ TEMP_DIR_PREFIX = 'PS_TESTS_'
6
+
7
+ module ClassMethods
8
+
9
+
10
+ def temporary_project(project_name, with_git_support: false, scope: :all)
11
+ self.instance_eval do
12
+ puts scope
13
+ around(scope) do |execution|
14
+ Dir.mktmpdir(TEMP_DIR_PREFIX) do |tests_root_dir|
15
+ tmp_project_path = File.join tests_root_dir, project_name
16
+ create_project_including_this_plugin tmp_project_path, with_git_support: with_git_support
17
+ execution.run
18
+ @tmp_project_path = nil
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def plugin_path
25
+ File.expand_path File.join('..', '..'), __FILE__
26
+ end
27
+
28
+ end
29
+
30
+ attr_reader :tmp_project_path
31
+
32
+ def self.included(base)
33
+ base.extend(ClassMethods)
34
+ end
35
+
36
+ def create_project_including_this_plugin(project_path, with_git_support: false)
37
+ cmd = "power_stencil init --project-path '#{project_path}'"
38
+ cmd << ' --no-git' unless with_git_support
39
+ `#{cmd}`
40
+ project_plugin_path = File.join project_path, '.ps_project', 'plugins'
41
+ `ln -s '#{self.class.plugin_path}' '#{project_plugin_path}'`
42
+ @tmp_project_path = project_path
43
+ end
44
+
45
+ def temporary_project_cmd(params)
46
+ "power_stencil #{params} --project-path '#{tmp_project_path}'"
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler/setup'
2
+ require 'power_stencil'
3
+ require "<%= plugin_name %>"
4
+ require 'project_helper'
5
+
6
+ RSpec.configure do |config|
7
+ # Enable flags like --only-failures and --next-failure
8
+ config.example_status_persistence_file_path = ".rspec_status"
9
+
10
+ # Disable RSpec exposing methods globally on `Module` and `main`
11
+ config.disable_monkey_patching!
12
+
13
+ config.expect_with :rspec do |c|
14
+ c.syntax = :expect
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ RSpec.describe <%= plugin_module_name %> do
2
+
3
+ include PowerStencilTests::Project
4
+ temporary_project 'test_project', scope: :all
5
+
6
+ let(:plugin_list) { 'plugin --list' }
7
+ let(:test_entity) { '<%= plugin_name %>_entity/test_<%= plugin_name %>' }
8
+ let(:create_<%= plugin_name %>) { "create #{test_entity}" }
9
+ let(:get_<%= plugin_name %>) { "get #{test_entity}" }
10
+
11
+ it 'has a version number' do
12
+ expect(<%= plugin_module_name %>::VERSION).not_to be nil
13
+ end
14
+
15
+ it 'should add a "<%= plugin_name %>" sub-command' do
16
+ expect(`#{temporary_project_cmd plugin_list}`).to match '- <%= plugin_name %>'
17
+ end
18
+
19
+ it 'should be possible to create a "<%= plugin_name %>_entity"' do
20
+ `#{temporary_project_cmd create_<%= plugin_name %>}`
21
+ expect($?.success?).to be_truthy
22
+ expect(`#{temporary_project_cmd get_<%= plugin_name %>}`).not_to be_empty
23
+ end
24
+
25
+ it 'should do something useful' do
26
+ pending 'Tests implementation'
27
+ RSpec.fail
28
+ end
29
+
30
+ end