Class: Cumulus::S3::ReplicationDiff

Inherits:
Common::Diff show all
Includes:
ReplicationChange
Defined in:
lib/s3/models/ReplicationDiff.rb

Overview

Public: Represents a single difference between local configuration and AWS S3 Replication configuration.

Constant Summary

Constants included from ReplicationChange

Cumulus::S3::ReplicationChange::DESTINATION, Cumulus::S3::ReplicationChange::PREFIX, Cumulus::S3::ReplicationChange::ROLE

Constants included from Common::DiffChange

Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED

Instance Attribute Summary

Attributes inherited from Common::Diff

#aws, #changes, #info_only, #local, #type

Instance Method Summary collapse

Methods included from Common::DiffChange

next_change_id

Methods inherited from Common::Diff

#add_string, added, modified, #to_s, unmanaged, #unmanaged_string

Constructor Details

#initialize(type, aws = nil, local = nil) ⇒ ReplicationDiff

Returns a new instance of ReplicationDiff.



21
22
23
24
25
26
27
28
29
30
# File 'lib/s3/models/ReplicationDiff.rb', line 21

def initialize(type, aws = nil, local = nil)
  super(type, aws, local)

  if aws and local
    @prefixes = Common::ListChange.new(
      local.prefixes - aws.prefixes,
      aws.prefixes - local.prefixes
    )
  end
end

Instance Method Details

#asset_typeObject



32
33
34
# File 'lib/s3/models/ReplicationDiff.rb', line 32

def asset_type
  "S3 Replication"
end

#aws_nameObject



36
37
38
# File 'lib/s3/models/ReplicationDiff.rb', line 36

def aws_name
  "Configuration"
end

#diff_stringObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/s3/models/ReplicationDiff.rb', line 44

def diff_string
  case @type
  when DESTINATION
    "Destination: AWS - #{Colors.aws_changes(@aws.destination)}, Local - #{Colors.local_changes(@local.destination)}"
  when ROLE
    "IAM Role: AWS - #{Colors.aws_changes(@aws.iam_role)}, Local - #{Colors.local_changes(@local.iam_role)}"
  when PREFIX
    [
      "Prefixes:",
      @prefixes.removed.map { |p| Colors.removed("\t#{p}") },
      @prefixes.added.map { |p| Colors.added("\t#{p}") },
    ].flatten.join("\n")
  end
end

#local_nameObject



40
41
42
# File 'lib/s3/models/ReplicationDiff.rb', line 40

def local_name
  "Configuration"
end