Rakefile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Rakefile for Rack. -*-ruby-*-
  2. desc "Run all the tests"
  3. task :default => [:test]
  4. desc "Install gem dependencies"
  5. task :deps do
  6. require 'rubygems'
  7. spec = Gem::Specification.load('rack.gemspec')
  8. spec.dependencies.each do |dep|
  9. reqs = dep.requirements_list
  10. reqs = (["-v"] * reqs.size).zip(reqs).flatten
  11. # Use system over sh, because we want to ignore errors!
  12. system "gem", "install", '--conservative', dep.name, *reqs
  13. end
  14. end
  15. desc "Make an archive as .tar.gz"
  16. task :dist => [:chmod, :changelog, :rdoc, "SPEC"] do
  17. sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
  18. sh "pax -waf #{release}.tar -s ':^:#{release}/:' SPEC ChangeLog doc rack.gemspec"
  19. sh "gzip -f -9 #{release}.tar"
  20. end
  21. desc "Make an official release"
  22. task :officialrelease do
  23. puts "Official build for #{release}..."
  24. sh "rm -rf stage"
  25. sh "git clone --shared . stage"
  26. sh "cd stage && rake officialrelease_really"
  27. sh "mv stage/#{release}.tar.gz stage/#{release}.gem ."
  28. end
  29. task :officialrelease_really => ["SPEC", :dist, :gem] do
  30. sh "sha1sum #{release}.tar.gz #{release}.gem"
  31. end
  32. def release
  33. "rack-#{File.read("rack.gemspec")[/s.version *= *"(.*?)"/, 1]}"
  34. end
  35. desc "Make binaries executable"
  36. task :chmod do
  37. Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
  38. Dir["test/cgi/test*"].each { |binary| File.chmod(0775, binary) }
  39. end
  40. desc "Generate a ChangeLog"
  41. task :changelog do
  42. File.open("ChangeLog", "w") { |out|
  43. `git log -z`.split("\0").map { |chunk|
  44. author = chunk[/Author: (.*)/, 1].strip
  45. date = chunk[/Date: (.*)/, 1].strip
  46. desc, detail = $'.strip.split("\n", 2)
  47. detail ||= ""
  48. detail = detail.gsub(/.*darcs-hash:.*/, '')
  49. detail.rstrip!
  50. out.puts "#{date} #{author}"
  51. out.puts " * #{desc.strip}"
  52. out.puts detail unless detail.empty?
  53. out.puts
  54. }
  55. }
  56. end
  57. file 'lib/rack/lint.rb'
  58. desc "Generate Rack Specification"
  59. file "SPEC" => 'lib/rack/lint.rb' do
  60. File.open("SPEC", "wb") { |file|
  61. IO.foreach("lib/rack/lint.rb") { |line|
  62. if line =~ /## (.*)/
  63. file.puts $1
  64. end
  65. }
  66. }
  67. end
  68. desc "Run all the fast + platform agnostic tests"
  69. task :test => 'SPEC' do
  70. opts = ENV['TEST'] || '-a'
  71. specopts = ENV['TESTOPTS'] ||
  72. "-q -t '^(?!Rack::Adapter|Rack::Session::Memcache|Rack::Server|Rack::Handler)'"
  73. sh "bacon -I./lib:./test #{opts} #{specopts}"
  74. end
  75. desc "Run all the tests we run on CI"
  76. task :ci => :test
  77. desc "Run all the tests"
  78. task :fulltest => %w[SPEC chmod] do
  79. opts = ENV['TEST'] || '-a'
  80. specopts = ENV['TESTOPTS'] || '-q'
  81. sh "bacon -r./test/gemloader -I./lib:./test -w #{opts} #{specopts}"
  82. end
  83. task :gem => ["SPEC"] do
  84. sh "gem build rack.gemspec"
  85. end
  86. desc "Generate RDoc documentation"
  87. task :rdoc => ["SPEC"] do
  88. sh(*%w{rdoc --line-numbers --main README.rdoc
  89. --title 'Rack\ Documentation' --charset utf-8 -U -o doc} +
  90. %w{README.rdoc KNOWN-ISSUES SPEC} +
  91. Dir["lib/**/*.rb"])
  92. end
  93. task :pushsite => [:rdoc] do
  94. sh "cd site && git gc"
  95. sh "rsync -avz doc/ chneukirchen@rack.rubyforge.org:/var/www/gforge-projects/rack/doc/"
  96. sh "rsync -avz site/ chneukirchen@rack.rubyforge.org:/var/www/gforge-projects/rack/"
  97. sh "cd site && git push"
  98. end