class Terraspace::All::Preview
Public Class Methods
new(command, batches, options={})
click to toggle source
# File lib/terraspace/all/preview.rb, line 7 def initialize(command, batches, options={}) @command, @batches, @options = command, batches, options end
Public Instance Methods
header()
click to toggle source
# File lib/terraspace/all/preview.rb, line 16 def header %w[up down].include?(@command) && !@options[:yes] ? "Will run:" : "Running:" end
max_name_size()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/terraspace/all/preview.rb, line 11 def show logger.info header logger.info preview end