Sha256: b2774f91df4a5a3898fb203d9360c19b6ff711320eaafcb1dd427e1cb0b9628b
Contents?: true
Size: 1.29 KB
Versions: 52
Compression:
Stored size: 1.29 KB
Contents
require_relative './mixin/colorize' require_relative './replace_properties' module Convection module Model ## # Difference between an item in two templates ## class Diff extend Mixin::Colorize attr_reader :key attr_reader :action attr_reader :ours attr_reader :theirs colorize :action, :green => [:create], :yellow => [:update], :red => [:delete, :replace] def initialize(key, ours, theirs) @key = key @ours = ours @theirs = theirs @action = if ours && theirs property_name = key[/AWS::[A-Za-z0-9:]+\.[A-Za-z0-9]+/] if REPLACE_PROPERTIES.include?(property_name) :replace else :update end elsif ours :create else :delete end end def to_thor message = case action when :create then "#{ key }: #{ ours }" when :update then "#{ key }: #{ theirs } => #{ ours }" when :replace then "#{ key }: #{ theirs } => #{ ours }" when :delete then key end [action, message, color] end end end end
Version data entries
52 entries across 52 versions & 1 rubygems