Sha256: a59473a29325febb120ed66d64a8b2b5a9acb3020caa5ad55f61827e2342f143
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require "date" module Groundskeeper # The `CHANGELOG.md` file in an application. class Changelog attr_reader :document, :date FILENAME = "CHANGELOG.md" TITLE_EXPRESSION = "# Changelog" def self.build(filename: FILENAME) new( document: Groundskeeper::Document.new(filename), date: Date.today.iso8601 ) end def initialize(document:, date:) @document = document @date = date end # rubocop:disable Performance/RedundantMatch,Performance/RegexpMatch def update_file(version, changes) unless document.match(/(#{TITLE_EXPRESSION})/o) document.prepend_file("#{TITLE_EXPRESSION}\n\n") end document .append_to_file(TITLE_EXPRESSION, version_template(version, changes)) end # rubocop:enable Performance/RedundantMatch,Performance/RegexpMatch private def version_template(version, changes) ["\n", "## #{version} - #{date}", ""] .concat((changes || []).map { |change| "* #{change}" }) .join("\n") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
groundskeeper-bitcore-0.28.0 | lib/groundskeeper/changelog.rb |
groundskeeper-bitcore-0.27.0 | lib/groundskeeper/changelog.rb |
groundskeeper-bitcore-0.26.0 | lib/groundskeeper/changelog.rb |