class Fastlane::Helper::ChangelogHelper

TODO: Add unit tests for methods in this class

Public Class Methods

ensure_changelog_exists(path) click to toggle source

Ensures CHANGELOG.md exists at given path. If not, offers to create a default one. Returns path to CHANGELOG.md to be used

# File lib/fastlane/plugin/changelog/helper/changelog_helper.rb, line 18
def self.ensure_changelog_exists(path)
  if File.exist?(path)
    FastlaneCore::UI.success "Found CHANGELOG.md at #{path}"
    path
  else
    FastlaneCore::UI.message("Cannot find CHANGELOG.md at #{path}")
    generate_changelog
    CHANGELOG_PATH
  end
end
generate_changelog() click to toggle source

Generates CHANGELOG.md in project root

# File lib/fastlane/plugin/changelog/helper/changelog_helper.rb, line 30
def self.generate_changelog
  if FastlaneCore::UI.confirm('Do you want to generate default CHANGELOG.md in the project root?')
    FileUtils.touch 'CHANGELOG.md'
    generate_comparison_link
  else
    FastlaneCore::UI.error("Cannot continue without CHANGELOG.md file")
  end
end
get_line_separator(file_path) click to toggle source
# File lib/fastlane/plugin/changelog/helper/changelog_helper.rb, line 71
def self.get_line_separator(file_path)
  f = File.open(file_path)
  enum = f.each_char
  c = enum.next
  loop do
    case c[/\r|\n/]
    when "\n" then break
    when "\r"
      c << "\n" if enum.peek == "\n"
      break
    end
    c = enum.next
  end
  c[0][/\r|\n/] ? c : "\n"
end
write_to_changelog(changelog) click to toggle source

Writes given content to CHANGELOG.md in project root

# File lib/fastlane/plugin/changelog/helper/changelog_helper.rb, line 66
def self.write_to_changelog(changelog)
  File.open(CHANGELOG_PATH, 'w') { |f| f.write(changelog) }
  FastlaneCore::UI.success('Successfully created CHANGELOG.md')
end