Module: Cumulus::Common::TagsDiff

Overview

Public: A module to be mixed in to Diff classes that have tags

Instance Method Summary collapse

Instance Method Details

#tags_diff_stringObject

Public: Get the diff string for tag differences

Returns the string to display



8
9
10
11
12
13
# File 'lib/common/models/TagsDiff.rb', line 8

def tags_diff_string
  lines = ["Tags:"]
  lines << tags_to_remove.map { |k, v| "\t#{Colors.removed("#{k} => #{v}")}" }
  lines << tags_to_add.map { |k, v| "\t#{Colors.added("#{k} => #{v}")}" }
  lines.flatten.join("\n")
end

#tags_to_addObject

Public: Get the tags that are in local configuration but not in AWS

Returns a hash of tags



25
26
27
# File 'lib/common/models/TagsDiff.rb', line 25

def tags_to_add
  local_tags.reject { |t, v| aws_tags.include?(t) and aws_tags[t] == v }
end

#tags_to_removeObject

Public: Get the tags that are in AWS that are not in local configuration

Returns a hash of tags



18
19
20
# File 'lib/common/models/TagsDiff.rb', line 18

def tags_to_remove
  aws_tags.reject { |t, v| local_tags.include?(t) and local_tags[t] == v }
end