class GitHubChangelogGenerator::RakeTask

Constants

OPTIONS

Public Class Methods

new(*args, &task_block) click to toggle source

Public: Initialise a new GitHubChangelogGenerator::RakeTask.

Example

GitHubChangelogGenerator::RakeTask.new
Calls superclass method
# File lib/github_changelog_generator/task.rb, line 33
def initialize(*args, &task_block)
  super()
  @name = args.shift || :changelog

  define(args, &task_block)
end

Public Instance Methods

define(args) { |*[self, args].slice(0, arity)| ... } click to toggle source
# File lib/github_changelog_generator/task.rb, line 40
def define(args, &task_block)
  desc "Generate a Changelog from GitHub"

  yield(*[self, args].slice(0, task_block.arity)) if task_block

  # clear any (auto-)pre-existing task
  Rake::Task[@name].clear if Rake::Task.task_defined?(@name)

  task @name do
    # mimick parse_options
    options = Parser.default_options

    OPTIONS.each do |o|
      v = instance_variable_get("@#{o}")
      options[o.to_sym] = v unless v.nil?
    end
    abort "user and project are required." unless options[:user] && options[:project]
    generator = Generator.new options

    log = generator.compound_changelog

    output_filename = (options[:output]).to_s
    File.open(output_filename, "w") { |file| file.write(log) }
    puts "Done!"
    puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
  end
end