lono 6.1.7 → 6.1.8
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/CHANGELOG.md +4 -0
- data/lib/lono/template/dsl/builder/base.rb +11 -5
- data/lib/lono/template/dsl/builder/hash_squeezer.rb +20 -0
- data/lib/lono/template/dsl/builder/helpers/core_helper.rb +12 -0
- data/lib/lono/template/dsl/builder/resource.rb +1 -15
- data/lib/lono/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b44dae2e1a33765ce3e3d969e0f2ca6ad0230f027b1ff94863b27bb3077b4e26
|
4
|
+
data.tar.gz: 280c9073d25b90b02afe7e44aa22514fb21ad8affd3ed3272c4315edd6f2acd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ed15e4146cfb29b71e6399f1f7424ec6533bbe0def6886b931e2bf506a1913bdb8bf518a599e100679638de1a603942a814aa1e3b7268b29d49fb1664a1b614
|
7
|
+
data.tar.gz: 45dfae54e67bdd6b51ac6ad2943b86126c4e1f4d8ac6fe6c1f24d923e9e67d12e514bbcf6f3cc636e08ca0f0a7a352df84dc0c981345bb551dd6e145c70d838f
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [6.1.8]
|
7
|
+
- #28 add user_data_script helper
|
8
|
+
- #29 remove items in Hash structure with nil value at any level
|
9
|
+
|
6
10
|
## [6.1.7]
|
7
11
|
- #25 add stack_name helper
|
8
12
|
- #26 ref Split: true option
|
@@ -13,11 +13,12 @@ class Lono::Template::Dsl::Builder
|
|
13
13
|
blueprint_meta = Lono::Blueprint::Meta.new(@blueprint)
|
14
14
|
target_section = self.class.to_s.split('::').last.underscore
|
15
15
|
# target_section: Lono::Template::Dsl::Builder::Parameter => parameter
|
16
|
-
if blueprint_meta.auto_camelize?(target_section)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
data = if blueprint_meta.auto_camelize?(target_section)
|
17
|
+
CfnCamelizer.transform(attributes)
|
18
|
+
else
|
19
|
+
stringify_keys!(attributes)
|
20
|
+
end
|
21
|
+
clean(data)
|
21
22
|
end
|
22
23
|
|
23
24
|
# Accounts for Arrays also. ActiveSupport only works for Hashes.
|
@@ -31,5 +32,10 @@ class Lono::Template::Dsl::Builder
|
|
31
32
|
data # do not transform
|
32
33
|
end
|
33
34
|
end
|
35
|
+
|
36
|
+
# Remove items with nil value automatically
|
37
|
+
def clean(data)
|
38
|
+
HashSqueezer.new(data).squeeze
|
39
|
+
end
|
34
40
|
end
|
35
41
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Based on https://stackoverflow.com/questions/32174183/remove-nil-values-from-hash
|
2
|
+
class Lono::Template::Dsl::Builder
|
3
|
+
class HashSqueezer
|
4
|
+
def initialize(data)
|
5
|
+
@data = data
|
6
|
+
end
|
7
|
+
|
8
|
+
def squeeze(new_data=nil)
|
9
|
+
data = new_data || @data
|
10
|
+
data.each_with_object({}) do |(k, v), squeezed|
|
11
|
+
if v.is_a?(Hash)
|
12
|
+
squeezed[k] = squeeze(v)
|
13
|
+
else
|
14
|
+
squeezed[k] = v unless v.nil?
|
15
|
+
end
|
16
|
+
squeezed
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -59,6 +59,18 @@ module Lono::Template::Dsl::Builder::Helpers
|
|
59
59
|
render_file(Lono.config.user_data_path, path)
|
60
60
|
end
|
61
61
|
|
62
|
+
def user_data_script
|
63
|
+
return "# @user_data variable not set" unless @user_data
|
64
|
+
|
65
|
+
if File.exist?(@user_data)
|
66
|
+
IO.read(@user_data)
|
67
|
+
else
|
68
|
+
message = "WARN: #{@user_data} not found"
|
69
|
+
puts message.color(:yellow)
|
70
|
+
"# #{message}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
62
74
|
def render_file(folder, path)
|
63
75
|
path = "#{folder}/#{path}"
|
64
76
|
if File.exist?(path)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
class Lono::Template::Dsl::Builder
|
6
6
|
class Resource < Base
|
7
7
|
def template
|
8
|
-
camelize(
|
8
|
+
camelize(standarize(@definition))
|
9
9
|
end
|
10
10
|
|
11
11
|
# Type is the only required property: https://amzn.to/2x8W5aD
|
@@ -40,19 +40,5 @@ class Lono::Template::Dsl::Builder
|
|
40
40
|
raise "Invalid form provided. definition #{definition.inspect}"
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
44
|
-
# Remove properties with nil value automatically
|
45
|
-
def clean(resource)
|
46
|
-
logical_id = resource.keys.first
|
47
|
-
attributes = resource[logical_id]
|
48
|
-
properties = attributes["Properties"]
|
49
|
-
|
50
|
-
if properties
|
51
|
-
properties.delete_if { |k,v| v.nil? }
|
52
|
-
resource[logical_id]["Properties"] = properties
|
53
|
-
end
|
54
|
-
|
55
|
-
resource
|
56
|
-
end
|
57
43
|
end
|
58
44
|
end
|
data/lib/lono/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
@@ -555,6 +555,7 @@ files:
|
|
555
555
|
- lib/lono/template/dsl/builder/base.rb
|
556
556
|
- lib/lono/template/dsl/builder/condition.rb
|
557
557
|
- lib/lono/template/dsl/builder/fn.rb
|
558
|
+
- lib/lono/template/dsl/builder/hash_squeezer.rb
|
558
559
|
- lib/lono/template/dsl/builder/helpers.rb
|
559
560
|
- lib/lono/template/dsl/builder/helpers/core_helper.rb
|
560
561
|
- lib/lono/template/dsl/builder/helpers/param_helper.rb
|