yahns.git  about / heads / tags
sleepy, multi-threaded, non-blocking application server for Ruby
blob cbf59646a62daf0dfa273eca7b19e384a290223f 2486 bytes (raw)
$ git show maint:Rakefile	# shows this blob on the CLI

 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
 
# Copyright (C) 2013-2016 all contributors <yahns-public@yhbt.net>
# License: GPL-3.0+ (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)
  make = ENV['MAKE'] || 'make'
  sh(%Q(#{make} -C Documentation))

  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)
  files.concat(%w(yahns yahns-rackup yahns_config).map! { |x|
    "Documentation/#{x}.txt"
  })
  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

desc 'prints news as an Atom feed'
task "NEWS.atom.xml" do
  # gem install 'olddoc', 'olddoc prepare' has no API besides the
  # command-line.  This requires olddoc 1.1 or later.
  system('olddoc', 'prepare') or abort "olddoc prepare failed #$?"
end

desc 'prints news as a text file'
task 'NEWS' => 'NEWS.atom.xml'

git clone git://yhbt.net/yahns.git
git clone https://yhbt.net/yahns.git