class AwsCftTools::Change

Represents a change in a changeset.

Attributes

resource[R]

Public Class Methods

new(change) click to toggle source

@param change [Aws::CloudFormation::Types::Change] The AWS SDK change object to be wrapped.

# File lib/aws_cft_tools/change.rb, line 13
def initialize(change)
  @resource = change.resource_change
end

Public Instance Methods

scopes() click to toggle source

@return [String] a comma-separated list of scopes

# File lib/aws_cft_tools/change.rb, line 37
def scopes
  resource.scope.sort.join(', ')
end
to_narrative() click to toggle source

@return [Hash] information useful for creating a tabular report

# File lib/aws_cft_tools/change.rb, line 45
def to_narrative
  {
    action: action,
    logical_id: logical_id,
    physical_id: physical_id,
    type: type,
    scopes: scopes,
    replacement: replacement
  }
end
type() click to toggle source

@return [String] human readable type of resource being changed

@example EC2::Network::ACL

"ec2 network acl"
# File lib/aws_cft_tools/change.rb, line 29
def type
  humanize_camelized(resource.resource_type)
end

Protected Instance Methods

humanize_camelized(string) click to toggle source
# File lib/aws_cft_tools/change.rb, line 58
def humanize_camelized(string)
  string.sub(/^AWS::/, '')
        .gsub(/:+/, ' ')
        .gsub(/([A-Z]+)([A-Z][a-z])/, '\1 \2')
        .gsub(/([a-z\d])([A-Z])/, '\1 \2')
        .downcase
end