module Yaks
  module Changelog
    extend self

    def current
      versions[Yaks::VERSION]
    end

    def versions
      markdown.split(/(?=###\s*[\d\.]+\n)/).each_with_object({}) do |section, hsh|
        version = section.each_line.first[/[\d\.]+/]
        log     = section.each_line.drop(1).join.strip
        hsh[version] = log
      end
    end

    def markdown
      Yaks::Root.join('../CHANGELOG.md').read
    end
  end
end

module Yaks
  module Changelog
    extend self

    def current
      versions[Yaks::VERSION]
    end

    def versions
      markdown.split(/(?=###\s*[\d\.]+\n)/).each_with_object({}) do |section, hsh|
        version = section.each_line.first[/[\d\.]+/]
        log     = section.each_line.drop(1).join.strip
        hsh[version] = log
      end
    end

    def markdown
      Pathname(__FILE__).join('../../../../CHANGELOG.md').read
    end
  end
end

Make sure Yaks::Changelog can be used without requiring yaks
Make sure Yaks::Changelog can be used without requiring yaks

Preferably we don't load the whole of Yaks in the gemspec, this makes
Yaks::Changelog self contained
