Class: Cumulus::Common::Diff
- Inherits:
-
Object
- Object
- Cumulus::Common::Diff
- Includes:
- DiffChange
- Defined in:
- lib/common/models/Diff.rb
Overview
Public: The base class for all Diff classes.
To extend this class, do the following:
-
Provide a ‘diff_string` method. This method will be called if the default to_s method cannot produce a result.
-
Provide a ‘asset_type` method. This method should return the string type of asset for which this is a diff.
-
Provide an ‘aws_name` method. This method should give back the string name of the aws asset.
-
(Optional) Replace the existing ‘local_name` method. This method produces the string name of the local asset. Defaults to `name` on the local asset.
Direct Known Subclasses
AutoScaling::AlarmDiff, AutoScaling::AutoScalingDiff, AutoScaling::PolicyDiff, AutoScaling::ScheduledActionDiff, Cumulus::CloudFront::CacheBehaviorDiff, Cumulus::CloudFront::CustomHeaderDiff, Cumulus::CloudFront::CustomOriginDiff, Cumulus::CloudFront::DistributionDiff, Cumulus::CloudFront::OriginDiff, Cumulus::CloudFront::OriginSslProtocolsDiff, EC2::EbsGroupDiff, EC2::InstanceDiff, ELB::AccessLogDiff, ELB::HealthCheckDiff, ELB::ListenerDiff, ELB::LoadBalancerDiff, IAM::IamDiff, Kinesis::StreamDiff, Route53::RecordDiff, Route53::SingleRecordDiff, Route53::ZoneDiff, S3::BucketDiff, S3::DefaultEncryptionDiff, S3::GrantDiff, S3::LifecycleDiff, S3::NotificationDiff, S3::ReplicationDiff, SQS::DeadLetterDiff, SQS::QueueDiff, SecurityGroups::RuleDiff, SecurityGroups::SecurityGroupDiff, VPC::AclEntryDiff, VPC::DhcpDiff, VPC::EndpointDiff, VPC::NetworkAclDiff, VPC::RouteDiff, VPC::RouteTableDiff, VPC::SubnetDiff, VPC::VpcDiff
Constant Summary
Constants included from DiffChange
Cumulus::Common::DiffChange::ADD, Cumulus::Common::DiffChange::MODIFIED, Cumulus::Common::DiffChange::UNMANAGED
Instance Attribute Summary collapse
-
#aws ⇒ Object
readonly
Returns the value of attribute aws.
-
#changes ⇒ Object
Returns the value of attribute changes.
-
#info_only ⇒ Object
Returns the value of attribute info_only.
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.added(local) ⇒ Object
Public: Static method that will produce an “added” diff.
-
.modified(aws, local, changes) ⇒ Object
Public: Static method that will produce a “modified” diff.
-
.unmanaged(aws) ⇒ Object
Public: Static method that will produce an “unmanaged” diff.
Instance Method Summary collapse
-
#add_string ⇒ Object
Public: A method that produces the string that describes what will be done with new assets.
-
#initialize(type, aws = nil, local = nil, changes = nil) ⇒ Diff
constructor
Public: Constructor.
- #local_name ⇒ Object
- #to_s ⇒ Object
-
#unmanaged_string ⇒ Object
Public: A method that produces the string that describes what will be done with unmanaged assets.
Methods included from DiffChange
Constructor Details
#initialize(type, aws = nil, local = nil, changes = nil) ⇒ Diff
Public: Constructor
type - the type of the difference aws - the aws resource that’s different (defaults to nil) local - the local resource that’s difference (defaults to nil) changes - an object to describe what changed in a MODIFIED diff (defaults to nil)
74 75 76 77 78 79 80 |
# File 'lib/common/models/Diff.rb', line 74 def initialize(type, aws = nil, local = nil, changes = nil) @aws = aws @local = local @type = type @changes = changes @info_only = false end |
Instance Attribute Details
#aws ⇒ Object (readonly)
Returns the value of attribute aws.
38 39 40 |
# File 'lib/common/models/Diff.rb', line 38 def aws @aws end |
#changes ⇒ Object
Returns the value of attribute changes.
39 40 41 |
# File 'lib/common/models/Diff.rb', line 39 def changes @changes end |
#info_only ⇒ Object
Returns the value of attribute info_only.
39 40 41 |
# File 'lib/common/models/Diff.rb', line 39 def info_only @info_only end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
38 39 40 |
# File 'lib/common/models/Diff.rb', line 38 def local @local end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
38 39 40 |
# File 'lib/common/models/Diff.rb', line 38 def type @type end |
Class Method Details
.added(local) ⇒ Object
Public: Static method that will produce an “added” diff
local - the local configuration that is added
Returns the diff
55 56 57 |
# File 'lib/common/models/Diff.rb', line 55 def self.added(local) self.new(ADD, nil, local) end |
.modified(aws, local, changes) ⇒ Object
Public: Static method that will produce a “modified” diff
local - the local configuration aws - the aws resource changes - an object describing what was modified
64 65 66 |
# File 'lib/common/models/Diff.rb', line 64 def self.modified(aws, local, changes) self.new(MODIFIED, aws, local, changes) end |
.unmanaged(aws) ⇒ Object
Public: Static method that will produce an “unmanaged” diff
aws - the aws resource that is unmanaged
Returns the diff
46 47 48 |
# File 'lib/common/models/Diff.rb', line 46 def self.unmanaged(aws) self.new(UNMANAGED, aws) end |
Instance Method Details
#add_string ⇒ Object
Public: A method that produces the string that describes what will be done with new assets. This can be overridden for the case that the ADD case doesn’t create the asset.
Returns the string describing the action that will be taken.
97 98 99 |
# File 'lib/common/models/Diff.rb', line 97 def add_string "will be created." end |
#local_name ⇒ Object
109 110 111 |
# File 'lib/common/models/Diff.rb', line 109 def local_name @local.name end |
#to_s ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/common/models/Diff.rb', line 82 def to_s case @type when ADD Colors.added("#{asset_type} #{local_name} #{add_string}") when UNMANAGED Colors.unmanaged("#{asset_type} #{aws_name} #{unmanaged_string}") else diff_string end end |
#unmanaged_string ⇒ Object
Public: A method that produces the string that describes what will be done with unmanaged assets. This can be overriden for the case that the UNMANAGED case does not ignore the asset.
Returns the string describing the action that will be taken
105 106 107 |
# File 'lib/common/models/Diff.rb', line 105 def unmanaged_string "is not managed by Cumulus." end |