Module: CFnDK

Defined in:
lib/cfndk.rb,
lib/cfndk/diff.rb,
lib/cfndk/uuid.rb,
lib/cfndk/stack.rb,
lib/cfndk/logger.rb,
lib/cfndk/stacks.rb,
lib/cfndk/command.rb,
lib/cfndk/version.rb,
lib/cfndk/key_pair.rb,
lib/cfndk/key_pairs.rb,
lib/cfndk/erb_string.rb,
lib/cfndk/global_config.rb,
lib/cfndk/stack_command.rb,
lib/cfndk/key_pair_command.rb,
lib/cfndk/template_packager.rb,
lib/cfndk/change_set_command.rb,
lib/cfndk/config_file_loadable.rb,
lib/cfndk/credential_resolvable.rb,
lib/cfndk/credential_provider_chain.rb,
lib/cfndk/subcommand_help_returnable.rb

Defined Under Namespace

Modules: ConfigFileLoadable, CredentialResolvable, SubcommandHelpReturnable Classes: CFnDKLogger, ChangeSetCommand, Command, CredentialProviderChain, ErbString, GlobalConfig, KeyPair, KeyPairCommand, KeyPairs, Stack, StackCommand, Stacks, TemplatePackager, Uuid

Constant Summary collapse

FORMAT =
:unified
LINES =
3
VERSION =
'0.1.3'.freeze

Class Method Summary collapse

Class Method Details

.diff(data_old, data_new) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cfndk/diff.rb', line 5

def self.diff(data_old, data_new)
  result = ''

  file_length_difference = 0

  data_old = data_old.split($/).map { |e| e.chomp }
  data_new = data_new.split($/).map { |e| e.chomp }

  diffs = Diff::LCS.diff(data_old, data_new)
  diffs = nil if diffs.empty?

  return '' unless diffs

  oldhunk = hunk = nil

  diffs.each do |piece|
    begin
      hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, LINES, file_length_difference)
      file_length_difference = hunk.file_length_difference

      next unless oldhunk
      next if LINES.positive? and hunk.merge(oldhunk)

      result << oldhunk.diff(FORMAT) << "\n"
    ensure
      oldhunk = hunk
    end
  end

  last = oldhunk.diff(FORMAT)
  last << "\n" if last.respond_to?(:end_with?) && !last.end_with?("\n")
  result << last
end

.loggerObject



2
3
4
5
# File 'lib/cfndk/logger.rb', line 2

def self.logger
  @logger = CFnDKLogger.new({}) if @logger.nil?
  @logger
end

.logger=(logger) ⇒ Object



7
8
9
# File 'lib/cfndk/logger.rb', line 7

def self.logger=(logger)
  @logger = logger
end