power_stencil 0.3.9 → 0.4.0

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: 63b5292b83c11cf7fb867257189af4945225de5b
4
- data.tar.gz: 104f23b19dfc0d0851e06bdb34f8e8ec5fe2c59e
3
+ metadata.gz: 9852320333b0476c1e74b31ea327946e3a6d94b9
4
+ data.tar.gz: 44de44adfb97d695d8f1e7311566cea9b4ae47a9
5
5
  SHA512:
6
- metadata.gz: e6baf3d3caecbf9a102dbc42c272db77d7092dc77b97be2a87f98f6f1f807d3229c45fddcf36fc03bfbc678eb24aff074fdd9473652cc688e38a05e875aba76f
7
- data.tar.gz: 41353ec4a84de5acabee14f9338ba9f311e9aed5c9a82588037cba254ad22c8bbc8d5a8ca82da0e940e5fd48183984832e0b9147dd4bb022821516d39b757886
6
+ metadata.gz: d867a9e2efa622ecce40dac7446309a1164c1a8b2750855ef4217708e519984c31698a1c567090d5defe630045c056397f9083ebbdfd15b698acdf4a295063b5
7
+ data.tar.gz: fc06c6240c6d8f60a4eabe4f0c1a7fc3cb83a9d72c5e2ed7878296466637f8fa03519994f8ec66222f7a4d838e38081f15ab2a593d965be583900fed7a5f59aa
data/.gitignore CHANGED
@@ -10,4 +10,5 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  /.idea/
13
+ /.ruby-version
13
14
  /test/test_project/build/
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in power_stencil.gemspec
4
+
4
5
  gemspec
data/README.md CHANGED
@@ -13,6 +13,7 @@ PowerStencil
13
13
  - [Creating a `PowerStencil` project](#creating-a-powerstencil-project)
14
14
  - [`PowerStencil` project structure](#powerstencil-project-structure)
15
15
  - [Getting started](#getting-started)
16
+ - [Project status](#project-status)
16
17
  - [Contributing](#contributing)
17
18
  - [License](#license)
18
19
  - [Code of Conduct](#code-of-conduct)
@@ -23,7 +24,7 @@ PowerStencil
23
24
 
24
25
  `PowerStencil` proposes a radical approach on how to manage your shared configuration.
25
26
 
26
- 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.
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.
27
28
 
28
29
  From a very high level point of view, the workfow `PowerStencil` proposes looks like:
29
30
 
@@ -35,6 +36,8 @@ It is a common pattern to introduce a database to manage shared configuration fo
35
36
 
36
37
  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.
37
38
 
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.
40
+
38
41
  The `PowerStencil` gem provides the `power_stencil` executable which is a pluggable CLI to:
39
42
 
40
43
  - Manage the project data
@@ -174,6 +177,9 @@ And course, you may:
174
177
  - Read the [F.A.Q.]
175
178
  - See some real world [example use cases].
176
179
 
180
+ # Project status
181
+
182
+ Check `PowerStencil` [status in the F.A.Q.].
177
183
 
178
184
  # Contributing
179
185
 
@@ -196,6 +202,7 @@ Everyone interacting in the PowerStencil project’s codebases, issue trackers,
196
202
  [plugins]: doc/plugins.md "Plugins in PowerStencil"
197
203
  [example use cases]: doc/example_use_cases.md "Example uses cases using PowerStencil"
198
204
  [F.A.Q.]: doc/faq.md "PowerStencil F.A.Q."
205
+ [status in the F.A.Q.]: doc/faq.md#what-is-the-status-of-powerstencil- "PowerStencil project status"
199
206
  [code of conduct]: CODE_OF_CONDUCT.md
200
207
 
201
208
  <!-- Code links -->
@@ -208,4 +215,4 @@ Everyone interacting in the PowerStencil project’s codebases, issue trackers,
208
215
  [MIT License]: http://opensource.org/licenses/MIT "The MIT license"
209
216
  [ERB]: https://ruby-doc.org/stdlib-2.6.3/libdoc/erb/rdoc/ERB.html "Quick ERB description"
210
217
  [Haml]: http://haml.info/ "The templating engine for XML-like documents"
211
- [Ruby]: https://www.ruby-lang.org "The powerful Ruby language"
218
+ [Ruby]: https://www.ruby-lang.org "The powerful Ruby language"
@@ -272,7 +272,12 @@ $ power_stencil get base_entity --names-only --regexp
272
272
 
273
273
  - my_1st_entity
274
274
  ```
275
- There are 2 other options (`--compiled` and `--scenario`) but they will be covered in the scope of [builds].
275
+ There are 2 other interesting options (`--compiled` and `--scenario`) but they will be covered in the scope of [builds].
276
+
277
+ :information_source: Another very interesting option is `--graph`. **It will generate a [Graphviz] graph of the relations of the entities within the repository.** This is actually provided by the [universe_compiler] Gem. The display of this graph can be completed customized at project level (the 2 versioned and unversioned config files), at entity level (by providing a `#graphviz_label` method in your entities. You'll see later in that document what it means in [creating custom entity types](#creating-custom-entity-types)), and even at plugin level.
278
+
279
+ By default the graph is generated in a temporary folder, but of course you can specify the file name using the `--graph-file` options. The default is to generate an svg file (best viewed in a browser as it contains _hover_ over its nodes).
280
+
276
281
 
277
282
  ## Creating entities
278
283
 
@@ -963,4 +968,5 @@ Now you know an entity type is just a regular Ruby class. As such you could add
963
968
  [Pry]: https://github.com/pry/pry "The awesome Pry console"
964
969
  [ActiveRecord]: https://guides.rubyonrails.org/active_record_basics.html "The ultimate ORM"
965
970
  [Ruby On Rails]: https://rubyonrails.org/ "One of the best Web framework"
966
- [universe_compiler]: https://gitlab.com/tools4devops/universe_compiler "The underlying engine to manage entities and compilation !"
971
+ [universe_compiler]: https://gitlab.com/tools4devops/universe_compiler "The underlying engine to manage entities and compilation !"
972
+ [Graphviz]: (https://www.graphviz.org/) "Graph Visualization Software"
@@ -148,6 +148,11 @@
148
148
  :summary: Displays the query result as a graph.
149
149
  :short_aliases:
150
150
  - g
151
+ graph-file:
152
+ :type: string
153
+ :summary: Displays the query result as a graph in the specified file.
154
+ :long_aliases:
155
+ - gf
151
156
  shell:
152
157
  :banner: |
153
158
  Opens a shell to interact with entities.
@@ -1,4 +1,27 @@
1
1
  # This config file provided by the plugin '<%= main_entry_point %>' will be
2
2
  # automatically merged into the global project config
3
3
 
4
- # :<%= plugin_name %>.property1: value 1
4
+ :<%= plugin_name %>.property1: value 1
5
+
6
+ # Graphviz configuration
7
+ #
8
+ # If you are under Gnome, chances are that you have 'eog' installed
9
+ # or put you own there. Unless in the path specify full path to it:
10
+ # node defines the default graphviz node attributes. In customization
11
+ # each key can be an entity type, that you can fully customize using the
12
+ # same mechanism
13
+
14
+ #:graphviz:
15
+ # :viewer: eog '%s'
16
+ # :label: < Repository Entities <br/> >
17
+ # :labelloc: :t
18
+ # :show_config: false
19
+ # :file_type: svg
20
+ # :node:
21
+ # :shape: box
22
+ # :style: filled
23
+ # :fillcolor: grey95
24
+ # :customizations:
25
+ # :my_custom_entity:
26
+ # :shape: circle
27
+ # :fillcolor: red
@@ -9,7 +9,6 @@ module <%= plugin_module_name %>
9
9
 
10
10
  def execute
11
11
  puts '<%= main_entry_point.upcase %> PLUGIN WAZ HERE'
12
- puts_and_logs config[].to_yaml
13
12
  end
14
13
 
15
14
 
@@ -82,7 +82,19 @@
82
82
  # are automatically discovered and loaded.
83
83
  :project_plugins: []
84
84
 
85
-
85
+ # Graphviz
86
+
87
+ # Customize graphviz properties
88
+ :graphviz:
89
+ :label: < Repository Entities <br/> >
90
+ :labelloc: :t
91
+ :show_config: false
92
+ :file_type: :svg
93
+ :node:
94
+ :shape: box
95
+ :style: filled
96
+ :fillcolor: grey95
97
+ :customizations: {}
86
98
 
87
99
  # MISC
88
100
 
@@ -1,4 +1,27 @@
1
1
  # This config file provided by the plugin '<%= main_entry_point %>' will be
2
2
  # automatically merged into the global project config
3
3
 
4
- # :<%= plugin_name %>.property1: value 1
4
+ :<%= plugin_name %>.property1: value 1
5
+
6
+ # Graphviz configuration
7
+ #
8
+ # If you are under Gnome, chances are that you have 'eog' installed
9
+ # or put you own there. Unless in the path specify full path to it:
10
+ # node defines the default graphviz node attributes. In customization
11
+ # each key can be an entity type, that you can fully customize using the
12
+ # same mechanism
13
+
14
+ #:graphviz:
15
+ # :viewer: eog '%s'
16
+ # :label: < Repository Entities <br/> >
17
+ # :labelloc: :t
18
+ # :show_config: false
19
+ # :file_type: svg
20
+ # :node:
21
+ # :shape: box
22
+ # :style: filled
23
+ # :fillcolor: grey95
24
+ # :customizations:
25
+ # :my_custom_entity:
26
+ # :shape: circle
27
+ # :fillcolor: red
@@ -9,7 +9,6 @@ module <%= plugin_module_name %>
9
9
 
10
10
  def execute
11
11
  puts '<%= main_entry_point.upcase %> PLUGIN WAZ HERE'
12
- puts_and_logs config[].to_yaml
13
12
  end
14
13
 
15
14
 
@@ -2,7 +2,32 @@
2
2
  # THIS FILE *IS NOT* MEANT TO BE VERSIONED (and is not by default)
3
3
  # You can use it for any configuration you want to keep local
4
4
 
5
+ # Common configuration
6
+
5
7
  # :debug: true
6
- # :log-level: 2
8
+ :log-level: 2
7
9
  # :debug-on-stderr: true
8
- # :verbose: true
10
+ # :verbose: true
11
+
12
+ # Graphviz configuration
13
+ #
14
+ # If you are under Gnome, chances are that you have 'eog' installed
15
+ # or put you own there. Unless in the path specify full path to it:
16
+ # node defines the default graphviz node attributes. In customization
17
+ # each key can be an entity type, that you can fully customize using the
18
+ # same mechanism
19
+
20
+ #:graphviz:
21
+ # :viewer: eog '%s'
22
+ # :label: < Repository Entities <br/> >
23
+ # :labelloc: :t
24
+ # :show_config: false
25
+ # :file_type: svg
26
+ # :node:
27
+ # :shape: box
28
+ # :style: filled
29
+ # :fillcolor: grey95
30
+ # :customizations:
31
+ # :my_custom_entity:
32
+ # :shape: circle
33
+ # :fillcolor: red
@@ -3,4 +3,27 @@
3
3
  # You can use it for any configuration you want to keep at repository level
4
4
 
5
5
  # If you want to ensure a minimal version number of PowerStencil
6
- :min_power_stencil_version: <%= PowerStencil::VERSION %>
6
+ :min_power_stencil_version: <%= PowerStencil::VERSION %>
7
+
8
+ # Graphviz configuration
9
+ #
10
+ # If you are under Gnome, chances are that you have 'eog' installed
11
+ # or put you own there. Unless in the path specify full path to it:
12
+ # node defines the default graphviz node attributes. In customization
13
+ # each key can be an entity type, that you can fully customize using the
14
+ # same mechanism
15
+
16
+ #:graphviz:
17
+ # :viewer: eog '%s'
18
+ # :label: < Repository Entities <br/> >
19
+ # :labelloc: :t
20
+ # :show_config: false
21
+ # :file_type: svg
22
+ # :node:
23
+ # :shape: box
24
+ # :style: filled
25
+ # :fillcolor: grey95
26
+ # :customizations:
27
+ # :my_custom_entity:
28
+ # :shape: circle
29
+ # :fillcolor: red
@@ -13,6 +13,7 @@ require 'power_stencil/utils/directory_processor'
13
13
  require 'power_stencil/utils/secure_require'
14
14
  require 'power_stencil/utils/gem_utils'
15
15
  require 'power_stencil/utils/file_edit'
16
+ require 'power_stencil/utils/graphviz'
16
17
 
17
18
  require 'climatic/script/unimplemented_processor'
18
19
  require 'power_stencil/project/proxy'
@@ -7,15 +7,25 @@ module PowerStencil
7
7
  include Climatic::Proxy
8
8
  include PowerStencil::Project::Proxy
9
9
  include PowerStencil::CommandProcessors::EntityHelper
10
+ include PowerStencil::Utils::Graphviz
10
11
 
11
12
  def execute
12
13
  targets = targets_from_criteria analyse_extra_params, project.engine.root_universe
13
- targets.sort{|a, b| a.as_path <=> b.as_path}.each do |target|
14
- display_entity target
14
+ if config[:graph] || config[:'graph-file']
15
+ filename = graph_entities targets, config[:'graph-file']
16
+ msg = "Graphviz graph saved into '#{filename}'."
17
+ logger.info msg
18
+ puts msg
19
+ if config[:graphviz][:viewer]
20
+ cmd = config[:graphviz][:viewer] % [filename]
21
+ `#{cmd}`
22
+ end
23
+ else
24
+ targets.sort{|a, b| a.as_path <=> b.as_path}.each {|target| display_entity target }
15
25
  end
16
26
  end
17
-
18
27
  end
19
28
 
20
29
  end
30
+
21
31
  end
@@ -0,0 +1,56 @@
1
+ module PowerStencil
2
+ module Utils
3
+
4
+ module Graphviz
5
+
6
+ include UniverseCompiler::Utils::Graphviz
7
+
8
+ def graph_entities(entities, filename = nil)
9
+ entities_to_process = unless config[:graphviz][:show_config]
10
+ entities.reject {|e| e.type == :project_config}
11
+ else
12
+ entities
13
+ end
14
+ graph_entities_to_file entities_to_process,
15
+ output_file_name: filename,
16
+ file_type: config[:graphviz][:file_type] do |graph, cache|
17
+ graph[:label] = config[:graphviz][:label]
18
+ graph[:labelloc] = config[:graphviz][:labelloc]
19
+ graph.each_node do |node_name|
20
+ node = graph.get_node node_name
21
+ entity = cache[:by_node][node]
22
+
23
+ # Set default node attributes
24
+ config[:graphviz][:node].each do |k,v|
25
+ node[k] = v
26
+ end
27
+ fields_to_display = {}
28
+
29
+ # Define node tooltip
30
+ entity.fields.keys.each do |field_name|
31
+ constraints = entity.class.fields_constraints[field_name]
32
+ unless constraints.nil?
33
+ # Remove relations as they are represented as edges
34
+ next if constraints.keys.include? :has_one
35
+ next if constraints.keys.include? :has_many
36
+ end
37
+ fields_to_display[field_name] = entity[field_name]
38
+ end
39
+ node[:tooltip] = fields_to_display.to_yaml
40
+
41
+ # specific customizations
42
+ if config[:graphviz][:customizations][entity.type]
43
+ config[:graphviz][:customizations][entity.type].each do |k,v|
44
+ node[k] = v
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+
53
+ end
54
+
55
+ end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module PowerStencil
2
- VERSION = '0.3.9'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'rake', '~> 10.0'
26
26
  spec.add_development_dependency 'rspec', '~> 3.0'
27
27
 
28
- spec.add_dependency 'climatic', '~> 0.2', '>= 0.2.28'
28
+ spec.add_dependency 'climatic', '~> 0.2', '>= 0.2.29'
29
29
  spec.add_dependency 'dir_glob_ignore', '~> 0.3'
30
- spec.add_dependency 'universe_compiler', '~> 0.2', '>= 0.2.16'
30
+ spec.add_dependency 'universe_compiler', '~> 0.3.0', '>= 0.3.2'
31
31
  spec.add_dependency 'pry'
32
32
 
33
33
  spec.post_install_message = %Q{
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.3.9
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent B.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-13 00:00:00.000000000 Z
11
+ date: 2019-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,7 +61,7 @@ dependencies:
61
61
  version: '0.2'
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: 0.2.28
64
+ version: 0.2.29
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
@@ -71,7 +71,7 @@ dependencies:
71
71
  version: '0.2'
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 0.2.28
74
+ version: 0.2.29
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: dir_glob_ignore
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -92,20 +92,20 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0.2'
95
+ version: 0.3.0
96
96
  - - ">="
97
97
  - !ruby/object:Gem::Version
98
- version: 0.2.16
98
+ version: 0.3.2
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '0.2'
105
+ version: 0.3.0
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 0.2.16
108
+ version: 0.3.2
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: pry
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -256,6 +256,7 @@ files:
256
256
  - lib/power_stencil/utils/file_edit.rb
257
257
  - lib/power_stencil/utils/file_helper.rb
258
258
  - lib/power_stencil/utils/gem_utils.rb
259
+ - lib/power_stencil/utils/graphviz.rb
259
260
  - lib/power_stencil/utils/secure_require.rb
260
261
  - lib/power_stencil/utils/semantic_version.rb
261
262
  - lib/power_stencil/version.rb
@@ -264,7 +265,7 @@ homepage: https://gitlab.com/tools4devops/power_stencil
264
265
  licenses:
265
266
  - MIT
266
267
  metadata: {}
267
- post_install_message: "\nThank you for installing PowerStencil 0.3.9 !\nFrom the command
268
+ post_install_message: "\nThank you for installing PowerStencil 0.4.0 !\nFrom the command
268
269
  line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
269
270
  \ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nFull documentation
270
271
  here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel