Class: Ossy::CLI::Configs::Merge

Inherits:
Ossy::CLI::Commands::Core show all
Defined in:
lib/ossy/cli/configs/merge.rb

Instance Method Summary collapse

Instance Method Details

#call(source_path:, target_path:, output_path:, **opts) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ossy/cli/configs/merge.rb', line 21

def call(source_path:, target_path:, output_path:, **opts)
  puts "Merging #{source_path} + #{target_path} into #{output_path}"

  identifiers = opts[:identifiers].split(",").map { |s| s.split(":") }.to_h

  source = YAML.load_file(source_path, permitted_classes: [Date])
  target = YAML.load_file(target_path, permitted_classes: [Date])

  output = deep_merge(source, target, identifiers)

  File.write(output_path, YAML.dump(output))
end