module GemToys::Template::Release::Changelog
Helper module with methods about CHANGELOG file for `release` tool
Private Instance Methods
abort_without_unreleased_title()
click to toggle source
# File lib/gem_toys/template/release/changelog.rb, line 39 def abort_without_unreleased_title abort <<~TEXT `#{@template.unreleased_title}` not found in the `#{@template.changelog_file_name}` as the title for unreleased changes. Please, use `:unreleased_title` option if you have non-default one. TEXT end
new_changelog_content()
click to toggle source
# File lib/gem_toys/template/release/changelog.rb, line 26 def new_changelog_content unreleased_title = @template.unreleased_title unreleased_title_index = @changelog_lines.index("#{unreleased_title}\n") abort_without_unreleased_title unless unreleased_title_index @changelog_lines.insert( unreleased_title_index + 2, '#' * unreleased_title.scan(/^#+/).first.size + " #{@new_version} (#{@today})\n\n" ).join end
update_changelog_file()
click to toggle source
# File lib/gem_toys/template/release/changelog.rb, line 10 def update_changelog_file puts 'Updating changelog file...' @changelog_lines = File.readlines(changelog_file_path) existing_line = @changelog_lines.find { |line| line.start_with? "## #{@new_version} " } if existing_line return if (existing_date = existing_line.scan(/\(([^()]+)\)/).last.first) == @today abort "There is already #{new_version} version with date #{existing_date}" end File.write changelog_file_path, new_changelog_content end