Class: Cumulus::S3::NotificationDiff

Inherits:
Common::Diff show all
Includes:
NotificationChange
Defined in:
lib/s3/models/NotificationDiff.rb

Overview

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

Constant Summary

Constants included from NotificationChange

Cumulus::S3::NotificationChange::PREFIX, Cumulus::S3::NotificationChange::SUFFIX, Cumulus::S3::NotificationChange::TARGET, Cumulus::S3::NotificationChange::TRIGGERS, Cumulus::S3::NotificationChange::TYPE

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, #local_name, modified, #to_s, unmanaged, #unmanaged_string

Constructor Details

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

Returns a new instance of NotificationDiff.



23
24
25
26
27
28
29
30
31
32
# File 'lib/s3/models/NotificationDiff.rb', line 23

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

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

Instance Method Details

#asset_typeObject



34
35
36
# File 'lib/s3/models/NotificationDiff.rb', line 34

def asset_type
  "Notification"
end

#aws_nameObject



38
39
40
# File 'lib/s3/models/NotificationDiff.rb', line 38

def aws_name
  @aws.name
end

#diff_stringObject



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

def diff_string
  case @type
  when PREFIX
    "Prefix: AWS - #{Colors.aws_changes(@aws.prefix)}, Local - #{Colors.local_changes(@local.prefix)}"
  when SUFFIX
    "Suffix: AWS - #{Colors.aws_changes(@aws.suffix)}, Local - #{Colors.local_changes(@local.suffix)}"
  when TRIGGERS
    [
      "Triggers:",
      @triggers.removed.map { |t| Colors.removed("\t#{t}") },
      @triggers.added.map { |t| Colors.added("\t#{t}") },
    ].flatten.join("\n")
  when TYPE
    "Type: AWS - #{Colors.aws_changes(@aws.type)}, Local - #{Colors.local_changes(@local.type)}"
  when TARGET
    "Target: AWS - #{Colors.aws_changes(@aws.target)}, Local - #{Colors.local_changes(@local.target)}"
  end
end