cloud_shaped 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/simple.rb +20 -0
- data/lib/cloud_shaped/template_builder.rb +7 -1
- data/lib/cloud_shaped/version.rb +1 -1
- data/spec/cloud_shaped/template_builder_spec.rb +22 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81578102167a9548f023eb99b7fe9d3302fced4e
|
4
|
+
data.tar.gz: 036c15cb87e71bf50808816ebfd4a406656e1f2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1bb9c3342bd70f0e32968ed64cbe0b9940aa47e0474c8f09dbfe4a98378543d9398f9001bc067b607d0bd0304b262484c7215bddaaa157d1883cfb71ea4011
|
7
|
+
data.tar.gz: b60601ccf0ace938272dbe70cae75abacd3ed60656cb13fcdf86629aff1f747f6b6bf1dbbd5bcd4bd317c7819fb6e3010707fcd9d67062fd19fc7db3805a4abf
|
data/examples/simple.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cloud_shaped'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
template = CloudShaped.template do
|
7
|
+
|
8
|
+
self.description = "Make a bucket"
|
9
|
+
|
10
|
+
self.metadata["foo"] = {
|
11
|
+
"bar" => "baz"
|
12
|
+
}
|
13
|
+
|
14
|
+
def_resource "myBucket", "AWS::S3::Bucket" do |b|
|
15
|
+
b["BucketName"] = "my-bucket"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
puts YAML.dump(template)
|
@@ -6,7 +6,8 @@ module CloudShaped
|
|
6
6
|
#
|
7
7
|
class TemplateBuilder
|
8
8
|
|
9
|
-
def initialize
|
9
|
+
def initialize
|
10
|
+
@metadata = {}
|
10
11
|
@parameters = {}
|
11
12
|
@mappings = {}
|
12
13
|
@resources = {}
|
@@ -18,6 +19,8 @@ module CloudShaped
|
|
18
19
|
def template
|
19
20
|
{}.tap do |template|
|
20
21
|
template["AWSTemplateFormatVersion"] = '2010-09-09'
|
22
|
+
template["Description"] = description if description
|
23
|
+
template["Metadata"] = metadata unless metadata.empty?
|
21
24
|
template["Parameters"] = parameters unless parameters.empty?
|
22
25
|
template["Mappings"] = mappings unless mappings.empty?
|
23
26
|
template["Resources"] = resources
|
@@ -82,6 +85,9 @@ module CloudShaped
|
|
82
85
|
outputs[name] = output(value)
|
83
86
|
end
|
84
87
|
|
88
|
+
attr_accessor :description
|
89
|
+
attr_reader :metadata
|
90
|
+
|
85
91
|
protected
|
86
92
|
|
87
93
|
attr_reader :parameters
|
data/lib/cloud_shaped/version.rb
CHANGED
@@ -21,6 +21,15 @@ describe CloudShaped::TemplateBuilder do
|
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
+
describe "#description=" do
|
25
|
+
|
26
|
+
it "sets the Description" do
|
27
|
+
template_builder.description = "My awesome template"
|
28
|
+
expect(template["Description"]).to eq("My awesome template")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
24
33
|
describe "#def_resource" do
|
25
34
|
|
26
35
|
it "defines a Resource" do
|
@@ -160,4 +169,17 @@ describe CloudShaped::TemplateBuilder do
|
|
160
169
|
|
161
170
|
end
|
162
171
|
|
172
|
+
describe "#metadata" do
|
173
|
+
|
174
|
+
it "allows attachment of stack metadata" do
|
175
|
+
template_builder.metadata["Foo"] = { "bar" => "baz" }
|
176
|
+
expected_metadata = {
|
177
|
+
"Foo" => {
|
178
|
+
"bar" => "baz"
|
179
|
+
}
|
180
|
+
}
|
181
|
+
expect(template["Metadata"]).to eq(expected_metadata)
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
163
185
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_shaped
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- cloud_shaped.gemspec
|
70
70
|
- examples/buckets.rb
|
71
71
|
- examples/macro.rb
|
72
|
+
- examples/simple.rb
|
72
73
|
- lib/cloud_shaped.rb
|
73
74
|
- lib/cloud_shaped/camelate.rb
|
74
75
|
- lib/cloud_shaped/core_methods.rb
|