Class: Terraspace::All::Preview
Instance Method Summary
collapse
#cache_dirs, #dirs, #extract_stack_name, #local_paths, #mod_names, #select_stack?, #stack_names, #with_each_mod
#logger
Constructor Details
#initialize(command, batches, options = {}) ⇒ Preview
Returns a new instance of Preview.
7
8
9
|
# File 'lib/terraspace/all/preview.rb', line 7
def initialize(command, batches, options={})
@command, @batches, @options = command, batches, options
end
|
Instance Method Details
16
17
18
|
# File 'lib/terraspace/all/preview.rb', line 16
def
%w[up down].include?(@command) && !@options[:yes] ? "Will run:" : "Running:"
end
|
#max_name_size ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/terraspace/all/preview.rb', line 33
def max_name_size
@batches.inject(0) do |max,batch|
batch.each do |node|
max = node.name.size if node.name.size > max
end
max
end
end
|
#preview ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/terraspace/all/preview.rb', line 20
def preview
i = 0
@batches.map do |batch|
i += 1
batch.map do |stack|
command = " terraspace #{@command}"
ljust = command.size + max_name_size + 1
command = "#{command} #{stack.name}"
command.ljust(ljust, ' ') + " # batch #{i}"
end
end.join("\n")
end
|
#show ⇒ Object
11
12
13
14
|
# File 'lib/terraspace/all/preview.rb', line 11
def show
logger.info
logger.info preview
end
|