humidifier 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -92,7 +92,7 @@ The default rake task runs the tests. Coverage is reported on the command line,
92
92
 
93
93
  ### Specs
94
94
 
95
- The specs pulled from the CFN docs lives in `specs/CloudFormationResourceSpecification.json`. You can update it by running `bundle exec rake specs`. This script will pull down the latest [resource specification](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html) to be used with Humidifier.
95
+ The specs pulled from the CFN docs is saved to `CloudFormationResourceSpecification.json`. You can update it by running `bundle exec rake specs`. This script will pull down the latest [resource specification](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html) to be used with Humidifier.
96
96
 
97
97
  ### Extension
98
98
 
@@ -4,6 +4,11 @@ module Humidifier
4
4
  class ListProp < Base
5
5
  attr_reader :subprop
6
6
 
7
+ # CFN stack syntax
8
+ def to_cf(list)
9
+ [key, list.map { |value| subprop.to_cf(value).last }]
10
+ end
11
+
7
12
  # Valid if the value is whitelisted or every value in the list is valid on the subprop
8
13
  def valid?(list)
9
14
  whitelisted_value?(list) || (list.is_a?(Enumerable) && list.all? { |value| subprop.valid?(value) })
@@ -4,6 +4,15 @@ module Humidifier
4
4
  class MapProp < Base
5
5
  attr_reader :subprop
6
6
 
7
+ # CFN stack syntax
8
+ def to_cf(map)
9
+ dumped =
10
+ Utils.enumerable_to_h(map) do |(subkey, subvalue)|
11
+ [subkey, subprop.to_cf(subvalue).last]
12
+ end
13
+ [key, dumped]
14
+ end
15
+
7
16
  # Valid if the value is whitelisted or every value in the map is valid on the subprop
8
17
  def valid?(map)
9
18
  whitelisted_value?(map) || (map.is_a?(Hash) && map.values.all? { |value| subprop.valid?(value) })
@@ -4,6 +4,15 @@ module Humidifier
4
4
  class StructureProp < Base
5
5
  attr_reader :subprops
6
6
 
7
+ # CFN stack syntax
8
+ def to_cf(value)
9
+ dumped =
10
+ Utils.enumerable_to_h(value) do |(subkey, subvalue)|
11
+ subprops[subkey.to_s].to_cf(subvalue)
12
+ end
13
+ [key, dumped]
14
+ end
15
+
7
16
  # true if the value is whitelisted or Hash and all keys are valid for their corresponding props
8
17
  def valid?(struct)
9
18
  whitelisted_value?(struct) ||
@@ -17,7 +26,7 @@ module Humidifier
17
26
  type = spec['ItemType'] || spec['Type']
18
27
  @subprops =
19
28
  Utils.enumerable_to_h(substructs[type]['Properties']) do |(key, config)|
20
- subprop = config['ItemType'] == type ? self : Props.from(nil, config, substructs)
29
+ subprop = config['ItemType'] == type ? self : Props.from(key, config, substructs)
21
30
  [Utils.underscore(key), subprop]
22
31
  end
23
32
  end
@@ -1,4 +1,4 @@
1
1
  module Humidifier
2
2
  # Gem version
3
- VERSION = '1.0.2'.freeze
3
+ VERSION = '1.0.4'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humidifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Localytics
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-06 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,6 +145,7 @@ extensions:
145
145
  - ext/humidifier/extconf.rb
146
146
  extra_rdoc_files: []
147
147
  files:
148
+ - CloudFormationResourceSpecification.json
148
149
  - LICENSE
149
150
  - README.md
150
151
  - ext/humidifier/extconf.rb