class AwsUtils::ElbLs
Attributes
args[R]
Public Instance Methods
run(args)
click to toggle source
# File lib/awsutils/elbls.rb, line 10 def run(args) @args = args if args.empty? puts connection.load_balancers.map(&:id).sort else args.each do |lb| puts colorize_yaml(attributes(lb).to_yaml) puts '---' if args.count > 1 end end end
Private Instance Methods
attributes(lb)
click to toggle source
# File lib/awsutils/elbls.rb, line 36 def attributes(lb) Hash[connection.load_balancers.get(lb).attributes.map do |key, val| case key when Symbol [key.to_s.titlecase, val] when String [key.split(/(?=[A-Z])/).join(' '), val] end end] end
colorize_yaml(yaml_string)
click to toggle source
# File lib/awsutils/elbls.rb, line 25 def colorize_yaml(yaml_string) yaml_string.split("\n").map do |line| if line =~ /:/ key, val = line.split(':', 2) [Rainbow(key).bright, val].join(':') else line end end.join("\n") end
connection()
click to toggle source
# File lib/awsutils/elbls.rb, line 47 def connection @connection ||= Fog::AWS::ELB.new end