unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 62c13448f4e00259b9fb49b144a73fa417155037 2738 bytes (raw)
$ git show v3.2.1: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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 
# -*- encoding: binary -*-
autoload :Gem, 'rubygems'

cgit_url = "http://git.bogomips.org/cgit/unicorn.git"
git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/unicorn.git'

desc "post to RAA"
task :raa_update do
  require 'net/http'
  require 'net/netrc'
  rc = Net::Netrc.locate('unicorn-raa') or abort "~/.netrc not found"
  password = rc.password

  s = Gem::Specification.load('unicorn.gemspec')
  desc = [ s.description.strip ]
  desc << ""
  desc << "* #{s.email}"
  desc << "* #{git_url}"
  desc << "* #{cgit_url}"
  desc = desc.join("\n")
  uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
  form = {
    :name => s.name,
    :short_description => s.summary,
    :version => s.version.to_s,
    :status => 'stable',
    :owner => s.authors.first,
    :email => s.email,
    :category_major => 'Library',
    :category_minor => 'Web',
    :url => s.homepage,
    :download => "http://rubyforge.org/frs/?group_id=1306",
    :license => "Ruby's",
    :description_style => 'Plain',
    :description => desc,
    :pass => password,
    :submit => "Update",
  }
  res = Net::HTTP.post_form(uri, form)
  p res
  puts res.body
end

desc "post to FM"
task :fm_update do
  require 'tempfile'
  require 'net/http'
  require 'net/netrc'
  require 'json'
  version = ENV['VERSION'] or abort "VERSION= needed"
  uri = URI.parse('http://freshmeat.net/projects/unicorn/releases.json')
  rc = Net::Netrc.locate('unicorn-fm') or abort "~/.netrc not found"
  api_token = rc.password
  changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body]
  tmp = Tempfile.new('fm-changelog')
  tmp.syswrite(changelog)
  system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
  changelog = File.read(tmp.path).strip

  req = {
    "auth_code" => api_token,
    "release" => {
      "tag_list" => "Experimental",
      "version" => version,
      "changelog" => changelog,
    },
  }.to_json

  if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z}
    Net::HTTP.start(uri.host, uri.port) do |http|
      p http.post(uri.path, req, {'Content-Type'=>'application/json'})
    end
  else
    warn "not updating freshmeat for v#{version}"
  end
end

# optional rake-compiler support in case somebody needs to cross compile
begin
  mk = "ext/unicorn_http/Makefile"
  if File.readable?(mk)
    warn "run 'gmake -C ext/unicorn_http clean' and\n" \
         "remove #{mk} before using rake-compiler"
  elsif ENV['VERSION']
    unless File.readable?("ext/unicorn_http/unicorn_http.c")
      abort "run 'gmake ragel' or 'make ragel' to generate the Ragel source"
    end
    spec = Gem::Specification.load('unicorn.gemspec')
    require 'rake/extensiontask'
    Rake::ExtensionTask.new('unicorn_http', spec)
  end
rescue LoadError
end

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