Sha256: be10b7035a1b5149d167c40ded5c1c116b45e587ca753ad0b4769024f4bb6623

Contents?: true

Size: 935 Bytes

Versions: 8

Compression:

Stored size: 935 Bytes

Contents

# -*- encoding: utf-8 -*-
# Copyright (C) 2015-2016 all contributors <olddoc-public@80x24.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
#
require 'tempfile'

module Olddoc::NewsRdoc # :nodoc:
  include Olddoc::History

  def puts_tag(fp, tag)
    time = tag[:time].tr('T', ' ').gsub!(/:\d\dZ/, ' UTC')
    fp.puts "=== #{tag[:subject]} / #{time}"
    fp.puts ""

    fp.puts tag[:body].gsub(/^/smu, "  ").gsub(/[ \t]+$/smu, "")
    fp.puts ""
  end

  # generates a NEWS file in the top-level directory based on git tags
  def news_rdoc
    news = Tempfile.new('NEWS', '.')
    tags.each { |tag| puts_tag(news, tag) }
    File.open("LATEST", "wb") { |latest|
      if tags.empty?
        latest.puts "Currently unreleased"
        news.puts "No news yet."
      else
        puts_tag(latest, tags[0])
      end
    }
    news.chmod(0666 & ~File.umask)
    File.rename(news.path, 'NEWS')
    news.close!
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
olddoc-1.9.0 lib/olddoc/news_rdoc.rb
olddoc-1.8.0 lib/olddoc/news_rdoc.rb
olddoc-1.7.1 lib/olddoc/news_rdoc.rb
olddoc-1.7.0 lib/olddoc/news_rdoc.rb
olddoc-1.6.0 lib/olddoc/news_rdoc.rb
olddoc-1.5.1 lib/olddoc/news_rdoc.rb
olddoc-1.5.0 lib/olddoc/news_rdoc.rb
olddoc-1.4.0 lib/olddoc/news_rdoc.rb