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