Class: Lono::Inspector::Summary
- Inherits:
-
Base
- Object
- Base
- Lono::Inspector::Summary
show all
- Defined in:
- lib/lono/inspector/summary.rb
Instance Method Summary
collapse
Methods inherited from Base
#check_template_exists, #data, #generate_templates, #initialize, #run
Instance Method Details
#optional_parameters ⇒ Object
40
41
42
|
# File 'lib/lono/inspector/summary.rb', line 40
def optional_parameters
parameters.select { |logical_id, p| p["Default"] }
end
|
#parameters ⇒ Object
44
45
46
|
# File 'lib/lono/inspector/summary.rb', line 44
def parameters
data["Parameters"] || []
end
|
2
3
4
5
6
7
8
9
10
|
# File 'lib/lono/inspector/summary.rb', line 2
def perform
puts "=> CloudFormation Template Summary:".colorize(:green)
return if @options[:noop]
print_parameters_summary
puts "Resources:"
print_resource_types
end
|
#print_parameters(label, parameters) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/lono/inspector/summary.rb', line 21
def print_parameters(label, parameters)
puts "#{label}:"
if parameters.empty?
puts " There are no #{label.downcase} parameters"
else
parameters.each do |logical_id, p|
output = " #{logical_id} (#{p["Type"]})"
if p["Default"]
output << " Default: #{p["Default"]}"
end
puts output
end
end
end
|
#print_parameters_summary ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/lono/inspector/summary.rb', line 12
def print_parameters_summary
if parameters.empty?
puts "There are no parameters in this template."
else
print_parameters("Required Parameters", required_parameters)
print_parameters("Optional Parameters", optional_parameters)
end
end
|
#print_resource_types ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/lono/inspector/summary.rb', line 56
def print_resource_types
types = resource_types.sort_by {|r| r[1] * -1} types.each do |a|
type, count = a
printf "%3s %s\n", count, type
end
printf "%3s %s\n", resource_types.size, "Total"
end
|
#required_parameters ⇒ Object
36
37
38
|
# File 'lib/lono/inspector/summary.rb', line 36
def required_parameters
parameters.reject { |logical_id, p| p["Default"] }
end
|
#resource_types ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/lono/inspector/summary.rb', line 48
def resource_types
types = Hash.new(0)
data["Resources"].each do |logical_id, resource|
types[resource["Type"]] += 1
end
types
end
|