Class: SportNginAwsAuditor::Scripts::Inspect
- Inherits:
-
Object
- Object
- SportNginAwsAuditor::Scripts::Inspect
- Extended by:
- AWSWrapper, OpsWorksWrapper
- Defined in:
- lib/sport_ngin_aws_auditor/scripts/inspect.rb
Instance Attribute Summary
Attributes included from AWSWrapper
Attributes included from OpsWorksWrapper
Class Method Summary collapse
- .execute(environment, options = nil, global_options = nil) ⇒ Object
- .header(type, length = 50) ⇒ Object
- .output(class_type) ⇒ Object
- .pretty_print(title, body) ⇒ Object
Methods included from AWSWrapper
Class Method Details
.execute(environment, options = nil, global_options = nil) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/sport_ngin_aws_auditor/scripts/inspect.rb', line 7 def self.execute(environment, =nil, =nil) aws(environment, [:aws_roles]) no_selection = .values.uniq == [false] output("EC2Instance") if [:ec2] || no_selection output("RDSInstance") if [:rds] || no_selection output("CacheInstance") if [:cache] || no_selection end |
.header(type, length = 50) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/sport_ngin_aws_auditor/scripts/inspect.rb', line 25 def self.header(type, length = 50) type.upcase!.slice! "INSTANCE" half_length = (length - type.length)/2.0 - 1 [ "*" * length, "*" * half_length.floor + " #{type} " + "*" * half_length.ceil, "*" * length ].join("\n") end |
.output(class_type) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/sport_ngin_aws_auditor/scripts/inspect.rb', line 15 def self.output(class_type) klass = SportNginAwsAuditor.const_get(class_type) print "Gathering info, please wait..."; print "\r" instances = class_type == "EC2Instance" ? klass.bucketize : klass.instance_hash say "<%= color('#{header(class_type)}', :white) %>" instances.each do |key, value| pretty_print(key, klass.instance_count_hash(Array(value))) end end |
.pretty_print(title, body) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/sport_ngin_aws_auditor/scripts/inspect.rb', line 35 def self.pretty_print(title, body) puts "=======================================" puts "#{title}" puts "=======================================" body.each{ |key, value| say "<%= color('#{key}: #{value}', :white) %>" } puts "\n" end |