cloud-templates 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +4 -0
  3. data/.rubocop.yml +1 -0
  4. data/Rakefile +1 -1
  5. data/bin/cloud-templates-runner.rb +5 -0
  6. data/cloud-templates.gemspec +9 -4
  7. data/examples/lib/user_directory.rb +0 -10
  8. data/examples/lib/user_directory/artifacts.rb +8 -0
  9. data/examples/lib/user_directory/artifacts/catalogized.rb +8 -7
  10. data/examples/lib/user_directory/artifacts/group.rb +27 -30
  11. data/examples/lib/user_directory/artifacts/ided.rb +8 -7
  12. data/examples/lib/user_directory/artifacts/organization.rb +10 -11
  13. data/examples/lib/user_directory/artifacts/pathed.rb +17 -17
  14. data/examples/lib/user_directory/artifacts/person.rb +20 -15
  15. data/examples/lib/user_directory/artifacts/team.rb +26 -21
  16. data/examples/lib/user_directory/artifacts/unit.rb +15 -17
  17. data/examples/lib/user_directory/artifacts/user.rb +26 -23
  18. data/examples/lib/user_directory/render.rb +8 -0
  19. data/examples/lib/user_directory/render/etc.rb +2 -0
  20. data/examples/lib/user_directory/render/etc/artifact_view.rb +2 -2
  21. data/examples/lib/user_directory/render/etc/composite_view.rb +1 -2
  22. data/examples/lib/user_directory/render/etc/group_view.rb +3 -3
  23. data/examples/lib/user_directory/render/etc/person_view.rb +2 -2
  24. data/examples/lib/user_directory/render/etc/registry.rb +4 -6
  25. data/examples/lib/user_directory/render/etc/user_view.rb +2 -3
  26. data/examples/lib/user_directory/render/ldap.rb +2 -0
  27. data/examples/lib/user_directory/render/ldap/artifact_view.rb +3 -4
  28. data/examples/lib/user_directory/render/ldap/composite_view.rb +3 -4
  29. data/examples/lib/user_directory/render/ldap/group_view.rb +3 -4
  30. data/examples/lib/user_directory/render/ldap/organization_view.rb +3 -4
  31. data/examples/lib/user_directory/render/ldap/person_view.rb +3 -4
  32. data/examples/lib/user_directory/render/ldap/registry.rb +3 -4
  33. data/examples/lib/user_directory/render/ldap/unit_view.rb +3 -4
  34. data/examples/lib/user_directory/render/ldap/user_view.rb +3 -4
  35. data/examples/lib/user_directory/utils.rb +1 -1
  36. data/examples/spec/user_directory_spec.rb +24 -25
  37. data/lib/aws/templates.rb +0 -8
  38. data/lib/aws/templates/artifact.rb +20 -12
  39. data/lib/aws/templates/cli.rb +14 -0
  40. data/lib/aws/templates/cli/formatter.rb +21 -0
  41. data/lib/aws/templates/cli/formatter/json.rb +20 -0
  42. data/lib/aws/templates/cli/interface.rb +92 -0
  43. data/lib/aws/templates/composite.rb +6 -9
  44. data/lib/aws/templates/exception.rb +8 -0
  45. data/lib/aws/templates/exception/nested_parameter_exception.rb +19 -0
  46. data/lib/aws/templates/exception/option_error.rb +14 -0
  47. data/lib/aws/templates/exception/option_scalar_on_the_way.rb +26 -0
  48. data/lib/aws/templates/exception/option_should_be_recursive.rb +20 -0
  49. data/lib/aws/templates/exception/option_value_deleted.rb +22 -0
  50. data/lib/aws/templates/exception/parameter_already_exist.rb +26 -0
  51. data/lib/aws/templates/exception/parameter_exception.rb +26 -0
  52. data/lib/aws/templates/exception/parameter_getter_is_not_defined.rb +23 -0
  53. data/lib/aws/templates/exception/parameter_method_name_conflict.rb +26 -0
  54. data/lib/aws/templates/exception/parameter_specification_is_invalid.rb +30 -0
  55. data/lib/aws/templates/exception/parameter_value_invalid.rb +37 -0
  56. data/lib/aws/templates/exception/parametrized_dsl_error.rb +14 -0
  57. data/lib/aws/templates/exception/view_not_found.rb +26 -0
  58. data/lib/aws/templates/help.rb +43 -0
  59. data/lib/aws/templates/help/aggregate.rb +74 -0
  60. data/lib/aws/templates/help/dsl.rb +30 -0
  61. data/lib/aws/templates/help/provider.rb +15 -0
  62. data/lib/aws/templates/help/rdoc.rb +105 -0
  63. data/lib/aws/templates/help/rdoc/artifact.rb +50 -0
  64. data/lib/aws/templates/help/rdoc/composite.rb +20 -0
  65. data/lib/aws/templates/help/rdoc/contextualized.rb +12 -0
  66. data/lib/aws/templates/help/rdoc/contextualized/filter.rb +19 -0
  67. data/lib/aws/templates/help/rdoc/contextualized/filters.rb +14 -0
  68. data/lib/aws/templates/help/rdoc/contextualized/filters/add.rb +21 -0
  69. data/lib/aws/templates/help/rdoc/contextualized/filters/chain.rb +33 -0
  70. data/lib/aws/templates/help/rdoc/contextualized/filters/copy.rb +23 -0
  71. data/lib/aws/templates/help/rdoc/contextualized/filters/identity.rb +23 -0
  72. data/lib/aws/templates/help/rdoc/contextualized/filters/override.rb +29 -0
  73. data/lib/aws/templates/help/rdoc/contextualized/filters/proxy.rb +28 -0
  74. data/lib/aws/templates/help/rdoc/contextualized/filters/recursive_schema_filter.rb +28 -0
  75. data/lib/aws/templates/help/rdoc/contextualized/filters/remove.rb +21 -0
  76. data/lib/aws/templates/help/rdoc/contextualized/filters/scoped.rb +29 -0
  77. data/lib/aws/templates/help/rdoc/contextualized/provider.rb +28 -0
  78. data/lib/aws/templates/help/rdoc/default.rb +12 -0
  79. data/lib/aws/templates/help/rdoc/default/definition.rb +89 -0
  80. data/lib/aws/templates/help/rdoc/default/provider.rb +25 -0
  81. data/lib/aws/templates/help/rdoc/dsl.rb +20 -0
  82. data/lib/aws/templates/help/rdoc/inheritable.rb +48 -0
  83. data/lib/aws/templates/help/rdoc/parametrized.rb +12 -0
  84. data/lib/aws/templates/help/rdoc/parametrized/constraint.rb +31 -0
  85. data/lib/aws/templates/help/rdoc/parametrized/constraints.rb +14 -0
  86. data/lib/aws/templates/help/rdoc/parametrized/constraints/all_of.rb +39 -0
  87. data/lib/aws/templates/help/rdoc/parametrized/constraints/condition.rb +44 -0
  88. data/lib/aws/templates/help/rdoc/parametrized/constraints/depends_on_value.rb +41 -0
  89. data/lib/aws/templates/help/rdoc/parametrized/constraints/enum.rb +33 -0
  90. data/lib/aws/templates/help/rdoc/parametrized/constraints/matches.rb +27 -0
  91. data/lib/aws/templates/help/rdoc/parametrized/constraints/not_nil.rb +27 -0
  92. data/lib/aws/templates/help/rdoc/parametrized/constraints/requires.rb +33 -0
  93. data/lib/aws/templates/help/rdoc/parametrized/constraints/satisfies_condition.rb +28 -0
  94. data/lib/aws/templates/help/rdoc/parametrized/getter.rb +17 -0
  95. data/lib/aws/templates/help/rdoc/parametrized/getters.rb +14 -0
  96. data/lib/aws/templates/help/rdoc/parametrized/nested.rb +32 -0
  97. data/lib/aws/templates/help/rdoc/parametrized/parameter.rb +55 -0
  98. data/lib/aws/templates/help/rdoc/parametrized/provider.rb +32 -0
  99. data/lib/aws/templates/help/rdoc/parametrized/transformation.rb +17 -0
  100. data/lib/aws/templates/help/rdoc/parametrized/transformations.rb +14 -0
  101. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_boolean.rb +25 -0
  102. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_chain.rb +34 -0
  103. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_hash.rb +40 -0
  104. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_integer.rb +26 -0
  105. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_list.rb +32 -0
  106. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_module.rb +25 -0
  107. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_object.rb +32 -0
  108. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_rendered.rb +28 -0
  109. data/lib/aws/templates/help/rdoc/parametrized/transformations/as_string.rb +25 -0
  110. data/lib/aws/templates/help/rdoc/provider.rb +20 -0
  111. data/lib/aws/templates/help/rdoc/routing.rb +104 -0
  112. data/lib/aws/templates/help/rdoc/texting.rb +42 -0
  113. data/lib/aws/templates/processor.rb +53 -0
  114. data/lib/aws/templates/processor/handler.rb +104 -0
  115. data/lib/aws/templates/processor/registry.rb +74 -0
  116. data/lib/aws/templates/processor/routing.rb +27 -0
  117. data/lib/aws/templates/render.rb +27 -25
  118. data/lib/aws/templates/render/basic_view.rb +47 -0
  119. data/lib/aws/templates/render/utils.rb +14 -0
  120. data/lib/aws/templates/render/utils/base_type_views.rb +12 -19
  121. data/lib/aws/templates/render/utils/inspect.rb +2 -4
  122. data/lib/aws/templates/render/utils/stringify.rb +2 -5
  123. data/lib/aws/templates/render/view.rb +3 -100
  124. data/lib/aws/templates/utils.rb +39 -15
  125. data/lib/aws/templates/utils/artifact_storage.rb +2 -3
  126. data/lib/aws/templates/utils/{named.rb → as_named.rb} +2 -3
  127. data/lib/aws/templates/utils/autoload.rb +224 -0
  128. data/lib/aws/templates/utils/contextualized.rb +8 -17
  129. data/lib/aws/templates/utils/contextualized/filter.rb +62 -0
  130. data/lib/aws/templates/utils/contextualized/filter/add.rb +67 -0
  131. data/lib/aws/templates/utils/contextualized/filter/chain.rb +56 -0
  132. data/lib/aws/templates/utils/contextualized/filter/copy.rb +38 -0
  133. data/lib/aws/templates/utils/contextualized/filter/dsl.rb +50 -0
  134. data/lib/aws/templates/utils/contextualized/filter/identity.rb +45 -0
  135. data/lib/aws/templates/utils/contextualized/filter/override.rb +62 -0
  136. data/lib/aws/templates/utils/contextualized/filter/proxy.rb +29 -0
  137. data/lib/aws/templates/utils/contextualized/filter/recursive_schema_filter.rb +46 -0
  138. data/lib/aws/templates/utils/contextualized/filter/remove.rb +66 -0
  139. data/lib/aws/templates/utils/contextualized/filter/scoped.rb +42 -0
  140. data/lib/aws/templates/utils/contextualized/refinements.rb +51 -0
  141. data/lib/aws/templates/utils/default.rb +258 -50
  142. data/lib/aws/templates/utils/dependency.rb +7 -6
  143. data/lib/aws/templates/utils/dependency/refinements.rb +80 -0
  144. data/lib/aws/templates/utils/dependent.rb +6 -3
  145. data/lib/aws/templates/utils/guarded.rb +30 -0
  146. data/lib/aws/templates/utils/inheritable.rb +21 -16
  147. data/lib/aws/templates/utils/inspectable.rb +4 -4
  148. data/lib/aws/templates/utils/late_bound.rb +2 -2
  149. data/lib/aws/templates/utils/memoized.rb +2 -0
  150. data/lib/aws/templates/utils/options.rb +49 -35
  151. data/lib/aws/templates/utils/parametrized.rb +32 -25
  152. data/lib/aws/templates/utils/parametrized/constraint.rb +95 -0
  153. data/lib/aws/templates/utils/parametrized/constraint/all_of.rb +51 -0
  154. data/lib/aws/templates/utils/parametrized/constraint/condition.rb +93 -0
  155. data/lib/aws/templates/utils/parametrized/constraint/depends_on_value.rb +60 -0
  156. data/lib/aws/templates/utils/parametrized/constraint/dsl.rb +86 -0
  157. data/lib/aws/templates/utils/parametrized/constraint/enum.rb +45 -0
  158. data/lib/aws/templates/utils/parametrized/constraint/matches.rb +44 -0
  159. data/lib/aws/templates/utils/parametrized/constraint/not_nil.rb +38 -0
  160. data/lib/aws/templates/utils/parametrized/constraint/requires.rb +54 -0
  161. data/lib/aws/templates/utils/parametrized/constraint/satisfies_condition.rb +55 -0
  162. data/lib/aws/templates/utils/parametrized/getter.rb +67 -0
  163. data/lib/aws/templates/utils/parametrized/getter/as_instance_variable.rb +41 -0
  164. data/lib/aws/templates/utils/parametrized/getter/as_is.rb +37 -0
  165. data/lib/aws/templates/utils/parametrized/getter/dsl.rb +62 -0
  166. data/lib/aws/templates/utils/parametrized/getter/one_of.rb +48 -0
  167. data/lib/aws/templates/utils/parametrized/getter/path.rb +53 -0
  168. data/lib/aws/templates/utils/parametrized/getter/value.rb +50 -0
  169. data/lib/aws/templates/utils/parametrized/nested.rb +9 -16
  170. data/lib/aws/templates/utils/parametrized/transformation.rb +74 -0
  171. data/lib/aws/templates/utils/parametrized/transformation/as_boolean.rb +42 -0
  172. data/lib/aws/templates/utils/parametrized/transformation/as_chain.rb +57 -0
  173. data/lib/aws/templates/utils/parametrized/transformation/as_hash.rb +89 -0
  174. data/lib/aws/templates/utils/parametrized/transformation/as_integer.rb +39 -0
  175. data/lib/aws/templates/utils/parametrized/transformation/as_list.rb +97 -0
  176. data/lib/aws/templates/utils/parametrized/transformation/as_module.rb +42 -0
  177. data/lib/aws/templates/utils/parametrized/transformation/as_object.rb +76 -0
  178. data/lib/aws/templates/utils/parametrized/transformation/as_rendered.rb +100 -0
  179. data/lib/aws/templates/utils/parametrized/transformation/as_string.rb +39 -0
  180. data/lib/aws/templates/utils/parametrized/transformation/dsl.rb +94 -0
  181. data/lib/aws/templates/utils/recursive.rb +22 -0
  182. data/spec/aws/templates/artifact_spec.rb +10 -10
  183. data/spec/aws/templates/cli_spec.rb +83 -0
  184. data/spec/aws/templates/composite_spec.rb +6 -4
  185. data/spec/aws/templates/help/rdoc/artifact_spec.rb +94 -0
  186. data/spec/aws/templates/help/rdoc/composite_spec.rb +53 -0
  187. data/spec/aws/templates/help/rdoc/parametrized/constraints/all_of_spec.rb +17 -0
  188. data/spec/aws/templates/help/rdoc/parametrized/constraints/depends_on_value_spec.rb +21 -0
  189. data/spec/aws/templates/help/rdoc/parametrized/constraints/enum_spec.rb +17 -0
  190. data/spec/aws/templates/help/rdoc/parametrized/constraints/matches_spec.rb +17 -0
  191. data/spec/aws/templates/help/rdoc/parametrized/constraints/satisfies_condition_spec.rb +17 -0
  192. data/spec/aws/templates/help/rdoc/parametrized/transformations/as_boolean_spec.rb +17 -0
  193. data/spec/aws/templates/help/rdoc/parametrized/transformations/as_chain_spec.rb +17 -0
  194. data/spec/aws/templates/help/rdoc/parametrized/transformations/as_hash_spec.rb +72 -0
  195. data/spec/aws/templates/help/rdoc/parametrized/transformations/as_integer_spec.rb +17 -0
  196. data/spec/aws/templates/help/rdoc/parametrized/transformations/as_list_spec.rb +39 -0
  197. data/spec/aws/templates/help/rdoc/parametrized/transformations/as_module_spec.rb +17 -0
  198. data/spec/aws/templates/help/rdoc/parametrized/transformations/as_object_spec.rb +38 -0
  199. data/spec/aws/templates/help/rdoc/parametrized/transformations/as_rendered_spec.rb +17 -0
  200. data/spec/aws/templates/render/utils/base_type_views_spec.rb +9 -11
  201. data/spec/aws/templates/render_spec.rb +1 -1
  202. data/spec/aws/templates/utils/as_named_spec.rb +0 -2
  203. data/spec/aws/templates/utils/autoload_spec.rb +14 -0
  204. data/spec/aws/templates/utils/contextualized_spec.rb +5 -5
  205. data/spec/aws/templates/utils/late_bound_spec.rb +2 -2
  206. data/spec/aws/templates/utils/parametrized/constraint_spec.rb +8 -10
  207. data/spec/aws/templates/utils/parametrized/getters_spec.rb +6 -7
  208. data/spec/aws/templates/utils/parametrized/transformation_spec.rb +3 -6
  209. data/spec/aws/templates/utils/parametrized_spec.rb +9 -10
  210. data/spec/aws/templates/utils_spec.rb +18 -0
  211. data/spec/test_empty/stuff.rb +4 -0
  212. data/spec/test_empty/stuff/here/test.rb +9 -0
  213. metadata +235 -19
  214. data/lib/aws/templates/exceptions.rb +0 -221
  215. data/lib/aws/templates/render/registry.rb +0 -60
  216. data/lib/aws/templates/utils/contextualized/filters.rb +0 -437
  217. data/lib/aws/templates/utils/contextualized/hash.rb +0 -13
  218. data/lib/aws/templates/utils/contextualized/nil.rb +0 -13
  219. data/lib/aws/templates/utils/contextualized/proc.rb +0 -13
  220. data/lib/aws/templates/utils/dependency/enumerable.rb +0 -13
  221. data/lib/aws/templates/utils/dependency/object.rb +0 -46
  222. data/lib/aws/templates/utils/parametrized/constraints.rb +0 -423
  223. data/lib/aws/templates/utils/parametrized/getters.rb +0 -293
  224. data/lib/aws/templates/utils/parametrized/guarded.rb +0 -32
  225. data/lib/aws/templates/utils/parametrized/transformations.rb +0 -652
@@ -0,0 +1,14 @@
1
+ require 'json'
2
+ require 'aws/templates/utils'
3
+
4
+ module Aws
5
+ module Templates
6
+ ##
7
+ # CLI namespace. See Cli::Processor
8
+ module Cli
9
+ def self.start(*args)
10
+ Cli::Interface.start(*args)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'aws/templates/utils'
2
+ require 'facets/string/pathize'
3
+
4
+ module Aws
5
+ module Templates
6
+ module Cli
7
+ ##
8
+ # Pluggable formatters
9
+ #
10
+ # The module contains formatter factory method and default formatter (AsIs) definition.
11
+ # Formatters are classes implementing simple "format" method accepting object and returning
12
+ # its' formatted string version.
13
+ module Formatter
14
+ def self.format_as(type, *params)
15
+ require "aws/templates/cli/formatter/#{type.pathize}"
16
+ const_get(type).new(*params)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+ require 'aws/templates/utils'
3
+
4
+ module Aws
5
+ module Templates
6
+ module Cli
7
+ module Formatter
8
+ ##
9
+ # JSON formatter
10
+ #
11
+ # Transforms passed object into valid JSON document
12
+ class Json
13
+ def format(obj)
14
+ obj.to_json
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,92 @@
1
+ require 'json'
2
+ require 'aws/templates/utils'
3
+
4
+ module Aws
5
+ module Templates
6
+ module Cli
7
+ ##
8
+ # Templates CLI
9
+ #
10
+ # The class provides command-line utilities to use cloud templates and artifacts without
11
+ # knowledge of Ruby directly from command line.
12
+ # Commands:
13
+ # * render - It is used to setup and execute rendering of a single artifact. Also, different
14
+ # formatters supported for output. By default, render output is not formatted
15
+ # at all and is returned as is. JSON formatter is available out-of-box.
16
+ # * document - provide online documentation for selected artifact optionally using specific
17
+ # documentation generator
18
+ class Interface < ::Thor
19
+ desc 'render ARTIFACT', 'Render ARTIFACT with RENDER and print result'
20
+
21
+ method_option :format,
22
+ desc: 'Formatter used for final output',
23
+ aliases: :f,
24
+ required: false,
25
+ default: 'Json',
26
+ type: :string
27
+
28
+ method_option :options,
29
+ desc: 'JSON-formatted options to pass to the artifact',
30
+ aliases: :o,
31
+ required: false,
32
+ type: :string
33
+
34
+ method_option :render,
35
+ desc: 'Render',
36
+ aliases: :r,
37
+ required: true,
38
+ type: :string
39
+
40
+ def render(artifact_path)
41
+ say _format(
42
+ Templates::Utils.lookup_module(artifact_path),
43
+ Templates::Utils.lookup_module(options[:render]),
44
+ Aws::Templates::Cli::Formatter.format_as(options[:format]),
45
+ ::JSON.parse(options[:options] || _as_string(STDIN), symbolize_names: true)
46
+ )
47
+ end
48
+
49
+ desc 'document ARTIFACT', 'Show help for the ARTIFACT'
50
+
51
+ method_option :generator,
52
+ desc: 'Generator to be used to generate the documentation',
53
+ aliases: :g,
54
+ required: false,
55
+ default: 'Aws::Templates::Help::Rdoc',
56
+ type: :string
57
+
58
+ method_option :parameters,
59
+ desc: 'JSON-formatted generator optional parameters',
60
+ aliases: :p,
61
+ required: false,
62
+ type: :string
63
+
64
+ def document(artifact_path)
65
+ artifact = Templates::Utils.lookup_module(artifact_path)
66
+ generator = Templates::Utils.lookup_module(options[:generator])
67
+ params = options[:parameters] && ::JSON.parse(options[:parameters], symbolize_names: true)
68
+
69
+ say(generator.show(artifact, params))
70
+ end
71
+
72
+ private
73
+
74
+ def _format(artifact, render, format, artifact_options)
75
+ format.format(render.view_for(artifact.new(artifact_options)).to_rendered)
76
+ end
77
+
78
+ def _as_string(obj)
79
+ if obj.respond_to?(:to_str)
80
+ obj.to_str
81
+ elsif obj.respond_to?(:to_io)
82
+ obj.to_io.read
83
+ elsif obj.respond_to?(:read)
84
+ obj.read
85
+ else
86
+ obj.to_s
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -1,7 +1,4 @@
1
- require 'aws/templates/artifact'
2
- require 'aws/templates/utils/artifact_storage'
3
- require 'aws/templates/utils/contextualized'
4
- require 'aws/templates/utils/dependency'
1
+ require 'aws/templates/utils'
5
2
 
6
3
  module Aws
7
4
  module Templates
@@ -25,7 +22,9 @@ module Aws
25
22
  # supports inheritance as artifact does. So every component defined in
26
23
  # the parent class will be initialized properly in all children too.
27
24
  class Composite < Artifact
28
- include Aws::Templates::Utils::Contextualized
25
+ include Templates::Utils::Contextualized
26
+ using Templates::Utils::Contextualized::Refinements
27
+ using Templates::Utils::Dependency::Refinements
29
28
 
30
29
  # propagate root to the components and set itself as the parent
31
30
  contextualize filter(:add, :root) & (filter(:override) { { parent: self } })
@@ -37,7 +36,7 @@ module Aws
37
36
  # Accessor returning dictionary of artifacts currently residing in
38
37
  # composite instance with labels as keys
39
38
  def artifacts
40
- @artifacts ||= Utils::ArtifactStorage.new
39
+ @artifacts ||= Templates::Utils::ArtifactStorage.new
41
40
  end
42
41
 
43
42
  ##
@@ -168,9 +167,7 @@ module Aws
168
167
 
169
168
  def create_components; end
170
169
 
171
- private
172
-
173
- def create_artifact_object(type, params, &blk)
170
+ def create_artifact_object(type, params = nil, &blk)
174
171
  type.new(options.filter(&contextualize(params.to_filter)), &blk)
175
172
  end
176
173
  end
@@ -0,0 +1,8 @@
1
+ module Aws
2
+ module Templates
3
+ ##
4
+ # Namespace for framework-specific exceptions
5
+ module Exception
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # If something happens during parameter calculation
8
+ class NestedParameterException < ParameterException
9
+ def initialize(target_parameter)
10
+ super(
11
+ target_parameter,
12
+ 'Exception was thrown by nested parameter while calculating ' \
13
+ "#{target_parameter.name} (#{target_parameter.description})"
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # Options exception
8
+ #
9
+ # The parent of all exceptions Options method can throw
10
+ class OptionError < ArgumentError
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # Scalar is met while traversing Options path
8
+ #
9
+ # Path is not empty yet but we can't traverse deeper because the current value is a scalar
10
+ class OptionScalarOnTheWay < OptionError
11
+ attr_reader :value
12
+ attr_reader :path
13
+
14
+ def initialize(value, path)
15
+ @value = value
16
+ @path = path
17
+
18
+ super(
19
+ "Value #{value} is not a recursive data structure and we have still #{path} keys " \
20
+ 'to look-up'
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # Recursive value is expected
8
+ #
9
+ # Value passed doesn't not support "recursive" contract. See Utils.recursive?
10
+ class OptionShouldBeRecursive < OptionError
11
+ attr_reader :value
12
+
13
+ def initialize(value)
14
+ @value = value
15
+ super("Value #{value} is not a recursive data structure")
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # Deleted branch detected
8
+ #
9
+ # While traversing Options layers for a value, deleted branch marker was discovered.
10
+ class OptionValueDeleted < OptionError
11
+ attr_reader :path
12
+
13
+ def initialize(path)
14
+ @path = path
15
+ super(
16
+ "Deleted value was detected while traversing path. The path left untraversed: #{path}"
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # Parameter already exists
8
+ #
9
+ # If you're trying to define a parameter in a parametrized artifact
10
+ # and this parameter either already defined for the class or defined
11
+ # in an ancestor.
12
+ class ParameterAlreadyExist < ParametrizedDSLError
13
+ # Parameter object of the conflicting parameter
14
+ attr_reader :parameter
15
+
16
+ def initialize(target_parameter)
17
+ @parameter = target_parameter
18
+ super(
19
+ "Parameter #{target_parameter.name} already in " \
20
+ "#{target_parameter.klass}."
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # Parameter exception
8
+ #
9
+ # Happens during runtime if an error happens during parameter
10
+ # evaluation
11
+ class ParameterException < RuntimeError
12
+ # Parameter object
13
+ attr_reader :parameter
14
+
15
+ def message
16
+ cause.nil? ? super : "#{super} : #{cause.message}"
17
+ end
18
+
19
+ def initialize(target_parameter, custom_message)
20
+ @parameter = target_parameter
21
+ super(custom_message)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # Getter is not specified
8
+ #
9
+ # Getter wasn't specified neither for the individual parameter nor for the mixing instance nor
10
+ # for its class.
11
+ class ParameterGetterIsNotDefined < ParameterException
12
+ def initialize(target_parameter)
13
+ super(
14
+ target_parameter,
15
+ "Can't find getter for #{target_parameter.name} (#{target_parameter.description}): " \
16
+ 'a getter should be attached either to the parameter or the instance ' \
17
+ 'or the instance class'
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # A regular method and a parameter have the same name in a class
8
+ #
9
+ # A parameter was specified with the same name as exsiting method
10
+ # in the class or in an ancestor of the class.
11
+ class ParameterMethodNameConflict < ParametrizedDSLError
12
+ # Method object of the method specified
13
+ attr_reader :method_object
14
+
15
+ def initialize(target_method)
16
+ @method_object = target_method
17
+
18
+ super(
19
+ "Parameter name #{target_method.name} clashes with a method name in " \
20
+ "#{target_method.owner.name}"
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ require 'aws/templates/utils'
2
+
3
+ module Aws
4
+ module Templates
5
+ module Exception
6
+ ##
7
+ # Invalid parameter specification hash
8
+ #
9
+ # If unknown option is passed in a parameter description block
10
+ class ParameterSpecificationIsInvalid < ParametrizedDSLError
11
+ # Parameter object faulty options were specified for
12
+ attr_reader :parameter
13
+
14
+ # Options unknown to Parametrized
15
+ attr_reader :options
16
+
17
+ def initialize(target_parameter, opts)
18
+ @parameter = target_parameter
19
+ @options = opts
20
+
21
+ super(
22
+ 'Unsupported options are in specification for ' \
23
+ "parameter #{target_parameter.name} in class " \
24
+ "#{target_parameter.klass} : #{opts}"
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end