module Terradactyl::Common
Constants
- BORDER_CHAR
- COLUMN_WIDTH
Public Instance Methods
border()
click to toggle source
# File lib/terradactyl/common.rb, line 30 def border BORDER_CHAR * COLUMN_WIDTH end
centre()
click to toggle source
# File lib/terradactyl/common.rb, line 34 def centre COLUMN_WIDTH / 2 end
config()
click to toggle source
# File lib/terradactyl/common.rb, line 18 def config @config ||= ConfigProject.instance end
cputs(msg, color)
click to toggle source
# File lib/terradactyl/common.rb, line 89 def cputs(msg, color) puts config.misc.disable_color ? msg : msg.send(color.to_s) end
dot_icon()
click to toggle source
# File lib/terradactyl/common.rb, line 38 def dot_icon config.misc.utf8 ? '•' : '*' end
print_content(content)
click to toggle source
# File lib/terradactyl/common.rb, line 58 def print_content(content) content.split("\n").each do |line| print_line line end puts end
print_crit(msg)
click to toggle source
# File lib/terradactyl/common.rb, line 46 def print_crit(msg) print_message(msg, :light_red) end
print_dot(msg, color = :light_blue)
click to toggle source
# File lib/terradactyl/common.rb, line 65 def print_dot(msg, color = :light_blue) string = " #{dot_icon} #{msg}" cputs(string, color) end
print_header(msg, color = :blue)
click to toggle source
# File lib/terradactyl/common.rb, line 81 def print_header(msg, color = :blue) indent = centre + msg.size / 2 - 1 content = format("#%#{indent}s", "#{tag} | #{msg}") string = [border, content, border].join("\n") cputs(string, color) puts end
print_line(msg, color = :light_blue)
click to toggle source
# File lib/terradactyl/common.rb, line 70 def print_line(msg, color = :light_blue) string = " #{msg}" cputs(string, color) end
print_message(msg, color = :light_blue)
click to toggle source
# File lib/terradactyl/common.rb, line 75 def print_message(msg, color = :light_blue) string = "#{stack_icon}[#{tag}] #{msg}" cputs(string, color) puts end
print_ok(msg)
click to toggle source
# File lib/terradactyl/common.rb, line 50 def print_ok(msg) print_message(msg, :light_green) end
print_warning(msg)
click to toggle source
# File lib/terradactyl/common.rb, line 54 def print_warning(msg) print_message(msg, :light_yellow) end
required_versions_re()
click to toggle source
# File lib/terradactyl/common.rb, line 10 def required_versions_re /(?<assignment>(?:\n\s)*required_version\s+=\s+)(?<value>".*?")/m end
stack_icon()
click to toggle source
# File lib/terradactyl/common.rb, line 42 def stack_icon config.misc.utf8 ? ' 𝓣 ' : ' ||| ' end
supported_revisions()
click to toggle source
# File lib/terradactyl/common.rb, line 14 def supported_revisions Terradactyl::Commands.constants.select { |c| c =~ /Rev/ }.sort end
tag()
click to toggle source
# File lib/terradactyl/common.rb, line 26 def tag 'Terradactyl' end
terraform_binary()
click to toggle source
# File lib/terradactyl/common.rb, line 22 def terraform_binary config.terraform.binary || %(terraform) end