Ruby tdb - 0.2.0 - optional thread-safety
[ruby-tdb.git] / Rakefile
blobd8158a00cf124e5258f9deaf92e8483ccb2e5eaf
1 # -*- encoding: binary -*-
3 # most tasks are in the GNUmakefile which offers better parallelism
5 def tags
6   timefmt = '%Y-%m-%dT%H:%M:%SZ'
7   @tags ||= `git tag -l`.split(/\n/).map do |tag|
8     if %r{\Av[\d\.]+} =~ tag
9       header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
10       header = header.split(/\n/)
11       tagger = header.grep(/\Atagger /).first
12       body ||= "initial"
13       {
14         :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
15         :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
16         :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
17         :id => `git rev-parse refs/tags/#{tag}`.chomp!,
18         :tag => tag,
19         :subject => subject,
20         :body => body,
21       }
22     end
23   end.compact.sort { |a,b| b[:time] <=> a[:time] }
24 end
26 cgit_url = "http://git.bogomips.org/cgit/ruby-tdb.git"
27 git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/ruby-tdb.git'
28 web_url = "http://bogomips.org/ruby-tdb/"
30 desc 'prints news as an Atom feed'
31 task :news_atom do
32   require 'nokogiri'
33   new_tags = tags[0,10]
34   puts(Nokogiri::XML::Builder.new do
35     feed :xmlns => "http://www.w3.org/2005/Atom" do
36       id! "#{web_url}NEWS.atom.xml"
37       title "Ruby tdb news"
38       subtitle "Trivial Database bindings for Ruby"
39       link! :rel => "alternate", :type => "text/html",
40             :href => "#{web_url}NEWS.html"
41       updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time])
42       new_tags.each do |tag|
43         entry do
44           title tag[:subject]
45           updated tag[:time]
46           published tag[:time]
47           author {
48             name tag[:tagger_name]
49             email tag[:tagger_email]
50           }
51           url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
52           link! :rel => "alternate", :type => "text/html", :href =>url
53           id! url
54           message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
55           content({:type =>:text}, message_only)
56           content(:type =>:xhtml) { pre tag[:body] }
57         end
58       end
59     end
60   end.to_xml)
61 end
63 desc 'prints RDoc-formatted news'
64 task :news_rdoc do
65   tags.each do |tag|
66     time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
67     puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}"
68     puts ""
70     body = tag[:body]
71     puts tag[:body].gsub(/^/sm, "  ").gsub(/[ \t]+$/sm, "")
72     puts ""
73   end
74 end
76 desc "print release changelog for Rubyforge"
77 task :release_changes do
78   version = ENV['VERSION'] or abort "VERSION= needed"
79   version = "v#{version}"
80   vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
81   prev = vtags[vtags.index(version) - 1]
82   if prev
83     system('git', 'diff', '--stat', prev, version) or abort $?
84     puts ""
85     system('git', 'log', "#{prev}..#{version}") or abort $?
86   else
87     system('git', 'log', version) or abort $?
88   end
89 end
91 desc "print release notes for Rubyforge"
92 task :release_notes do
93   spec = Gem::Specification.load('tdb.gemspec')
94   puts spec.description.strip
95   puts ""
96   puts "* #{spec.homepage}"
97   puts "* #{spec.email}"
98   puts "* #{git_url}"
100   _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
101   print "\nChanges:\n\n"
102   puts body
105 desc "post to RAA"
106 task :raa_update do
107   require 'net/http'
108   require 'net/netrc'
109   rc = Net::Netrc.locate('tdb-raa') or abort "~/.netrc not found"
110   password = rc.password
112   s = Gem::Specification.load('tdb.gemspec')
113   desc = [ s.description.strip ]
114   desc << ""
115   desc << "* #{s.email}"
116   desc << "* #{git_url}"
117   desc << "* #{cgit_url}"
118   desc = desc.join("\n")
119   uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
120   form = {
121     :name => s.name,
122     :short_description => s.summary,
123     :version => s.version.to_s,
124     :status => 'experimental',
125     :owner => s.authors.first,
126     :email => s.email,
127     :category_major => 'Library',
128     :category_minor => 'Database',
129     :url => s.homepage,
130     :download => 'http://bogomips.org/ruby-tdb/files/',
131     :license => "LGPL",
132     :description_style => 'Plain',
133     :description => desc,
134     :pass => password,
135     :submit => 'Update',
136   }
137   res = Net::HTTP.post_form(uri, form)
138   p res
139   puts res.body