making server more demanding- closing connections on errors
[ebb.git] / Rakefile
blob38cfa1f6898b2c2a3ce40ad8eadd2645b29c7240
1 require 'rake'
2 require 'rake/testtask'
3 require 'rake/gempackagetask'
4 require 'rake/clean'
6 COMMON_DISTFILES = FileList.new('src/ebb.{c,h}', 'src/parser.{c,h}', 
7   'libev/*', 'VERSION', 'README')
9 RUBY_DISTFILES = COMMON_DISTFILES + FileList.new('src/ebb_ruby.c', 
10   'src/extconf.rb', 'ruby_lib/**/*', 'benchmark/*.rb', 'bin/ebb_rails', 
11   'test/*')
13 PYTHON_DISTFILES = COMMON_DISTFILES + FileList.new('setup.py', 
14   'src/ebb_python.c')
16 CLEAN.add ["**/*.{o,bundle,so,obj,pdb,lib,def,exp}", "benchmark/*.dump", 
17   'site/index.html', 'MANIFEST']
19 CLOBBER.add ['src/Makefile', 'src/parser.c', 'src/mkmf.log', 'build']
22 def dir(path)
23   File.expand_path File.join(File.dirname(__FILE__), path)
24 end
26 task(:default => :test)
28 task(:package => 'src/parser.c')
30 task(:compile => 'src/parser.c') do 
31   sh "cd #{dir('src')} && ruby extconf.rb && make"
32 end
34 file('MANIFEST') do
35   File.open(dir('MANIFEST'), "w+") do |manifest|
36     PYTHON_DISTFILES.each { |file| manifest.puts(file) }
37   end
38 end
42 task(:wc) { sh "wc -l ruby_lib/*.rb src/ebb*.{c,h}" }
44 task(:test => :compile)
45 Rake::TestTask.new do |t|
46   t.test_files = 'test/basic_test.rb'
47   t.verbose = true
48 end
50 task(:site_upload => :site) do
51   sh 'scp -r site/* rydahl@rubyforge.org:/var/www/gforge-projects/ebb/'
52 end
53 task(:site => 'site/index.html')
54 file('site/index.html' => %w{README site/style.css}) do
55   require 'BlueCloth'
56   doc = BlueCloth.new(File.read(dir('README')))
57   template = <<-HEREDOC
58 <html>
59   <head>
60     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
61     <title>Ebb</title>
62     <link rel="alternate" href="http://max.kanat.us/tag-syndicate/?user=four&tag=ebb" title="RSS Feed" type="application/rss+xml" />
63     <link type="text/css" rel="stylesheet" href="style.css" media="screen"/>
64   </head>
65   <body>  
66     <div id="content">CONTENT</div>
67   </body>
68 </html>
69 HEREDOC
70   
71   File.open(dir('site/index.html'), "w+") do |f|
72     f.write template.sub('CONTENT', doc.to_html)
73   end
74 end
76 spec = Gem::Specification.new do |s|
77   s.platform = Gem::Platform::RUBY
78   s.summary = "A Web Server"
79   s.description = ''
80   s.name = 'ebb'
81   s.author = 'ry dahl'
82   s.email = 'ry at tiny clouds dot org'
83   s.homepage = 'http://ebb.rubyforge.org'
84   s.version = File.read(dir("VERSION")).gsub(/\s/,'')
85   s.rubyforge_project = 'ebb'
86   
87   s.add_dependency('rack')
88   s.required_ruby_version = '>= 1.8.4'
89   
90   s.require_path = 'ruby_lib'
91   s.extensions = 'src/extconf.rb'
92   s.bindir = 'bin'
93   s.executables = %w(ebb_rails)
94   
95   s.files = RUBY_DISTFILES
96 end
98 Rake::GemPackageTask.new(spec) do |pkg|
99   pkg.need_zip = true
102 ## Compile 
103 file('src/parser.c' => 'src/parser.rl') do
104   #sh "ragel src/parser.rl | rlgen-cd -G2 -o src/parser.c"  # ragel 5
105   sh 'ragel -G2 src/parser.rl' # ragel 6
108 file('test/parser_test' => ['src/parser.c', 'src/parser.h']) do
109   sh "gcc -g -Wall -I#{dir('src')} -DPARSER_TEST #{dir('src/parser.c')} -o #{dir('test/parser_test')}"