1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
| | # Copyright (C) 2013-2015 all contributors <yahns-public@yhbt.net>
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require 'tempfile'
include Rake::DSL
gendocs = %w(NEWS NEWS.atom.xml)
task rsync_docs: gendocs do
dest = ENV["RSYNC_DEST"] || "yahns.yhbt.net:/srv/yahns/"
top = %w(INSTALL HACKING README COPYING)
# git-set-file-times is distributed with rsync,
# Also available at: http://yhbt.net/git-set-file-times
# on Debian systems: /usr/share/doc/rsync/scripts/git-set-file-times.gz
sh("git", "set-file-times", "Documentation", "examples", *top)
do_gzip = lambda do |txt|
gz = "#{txt}.gz"
tmp = "#{gz}.#$$"
sh("gzip --rsyncable -9 < #{txt} > #{tmp}")
st = File.stat(txt)
File.utime(st.atime, st.mtime, tmp) # make nginx gzip_static happy
File.rename(tmp, gz)
gz
end
files = `git ls-files Documentation/*.txt`.split(/\n/)
files.concat(top)
files.concat(gendocs)
gzfiles = files.map { |txt| do_gzip.call(txt) }
files.concat(gzfiles)
sh("rsync --chmod=Fugo=r -av #{files.join(' ')} #{dest}")
examples = `git ls-files examples`.split(/\n/)
gzex = examples.map { |txt| do_gzip.call(txt) }
examples.concat(gzex)
sh("rsync --chmod=Fugo=r -av #{examples.join(' ')} #{dest}/examples/")
end
def tags
timefmt = '%Y-%m-%dT%H:%M:%SZ'
@tags ||= `git tag -l`.split(/\n/).map do |tag|
if %r{\Av[\d\.]+} =~ tag
header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
header = header.split(/\n/)
tagger = header.grep(/\Atagger /).first
body ||= "initial"
time = Time.at(tagger.split(/ /)[-2].to_i).utc
{
time_obj: time,
time: time.strftime(timefmt),
tagger_name: %r{^tagger ([^<]+)}.match(tagger)[1].strip,
tagger_email: %r{<([^>]+)>}.match(tagger)[1].strip,
id: `git rev-parse refs/tags/#{tag}`.chomp!,
tag: tag,
subject: subject,
body: body,
}
end
end.compact.sort { |a,b| b[:time] <=> a[:time] }
end
url_base = 'http://yahns.yhbt.net'
cgit_url = 'http://yhbt.net/yahns.git'
git_url = 'git://yhbt.net/yahns.git'
since = "v0.0.2"
desc 'prints news as an Atom feed'
task "NEWS.atom.xml" do
require 'nokogiri'
new_tags = tags[0,10]
time = nil
str = Nokogiri::XML::Builder.new do
feed :xmlns => "http://www.w3.org/2005/Atom" do
id! "#{url_base}/NEWS.atom.xml"
title "yahns news"
subtitle "sleepy, multi-threaded, non-blocking Ruby application server"
link! :rel => 'alternate', :type => 'text/plain',
:href => "#{url_base}/NEWS"
updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time])
new_tags.each do |tag|
time ||= tag[:time_obj]
entry do
title tag[:subject]
updated tag[:time]
published tag[:time]
author {
name tag[:tagger_name]
email tag[:tagger_email]
}
url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
link! :rel => "alternate", :type => "text/html", :href =>url
id! url
message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/).first.strip
content({:type =>:text}, message_only)
content(:type =>:xhtml) { pre tag[:body] }
end
end
end
end.to_xml
fp = Tempfile.new("NEWS.atom.xml", ".")
fp.sync = true
fp.write(str)
fp.chmod 0644
File.utime(time, time, fp.path) if time
File.rename(fp.path, "NEWS.atom.xml")
fp.close!
end
desc 'prints news as a text file'
task "NEWS" do
fp = Tempfile.new("NEWS", ".")
fp.sync = true
time = nil
tags.each do |tag|
time ||= tag[:time_obj]
line = tag[:subject] + " / " + tag[:time].sub(/T.*/, '')
fp.puts line
fp.puts("-" * line.length)
fp.puts
fp.puts tag[:body]
fp.puts
end
fp.write("Unreleased\n\n") unless fp.size > 0
fp.puts "COPYRIGHT"
fp.puts "---------"
bdfl = 'Eric Wong <normalperson@yhbt.net>'
fp.puts "Copyright (C) 2013, #{bdfl} and all contributors"
fp.puts "License: GPLv3 or later (http://www.gnu.org/licenses/gpl-3.0.txt)"
fp.chmod 0644
File.utime(time, time, fp.path) if time
File.rename(fp.path, "NEWS")
fp.close!
end
|