about summary refs log tree commit homepage
path: root/lib/wrongdoc/news_rdoc.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-24 00:24:59 +0000
committerEric Wong <normalperson@yhbt.net>2010-12-24 01:06:37 +0000
commit24415920ff7ee31b294d785e776a2a7dd2ad6367 (patch)
tree30e0bac3f2c6944c6705b73ddc4c668944b4c3f8 /lib/wrongdoc/news_rdoc.rb
downloadwrongdoc-24415920ff7ee31b294d785e776a2a7dd2ad6367.tar.gz
wrongdoc 1.0.0 - initial release v1.0.0
Welcome to hell
Diffstat (limited to 'lib/wrongdoc/news_rdoc.rb')
-rw-r--r--lib/wrongdoc/news_rdoc.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/wrongdoc/news_rdoc.rb b/lib/wrongdoc/news_rdoc.rb
new file mode 100644
index 0000000..ee21d6b
--- /dev/null
+++ b/lib/wrongdoc/news_rdoc.rb
@@ -0,0 +1,30 @@
+# -*- encoding: utf-8 -*-
+module Wrongdoc::NewsRdoc
+  include Wrongdoc::History
+
+  def puts_tag(fp, tag)
+    time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
+    fp.puts "=== #{tag[:subject]} / #{time}"
+    fp.puts ""
+
+    body = tag[:body]
+    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
+    }
+    File.rename(news.path, 'NEWS')
+    news.close!
+  end
+end