cloud-templates 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/.rspec +4 -0
- data/.rubocop.yml +1 -0
- data/Rakefile +1 -1
- data/bin/cloud-templates-runner.rb +5 -0
- data/cloud-templates.gemspec +9 -4
- data/examples/lib/user_directory.rb +0 -10
- data/examples/lib/user_directory/artifacts.rb +8 -0
- data/examples/lib/user_directory/artifacts/catalogized.rb +8 -7
- data/examples/lib/user_directory/artifacts/group.rb +27 -30
- data/examples/lib/user_directory/artifacts/ided.rb +8 -7
- data/examples/lib/user_directory/artifacts/organization.rb +10 -11
- data/examples/lib/user_directory/artifacts/pathed.rb +17 -17
- data/examples/lib/user_directory/artifacts/person.rb +20 -15
- data/examples/lib/user_directory/artifacts/team.rb +26 -21
- data/examples/lib/user_directory/artifacts/unit.rb +15 -17
- data/examples/lib/user_directory/artifacts/user.rb +26 -23
- data/examples/lib/user_directory/render.rb +8 -0
- data/examples/lib/user_directory/render/etc.rb +2 -0
- data/examples/lib/user_directory/render/etc/artifact_view.rb +2 -2
- data/examples/lib/user_directory/render/etc/composite_view.rb +1 -2
- data/examples/lib/user_directory/render/etc/group_view.rb +3 -3
- data/examples/lib/user_directory/render/etc/person_view.rb +2 -2
- data/examples/lib/user_directory/render/etc/registry.rb +4 -6
- data/examples/lib/user_directory/render/etc/user_view.rb +2 -3
- data/examples/lib/user_directory/render/ldap.rb +2 -0
- data/examples/lib/user_directory/render/ldap/artifact_view.rb +3 -4
- data/examples/lib/user_directory/render/ldap/composite_view.rb +3 -4
- data/examples/lib/user_directory/render/ldap/group_view.rb +3 -4
- data/examples/lib/user_directory/render/ldap/organization_view.rb +3 -4
- data/examples/lib/user_directory/render/ldap/person_view.rb +3 -4
- data/examples/lib/user_directory/render/ldap/registry.rb +3 -4
- data/examples/lib/user_directory/render/ldap/unit_view.rb +3 -4
- data/examples/lib/user_directory/render/ldap/user_view.rb +3 -4
- data/examples/lib/user_directory/utils.rb +1 -1
- data/examples/spec/user_directory_spec.rb +24 -25
- data/lib/aws/templates.rb +0 -8
- data/lib/aws/templates/artifact.rb +20 -12
- data/lib/aws/templates/cli.rb +14 -0
- data/lib/aws/templates/cli/formatter.rb +21 -0
- data/lib/aws/templates/cli/formatter/json.rb +20 -0
- data/lib/aws/templates/cli/interface.rb +92 -0
- data/lib/aws/templates/composite.rb +6 -9
- data/lib/aws/templates/exception.rb +8 -0
- data/lib/aws/templates/exception/nested_parameter_exception.rb +19 -0
- data/lib/aws/templates/exception/option_error.rb +14 -0
- data/lib/aws/templates/exception/option_scalar_on_the_way.rb +26 -0
- data/lib/aws/templates/exception/option_should_be_recursive.rb +20 -0
- data/lib/aws/templates/exception/option_value_deleted.rb +22 -0
- data/lib/aws/templates/exception/parameter_already_exist.rb +26 -0
- data/lib/aws/templates/exception/parameter_exception.rb +26 -0
- data/lib/aws/templates/exception/parameter_getter_is_not_defined.rb +23 -0
- data/lib/aws/templates/exception/parameter_method_name_conflict.rb +26 -0
- data/lib/aws/templates/exception/parameter_specification_is_invalid.rb +30 -0
- data/lib/aws/templates/exception/parameter_value_invalid.rb +37 -0
- data/lib/aws/templates/exception/parametrized_dsl_error.rb +14 -0
- data/lib/aws/templates/exception/view_not_found.rb +26 -0
- data/lib/aws/templates/help.rb +43 -0
- data/lib/aws/templates/help/aggregate.rb +74 -0
- data/lib/aws/templates/help/dsl.rb +30 -0
- data/lib/aws/templates/help/provider.rb +15 -0
- data/lib/aws/templates/help/rdoc.rb +105 -0
- data/lib/aws/templates/help/rdoc/artifact.rb +50 -0
- data/lib/aws/templates/help/rdoc/composite.rb +20 -0
- data/lib/aws/templates/help/rdoc/contextualized.rb +12 -0
- data/lib/aws/templates/help/rdoc/contextualized/filter.rb +19 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters.rb +14 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/add.rb +21 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/chain.rb +33 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/copy.rb +23 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/identity.rb +23 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/override.rb +29 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/proxy.rb +28 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/recursive_schema_filter.rb +28 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/remove.rb +21 -0
- data/lib/aws/templates/help/rdoc/contextualized/filters/scoped.rb +29 -0
- data/lib/aws/templates/help/rdoc/contextualized/provider.rb +28 -0
- data/lib/aws/templates/help/rdoc/default.rb +12 -0
- data/lib/aws/templates/help/rdoc/default/definition.rb +89 -0
- data/lib/aws/templates/help/rdoc/default/provider.rb +25 -0
- data/lib/aws/templates/help/rdoc/dsl.rb +20 -0
- data/lib/aws/templates/help/rdoc/inheritable.rb +48 -0
- data/lib/aws/templates/help/rdoc/parametrized.rb +12 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraint.rb +31 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints.rb +14 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints/all_of.rb +39 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints/condition.rb +44 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints/depends_on_value.rb +41 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints/enum.rb +33 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints/matches.rb +27 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints/not_nil.rb +27 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints/requires.rb +33 -0
- data/lib/aws/templates/help/rdoc/parametrized/constraints/satisfies_condition.rb +28 -0
- data/lib/aws/templates/help/rdoc/parametrized/getter.rb +17 -0
- data/lib/aws/templates/help/rdoc/parametrized/getters.rb +14 -0
- data/lib/aws/templates/help/rdoc/parametrized/nested.rb +32 -0
- data/lib/aws/templates/help/rdoc/parametrized/parameter.rb +55 -0
- data/lib/aws/templates/help/rdoc/parametrized/provider.rb +32 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformation.rb +17 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations.rb +14 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_boolean.rb +25 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_chain.rb +34 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_hash.rb +40 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_integer.rb +26 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_list.rb +32 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_module.rb +25 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_object.rb +32 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_rendered.rb +28 -0
- data/lib/aws/templates/help/rdoc/parametrized/transformations/as_string.rb +25 -0
- data/lib/aws/templates/help/rdoc/provider.rb +20 -0
- data/lib/aws/templates/help/rdoc/routing.rb +104 -0
- data/lib/aws/templates/help/rdoc/texting.rb +42 -0
- data/lib/aws/templates/processor.rb +53 -0
- data/lib/aws/templates/processor/handler.rb +104 -0
- data/lib/aws/templates/processor/registry.rb +74 -0
- data/lib/aws/templates/processor/routing.rb +27 -0
- data/lib/aws/templates/render.rb +27 -25
- data/lib/aws/templates/render/basic_view.rb +47 -0
- data/lib/aws/templates/render/utils.rb +14 -0
- data/lib/aws/templates/render/utils/base_type_views.rb +12 -19
- data/lib/aws/templates/render/utils/inspect.rb +2 -4
- data/lib/aws/templates/render/utils/stringify.rb +2 -5
- data/lib/aws/templates/render/view.rb +3 -100
- data/lib/aws/templates/utils.rb +39 -15
- data/lib/aws/templates/utils/artifact_storage.rb +2 -3
- data/lib/aws/templates/utils/{named.rb → as_named.rb} +2 -3
- data/lib/aws/templates/utils/autoload.rb +224 -0
- data/lib/aws/templates/utils/contextualized.rb +8 -17
- data/lib/aws/templates/utils/contextualized/filter.rb +62 -0
- data/lib/aws/templates/utils/contextualized/filter/add.rb +67 -0
- data/lib/aws/templates/utils/contextualized/filter/chain.rb +56 -0
- data/lib/aws/templates/utils/contextualized/filter/copy.rb +38 -0
- data/lib/aws/templates/utils/contextualized/filter/dsl.rb +50 -0
- data/lib/aws/templates/utils/contextualized/filter/identity.rb +45 -0
- data/lib/aws/templates/utils/contextualized/filter/override.rb +62 -0
- data/lib/aws/templates/utils/contextualized/filter/proxy.rb +29 -0
- data/lib/aws/templates/utils/contextualized/filter/recursive_schema_filter.rb +46 -0
- data/lib/aws/templates/utils/contextualized/filter/remove.rb +66 -0
- data/lib/aws/templates/utils/contextualized/filter/scoped.rb +42 -0
- data/lib/aws/templates/utils/contextualized/refinements.rb +51 -0
- data/lib/aws/templates/utils/default.rb +258 -50
- data/lib/aws/templates/utils/dependency.rb +7 -6
- data/lib/aws/templates/utils/dependency/refinements.rb +80 -0
- data/lib/aws/templates/utils/dependent.rb +6 -3
- data/lib/aws/templates/utils/guarded.rb +30 -0
- data/lib/aws/templates/utils/inheritable.rb +21 -16
- data/lib/aws/templates/utils/inspectable.rb +4 -4
- data/lib/aws/templates/utils/late_bound.rb +2 -2
- data/lib/aws/templates/utils/memoized.rb +2 -0
- data/lib/aws/templates/utils/options.rb +49 -35
- data/lib/aws/templates/utils/parametrized.rb +32 -25
- data/lib/aws/templates/utils/parametrized/constraint.rb +95 -0
- data/lib/aws/templates/utils/parametrized/constraint/all_of.rb +51 -0
- data/lib/aws/templates/utils/parametrized/constraint/condition.rb +93 -0
- data/lib/aws/templates/utils/parametrized/constraint/depends_on_value.rb +60 -0
- data/lib/aws/templates/utils/parametrized/constraint/dsl.rb +86 -0
- data/lib/aws/templates/utils/parametrized/constraint/enum.rb +45 -0
- data/lib/aws/templates/utils/parametrized/constraint/matches.rb +44 -0
- data/lib/aws/templates/utils/parametrized/constraint/not_nil.rb +38 -0
- data/lib/aws/templates/utils/parametrized/constraint/requires.rb +54 -0
- data/lib/aws/templates/utils/parametrized/constraint/satisfies_condition.rb +55 -0
- data/lib/aws/templates/utils/parametrized/getter.rb +67 -0
- data/lib/aws/templates/utils/parametrized/getter/as_instance_variable.rb +41 -0
- data/lib/aws/templates/utils/parametrized/getter/as_is.rb +37 -0
- data/lib/aws/templates/utils/parametrized/getter/dsl.rb +62 -0
- data/lib/aws/templates/utils/parametrized/getter/one_of.rb +48 -0
- data/lib/aws/templates/utils/parametrized/getter/path.rb +53 -0
- data/lib/aws/templates/utils/parametrized/getter/value.rb +50 -0
- data/lib/aws/templates/utils/parametrized/nested.rb +9 -16
- data/lib/aws/templates/utils/parametrized/transformation.rb +74 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_boolean.rb +42 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_chain.rb +57 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_hash.rb +89 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_integer.rb +39 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_list.rb +97 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_module.rb +42 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_object.rb +76 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_rendered.rb +100 -0
- data/lib/aws/templates/utils/parametrized/transformation/as_string.rb +39 -0
- data/lib/aws/templates/utils/parametrized/transformation/dsl.rb +94 -0
- data/lib/aws/templates/utils/recursive.rb +22 -0
- data/spec/aws/templates/artifact_spec.rb +10 -10
- data/spec/aws/templates/cli_spec.rb +83 -0
- data/spec/aws/templates/composite_spec.rb +6 -4
- data/spec/aws/templates/help/rdoc/artifact_spec.rb +94 -0
- data/spec/aws/templates/help/rdoc/composite_spec.rb +53 -0
- data/spec/aws/templates/help/rdoc/parametrized/constraints/all_of_spec.rb +17 -0
- data/spec/aws/templates/help/rdoc/parametrized/constraints/depends_on_value_spec.rb +21 -0
- data/spec/aws/templates/help/rdoc/parametrized/constraints/enum_spec.rb +17 -0
- data/spec/aws/templates/help/rdoc/parametrized/constraints/matches_spec.rb +17 -0
- data/spec/aws/templates/help/rdoc/parametrized/constraints/satisfies_condition_spec.rb +17 -0
- data/spec/aws/templates/help/rdoc/parametrized/transformations/as_boolean_spec.rb +17 -0
- data/spec/aws/templates/help/rdoc/parametrized/transformations/as_chain_spec.rb +17 -0
- data/spec/aws/templates/help/rdoc/parametrized/transformations/as_hash_spec.rb +72 -0
- data/spec/aws/templates/help/rdoc/parametrized/transformations/as_integer_spec.rb +17 -0
- data/spec/aws/templates/help/rdoc/parametrized/transformations/as_list_spec.rb +39 -0
- data/spec/aws/templates/help/rdoc/parametrized/transformations/as_module_spec.rb +17 -0
- data/spec/aws/templates/help/rdoc/parametrized/transformations/as_object_spec.rb +38 -0
- data/spec/aws/templates/help/rdoc/parametrized/transformations/as_rendered_spec.rb +17 -0
- data/spec/aws/templates/render/utils/base_type_views_spec.rb +9 -11
- data/spec/aws/templates/render_spec.rb +1 -1
- data/spec/aws/templates/utils/as_named_spec.rb +0 -2
- data/spec/aws/templates/utils/autoload_spec.rb +14 -0
- data/spec/aws/templates/utils/contextualized_spec.rb +5 -5
- data/spec/aws/templates/utils/late_bound_spec.rb +2 -2
- data/spec/aws/templates/utils/parametrized/constraint_spec.rb +8 -10
- data/spec/aws/templates/utils/parametrized/getters_spec.rb +6 -7
- data/spec/aws/templates/utils/parametrized/transformation_spec.rb +3 -6
- data/spec/aws/templates/utils/parametrized_spec.rb +9 -10
- data/spec/aws/templates/utils_spec.rb +18 -0
- data/spec/test_empty/stuff.rb +4 -0
- data/spec/test_empty/stuff/here/test.rb +9 -0
- metadata +235 -19
- data/lib/aws/templates/exceptions.rb +0 -221
- data/lib/aws/templates/render/registry.rb +0 -60
- data/lib/aws/templates/utils/contextualized/filters.rb +0 -437
- data/lib/aws/templates/utils/contextualized/hash.rb +0 -13
- data/lib/aws/templates/utils/contextualized/nil.rb +0 -13
- data/lib/aws/templates/utils/contextualized/proc.rb +0 -13
- data/lib/aws/templates/utils/dependency/enumerable.rb +0 -13
- data/lib/aws/templates/utils/dependency/object.rb +0 -46
- data/lib/aws/templates/utils/parametrized/constraints.rb +0 -423
- data/lib/aws/templates/utils/parametrized/getters.rb +0 -293
- data/lib/aws/templates/utils/parametrized/guarded.rb +0 -32
- data/lib/aws/templates/utils/parametrized/transformations.rb +0 -652
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Constraints::SatisfiesCondition do
|
|
5
|
+
let(:parametrized) do
|
|
6
|
+
Module.new do
|
|
7
|
+
include Aws::Templates::Utils::Parametrized
|
|
8
|
+
parameter :satisfies_field, constraint: satisfies('less than 10') { |v| v < 10 }
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
13
|
+
|
|
14
|
+
it 'prints documentation' do
|
|
15
|
+
expect(help).to match(/satisfies_field.*less than 10/m)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Transformations::AsBoolean do
|
|
5
|
+
let(:parametrized) do
|
|
6
|
+
Module.new do
|
|
7
|
+
include Aws::Templates::Utils::Parametrized
|
|
8
|
+
parameter :as_boolean_field, transform: as_boolean
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
13
|
+
|
|
14
|
+
it 'prints documentation' do
|
|
15
|
+
expect(help).to match(/as_boolean_field.*transform.*to boolean/m)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Transformations::AsChain do
|
|
5
|
+
let(:parametrized) do
|
|
6
|
+
Module.new do
|
|
7
|
+
include Aws::Templates::Utils::Parametrized
|
|
8
|
+
parameter :as_chain_field, transform: as_chain(as_boolean, as_string)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
13
|
+
|
|
14
|
+
it 'prints documentation' do
|
|
15
|
+
expect(help).to match(/as_chain_field.*transform.*to boolean.*to string/m)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Transformations::AsHash do
|
|
5
|
+
let(:parametrized) {}
|
|
6
|
+
|
|
7
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
8
|
+
|
|
9
|
+
context 'with any key and value' do
|
|
10
|
+
let(:parametrized) do
|
|
11
|
+
Module.new do
|
|
12
|
+
include Aws::Templates::Utils::Parametrized
|
|
13
|
+
parameter :as_random_hash, transform: as_hash
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'prints documentation' do
|
|
18
|
+
expect(help).to match(/key.*can be anything.*value.*can be anything/m)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'with key specification' do
|
|
23
|
+
let(:parametrized) do
|
|
24
|
+
Module.new do
|
|
25
|
+
include Aws::Templates::Utils::Parametrized
|
|
26
|
+
parameter :as_hash_with_defined_key,
|
|
27
|
+
transform: as_hash {
|
|
28
|
+
key name: :id,
|
|
29
|
+
description: 'Object ID',
|
|
30
|
+
constraint: not_nil
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'prints documentation' do
|
|
36
|
+
expect(help).to match(/id.*Object ID.*be nil.*value.*anything/m)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'with value specification' do
|
|
41
|
+
let(:parametrized) do
|
|
42
|
+
Module.new do
|
|
43
|
+
include Aws::Templates::Utils::Parametrized
|
|
44
|
+
parameter :as_hash_with_defined_value,
|
|
45
|
+
transform: as_hash {
|
|
46
|
+
value name: :object, description: 'Object itself', constraint: not_nil
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'prints documentation' do
|
|
52
|
+
expect(help).to match(/key.*anything.*object.*Object itself.*be nil/m)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'with key and value specifications' do
|
|
57
|
+
let(:parametrized) do
|
|
58
|
+
Module.new do
|
|
59
|
+
include Aws::Templates::Utils::Parametrized
|
|
60
|
+
parameter :as_hash_with_defined_key_and_value,
|
|
61
|
+
transform: as_hash {
|
|
62
|
+
key name: :id, description: 'Object ID', constraint: not_nil
|
|
63
|
+
value name: :object, description: 'Object itself', constraint: not_nil
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'prints documentation' do
|
|
69
|
+
expect(help).to match(/id.*Object ID.*be nil.*object.*Object itself.*be nil/m)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Transformations::AsInteger do
|
|
5
|
+
let(:parametrized) do
|
|
6
|
+
Module.new do
|
|
7
|
+
include Aws::Templates::Utils::Parametrized
|
|
8
|
+
parameter :integer_field, transform: as_integer
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
13
|
+
|
|
14
|
+
it 'prints documentation' do
|
|
15
|
+
expect(help).to match(/integer_field.*to integer/m)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Transformations::AsList do
|
|
5
|
+
let(:parametrized) {}
|
|
6
|
+
|
|
7
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
8
|
+
|
|
9
|
+
context 'with any element' do
|
|
10
|
+
let(:parametrized) do
|
|
11
|
+
Module.new do
|
|
12
|
+
include Aws::Templates::Utils::Parametrized
|
|
13
|
+
parameter :simple_list_field, transform: as_list
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'prints documentation' do
|
|
18
|
+
expect(help).to match(/simple_list_field.*can be anything/m)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'with typed element' do
|
|
23
|
+
let(:parametrized) do
|
|
24
|
+
Module.new do
|
|
25
|
+
include Aws::Templates::Utils::Parametrized
|
|
26
|
+
parameter :typed_list_field,
|
|
27
|
+
transform: as_list(
|
|
28
|
+
name: :thing,
|
|
29
|
+
description: 'One of many',
|
|
30
|
+
constraint: not_nil
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'prints documentation' do
|
|
36
|
+
expect(help).to match(/typed_list_field.*thing.*One of many.*be nil/m)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Transformations::AsModule do
|
|
5
|
+
let(:parametrized) do
|
|
6
|
+
Module.new do
|
|
7
|
+
include Aws::Templates::Utils::Parametrized
|
|
8
|
+
parameter :module_field, transform: as_module
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
13
|
+
|
|
14
|
+
it 'prints documentation' do
|
|
15
|
+
expect(help).to match(/module_field.*as a module/m)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Transformations::AsObject do
|
|
5
|
+
let(:parametrized) {}
|
|
6
|
+
|
|
7
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
8
|
+
|
|
9
|
+
context 'without specification' do
|
|
10
|
+
let(:parametrized) do
|
|
11
|
+
Module.new do
|
|
12
|
+
include Aws::Templates::Utils::Parametrized
|
|
13
|
+
parameter :object_field, transform: as_object
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'prints documentation' do
|
|
18
|
+
expect(help).to match(/object_field.*as an object\s*$/m)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'with object scheme' do
|
|
23
|
+
let(:parametrized) do
|
|
24
|
+
Module.new do
|
|
25
|
+
include Aws::Templates::Utils::Parametrized
|
|
26
|
+
parameter :nested_object_field,
|
|
27
|
+
transform: as_object {
|
|
28
|
+
default id: 1
|
|
29
|
+
parameter :id, description: 'Tux', constraint: not_nil
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'prints documentation' do
|
|
35
|
+
expect(help).to match(/nested_object_field.*as an object.*id.*Tux.*id.*1/m)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Help::Rdoc::Parametrized::Transformations::AsRendered do
|
|
5
|
+
let(:parametrized) do
|
|
6
|
+
Module.new do
|
|
7
|
+
include Aws::Templates::Utils::Parametrized
|
|
8
|
+
parameter :rendered_field, transform: as_rendered(Aws::Templates::Render::Utils::Inspect)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:help) { Aws::Templates::Help::Rdoc.show(parametrized) }
|
|
13
|
+
|
|
14
|
+
it 'prints documentation' do
|
|
15
|
+
expect(help).to match(/rendered_field.*render with Aws::Templates::Render::Utils::Inspect/m)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -2,8 +2,6 @@ require 'spec_helper'
|
|
|
2
2
|
require 'aws/templates/render/utils/base_type_views'
|
|
3
3
|
require 'aws/templates/render'
|
|
4
4
|
|
|
5
|
-
include Aws::Templates::Render::Utils::BaseTypeViews
|
|
6
|
-
|
|
7
5
|
describe Aws::Templates::Render::Utils::BaseTypeViews do
|
|
8
6
|
let(:render) do
|
|
9
7
|
Module.new do
|
|
@@ -12,7 +10,7 @@ describe Aws::Templates::Render::Utils::BaseTypeViews do
|
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
describe 'AsIs' do
|
|
15
|
-
before { render.define_view(Object, AsIs) }
|
|
13
|
+
before { render.define_view(Object, Aws::Templates::Render::Utils::BaseTypeViews::AsIs) }
|
|
16
14
|
|
|
17
15
|
it 'renders string' do
|
|
18
16
|
expect(render.view_for('123').to_rendered).to be == '123'
|
|
@@ -24,7 +22,7 @@ describe Aws::Templates::Render::Utils::BaseTypeViews do
|
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
describe 'ToString' do
|
|
27
|
-
before { render.define_view(Object, ToString) }
|
|
25
|
+
before { render.define_view(Object, Aws::Templates::Render::Utils::BaseTypeViews::ToString) }
|
|
28
26
|
|
|
29
27
|
it 'renders string' do
|
|
30
28
|
expect(render.view_for('123').to_rendered).to be == '123'
|
|
@@ -37,8 +35,8 @@ describe Aws::Templates::Render::Utils::BaseTypeViews do
|
|
|
37
35
|
|
|
38
36
|
describe 'ToArray' do
|
|
39
37
|
before do
|
|
40
|
-
render.define_view(Array, ToArray)
|
|
41
|
-
render.define_view(Object, ToString)
|
|
38
|
+
render.define_view(Array, Aws::Templates::Render::Utils::BaseTypeViews::ToArray)
|
|
39
|
+
render.define_view(Object, Aws::Templates::Render::Utils::BaseTypeViews::ToString)
|
|
42
40
|
end
|
|
43
41
|
|
|
44
42
|
it 'renders array' do
|
|
@@ -48,8 +46,8 @@ describe Aws::Templates::Render::Utils::BaseTypeViews do
|
|
|
48
46
|
|
|
49
47
|
describe 'ToHash' do
|
|
50
48
|
before do
|
|
51
|
-
render.define_view(Object, ToString)
|
|
52
|
-
render.define_view(Hash, ToHash)
|
|
49
|
+
render.define_view(Object, Aws::Templates::Render::Utils::BaseTypeViews::ToString)
|
|
50
|
+
render.define_view(Hash, Aws::Templates::Render::Utils::BaseTypeViews::ToHash)
|
|
53
51
|
end
|
|
54
52
|
|
|
55
53
|
it 'renders hash' do
|
|
@@ -59,7 +57,7 @@ describe Aws::Templates::Render::Utils::BaseTypeViews do
|
|
|
59
57
|
end
|
|
60
58
|
|
|
61
59
|
describe 'ToFloat' do
|
|
62
|
-
before { render.define_view(Object, ToFloat) }
|
|
60
|
+
before { render.define_view(Object, Aws::Templates::Render::Utils::BaseTypeViews::ToFloat) }
|
|
63
61
|
|
|
64
62
|
it 'renders integer' do
|
|
65
63
|
expect(render.view_for(1).to_rendered).to be == 1.0
|
|
@@ -71,7 +69,7 @@ describe Aws::Templates::Render::Utils::BaseTypeViews do
|
|
|
71
69
|
end
|
|
72
70
|
|
|
73
71
|
describe 'ToInteger' do
|
|
74
|
-
before { render.define_view(Object, ToInteger) }
|
|
72
|
+
before { render.define_view(Object, Aws::Templates::Render::Utils::BaseTypeViews::ToInteger) }
|
|
75
73
|
|
|
76
74
|
it 'renders float' do
|
|
77
75
|
expect(render.view_for(1.3).to_rendered).to be == 1
|
|
@@ -83,7 +81,7 @@ describe Aws::Templates::Render::Utils::BaseTypeViews do
|
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
describe 'ToBoolean' do
|
|
86
|
-
before { render.define_view(Object, ToBoolean) }
|
|
84
|
+
before { render.define_view(Object, Aws::Templates::Render::Utils::BaseTypeViews::ToBoolean) }
|
|
87
85
|
|
|
88
86
|
it 'renders random object' do
|
|
89
87
|
expect(render.view_for([]).to_rendered).to be == true
|
|
@@ -57,6 +57,6 @@ describe Aws::Templates::Render do
|
|
|
57
57
|
|
|
58
58
|
it 'throws an error once no classes are found' do
|
|
59
59
|
expect { render.view_for(unknown_artifact.new).to_rendered }
|
|
60
|
-
.to raise_error Aws::Templates::ViewNotFound
|
|
60
|
+
.to raise_error Aws::Templates::Exception::ViewNotFound
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'aws/templates/utils'
|
|
3
|
+
|
|
4
|
+
describe Aws::Templates::Utils::Autoload do
|
|
5
|
+
describe 'lazy' do
|
|
6
|
+
let(:test_module) do
|
|
7
|
+
::Object.lazy::Wert
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'doesn\'t have any methods' do
|
|
11
|
+
expect { test_module.rt(1) { 1 } }.to raise_error(NoMethodError, /Lazy.*Wert.*rt.*1.*Proc/m)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -34,7 +34,7 @@ describe Aws::Templates::Utils::Contextualized do
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
context '
|
|
37
|
+
context 'when class is inherited and the module is included' do
|
|
38
38
|
let(:parametrized_class) do
|
|
39
39
|
klass = Class.new(including_class)
|
|
40
40
|
klass.send(:include, including_module)
|
|
@@ -50,7 +50,7 @@ describe Aws::Templates::Utils::Contextualized do
|
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
context '
|
|
53
|
+
context 'when class is inherited and extended with filters' do
|
|
54
54
|
let(:parametrized_class) do
|
|
55
55
|
Class.new(including_class) do
|
|
56
56
|
contextualize lambda { |_, memo|
|
|
@@ -73,7 +73,7 @@ describe Aws::Templates::Utils::Contextualized do
|
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
context '
|
|
76
|
+
context 'when cnstance of the class created' do
|
|
77
77
|
let(:instance) { parametrized_class.new }
|
|
78
78
|
|
|
79
79
|
it 'filters it according to specified parameters' do
|
|
@@ -81,7 +81,7 @@ describe Aws::Templates::Utils::Contextualized do
|
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
context '
|
|
84
|
+
context 'when class is inherited and a filter added' do
|
|
85
85
|
let(:extending_class) do
|
|
86
86
|
Class.new(parametrized_class) do
|
|
87
87
|
contextualize lambda { |_, memo|
|
|
@@ -97,7 +97,7 @@ describe Aws::Templates::Utils::Contextualized do
|
|
|
97
97
|
expect(options.filter(&instance.context).to_hash).to be == { a: 3, z: 7, x: 4, w: 11 }
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
context '
|
|
100
|
+
context 'when class inherited and a filtered mixin added' do
|
|
101
101
|
let(:mixing_class) do
|
|
102
102
|
k = Class.new(extending_class)
|
|
103
103
|
k.send(:include, including_module)
|
|
@@ -21,7 +21,7 @@ describe Aws::Templates::Utils::LateBound do
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
describe 'behavior' do
|
|
24
|
-
|
|
24
|
+
describe 'class' do
|
|
25
25
|
let(:reference) { including_class.reference(%i[a b c], explosive: true) }
|
|
26
26
|
|
|
27
27
|
let(:evaluated) { instance.instance_exec(&reference) }
|
|
@@ -40,7 +40,7 @@ describe Aws::Templates::Utils::LateBound do
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
describe 'instance' do
|
|
44
44
|
let(:reference) { instance.reference(%i[a b c], explosive: true) }
|
|
45
45
|
|
|
46
46
|
it 'is evaluated into normal reference' do
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'aws/templates/utils/parametrized'
|
|
3
|
-
require 'aws/templates/utils/parametrized/constraints'
|
|
4
|
-
require 'aws/templates/utils/parametrized/getters'
|
|
5
3
|
|
|
6
4
|
module Constraints
|
|
7
5
|
include Aws::Templates::Utils::Parametrized
|
|
@@ -41,7 +39,7 @@ describe Aws::Templates::Utils::Parametrized::Constraint do
|
|
|
41
39
|
|
|
42
40
|
it 'throws error when parameter is not specified' do
|
|
43
41
|
expect { test_class.new(something_else: 1).something }
|
|
44
|
-
.to raise_error Aws::Templates::ParameterValueInvalid
|
|
42
|
+
.to raise_error Aws::Templates::Exception::ParameterValueInvalid
|
|
45
43
|
end
|
|
46
44
|
end
|
|
47
45
|
|
|
@@ -58,7 +56,7 @@ describe Aws::Templates::Utils::Parametrized::Constraint do
|
|
|
58
56
|
|
|
59
57
|
it 'throws an error when a value is specified which is not a member of the enumeration' do
|
|
60
58
|
expect { test_class.new(something: 5).something }
|
|
61
|
-
.to raise_error Aws::Templates::ParameterValueInvalid
|
|
59
|
+
.to raise_error Aws::Templates::Exception::ParameterValueInvalid
|
|
62
60
|
end
|
|
63
61
|
end
|
|
64
62
|
|
|
@@ -71,12 +69,12 @@ describe Aws::Templates::Utils::Parametrized::Constraint do
|
|
|
71
69
|
|
|
72
70
|
it 'throws an error if one of the constraints are failed (not_nil)' do
|
|
73
71
|
expect { test_class.new(something_else: 2).something }
|
|
74
|
-
.to raise_error Aws::Templates::ParameterValueInvalid
|
|
72
|
+
.to raise_error Aws::Templates::Exception::ParameterValueInvalid
|
|
75
73
|
end
|
|
76
74
|
|
|
77
75
|
it 'throws an error if one of the constraints are failed (enum)' do
|
|
78
76
|
expect { test_class.new(something: 5).something }
|
|
79
|
-
.to raise_error Aws::Templates::ParameterValueInvalid
|
|
77
|
+
.to raise_error Aws::Templates::Exception::ParameterValueInvalid
|
|
80
78
|
end
|
|
81
79
|
end
|
|
82
80
|
|
|
@@ -98,7 +96,7 @@ describe Aws::Templates::Utils::Parametrized::Constraint do
|
|
|
98
96
|
|
|
99
97
|
it 'throws an error when requirement is not satisfied' do
|
|
100
98
|
expect { test_class.new(something: 5).something }
|
|
101
|
-
.to raise_error Aws::Templates::ParameterValueInvalid
|
|
99
|
+
.to raise_error Aws::Templates::Exception::ParameterValueInvalid
|
|
102
100
|
end
|
|
103
101
|
end
|
|
104
102
|
|
|
@@ -130,7 +128,7 @@ describe Aws::Templates::Utils::Parametrized::Constraint do
|
|
|
130
128
|
|
|
131
129
|
it 'throws an error when conditional constraint is not met' do
|
|
132
130
|
expect { test_class.new(something: :condition, requirement: 2).something }
|
|
133
|
-
.to raise_error Aws::Templates::ParameterValueInvalid
|
|
131
|
+
.to raise_error Aws::Templates::Exception::ParameterValueInvalid
|
|
134
132
|
end
|
|
135
133
|
|
|
136
134
|
it 'passes when other conditional constraint is met' do
|
|
@@ -152,7 +150,7 @@ describe Aws::Templates::Utils::Parametrized::Constraint do
|
|
|
152
150
|
|
|
153
151
|
it 'throws an error when condition is not satisfied' do
|
|
154
152
|
expect { test_class.new(something: 1).something }
|
|
155
|
-
.to raise_error Aws::Templates::ParameterValueInvalid
|
|
153
|
+
.to raise_error Aws::Templates::Exception::ParameterValueInvalid
|
|
156
154
|
end
|
|
157
155
|
end
|
|
158
156
|
|
|
@@ -169,7 +167,7 @@ describe Aws::Templates::Utils::Parametrized::Constraint do
|
|
|
169
167
|
|
|
170
168
|
it 'throws an error when condition is not satisfied' do
|
|
171
169
|
expect { test_class.new(something: 'rooster').something }
|
|
172
|
-
.to raise_error Aws::Templates::ParameterValueInvalid
|
|
170
|
+
.to raise_error Aws::Templates::Exception::ParameterValueInvalid
|
|
173
171
|
end
|
|
174
172
|
end
|
|
175
173
|
end
|