mongrel 1.1.4-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +16 -0
  3. data/COPYING +55 -0
  4. data/LICENSE +55 -0
  5. data/Manifest +69 -0
  6. data/README +74 -0
  7. data/TODO +5 -0
  8. data/bin/mongrel_rails +283 -0
  9. data/examples/builder.rb +29 -0
  10. data/examples/camping/README +3 -0
  11. data/examples/camping/blog.rb +294 -0
  12. data/examples/camping/tepee.rb +149 -0
  13. data/examples/httpd.conf +474 -0
  14. data/examples/mime.yaml +3 -0
  15. data/examples/mongrel.conf +9 -0
  16. data/examples/mongrel_simple_ctrl.rb +92 -0
  17. data/examples/mongrel_simple_service.rb +116 -0
  18. data/examples/monitrc +57 -0
  19. data/examples/random_thrash.rb +19 -0
  20. data/examples/simpletest.rb +52 -0
  21. data/examples/webrick_compare.rb +20 -0
  22. data/ext/http11/ext_help.h +14 -0
  23. data/ext/http11/extconf.rb +6 -0
  24. data/ext/http11/http11.c +402 -0
  25. data/ext/http11/http11_parser.c +1221 -0
  26. data/ext/http11/http11_parser.h +49 -0
  27. data/ext/http11/http11_parser.java.rl +170 -0
  28. data/ext/http11/http11_parser.rl +152 -0
  29. data/ext/http11/http11_parser_common.rl +54 -0
  30. data/ext/http11_java/Http11Service.java +13 -0
  31. data/ext/http11_java/org/jruby/mongrel/Http11.java +266 -0
  32. data/ext/http11_java/org/jruby/mongrel/Http11Parser.java +572 -0
  33. data/lib/http11.so +0 -0
  34. data/lib/mongrel.rb +355 -0
  35. data/lib/mongrel/camping.rb +107 -0
  36. data/lib/mongrel/cgi.rb +181 -0
  37. data/lib/mongrel/command.rb +222 -0
  38. data/lib/mongrel/configurator.rb +388 -0
  39. data/lib/mongrel/const.rb +110 -0
  40. data/lib/mongrel/debug.rb +203 -0
  41. data/lib/mongrel/gems.rb +22 -0
  42. data/lib/mongrel/handlers.rb +468 -0
  43. data/lib/mongrel/header_out.rb +28 -0
  44. data/lib/mongrel/http_request.rb +155 -0
  45. data/lib/mongrel/http_response.rb +163 -0
  46. data/lib/mongrel/init.rb +10 -0
  47. data/lib/mongrel/mime_types.yml +616 -0
  48. data/lib/mongrel/rails.rb +185 -0
  49. data/lib/mongrel/stats.rb +89 -0
  50. data/lib/mongrel/tcphack.rb +18 -0
  51. data/lib/mongrel/uri_classifier.rb +76 -0
  52. data/mongrel-public_cert.pem +20 -0
  53. data/mongrel.gemspec +231 -0
  54. data/setup.rb +1585 -0
  55. data/test/mime.yaml +3 -0
  56. data/test/mongrel.conf +1 -0
  57. data/test/test_cgi_wrapper.rb +26 -0
  58. data/test/test_command.rb +86 -0
  59. data/test/test_conditional.rb +107 -0
  60. data/test/test_configurator.rb +87 -0
  61. data/test/test_debug.rb +25 -0
  62. data/test/test_handlers.rb +123 -0
  63. data/test/test_http11.rb +156 -0
  64. data/test/test_redirect_handler.rb +44 -0
  65. data/test/test_request_progress.rb +99 -0
  66. data/test/test_response.rb +127 -0
  67. data/test/test_stats.rb +35 -0
  68. data/test/test_uriclassifier.rb +261 -0
  69. data/test/test_ws.rb +115 -0
  70. data/test/testhelp.rb +66 -0
  71. data/tools/trickletest.rb +45 -0
  72. metadata +152 -0
  73. metadata.gz.sig +0 -0
@@ -0,0 +1,185 @@
1
+ # Copyright (c) 2005 Zed A. Shaw
2
+ # You can redistribute it and/or modify it under the same terms as Ruby.
3
+ #
4
+ # Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
5
+ # for more information.
6
+
7
+ require 'mongrel'
8
+ require 'cgi'
9
+
10
+
11
+ module Mongrel
12
+ module Rails
13
+ # Implements a handler that can run Rails and serve files out of the
14
+ # Rails application's public directory. This lets you run your Rails
15
+ # application with Mongrel during development and testing, then use it
16
+ # also in production behind a server that's better at serving the
17
+ # static files.
18
+ #
19
+ # The RailsHandler takes a mime_map parameter which is a simple suffix=mimetype
20
+ # mapping that it should add to the list of valid mime types.
21
+ #
22
+ # It also supports page caching directly and will try to resolve a request
23
+ # in the following order:
24
+ #
25
+ # * If the requested exact PATH_INFO exists as a file then serve it.
26
+ # * If it exists at PATH_INFO+".html" exists then serve that.
27
+ # * Finally, construct a Mongrel::CGIWrapper and run Dispatcher.dispatch to have Rails go.
28
+ #
29
+ # This means that if you are using page caching it will actually work with Mongrel
30
+ # and you should see a decent speed boost (but not as fast as if you use a static
31
+ # server like Apache or Litespeed).
32
+ class RailsHandler < Mongrel::HttpHandler
33
+ attr_reader :files
34
+ attr_reader :guard
35
+ @@file_only_methods = ["GET","HEAD"]
36
+
37
+ def initialize(dir, mime_map = {})
38
+ @files = Mongrel::DirHandler.new(dir,false)
39
+ @guard = Mutex.new
40
+
41
+ # Register the requested MIME types
42
+ mime_map.each {|k,v| Mongrel::DirHandler::add_mime_type(k,v) }
43
+ end
44
+
45
+ # Attempts to resolve the request as follows:
46
+ #
47
+ # * If the requested exact PATH_INFO exists as a file then serve it.
48
+ # * If it exists at PATH_INFO+".html" exists then serve that.
49
+ # * Finally, construct a Mongrel::CGIWrapper and run Dispatcher.dispatch to have Rails go.
50
+ def process(request, response)
51
+ return if response.socket.closed?
52
+
53
+ path_info = request.params[Mongrel::Const::PATH_INFO]
54
+ rest_operator = request.params[Mongrel::Const::REQUEST_URI][/^#{Regexp.escape path_info}(;[^\?]+)/, 1].to_s
55
+ path_info.chomp!("/")
56
+
57
+ page_cached = path_info + rest_operator + ActionController::Base.page_cache_extension
58
+ get_or_head = @@file_only_methods.include? request.params[Mongrel::Const::REQUEST_METHOD]
59
+
60
+ if get_or_head and @files.can_serve(path_info)
61
+ # File exists as-is so serve it up
62
+ @files.process(request,response)
63
+ elsif get_or_head and @files.can_serve(page_cached)
64
+ # Possible cached page, serve it up
65
+ request.params[Mongrel::Const::PATH_INFO] = page_cached
66
+ @files.process(request,response)
67
+ else
68
+ begin
69
+ cgi = Mongrel::CGIWrapper.new(request, response)
70
+ cgi.handler = self
71
+ # We don't want the output to be really final until we're out of the lock
72
+ cgi.default_really_final = false
73
+
74
+ @guard.synchronize {
75
+ @active_request_path = request.params[Mongrel::Const::PATH_INFO]
76
+ Dispatcher.dispatch(cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, response.body)
77
+ @active_request_path = nil
78
+ }
79
+
80
+ # This finalizes the output using the proper HttpResponse way
81
+ cgi.out("text/html",true) {""}
82
+ rescue Errno::EPIPE
83
+ response.socket.close
84
+ rescue Object => rails_error
85
+ STDERR.puts "#{Time.now}: Error calling Dispatcher.dispatch #{rails_error.inspect}"
86
+ STDERR.puts rails_error.backtrace.join("\n")
87
+ end
88
+ end
89
+ end
90
+
91
+ # Does the internal reload for Rails. It might work for most cases, but
92
+ # sometimes you get exceptions. In that case just do a real restart.
93
+ def reload!
94
+ begin
95
+ @guard.synchronize {
96
+ $".replace $orig_dollar_quote
97
+ GC.start
98
+ Dispatcher.reset_application!
99
+ ActionController::Routing::Routes.reload
100
+ }
101
+ end
102
+ end
103
+ end
104
+
105
+ # Creates Rails specific configuration options for people to use
106
+ # instead of the base Configurator.
107
+ class RailsConfigurator < Mongrel::Configurator
108
+
109
+ # Creates a single rails handler and returns it so you
110
+ # can add it to a URI. You can actually attach it to
111
+ # as many URIs as you want, but this returns the
112
+ # same RailsHandler for each call.
113
+ #
114
+ # Requires the following options:
115
+ #
116
+ # * :docroot => The public dir to serve from.
117
+ # * :environment => Rails environment to use.
118
+ # * :cwd => The change to working directory
119
+ #
120
+ # And understands the following optional settings:
121
+ #
122
+ # * :mime => A map of mime types.
123
+ #
124
+ # Because of how Rails is designed you can only have
125
+ # one installed per Ruby interpreter (talk to them
126
+ # about thread safety). Because of this the first
127
+ # time you call this function it does all the config
128
+ # needed to get your Rails working. After that
129
+ # it returns the one handler you've configured.
130
+ # This lets you attach Rails to any URI(s) you want,
131
+ # but it still protects you from threads destroying
132
+ # your handler.
133
+ def rails(options={})
134
+
135
+ return @rails_handler if @rails_handler
136
+
137
+ ops = resolve_defaults(options)
138
+
139
+ # fix up some defaults
140
+ ops[:environment] ||= "development"
141
+ ops[:docroot] ||= "public"
142
+ ops[:mime] ||= {}
143
+
144
+ $orig_dollar_quote = $".clone
145
+ ENV['RAILS_ENV'] = ops[:environment]
146
+ env_location = "#{ops[:cwd]}/config/environment"
147
+ require env_location
148
+ require 'dispatcher'
149
+ require 'mongrel/rails'
150
+
151
+ ActionController::AbstractRequest.relative_url_root = ops[:prefix] if ops[:prefix]
152
+
153
+ @rails_handler = RailsHandler.new(ops[:docroot], ops[:mime])
154
+ end
155
+
156
+ # Reloads Rails. This isn't too reliable really, but it
157
+ # should work for most minimal reload purposes. The only reliable
158
+ # way to reload properly is to stop and then start the process.
159
+ def reload!
160
+ if not @rails_handler
161
+ raise "Rails was not configured. Read the docs for RailsConfigurator."
162
+ end
163
+
164
+ log "Reloading Rails..."
165
+ @rails_handler.reload!
166
+ log "Done reloading Rails."
167
+
168
+ end
169
+
170
+ # Takes the exact same configuration as Mongrel::Configurator (and actually calls that)
171
+ # but sets up the additional HUP handler to call reload!.
172
+ def setup_rails_signals(options={})
173
+ ops = resolve_defaults(options)
174
+ setup_signals(options)
175
+
176
+ if RUBY_PLATFORM !~ /mswin/
177
+ # rails reload
178
+ trap("HUP") { log "HUP signal received."; reload! }
179
+
180
+ log "Rails signals registered. HUP => reload (without restart). It might not work well."
181
+ end
182
+ end
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,89 @@
1
+ # Copyright (c) 2005 Zed A. Shaw
2
+ # You can redistribute it and/or modify it under the same terms as Ruby.
3
+ #
4
+ # Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
5
+ # for more information.
6
+
7
+ # A very simple little class for doing some basic fast statistics sampling.
8
+ # You feed it either samples of numeric data you want measured or you call
9
+ # Stats.tick to get it to add a time delta between the last time you called it.
10
+ # When you're done either call sum, sumsq, n, min, max, mean or sd to get
11
+ # the information. The other option is to just call dump and see everything.
12
+ #
13
+ # It does all of this very fast and doesn't take up any memory since the samples
14
+ # are not stored but instead all the values are calculated on the fly.
15
+ module Mongrel
16
+ class Stats
17
+ attr_reader :sum, :sumsq, :n, :min, :max
18
+
19
+ def initialize(name)
20
+ @name = name
21
+ reset
22
+ end
23
+
24
+ # Resets the internal counters so you can start sampling again.
25
+ def reset
26
+ @sum = 0.0
27
+ @sumsq = 0.0
28
+ @last_time = Time.new
29
+ @n = 0.0
30
+ @min = 0.0
31
+ @max = 0.0
32
+ end
33
+
34
+ # Adds a sampling to the calculations.
35
+ def sample(s)
36
+ @sum += s
37
+ @sumsq += s * s
38
+ if @n == 0
39
+ @min = @max = s
40
+ else
41
+ @min = s if @min > s
42
+ @max = s if @max < s
43
+ end
44
+ @n+=1
45
+ end
46
+
47
+ # Dump this Stats object with an optional additional message.
48
+ def dump(msg = "", out=STDERR)
49
+ out.puts "#{msg}: #{self.to_s}"
50
+ end
51
+
52
+ # Returns a common display (used by dump)
53
+ def to_s
54
+ "[#{@name}]: SUM=%0.4f, SUMSQ=%0.4f, N=%0.4f, MEAN=%0.4f, SD=%0.4f, MIN=%0.4f, MAX=%0.4f" % [@sum, @sumsq, @n, mean, sd, @min, @max]
55
+ end
56
+
57
+
58
+ # Calculates and returns the mean for the data passed so far.
59
+ def mean
60
+ @sum / @n
61
+ end
62
+
63
+ # Calculates the standard deviation of the data so far.
64
+ def sd
65
+ # (sqrt( ((s).sumsq - ( (s).sum * (s).sum / (s).n)) / ((s).n-1) ))
66
+ begin
67
+ return Math.sqrt( (@sumsq - ( @sum * @sum / @n)) / (@n-1) )
68
+ rescue Errno::EDOM
69
+ return 0.0
70
+ end
71
+ end
72
+
73
+
74
+ # Adds a time delta between now and the last time you called this. This
75
+ # will give you the average time between two activities.
76
+ #
77
+ # An example is:
78
+ #
79
+ # t = Stats.new("do_stuff")
80
+ # 10000.times { do_stuff(); t.tick }
81
+ # t.dump("time")
82
+ #
83
+ def tick
84
+ now = Time.now
85
+ sample(now - @last_time)
86
+ @last_time = now
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2005 Zed A. Shaw
2
+ # You can redistribute it and/or modify it under the same terms as Ruby.
3
+ #
4
+ # Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
5
+ # for more information.
6
+
7
+
8
+ # A modification proposed by Sean Treadway that increases the default accept
9
+ # queue of TCPServer to 1024 so that it handles more concurrent requests.
10
+ class TCPServer
11
+ def initialize_with_backlog(*args)
12
+ initialize_without_backlog(*args)
13
+ listen(1024)
14
+ end
15
+
16
+ alias_method :initialize_without_backlog, :initialize
17
+ alias_method :initialize, :initialize_with_backlog
18
+ end
@@ -0,0 +1,76 @@
1
+
2
+ module Mongrel
3
+ class URIClassifier
4
+
5
+ class RegistrationError < RuntimeError
6
+ end
7
+ class UsageError < RuntimeError
8
+ end
9
+
10
+ attr_reader :handler_map
11
+
12
+ # Returns the URIs that have been registered with this classifier so far.
13
+ def uris
14
+ @handler_map.keys
15
+ end
16
+
17
+ def initialize
18
+ @handler_map = {}
19
+ @matcher = //
20
+ @root_handler = nil
21
+ end
22
+
23
+ # Register a handler object at a particular URI. The handler can be whatever
24
+ # you want, including an array. It's up to you what to do with it.
25
+ #
26
+ # Registering a handler is not necessarily threadsafe, so be careful if you go
27
+ # mucking around once the server is running.
28
+ def register(uri, handler)
29
+ raise RegistrationError, "#{uri.inspect} is already registered" if @handler_map[uri]
30
+ raise RegistrationError, "URI is empty" if !uri or uri.empty?
31
+ raise RegistrationError, "URI must begin with a \"#{Const::SLASH}\"" unless uri[0..0] == Const::SLASH
32
+ @handler_map[uri.dup] = handler
33
+ rebuild
34
+ end
35
+
36
+ # Unregister a particular URI and its handler.
37
+ def unregister(uri)
38
+ handler = @handler_map.delete(uri)
39
+ raise RegistrationError, "#{uri.inspect} was not registered" unless handler
40
+ rebuild
41
+ handler
42
+ end
43
+
44
+ # Resolve a request URI by finding the best partial match in the registered
45
+ # handler URIs.
46
+ def resolve(request_uri)
47
+ if @root_handler
48
+ # Optimization for the pathological case of only one handler on "/"; e.g. Rails
49
+ [Const::SLASH, request_uri, @root_handler]
50
+ elsif match = @matcher.match(request_uri)
51
+ uri = match.to_s
52
+ # A root mounted ("/") handler must resolve such that path info matches the original URI.
53
+ [uri, (uri == Const::SLASH ? request_uri : match.post_match), @handler_map[uri]]
54
+ else
55
+ [nil, nil, nil]
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def rebuild
62
+ if @handler_map.size == 1 and @handler_map[Const::SLASH]
63
+ @root_handler = @handler_map.values.first
64
+ else
65
+ @root_handler = nil
66
+ routes = @handler_map.keys.sort.sort_by do |uri|
67
+ -uri.length
68
+ end
69
+ @matcher = Regexp.new(routes.map do |uri|
70
+ Regexp.new('^' + Regexp.escape(uri))
71
+ end.join('|'))
72
+ end
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDUDCCAjigAwIBAgIBADANBgkqhkiG9w0BAQUFADBOMRwwGgYDVQQDDBNtb25n
3
+ cmVsLWRldmVsb3BtZW50MRkwFwYKCZImiZPyLGQBGRYJcnVieWZvcmdlMRMwEQYK
4
+ CZImiZPyLGQBGRYDb3JnMB4XDTA3MDkxNjEwMzI0OVoXDTA4MDkxNTEwMzI0OVow
5
+ TjEcMBoGA1UEAwwTbW9uZ3JlbC1kZXZlbG9wbWVudDEZMBcGCgmSJomT8ixkARkW
6
+ CXJ1Ynlmb3JnZTETMBEGCgmSJomT8ixkARkWA29yZzCCASIwDQYJKoZIhvcNAQEB
7
+ BQADggEPADCCAQoCggEBAMb9v3B01eOHk3FyypbQgKXzJplUE5P6dXoG+xpPm0Lv
8
+ P7BQmeMncOwqQ7zXpVQU+lTpXtQFTsOE3vL7KnhQFJKGvUAkbh24VFyopu1I0yqF
9
+ mGu4nRqNXGXVj8TvLSj4S1WpSRLAa0acLPNyKhGmoV9+crqQypSjM6XKjBeppifo
10
+ 4eBmWGjiJEYMIJBvJZPJ4rAVDDA8C6CM1m3gMBGNh8ELDhU8HI9AP3dMIkTI2Wx9
11
+ 9xkJwHdroAaS0IFFtYChrwee4FbCF1FHDgoTosMwa47DrLHg4hZ6ojaKwK5QVWEV
12
+ XGb6ju5UqpktnSWF2W+Lvl/K0tI42OH2CAhebT1gEVUCAwEAAaM5MDcwCQYDVR0T
13
+ BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFGHChyMSZ16u9WOzKhgJSQ9lqDc5
14
+ MA0GCSqGSIb3DQEBBQUAA4IBAQA/lfeN2WdB1xN+82tT7vNS4HOjRQw6MUh5yktu
15
+ GQjaGqm0UB+aX0Z9y0B0qpfv9rj7nmIvEGiwBmDepNWYCGuW15JyqpN7QVVnG2xS
16
+ Mrame7VqgjM7A+VGDD5In5LtWbM/CHAATvvFlQ5Ph13YE1EdnVbZ65c+KQv+5sFY
17
+ Q+zEop74d878uaC/SAHHXS46TiXneocaLSYw1CEZs/MAIy+9c4Q5ESbGpgnfg1Ad
18
+ 6lwl7k3hsNHO/+tZzx4HJtOXDI1yAl3+q6T9J0yI3z97EinwvAKhS1eyOI2Y5eeT
19
+ tbQaNYkU127B3l/VNpd8fQm3Jkl/PqCCmDBQjUszFrJEODug
20
+ -----END CERTIFICATE-----
@@ -0,0 +1,231 @@
1
+
2
+ # Gem::Specification for Mongrel-1.1.4
3
+ # Originally generated by Echoe
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{mongrel}
7
+ s.version = "1.1.4"
8
+ s.platform = %q{x86-mswin32-60}
9
+
10
+ s.specification_version = 2 if s.respond_to? :specification_version=
11
+
12
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
+ s.authors = ["Zed A. Shaw"]
14
+ s.date = %q{2008-02-29}
15
+ s.default_executable = %q{mongrel_rails}
16
+ s.description = %q{A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps.}
17
+ s.email = %q{}
18
+ s.executables = ["mongrel_rails"]
19
+ s.has_rdoc = true
20
+ s.homepage = %q{http://mongrel.rubyforge.org}
21
+ s.require_paths = ["lib", "ext"]
22
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.4")
23
+ s.rubyforge_project = %q{mongrel}
24
+ s.rubygems_version = %q{1.0.1}
25
+ s.summary = %q{A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps.}
26
+ s.test_files = ["test/test_cgi_wrapper.rb", "test/test_command.rb", "test/test_conditional.rb", "test/test_configurator.rb", "test/test_debug.rb", "test/test_handlers.rb", "test/test_http11.rb", "test/test_redirect_handler.rb", "test/test_request_progress.rb", "test/test_response.rb", "test/test_stats.rb", "test/test_uriclassifier.rb", "test/test_ws.rb"]
27
+
28
+ s.add_dependency(%q<gem_plugin>, [">= 0.2.3"])
29
+ s.add_dependency(%q<cgi_multipart_eof_fix>, [">= 2.4"])
30
+ end
31
+
32
+
33
+ # # Original Rakefile source (requires the Echoe gem):
34
+ #
35
+ #
36
+ # require 'rubygems'
37
+ # gem 'echoe', '>=2.7.5'
38
+ # require 'echoe'
39
+ #
40
+ # e = Echoe.new("mongrel") do |p|
41
+ # p.summary = "A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps."
42
+ # p.author ="Zed A. Shaw"
43
+ # p.clean_pattern = ['ext/http11/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'lib/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'ext/http11/Makefile', 'pkg', 'lib/*.bundle', '*.gem', 'site/output', '.config', 'lib/http11.jar', 'ext/http11_java/classes', 'coverage', 'doc']
44
+ # p.url = "http://mongrel.rubyforge.org"
45
+ # p.rdoc_pattern = ['README', 'LICENSE', 'CHANGELOG', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc']
46
+ # p.docs_host = 'mongrel.cloudbur.st:/home/eweaver/www/mongrel/htdocs/web'
47
+ # p.ignore_pattern = /^(pkg|site|projects|doc|log)|CVS|\.log/
48
+ # p.ruby_version = '>=1.8.4'
49
+ # p.dependencies = ['gem_plugin >=0.2.3']
50
+ # p.extension_pattern = nil
51
+ #
52
+ # when 'eweaver'
53
+ # when 'luislavena'
54
+ # end
55
+ #
56
+ # p.need_tar_gz = false
57
+ # p.need_tgz = true
58
+ #
59
+ # if RUBY_PLATFORM !~ /mswin|java/
60
+ # p.extension_pattern = ["ext/**/extconf.rb"]
61
+ # end
62
+ #
63
+ # p.eval = proc do
64
+ # case RUBY_PLATFORM
65
+ # when /mswin/
66
+ # self.files += ['lib/http11.so']
67
+ # self.platform = Gem::Platform::CURRENT
68
+ # add_dependency('cgi_multipart_eof_fix', '>= 2.4')
69
+ # when /java/
70
+ # self.files += ['lib/http11.jar']
71
+ # self.platform = 'jruby' # XXX Is this right?
72
+ # else
73
+ # add_dependency('daemons', '>= 1.0.3')
74
+ # add_dependency('fastthread', '>= 1.0.1')
75
+ # add_dependency('cgi_multipart_eof_fix', '>= 2.4')
76
+ # end
77
+ # end
78
+ #
79
+ # end
80
+ #
81
+ # #### Ragel builder
82
+ #
83
+ # desc "Rebuild the Ragel sources"
84
+ # task :ragel do
85
+ # Dir.chdir "ext/http11" do
86
+ # target = "http11_parser.c"
87
+ # File.unlink target if File.exist? target
88
+ # sh "ragel http11_parser.rl | rlgen-cd -G2 -o #{target}"
89
+ # raise "Failed to build C source" unless File.exist? target
90
+ # end
91
+ # Dir.chdir "ext/http11" do
92
+ # target = "../../ext/http11_java/org/jruby/mongrel/Http11Parser.java"
93
+ # File.unlink target if File.exist? target
94
+ # sh "ragel -J http11_parser.java.rl | rlgen-java -o #{target}"
95
+ # raise "Failed to build Java source" unless File.exist? target
96
+ # end
97
+ # end
98
+ #
99
+ # #### Pre-compiled extensions for alternative platforms
100
+ #
101
+ # def move_extensions
102
+ # Dir["ext/**/*.#{Config::CONFIG['DLEXT']}"].each { |file| mv file, "lib/" }
103
+ # end
104
+ #
105
+ # def java_classpath_arg
106
+ # # A myriad of ways to discover the JRuby classpath
107
+ # classpath = begin
108
+ # require 'java'
109
+ # # Already running in a JRuby JVM
110
+ # Java::java.lang.System.getProperty('java.class.path')
111
+ # rescue LoadError
112
+ # ENV['JRUBY_PARENT_CLASSPATH'] || ENV['JRUBY_HOME'] && FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
113
+ # end
114
+ # classpath ? "-cp #{classpath}" : ""
115
+ # end
116
+ #
117
+ # case RUBY_PLATFORM
118
+ # when /mswin/
119
+ # filename = "lib/http11.so"
120
+ # file filename do
121
+ # Dir.chdir("ext/http11") do
122
+ # ruby "extconf.rb"
123
+ # system(PLATFORM =~ /mswin/ ? 'nmake' : 'make')
124
+ # end
125
+ # move_extensions
126
+ # end
127
+ # task :compile => [filename]
128
+ #
129
+ # when /java/
130
+ #
131
+ # # Avoid JRuby in-process launching problem
132
+ # begin
133
+ # require 'jruby'
134
+ # JRuby.runtime.instance_config.run_ruby_in_process = false
135
+ # rescue LoadError
136
+ # end
137
+ #
138
+ # filename = "lib/http11.jar"
139
+ # file filename do
140
+ # build_dir = "ext/http11_java/classes"
141
+ # mkdir_p build_dir
142
+ # sources = FileList['ext/http11_java/**/*.java'].join(' ')
143
+ # sh "javac -target 1.4 -source 1.4 -d #{build_dir} #{java_classpath_arg} #{sources}"
144
+ # sh "jar cf lib/http11.jar -C #{build_dir} ."
145
+ # move_extensions
146
+ # end
147
+ # task :compile => [filename]
148
+ #
149
+ # end
150
+ #
151
+ # #### Project-wide install and uninstall tasks
152
+ #
153
+ # def sub_project(project, *targets)
154
+ # targets.each do |target|
155
+ # Dir.chdir "projects/#{project}" do
156
+ # unless RUBY_PLATFORM =~ /mswin/
157
+ # sh("rake #{target.to_s}") # --trace
158
+ # end
159
+ # end
160
+ # end
161
+ # end
162
+ #
163
+ # desc "Package Mongrel and all subprojects"
164
+ # task :package_all => [:package] do
165
+ # sub_project("gem_plugin", :package)
166
+ # sub_project("cgi_multipart_eof_fix", :package)
167
+ # sub_project("fastthread", :package)
168
+ # sub_project("mongrel_status", :package)
169
+ # sub_project("mongrel_upload_progress", :package)
170
+ # sub_project("mongrel_console", :package)
171
+ # sub_project("mongrel_cluster", :package)
172
+ # sub_project("mongrel_experimental", :package)
173
+ #
174
+ # sh("rake java package") unless RUBY_PLATFORM =~ /java/
175
+ #
176
+ # # XXX Broken by RubyGems 0.9.5
177
+ # # sub_project("mongrel_service", :package) if RUBY_PLATFORM =~ /mswin/
178
+ # # sh("rake mswin package") unless RUBY_PLATFORM =~ /mswin/
179
+ # end
180
+ #
181
+ # task :install_requirements do
182
+ # # These run before Mongrel is installed
183
+ # sub_project("gem_plugin", :install)
184
+ # sub_project("cgi_multipart_eof_fix", :install)
185
+ # sub_project("fastthread", :install)
186
+ # end
187
+ #
188
+ # desc "for Mongrel and all subprojects"
189
+ # task :install => [:install_requirements] do
190
+ # # These run after Mongrel is installed
191
+ # sub_project("mongrel_status", :install)
192
+ # sub_project("mongrel_upload_progress", :install)
193
+ # sub_project("mongrel_console", :install)
194
+ # sub_project("mongrel_cluster", :install)
195
+ # # sub_project("mongrel_experimental", :install)
196
+ # sub_project("mongrel_service", :install) if RUBY_PLATFORM =~ /mswin/
197
+ # end
198
+ #
199
+ # desc "for Mongrel and all its subprojects"
200
+ # task :uninstall => [:clean] do
201
+ # sub_project("mongrel_status", :uninstall)
202
+ # sub_project("cgi_multipart_eof_fix", :uninstall)
203
+ # sub_project("mongrel_upload_progress", :uninstall)
204
+ # sub_project("mongrel_console", :uninstall)
205
+ # sub_project("gem_plugin", :uninstall)
206
+ # sub_project("fastthread", :uninstall)
207
+ # # sub_project("mongrel_experimental", :uninstall)
208
+ # sub_project("mongrel_service", :uninstall) if RUBY_PLATFORM =~ /mswin/
209
+ # end
210
+ #
211
+ # desc "for Mongrel and all its subprojects"
212
+ # task :clean do
213
+ # sub_project("gem_plugin", :clean)
214
+ # sub_project("cgi_multipart_eof_fix", :clean)
215
+ # sub_project("fastthread", :clean)
216
+ # sub_project("mongrel_status", :clean)
217
+ # sub_project("mongrel_upload_progress", :clean)
218
+ # sub_project("mongrel_console", :clean)
219
+ # sub_project("mongrel_cluster", :clean)
220
+ # sub_project("mongrel_experimental", :clean)
221
+ # sub_project("mongrel_service", :clean) if RUBY_PLATFORM =~ /mswin/
222
+ # end
223
+ #
224
+ # #### Site upload tasks
225
+ #
226
+ # namespace :site do
227
+ # desc "Upload the coverage report"
228
+ # task :coverage => [:rcov] do
229
+ # sh "rsync -azv --no-perms --no-times test/coverage/* mongrel.cloudbur.st:/home/eweaver/www/mongrel/htdocs/web/coverage" rescue nil
230
+ # end
231
+ # end