cloud-templates 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +29 -0
  3. data/.simplecov +6 -0
  4. data/Gemfile +2 -0
  5. data/LICENSE +201 -0
  6. data/NOTICE +13 -0
  7. data/README.md +124 -0
  8. data/Rakefile +27 -0
  9. data/cloud-templates.gemspec +27 -0
  10. data/examples/lib/user_directory/artifacts/catalogized.rb +11 -0
  11. data/examples/lib/user_directory/artifacts/group.rb +37 -0
  12. data/examples/lib/user_directory/artifacts/ided.rb +11 -0
  13. data/examples/lib/user_directory/artifacts/organization.rb +17 -0
  14. data/examples/lib/user_directory/artifacts/pathed.rb +22 -0
  15. data/examples/lib/user_directory/artifacts/person.rb +20 -0
  16. data/examples/lib/user_directory/artifacts/team.rb +31 -0
  17. data/examples/lib/user_directory/artifacts/unit.rb +24 -0
  18. data/examples/lib/user_directory/artifacts/user.rb +29 -0
  19. data/examples/lib/user_directory/render/etc/artifact_view.rb +15 -0
  20. data/examples/lib/user_directory/render/etc/composite_view.rb +26 -0
  21. data/examples/lib/user_directory/render/etc/group_view.rb +23 -0
  22. data/examples/lib/user_directory/render/etc/person_view.rb +19 -0
  23. data/examples/lib/user_directory/render/etc/registry.rb +33 -0
  24. data/examples/lib/user_directory/render/etc/user_view.rb +35 -0
  25. data/examples/lib/user_directory/render/etc.rb +3 -0
  26. data/examples/lib/user_directory/render/ldap/artifact_view.rb +27 -0
  27. data/examples/lib/user_directory/render/ldap/composite_view.rb +32 -0
  28. data/examples/lib/user_directory/render/ldap/group_view.rb +28 -0
  29. data/examples/lib/user_directory/render/ldap/organization_view.rb +26 -0
  30. data/examples/lib/user_directory/render/ldap/person_view.rb +39 -0
  31. data/examples/lib/user_directory/render/ldap/registry.rb +16 -0
  32. data/examples/lib/user_directory/render/ldap/unit_view.rb +26 -0
  33. data/examples/lib/user_directory/render/ldap/user_view.rb +39 -0
  34. data/examples/lib/user_directory/render/ldap.rb +3 -0
  35. data/examples/lib/user_directory/utils.rb +18 -0
  36. data/examples/lib/user_directory.rb +23 -0
  37. data/examples/lib_path.rb +2 -0
  38. data/examples/spec/spec_helper.rb +1 -0
  39. data/examples/spec/user_directory_spec.rb +568 -0
  40. data/lib/aws/templates/artifact.rb +140 -0
  41. data/lib/aws/templates/composite.rb +178 -0
  42. data/lib/aws/templates/exceptions.rb +221 -0
  43. data/lib/aws/templates/render/registry.rb +60 -0
  44. data/lib/aws/templates/render/utils/base_type_views.rb +131 -0
  45. data/lib/aws/templates/render/view.rb +127 -0
  46. data/lib/aws/templates/render.rb +72 -0
  47. data/lib/aws/templates/utils/artifact_storage.rb +141 -0
  48. data/lib/aws/templates/utils/contextualized/filters.rb +437 -0
  49. data/lib/aws/templates/utils/contextualized/hash.rb +13 -0
  50. data/lib/aws/templates/utils/contextualized/nil.rb +13 -0
  51. data/lib/aws/templates/utils/contextualized/proc.rb +13 -0
  52. data/lib/aws/templates/utils/contextualized.rb +113 -0
  53. data/lib/aws/templates/utils/default.rb +185 -0
  54. data/lib/aws/templates/utils/dependency/enumerable.rb +13 -0
  55. data/lib/aws/templates/utils/dependency/object.rb +46 -0
  56. data/lib/aws/templates/utils/dependency.rb +121 -0
  57. data/lib/aws/templates/utils/dependent.rb +28 -0
  58. data/lib/aws/templates/utils/inheritable.rb +52 -0
  59. data/lib/aws/templates/utils/late_bound.rb +89 -0
  60. data/lib/aws/templates/utils/memoized.rb +27 -0
  61. data/lib/aws/templates/utils/named.rb +19 -0
  62. data/lib/aws/templates/utils/options.rb +279 -0
  63. data/lib/aws/templates/utils/parametrized/constraints.rb +423 -0
  64. data/lib/aws/templates/utils/parametrized/getters.rb +293 -0
  65. data/lib/aws/templates/utils/parametrized/guarded.rb +32 -0
  66. data/lib/aws/templates/utils/parametrized/mapper.rb +73 -0
  67. data/lib/aws/templates/utils/parametrized/nested.rb +72 -0
  68. data/lib/aws/templates/utils/parametrized/transformations.rb +660 -0
  69. data/lib/aws/templates/utils/parametrized.rb +240 -0
  70. data/lib/aws/templates/utils.rb +219 -0
  71. data/lib/aws/templates.rb +16 -0
  72. data/spec/aws/templates/artifact_spec.rb +161 -0
  73. data/spec/aws/templates/composite_spec.rb +361 -0
  74. data/spec/aws/templates/render/utils/base_type_views_spec.rb +104 -0
  75. data/spec/aws/templates/render_spec.rb +62 -0
  76. data/spec/aws/templates/utils/as_named_spec.rb +31 -0
  77. data/spec/aws/templates/utils/contextualized/filters_spec.rb +108 -0
  78. data/spec/aws/templates/utils/contextualized_spec.rb +115 -0
  79. data/spec/aws/templates/utils/late_bound_spec.rb +52 -0
  80. data/spec/aws/templates/utils/options_spec.rb +67 -0
  81. data/spec/aws/templates/utils/parametrized/constraint_spec.rb +175 -0
  82. data/spec/aws/templates/utils/parametrized/getters_spec.rb +139 -0
  83. data/spec/aws/templates/utils/parametrized/transformation_spec.rb +314 -0
  84. data/spec/aws/templates/utils/parametrized_spec.rb +241 -0
  85. data/spec/spec_helper.rb +6 -0
  86. metadata +244 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4dd48a14067126047f160caf3ffdd1c48e2ff4e7
4
+ data.tar.gz: ef684b50d03d1fb6b69170b8aa10444895743c52
5
+ SHA512:
6
+ metadata.gz: c79052077800068fa8b569b2785f5ca6941a2193c23ead7f48713698a1e3443e9e735e849fec75166db08b66f5574d0e86877db0f7a0bab30fd421665be408e7
7
+ data.tar.gz: be49da0fd91ad960a80cdd07f72bf7306ceee9e8ebddada8f11cada9e70ba397d296a831254af515a247d3167edcfe9c847904486299f56e8c139ee2f3f55df4
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ require: rubocop-rspec
2
+
3
+ RSpec/NestedGroups:
4
+ Max: 4
5
+
6
+ Lint/EndAlignment:
7
+ EnforcedStyleAlignWith: variable
8
+
9
+ Lint/InheritException:
10
+ EnforcedStyle: standard_error
11
+
12
+ Style/Documentation:
13
+ Exclude:
14
+ - 'spec/**/*'
15
+ - 'test/**/*'
16
+ Metrics/BlockLength:
17
+ ExcludedMethods:
18
+ - class_scope
19
+ Exclude:
20
+ - 'spec/**/*'
21
+ - 'test/**/*'
22
+ Style/RaiseArgs:
23
+ EnforcedStyle: compact
24
+
25
+ Metrics/LineLength:
26
+ Max: 100
27
+
28
+ Performance/HashEachMethods:
29
+ Enabled: false
data/.simplecov ADDED
@@ -0,0 +1,6 @@
1
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
2
+
3
+ SimpleCov.start do
4
+ add_filter '/spec'
5
+ add_group 'Lib', 'lib'
6
+ end
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/NOTICE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2016-2017 Amazon.com, Inc. or its affiliates.
2
+ All Rights Reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License").
5
+ You may not use this file except in compliance with the License.
6
+ A copy of the License is located at
7
+
8
+ http://aws.amazon.com/apache2.0/
9
+
10
+ or in the "LICENSE" file accompanying this file. This file is distributed on an
11
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12
+ or implied. See the License for the specific language governing permissions
13
+ and limitations under the License.
data/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # Hierarchical data templates
2
+
3
+ > MVC-based templating framework for hierarchical data structures
4
+
5
+ The purpose of the framework is to bring templating capabilities to
6
+ the areas where traditional approach for auto-generation
7
+ (ERB can be an example) is problematic to apply.
8
+
9
+ Text-based templating frameworks work well when the resulting output has
10
+ moderate number of parameter-driven parts. For example, HTML output
11
+ is perfect candidate for such templating.
12
+
13
+ Problem arises when you try to template:
14
+ * A data structure
15
+ * A hierarchy of nested datastructures
16
+ * All of the above with parent-child relations in types of the data
17
+ structures
18
+
19
+ "Data structure" can be anything from XML, JSON, YAML, ASN or any
20
+ domain-specific language. The problem manifests itself in the fact
21
+ that data representation is very condensed so user ends up with
22
+ a template where number of substitutions is bigger than static content.
23
+ Also, usually, text template engines don't provide mechanisms for
24
+ template inheritance.
25
+
26
+ A practical examples of condensed data structure definition can be:
27
+ * CloudFormation template
28
+ * LDAP LDIF record
29
+ * SQL DML script
30
+
31
+ The core idea of the framework is to use hierarchical hash merges
32
+ and transformations employing standard language class hierarchy and
33
+ object embedding. Class hierarchy models commonalities in data
34
+ structure types like LDAP classes.
35
+
36
+ Framework also accommodates for the fact that there might be graph
37
+ of relations between data structures in definition. Examples of
38
+ such dependencies could be people org structure where some people
39
+ can work on different project with their peers, can be participants
40
+ of different groups or virtual teams. Another example is
41
+ CloudFormation resource in CFN stack definition which can be depend
42
+ on other resources outputs or sole fact of existence.
43
+
44
+ The framework build with documentation and extended introspection
45
+ features in mind. To support that there is a part of DSL which is
46
+ designed for input hash checks and extracting parameters from it
47
+ needed at the current processing step. For instance, you can specify
48
+ parameter definition with constraints, default value, input hash
49
+ extraction path or calculation block. This way you can use this
50
+ parameter later in hash amendment to be sure that all constraints
51
+ are met, default value is substituted and intermediate computations
52
+ have been performed with all errors happening in this process
53
+ wrapped in exceptions containing explaining what should be fixed.
54
+
55
+ The framework consists of a few decoupled parts which can be used
56
+ independently. Namely:
57
+ * Options class. It implements the core part of hash merging mechanics.
58
+ Also it implements hierarchical structure look-up mechanism so
59
+ you can specify wildcard configurations in your input parameters
60
+ or output hash if it is to be consumed by someone else
61
+ * Parametrized mixin. It implements hash parameter checking and depends
62
+ on presence of "options" method in your class which should implement
63
+ multiparameter look-up method []. It defines DSL for parameter
64
+ description. When applied it auto-generates options accessors
65
+ with value lookup in input hash, constraints validation,
66
+ value transformations and extended exceptions handling if an error
67
+ encountered during those stages
68
+ * Amendable mixin. It implements class instance-based definitions of
69
+ so-called amendments. Amendments are input hash alterations and
70
+ transformations which are defined per-class basis and applied
71
+ according to class hierarchy when invoked. Amendment can be
72
+ a hash to be added to options, a Proc which will be invoked in
73
+ instance context and which should produce a hash to be added to
74
+ options or a Module in which case it's just an alias for "include"
75
+ * Optionable class. A convenience intersection of embedded accessor
76
+ for Options field and Parametrized mixin. The basis for artifacts.
77
+ * Constraint class and children. They are concrete constraint types
78
+ for Parametrized mixin.
79
+ * Getter class and children. They are concrete look-up methods for
80
+ Parametrized mixin.
81
+ * Transformation class and children. They are concrete type
82
+ transformation methods for Parametrized mixin.
83
+ * Named mixin. A convenience util mixin which can be used for either
84
+ parameters as_object definitions which should contain "name" field
85
+ or as an artifact parameters definition mixin
86
+ * BasicArtifact class. Represents basic datastructure type class and
87
+ the main vehicle of the framework.
88
+ * BasicComposite class. A kind of BasicArtifact which is able to
89
+ embed other artifacts. This is a recursive structure so composite
90
+ can contain other composites since a composite is an artifact.
91
+ * Render and Render::Type classes. Decoupled rendering helper.
92
+ "render" means to transform an artifact into a domain-specific
93
+ representation like SQL DML statement, LDIF definition, etc.
94
+ Each artifact to be rendered should have attached render. The link
95
+ between two is defined in a concrete child of Render class. Renders
96
+ can be inherited so if you have a universal way to render all your
97
+ artifacts you can just link the single render to BasicArtifact class.
98
+ Artifact can have *multiple* renders. For instance, you can generate
99
+ both SQL DML and JSON from the same artifact definition. Or
100
+ you can automate human-readable description creation like wiki
101
+ pages if you want to describe in words what CloudFromation stack
102
+ definition would create.
103
+
104
+ ## Roadmap
105
+
106
+ * Optimization of internal logic
107
+ * Error message and exception handling improvements:
108
+ * Each exception should have clear indication of where the problem originates
109
+ * Embedded, class-based help
110
+ * Blurb should contain general description
111
+ * Help messages and documentation should support embedded pieces of sample code from examples
112
+ instead of inlining Ruby code directly into the doc
113
+ * Examples should be runnable directly inside of IRB
114
+ * Supported options list and provided defaults should be auto-generated from parameter
115
+ descriptions
116
+ * Internationalization
117
+ * Help messages should support pluggable content
118
+ * Exceptions should support regionalized messages
119
+ * Model-agnostic HTML/JS/SVG render
120
+ * Integrated IDE for constructing object schemas (Ruby interactive interpreter combined with
121
+ GUI)
122
+ * Assessment of the need of deep processing speed optimization:
123
+ * Assessment of alternative language technologies (Rust, Scala, C++, D) for re-implementation
124
+ * Assessment of moving separate parts to native code
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ require 'rubocop/rake_task'
2
+ require 'rspec/core/rake_task'
3
+ require 'bundler/gem_tasks'
4
+ require 'yard'
5
+
6
+ desc 'Generate documentation'
7
+ YARD::Rake::YardocTask.new(:doc) do |t|
8
+ t.files = ['lib/**/*.rb']
9
+ end
10
+
11
+ desc 'Check code notation'
12
+ RuboCop::RakeTask.new(:lint) do |task|
13
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb', 'examples/lib/**/*.rb', 'examples/spec/**/*.rb']
14
+ task.formatters += ['html']
15
+ task.options += [
16
+ '--fail-level', 'convention',
17
+ '--out', 'rubocop.html'
18
+ ]
19
+ end
20
+
21
+ desc 'Run unit tests'
22
+ RSpec::Core::RakeTask.new(:test) do |task|
23
+ task.rspec_opts = '--require ./examples/lib_path.rb'
24
+ task.pattern = '{spec/,examples/spec/}**{,/*/**}/*_spec.rb'
25
+ end
26
+
27
+ task default: [:test, :lint, :doc]
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'cloud-templates'
3
+ s.version = '0.1.0'
4
+ s.license = 'Apache 2.0'
5
+ s.summary = 'Hierarchical data templates'
6
+ s.description = 'MVC-based templating framework for hierarchical data structures. ' \
7
+ 'It is created to fulfil different needs of putting your entire application ' \
8
+ 'configuration and infrastructure definition under the same roof.'
9
+ s.authors = ['Ivan Matylitski', 'Corrado Primier']
10
+ s.email = ['buffovich@gmail.com', 'cp@corradoprimier.it']
11
+ s.files = Dir['lib/**/*'] +
12
+ Dir['spec/**/*'] +
13
+ Dir['examples/**/*'] +
14
+ [
15
+ 'LICENSE', 'Gemfile', 'NOTICE', 'README.md', 'Rakefile',
16
+ '.rubocop.yml', '.simplecov', 'cloud-templates.gemspec'
17
+ ]
18
+ s.test_files = Dir['spec/**/*'] + Dir['examples/spec/**/*']
19
+ s.homepage = 'https://rubygems.org/gems/cloud-templates'
20
+ s.required_ruby_version = Gem::Requirement.new(">= 2.1.0")
21
+ s.add_development_dependency('rspec', '>= 3.2', '~> 3')
22
+ s.add_development_dependency('rubocop', '~> 0.46')
23
+ s.add_development_dependency('rubocop-rspec', '~> 1.17')
24
+ s.add_development_dependency('byebug', '>= 9.0.5', '~> 9')
25
+ s.add_development_dependency('yard', '~> 0.9')
26
+ s.add_development_dependency('simplecov', '~> 0.14')
27
+ end
@@ -0,0 +1,11 @@
1
+ require 'aws/templates/utils/parametrized'
2
+ require 'aws/templates/utils/parametrized/constraints'
3
+
4
+ module UserDirectory
5
+ ##
6
+ # Parameter mixin containing universal catalog entry fields
7
+ module Catalogized
8
+ include Aws::Templates::Utils::Parametrized
9
+ parameter :dn, description: 'Object distinguished name', constraint: not_nil
10
+ end
11
+ end
@@ -0,0 +1,37 @@
1
+ require 'aws/templates/artifact'
2
+ require 'aws/templates/utils/parametrized/constraints'
3
+ require 'aws/templates/utils/parametrized/transformations'
4
+ require 'user_directory/artifacts/ided'
5
+ require 'user_directory/artifacts/catalogized'
6
+ require 'user_directory/artifacts/pathed'
7
+
8
+ module UserDirectory
9
+ ##
10
+ # POSIX Group
11
+ class Group < Aws::Templates::Artifact
12
+ include IDed
13
+ include Catalogized
14
+
15
+ default dn: proc { "cn=#{name},ou=System,#{organization.dn}" },
16
+ cn: proc { name }
17
+
18
+ parameter :cn, description: 'Group canonical name', constraint: not_nil
19
+ parameter :name, description: 'Group name'
20
+ parameter :organization,
21
+ description: 'Organization object',
22
+ constraint: not_nil,
23
+ transform: as_object(Catalogized)
24
+ parameter :members,
25
+ description: 'Group members list',
26
+ transform: as_list(
27
+ name: :member,
28
+ description: 'Member in the group',
29
+ constraint: not_nil,
30
+ transform: as_object do
31
+ parameter :login,
32
+ description: 'User login',
33
+ constraint: not_nil
34
+ end
35
+ )
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ require 'aws/templates/utils/parametrized'
2
+ require 'aws/templates/utils/parametrized/constraints'
3
+
4
+ module UserDirectory
5
+ ##
6
+ # Parameter mixin containing universal parameters for indexed objects
7
+ module IDed
8
+ include Aws::Templates::Utils::Parametrized
9
+ parameter :id, description: 'Object ID', constraint: not_nil
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ require 'aws/templates/composite'
2
+ require 'aws/templates/utils/parametrized'
3
+ require 'aws/templates/utils/parametrized/constraints'
4
+ require 'user_directory/artifacts/catalogized'
5
+
6
+ module UserDirectory
7
+ ##
8
+ # Catalog's organization
9
+ class Organization < Aws::Templates::Composite
10
+ include Catalogized
11
+
12
+ default dn: proc { "o=#{name}" }
13
+ parameter :name, description: 'Organization name', constraint: not_nil
14
+
15
+ contextualize filter(:override) { { organization: self, unit: self } }
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ require 'aws/templates/utils/parametrized'
2
+ require 'aws/templates/utils/parametrized/constraints'
3
+ require 'pathname'
4
+
5
+ module UserDirectory
6
+ ##
7
+ # Parameter mixin containing universal fields for file objects
8
+ #
9
+ # It contains "path" field with constraint checking if the path
10
+ # passed is absolute.
11
+ module Pathed
12
+ include Aws::Templates::Utils::Parametrized
13
+
14
+ parameter :path,
15
+ description: 'Path',
16
+ transform: ->(_, s) { Pathname.new(s) },
17
+ constraint: all_of(
18
+ not_nil,
19
+ satisfies('The path is a valid absolute path', &:absolute?)
20
+ )
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ require 'user_directory/utils'
2
+ require 'user_directory/artifacts/user'
3
+
4
+ module UserDirectory
5
+ ##
6
+ # Catalog's person
7
+ #
8
+ # Represents UNIX user who is a real person. Contains all related
9
+ # attributes.
10
+ class Person < User
11
+ default cn: proc { "#{given_name} #{last_name} (#{login})" }
12
+
13
+ parameter :given_name, description: 'Person\'s given name', constraint: not_nil
14
+ parameter :middle_name, description: 'Person\'s middle name'
15
+ parameter :last_name, description: 'Person\'s last name', constraint: not_nil
16
+ parameter :patronimic, description: 'Person\'s patronimic'
17
+ parameter :phone, description: 'Desk phone number', constraint: Utils.phone_number
18
+ parameter :manager, description: 'Person\'s manager', transform: as_object(Catalogized)
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ require 'user_directory/artifacts/unit'
2
+
3
+ module UserDirectory
4
+ ##
5
+ # Team composite
6
+ #
7
+ # Each team has a POSIX group assigned to its members, a manager,
8
+ # and subordinates. That's exactly what is represented here.
9
+ class Team < Unit
10
+ parameter :manager, description: 'Manager description hash', constraint: not_nil
11
+ parameter :subordinates,
12
+ description: 'List of subordinates\' descriptions',
13
+ constraint: not_nil
14
+ parameter :group_id, description: 'Team\'s group ID'
15
+
16
+ components do
17
+ group = artifact Group, label: 'group', name: name.downcase.tr(' ', '_'), id: group_id
18
+
19
+ contextualize(group: group) do
20
+ manager_artifact = artifact Person, manager.merge(label: 'manager')
21
+
22
+ # Circular dependency between group and its members
23
+ subordinates_artifacts = contextualize(manager: manager_artifact) do
24
+ subordinates.map { |subordinate| artifact Person, subordinate }
25
+ end
26
+
27
+ group.options[:members] = subordinates_artifacts << manager_artifact
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ require 'aws/templates/composite'
2
+ require 'aws/templates/utils/parametrized'
3
+ require 'aws/templates/utils/parametrized/constraints'
4
+ require 'user_directory/artifacts/user'
5
+ require 'user_directory/artifacts/catalogized'
6
+
7
+ module UserDirectory
8
+ ##
9
+ # Catalog's organizational unit
10
+ class Unit < Aws::Templates::Composite
11
+ include Catalogized
12
+
13
+ default label: proc { name },
14
+ dn: proc { "ou=#{name},#{unit.dn}" }
15
+
16
+ parameter :unit,
17
+ description: 'Hierarchical parent of the unit',
18
+ constraint: not_nil,
19
+ transform: as_object(Catalogized)
20
+ parameter :name, description: 'Organizational unit name', constraint: not_nil
21
+
22
+ contextualize filter(:add, :shell, :organization) & filter(:override) { { unit: self } }
23
+ end
24
+ end
@@ -0,0 +1,29 @@
1
+ require 'aws/templates/artifact'
2
+ require 'aws/templates/utils/parametrized/constraints'
3
+ require 'aws/templates/utils/parametrized/transformations'
4
+ require 'user_directory/artifacts/ided'
5
+ require 'user_directory/artifacts/pathed'
6
+ require 'user_directory/artifacts/catalogized'
7
+
8
+ module UserDirectory
9
+ ##
10
+ # POSIX user
11
+ class User < Aws::Templates::Artifact
12
+ include IDed
13
+ include Catalogized
14
+
15
+ default dn: proc { "cn=#{cn},#{unit.dn}" },
16
+ home_directory: proc { { path: "/home/#{login}" } },
17
+ shell: { path: '/bin/sh' }
18
+
19
+ parameter :cn, description: 'Object canonical name', constraint: not_nil
20
+ parameter :login, description: 'User login', constraint: not_nil
21
+ parameter :group,
22
+ description: 'User main group',
23
+ constraint: not_nil,
24
+ transform: as_object(IDed)
25
+ parameter :home_directory, description: 'Home directory', transform: as_object(Pathed)
26
+ parameter :shell, description: 'Shell path', transform: as_object(Pathed)
27
+ parameter :unit, description: 'User\'s organizational unit', transform: as_object(Catalogized)
28
+ end
29
+ end