cumuliform 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8e6b6392368ceef96436d11a3276315436d82c2f
4
- data.tar.gz: e69ae5e3488e78466dd6fb187b7b758fb322e18e
2
+ SHA256:
3
+ metadata.gz: 86477f5b5e5ff570e701ea108595ab37165e9c2c8c0b908d71a3376925a4d5f2
4
+ data.tar.gz: 6f77929d740fe9aaecdc83b65d691458441d762688f658b0fd338560b5501f79
5
5
  SHA512:
6
- metadata.gz: 65db6a7682acfa6e99bd3c9fb877efacc7c16ee0a8d299efc204be532d1f63074a62d506ab15b75f89c5de9fdbb6755c3aa3643813f11d33a44654ac691a58e3
7
- data.tar.gz: 3d76af0b68eba1ad4bdeb76871e7287c2a921743ea292f62d8abd575ea59729667f9a66fd2efc0877affe6b49e82bf3ae63cedcaf05112099a2656e4955968f2
6
+ metadata.gz: 6abcbc9530eddcf37006beaf07fa357ac21b51bc325195825ed9b04b71ee2fadf2a305fea65458b7595a4e522bf44ea751878a1965e8c7f51ce6c7f5dfd05dc8
7
+ data.tar.gz: ea4cd0da1e21c9a86514ec9d5f4ab7c754240f32bdde7567c8576ebad5786d9d9adbb3cc6bf6bcddae68960145175a8a16841097bf6d3e48d0c03654a7955b2d
@@ -1 +1 @@
1
- 2.3
1
+ 2.6
@@ -3,8 +3,6 @@ env:
3
3
  - CC_TEST_REPORTER_ID=ad171accd9e47d577857f84b0d9032042ea70bf942a219bfa4f5582b5e504a60
4
4
  language: ruby
5
5
  sudo: false
6
- rvm:
7
- 2.4.3
8
6
  before_script:
9
7
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
10
8
  - chmod +x ./cc-test-reporter
data/README.md CHANGED
@@ -17,9 +17,7 @@ provides a simple DSL that generates reliably valid JSON and enforces
17
17
  referential integrity through convenience wrappers around the common points
18
18
  where CloudFormation expects references between resources. provides.
19
19
 
20
- Cumuliform has been extracted from ops and deployment code at [tape.tv][tape]
21
-
22
- [tape]: https://www.tape.tv/
20
+ Cumuliform was originally extracted from ops and deployment code at tape.tv
23
21
 
24
22
  ## Installation
25
23
 
@@ -281,8 +279,36 @@ The generated template is:
281
279
  }
282
280
  ```
283
281
 
284
- Note that the optional `AWSTemplateFormatVersion`, `Description`, and
285
- `Metadata` sections are *not* currently supported.
282
+ Note that the optional `AWSTemplateFormatVersion`, and `Metadata` sections are
283
+ *not* currently supported.
284
+
285
+ Here's a trivial template that specifies a `Transform` top-level value (e.g. for [AWS SAM][])
286
+
287
+ [AWS SAM]: https://github.com/awslabs/serverless-application-model
288
+
289
+ ```ruby
290
+ Cumuliform.template do
291
+ transform 'AWS::Serverless-2016-10-31'
292
+ resource 'MyFunction' do
293
+ {
294
+ Type: 'AWS::Serverless::Function'
295
+ }
296
+ end
297
+ end
298
+ ```
299
+
300
+ And the result:
301
+
302
+ ```json
303
+ {
304
+ "Transform": "AWS::Serverless-2016-10-31",
305
+ "Resources": {
306
+ "MyFunction": {
307
+ "Type": "AWS::Serverless::Function"
308
+ }
309
+ }
310
+ }
311
+ ```
286
312
 
287
313
  ## Intrinsic functions
288
314
 
@@ -23,7 +23,6 @@ non-existent resources because you have a typo.
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.9"
27
26
  spec.add_development_dependency "rake", "~> 12.0"
28
27
  spec.add_development_dependency "rspec", "~> 3"
29
28
  spec.add_development_dependency "yard", ">= 0.8"
@@ -0,0 +1,8 @@
1
+ Cumuliform.template do
2
+ transform 'AWS::Serverless-2016-10-31'
3
+ resource 'MyFunction' do
4
+ {
5
+ Type: 'AWS::Serverless::Function'
6
+ }
7
+ end
8
+ end
@@ -13,7 +13,11 @@ module Cumuliform
13
13
  # @return [Hash] Hash representing the CloudFormation template
14
14
  def to_hash
15
15
  output = {}
16
- SECTIONS.each do |section_name, _|
16
+ TOP_LEVEL.each do |item_name|
17
+ value = get_top_level_value(item_name)
18
+ output[item_name] = value unless value.nil?
19
+ end
20
+ SECTION_NAMES.each do |section_name|
17
21
  section = get_section(section_name)
18
22
  output[section_name] = generate_section(section) unless section.empty?
19
23
  end
@@ -8,16 +8,18 @@ module Cumuliform
8
8
  "Resources" => :resource,
9
9
  "Outputs" => :output
10
10
  }
11
+ SECTION_NAMES = SECTIONS.map { |name, _| name }
11
12
 
12
13
  # @api private
13
14
  module Sections
14
15
  def initialize
15
- SECTIONS.each do |section_name, _|
16
+ SECTION_NAMES.each do |section_name|
16
17
  instance_variable_set(:"@#{section_name}", Section.new(section_name, imports))
17
18
  end
18
19
  end
19
20
 
20
21
  def get_section(name)
22
+ raise ArgumentError, "#{name} is not a valid template section" unless SECTION_NAMES.include?(name)
21
23
  instance_variable_get(:"@#{name}")
22
24
  end
23
25
 
@@ -11,12 +11,26 @@ module Cumuliform
11
11
  AWS::AccountId AWS::NotificationARNs AWS::NoValue
12
12
  AWS::Region AWS::StackId AWS::StackName
13
13
  }
14
+ TOP_LEVEL = %w{ Transform Description }
14
15
 
15
16
  # Represents a single CloudFormation template
16
17
  class Template
17
18
  include Output
18
19
  include Sections
19
20
 
21
+ def transform(transform)
22
+ @Transform = transform
23
+ end
24
+
25
+ def description(desc)
26
+ @Description = desc
27
+ end
28
+
29
+ def get_top_level_value(item_name)
30
+ raise ArgumentError, "Not an allowed top-level item name" unless TOP_LEVEL.include?(item_name)
31
+ instance_variable_get(:"@#{item_name}")
32
+ end
33
+
20
34
  # @api private
21
35
  def define(&block)
22
36
  instance_exec(&block)
@@ -1,3 +1,3 @@
1
1
  module Cumuliform
2
- VERSION = "0.5.3"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cumuliform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Patterson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-05 00:00:00.000000000 Z
11
+ date: 2020-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.9'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.9'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -115,6 +101,7 @@ files:
115
101
  - examples/module-helper.rb
116
102
  - examples/simplest.rb
117
103
  - examples/top-level-declarations.rb
104
+ - examples/top-level-value.rb
118
105
  - exe/cumuliform
119
106
  - lib/cumuliform.rb
120
107
  - lib/cumuliform/dsl.rb
@@ -149,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
136
  - !ruby/object:Gem::Version
150
137
  version: '0'
151
138
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.6.14
139
+ rubygems_version: 3.0.3
154
140
  signing_key:
155
141
  specification_version: 4
156
142
  summary: DSL library for generating AWS CloudFormation templates