Sha256: de896ee9c3ca825ad709f6ce897257dbecfe5c3740cc44c62acd78882e71c913

Contents?: true

Size: 877 Bytes

Versions: 12

Compression:

Stored size: 877 Bytes

Contents

require 'octokit'
require 'reverse_markdown'
require 'erb'

class ChangeLogGenerator
  attr :repository, :template_path, :changelog_path

  def initialize(repository, template_path: "CHANGELOG.md.erb", changelog_path: "CHANGELOG.md")
    @repository     = repository
    @template_path  = template_path
    @changelog_path = changelog_path
  end

  def generate_and_save!
    changelog_in_md   = ERB.new(template).result(binding)
    changelog_in_html = Octokit.markdown(changelog_in_md, context: repository, mode: "gfm")

    File.open(changelog_path, 'w') do |file|
      file.write ReverseMarkdown.convert(changelog_in_html, github_flavored: true)
    end
  end

  private

  def template
    open("#{__dir__}/#{template_path}").read
  end

  def releases
    @releases ||= Octokit.releases(repository)
  end
end

ChangeLogGenerator.new("yuki24/artemis").generate_and_save!

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
artemis-1.1.0 doc/changelog_generator.rb
artemis-1.0.2 doc/changelog_generator.rb
artemis-1.0.0 doc/changelog_generator.rb
artemis-0.9.0 doc/changelog_generator.rb
artemis-0.8.0 doc/changelog_generator.rb
artemis-0.7.0 doc/changelog_generator.rb
artemis-0.6.0 doc/changelog_generator.rb
artemis-0.5.2 doc/changelog_generator.rb
artemis-0.5.1 doc/changelog_generator.rb
artemis-0.5.0 doc/changelog_generator.rb
artemis-0.4.0 doc/changelog_generator.rb
artemis-0.2.0 doc/changelog_generator.rb