Class: Cumulus::SQS::QueueDiff

Inherits:
Common::Diff show all
Includes:
QueueChange
Defined in:
lib/sqs/models/QueueDiff.rb

Overview

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

Constant Summary

Constants included from QueueChange

Cumulus::SQS::QueueChange::DEAD, Cumulus::SQS::QueueChange::DELAY, Cumulus::SQS::QueueChange::MESSAGE_RETENTION, Cumulus::SQS::QueueChange::MESSAGE_SIZE, Cumulus::SQS::QueueChange::POLICY, Cumulus::SQS::QueueChange::RECEIVE_WAIT, Cumulus::SQS::QueueChange::VISIBILITY

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

Constructor Details

This class inherits a constructor from Cumulus::Common::Diff

Instance Method Details

#asset_typeObject



23
24
25
# File 'lib/sqs/models/QueueDiff.rb', line 23

def asset_type
  "Queue"
end

#aws_nameObject



27
28
29
# File 'lib/sqs/models/QueueDiff.rb', line 27

def aws_name
  @aws.name
end

#diff_stringObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/sqs/models/QueueDiff.rb', line 31

def diff_string
  case @type
  when DELAY
    [
      "Delay",
      Colors.aws_changes("\tAWS - #{aws} seconds"),
      Colors.local_changes("\tLocal - #{local} seconds")
    ].join("\n")
  when MESSAGE_SIZE
    [
      "Max Message Size",
      Colors.aws_changes("\tAWS - #{aws} bytes"),
      Colors.local_changes("\tLocal - #{local} bytes")
    ].join("\n")
  when MESSAGE_RETENTION
    [
      "Message Retention Period",
      Colors.aws_changes("\tAWS - #{aws} seconds"),
      Colors.local_changes("\tLocal - #{local} seconds")
    ].join("\n")
  when RECEIVE_WAIT
    [
      "Receive Wait Time",
      Colors.aws_changes("\tAWS - #{aws} seconds"),
      Colors.local_changes("\tLocal - #{local} seconds")
    ].join("\n")
  when VISIBILITY
    [
      "Message Visibility",
      Colors.aws_changes("\tAWS - #{aws} seconds"),
      Colors.local_changes("\tLocal - #{local} seconds")
    ].join("\n")
  when DEAD
    [
      "Dead Letter Queue",
      @changes.join("\n").lines.map { |l| "\t#{l}".chomp("\n") }
    ].flatten.join("\n")
  when POLICY
    [
      "Policy:",
      if aws
        Colors.unmanaged([
          "\tRemoving:",
          JSON.pretty_generate(aws).lines.map { |l| "\t\t#{l}".chomp("\n") }
        ].join("\n"))
      end,
      if local
        Colors.added([
          "\tAdding:",
          JSON.pretty_generate(local).lines.map { |l| "\t\t#{l}".chomp("\n") }
        ].join("\n"))
      end
    ].reject(&:nil?).join("\n")
  end
end