cfndsl 0.0.5 → 0.0.6
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.
- data/lib/cfndsl.rb +14 -443
- data/lib/cfndsl/CloudFormationTemplate.rb +151 -0
- data/lib/cfndsl/Errors.rb +33 -0
- data/lib/cfndsl/JSONable.rb +161 -0
- data/lib/cfndsl/Mappings.rb +25 -0
- data/lib/cfndsl/Metadata.rb +10 -0
- data/lib/cfndsl/Outputs.rb +13 -0
- data/lib/cfndsl/Parameters.rb +32 -0
- data/lib/cfndsl/Plurals.rb +28 -0
- data/lib/cfndsl/Properties.rb +25 -0
- data/lib/cfndsl/RefCheck.rb +48 -0
- data/lib/cfndsl/Resources.rb +28 -0
- data/lib/cfndsl/Types.rb +116 -0
- data/lib/cfndsl/aws_types.yaml +442 -0
- data/lib/cfndsl/module.rb +70 -0
- metadata +15 -1
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'cfndsl/Plurals'
|
2
|
+
class Module
|
3
|
+
private
|
4
|
+
def dsl_attr_setter(*symbols)
|
5
|
+
##
|
6
|
+
# Create setter methods
|
7
|
+
#
|
8
|
+
# Usage:
|
9
|
+
# class Something
|
10
|
+
# dsl_attr_setter :Thing
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# Generates a setter method like this one for each symbol in *symbols:
|
14
|
+
#
|
15
|
+
# def Thing(value)
|
16
|
+
# @Thing = value
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
symbols.each do |symbol|
|
20
|
+
class_eval do
|
21
|
+
define_method(symbol) do |value|
|
22
|
+
instance_variable_set( "@#{symbol}", value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def dsl_content_object(*symbols)
|
29
|
+
##
|
30
|
+
# Create object declaration methods.
|
31
|
+
#
|
32
|
+
# Usage:
|
33
|
+
# Class Something
|
34
|
+
# dsl_content_object :Stuff
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# Generates methods like this:
|
38
|
+
#
|
39
|
+
# def Stuff(name, *values, &block)
|
40
|
+
# @Stuffs ||= {}
|
41
|
+
# @Stuffs[name] ||= CfnDsl::#{symbol}Definition.new(*values)
|
42
|
+
# @Stuffs[name].instance_eval &block if block_given?
|
43
|
+
# return @Stuffs[name]
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# The effect of this is that you can then create named sub-objects
|
47
|
+
# from the main object. The sub objects get stuffed into a container
|
48
|
+
# on the main object, and the block is then evaluated in the context
|
49
|
+
# of the new object.
|
50
|
+
#
|
51
|
+
symbols.each do |symbol|
|
52
|
+
plural = CfnDsl::Plurals::pluralize(symbol) # @@plurals[symbol] || "#{symbol}s"
|
53
|
+
pluralvar = "@#{plural}".to_sym
|
54
|
+
definition_class = CfnDsl.const_get( "#{symbol}Definition" )
|
55
|
+
class_eval do
|
56
|
+
define_method(symbol) do |name,*values,&block|
|
57
|
+
name = name.to_s
|
58
|
+
hash = instance_variable_get( pluralvar )
|
59
|
+
if( ! hash ) then
|
60
|
+
hash = {}
|
61
|
+
instance_variable_set( pluralvar, hash )
|
62
|
+
end
|
63
|
+
hash[name] ||= definition_class.new(*values)
|
64
|
+
hash[name].instance_eval &block if block
|
65
|
+
return hash[name]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfndsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -19,6 +19,20 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- lib/cfndsl.rb
|
22
|
+
- lib/cfndsl/aws_types.yaml
|
23
|
+
- lib/cfndsl/JSONable.rb
|
24
|
+
- lib/cfndsl/module.rb
|
25
|
+
- lib/cfndsl/RefCheck.rb
|
26
|
+
- lib/cfndsl/Types.rb
|
27
|
+
- lib/cfndsl/Properties.rb
|
28
|
+
- lib/cfndsl/Mappings.rb
|
29
|
+
- lib/cfndsl/Resources.rb
|
30
|
+
- lib/cfndsl/Metadata.rb
|
31
|
+
- lib/cfndsl/Parameters.rb
|
32
|
+
- lib/cfndsl/Outputs.rb
|
33
|
+
- lib/cfndsl/Errors.rb
|
34
|
+
- lib/cfndsl/Plurals.rb
|
35
|
+
- lib/cfndsl/CloudFormationTemplate.rb
|
22
36
|
- bin/cfndsl
|
23
37
|
homepage: https://github.com/howech/cfndsl
|
24
38
|
licenses: []
|