class Ossy::CLI::Changelogs::Update
Constants
- KEYS
Public Instance Methods
call(config_path:, message:)
click to toggle source
# File lib/ossy/cli/changelogs/update.rb, line 20 def call(config_path:, message:) attrs = YAML.safe_load(message) target = YAML.load_file(config_path) version = attrs["version"] || target[0]["version"] entry = target.detect { |e| e["version"].eql?(version) } || {} release = Release.new(attrs.merge(version: version)) release.each do |type, logs| (entry[type.to_s] ||= []).concat(logs).uniq! end entry.update(release.meta) entry = KEYS.map { |key| [key, entry[key]] }.to_h unless target.include?(entry) target.unshift(entry.merge(release.meta)) end File.write(config_path, YAML.dump(target)) end