http: increase REQUEST_PATH maximum length to 4K
[unicorn.git] / Rakefile
blob44c569436ba3526a4793b6ab7993b60eaecb55b5
1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
3 require 'wrongdoc'
5 cgit_url = Wrongdoc.config[:cgit_url]
6 git_url = Wrongdoc.config[:git_url]
8 desc "post to RAA"
9 task :raa_update do
10   require 'net/http'
11   require 'net/netrc'
12   rc = Net::Netrc.locate('unicorn-raa') or abort "~/.netrc not found"
13   password = rc.password
15   s = Gem::Specification.load('unicorn.gemspec')
16   desc = [ s.description.strip ]
17   desc << ""
18   desc << "* #{s.email}"
19   desc << "* #{git_url}"
20   desc << "* #{cgit_url}"
21   desc = desc.join("\n")
22   uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
23   form = {
24     :name => s.name,
25     :short_description => s.summary,
26     :version => s.version.to_s,
27     :status => 'stable',
28     :owner => s.authors.first,
29     :email => s.email,
30     :category_major => 'Library',
31     :category_minor => 'Web',
32     :url => s.homepage,
33     :download => "http://rubyforge.org/frs/?group_id=1306",
34     :license => "Ruby's",
35     :description_style => 'Plain',
36     :description => desc,
37     :pass => password,
38     :submit => "Update",
39   }
40   res = Net::HTTP.post_form(uri, form)
41   p res
42   puts res.body
43 end
45 desc "post to FM"
46 task :fm_update do
47   require 'tempfile'
48   require 'net/http'
49   require 'net/netrc'
50   require 'json'
51   version = ENV['VERSION'] or abort "VERSION= needed"
52   uri = URI.parse('http://freecode.com/projects/unicorn/releases.json')
53   rc = Net::Netrc.locate('unicorn-fm') or abort "~/.netrc not found"
54   api_token = rc.password
55   _, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3)
56   tmp = Tempfile.new('fm-changelog')
57   tmp.puts subject
58   tmp.puts
59   tmp.puts body
60   tmp.flush
61   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
62   changelog = File.read(tmp.path).strip
64   req = {
65     "auth_code" => api_token,
66     "release" => {
67       "tag_list" => "Experimental",
68       "version" => version,
69       "changelog" => changelog,
70     },
71   }.to_json
73   if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z}
74     Net::HTTP.start(uri.host, uri.port) do |http|
75       p http.post(uri.path, req, {'Content-Type'=>'application/json'})
76     end
77   else
78     warn "not updating freshmeat for v#{version}"
79   end
80 end
82 # optional rake-compiler support in case somebody needs to cross compile
83 begin
84   mk = "ext/unicorn_http/Makefile"
85   if File.readable?(mk)
86     warn "run 'gmake -C ext/unicorn_http clean' and\n" \
87          "remove #{mk} before using rake-compiler"
88   elsif ENV['VERSION']
89     unless File.readable?("ext/unicorn_http/unicorn_http.c")
90       abort "run 'gmake ragel' or 'make ragel' to generate the Ragel source"
91     end
92     spec = Gem::Specification.load('unicorn.gemspec')
93     require 'rake/extensiontask'
94     Rake::ExtensionTask.new('unicorn_http', spec)
95   end
96 rescue LoadError
97 end