timocratic-rack 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/COPYING +18 -0
  2. data/KNOWN-ISSUES +18 -0
  3. data/README +353 -0
  4. data/Rakefile +164 -0
  5. data/bin/rackup +176 -0
  6. data/contrib/rack_logo.svg +111 -0
  7. data/example/lobster.ru +4 -0
  8. data/example/protectedlobster.rb +14 -0
  9. data/example/protectedlobster.ru +8 -0
  10. data/lib/rack.rb +89 -0
  11. data/lib/rack/adapter/camping.rb +22 -0
  12. data/lib/rack/auth/abstract/handler.rb +37 -0
  13. data/lib/rack/auth/abstract/request.rb +37 -0
  14. data/lib/rack/auth/basic.rb +58 -0
  15. data/lib/rack/auth/digest/md5.rb +124 -0
  16. data/lib/rack/auth/digest/nonce.rb +51 -0
  17. data/lib/rack/auth/digest/params.rb +55 -0
  18. data/lib/rack/auth/digest/request.rb +40 -0
  19. data/lib/rack/auth/openid.rb +480 -0
  20. data/lib/rack/builder.rb +63 -0
  21. data/lib/rack/cascade.rb +36 -0
  22. data/lib/rack/chunked.rb +49 -0
  23. data/lib/rack/commonlogger.rb +61 -0
  24. data/lib/rack/conditionalget.rb +45 -0
  25. data/lib/rack/content_length.rb +29 -0
  26. data/lib/rack/content_type.rb +23 -0
  27. data/lib/rack/deflater.rb +85 -0
  28. data/lib/rack/directory.rb +153 -0
  29. data/lib/rack/file.rb +88 -0
  30. data/lib/rack/handler.rb +48 -0
  31. data/lib/rack/handler/cgi.rb +61 -0
  32. data/lib/rack/handler/evented_mongrel.rb +8 -0
  33. data/lib/rack/handler/fastcgi.rb +89 -0
  34. data/lib/rack/handler/lsws.rb +55 -0
  35. data/lib/rack/handler/mongrel.rb +84 -0
  36. data/lib/rack/handler/scgi.rb +59 -0
  37. data/lib/rack/handler/swiftiplied_mongrel.rb +8 -0
  38. data/lib/rack/handler/thin.rb +18 -0
  39. data/lib/rack/handler/webrick.rb +67 -0
  40. data/lib/rack/head.rb +19 -0
  41. data/lib/rack/lint.rb +462 -0
  42. data/lib/rack/lobster.rb +65 -0
  43. data/lib/rack/lock.rb +16 -0
  44. data/lib/rack/methodoverride.rb +27 -0
  45. data/lib/rack/mime.rb +204 -0
  46. data/lib/rack/mock.rb +160 -0
  47. data/lib/rack/recursive.rb +57 -0
  48. data/lib/rack/reloader.rb +64 -0
  49. data/lib/rack/request.rb +241 -0
  50. data/lib/rack/response.rb +179 -0
  51. data/lib/rack/session/abstract/id.rb +142 -0
  52. data/lib/rack/session/cookie.rb +91 -0
  53. data/lib/rack/session/memcache.rb +109 -0
  54. data/lib/rack/session/pool.rb +100 -0
  55. data/lib/rack/showexceptions.rb +349 -0
  56. data/lib/rack/showstatus.rb +106 -0
  57. data/lib/rack/static.rb +38 -0
  58. data/lib/rack/urlmap.rb +55 -0
  59. data/lib/rack/utils.rb +392 -0
  60. data/rack.gemspec +61 -0
  61. data/test/cgi/lighttpd.conf +20 -0
  62. data/test/cgi/test +9 -0
  63. data/test/cgi/test.fcgi +8 -0
  64. data/test/cgi/test.ru +7 -0
  65. data/test/multipart/binary +0 -0
  66. data/test/multipart/empty +10 -0
  67. data/test/multipart/ie +6 -0
  68. data/test/multipart/nested +10 -0
  69. data/test/multipart/none +9 -0
  70. data/test/multipart/text +10 -0
  71. data/test/spec_rack_auth_basic.rb +73 -0
  72. data/test/spec_rack_auth_digest.rb +226 -0
  73. data/test/spec_rack_auth_openid.rb +84 -0
  74. data/test/spec_rack_builder.rb +84 -0
  75. data/test/spec_rack_camping.rb +51 -0
  76. data/test/spec_rack_cascade.rb +50 -0
  77. data/test/spec_rack_cgi.rb +89 -0
  78. data/test/spec_rack_chunked.rb +62 -0
  79. data/test/spec_rack_commonlogger.rb +32 -0
  80. data/test/spec_rack_conditionalget.rb +41 -0
  81. data/test/spec_rack_content_length.rb +43 -0
  82. data/test/spec_rack_content_type.rb +30 -0
  83. data/test/spec_rack_deflater.rb +127 -0
  84. data/test/spec_rack_directory.rb +61 -0
  85. data/test/spec_rack_fastcgi.rb +89 -0
  86. data/test/spec_rack_file.rb +75 -0
  87. data/test/spec_rack_handler.rb +43 -0
  88. data/test/spec_rack_head.rb +30 -0
  89. data/test/spec_rack_lint.rb +499 -0
  90. data/test/spec_rack_lobster.rb +45 -0
  91. data/test/spec_rack_lock.rb +38 -0
  92. data/test/spec_rack_methodoverride.rb +60 -0
  93. data/test/spec_rack_mock.rb +157 -0
  94. data/test/spec_rack_mongrel.rb +189 -0
  95. data/test/spec_rack_recursive.rb +77 -0
  96. data/test/spec_rack_request.rb +515 -0
  97. data/test/spec_rack_response.rb +218 -0
  98. data/test/spec_rack_rewindable_input.rb +118 -0
  99. data/test/spec_rack_session_cookie.rb +82 -0
  100. data/test/spec_rack_session_memcache.rb +240 -0
  101. data/test/spec_rack_session_pool.rb +172 -0
  102. data/test/spec_rack_showexceptions.rb +21 -0
  103. data/test/spec_rack_showstatus.rb +72 -0
  104. data/test/spec_rack_static.rb +37 -0
  105. data/test/spec_rack_thin.rb +91 -0
  106. data/test/spec_rack_urlmap.rb +185 -0
  107. data/test/spec_rack_utils.rb +341 -0
  108. data/test/spec_rack_webrick.rb +130 -0
  109. data/test/testrequest.rb +57 -0
  110. data/test/unregistered_handler/rack/handler/unregistered.rb +7 -0
  111. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +7 -0
  112. metadata +270 -0
data/COPYING ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2007, 2008, 2009 Christian Neukirchen <purl.org/net/chneukirchen>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ = Known issues with Rack and Web servers
2
+
3
+ * Lighttpd sets wrong SCRIPT_NAME and PATH_INFO if you mount your
4
+ FastCGI app at "/". This can be fixed by using this middleware:
5
+
6
+ class LighttpdScriptNameFix
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ env["PATH_INFO"] = env["SCRIPT_NAME"].to_s + env["PATH_INFO"].to_s
13
+ env["SCRIPT_NAME"] = ""
14
+ @app.call(env)
15
+ end
16
+ end
17
+
18
+ Of course, use this only when your app runs at "/".
data/README ADDED
@@ -0,0 +1,353 @@
1
+ = Rack, a modular Ruby webserver interface
2
+
3
+ Rack provides a minimal, modular and adaptable interface for developing
4
+ web applications in Ruby. By wrapping HTTP requests and responses in
5
+ the simplest way possible, it unifies and distills the API for web
6
+ servers, web frameworks, and software in between (the so-called
7
+ middleware) into a single method call.
8
+
9
+ The exact details of this are described in the Rack specification,
10
+ which all Rack applications should conform to.
11
+
12
+ == Specification changes in this release
13
+
14
+ With Rack 1.0, the Rack specification (found in SPEC) changed in the
15
+ following backward-incompatible ways. This was done to properly
16
+ support Ruby 1.9 and to deprecate some problematic techniques:
17
+
18
+ * Rack::VERSION has been pushed to [1,0].
19
+ * Header values must be Strings now, split on "\n".
20
+ * rack.input must be rewindable and support reading into a buffer,
21
+ wrap with Rack::RewindableInput if it isn't.
22
+ * Content-Length can be missing, in this case chunked transfer
23
+ encoding is used.
24
+ * Bodies can now additionally respond to #to_path with a filename to
25
+ be served.
26
+ * String bodies are deprecated and will not work with Ruby 1.9, use an
27
+ Array with a single String instead.
28
+ * rack.session is now specified.
29
+
30
+ == Supported web servers
31
+
32
+ The included *handlers* connect all kinds of web servers to Rack:
33
+ * Mongrel
34
+ * EventedMongrel
35
+ * SwiftipliedMongrel
36
+ * WEBrick
37
+ * FCGI
38
+ * CGI
39
+ * SCGI
40
+ * LiteSpeed
41
+ * Thin
42
+
43
+ These web servers include Rack handlers in their distributions:
44
+ * Ebb
45
+ * Fuzed
46
+ * Phusion Passenger (which is mod_rack for Apache and for nginx)
47
+ * Unicorn
48
+
49
+ Any valid Rack app will run the same on all these handlers, without
50
+ changing anything.
51
+
52
+ == Supported web frameworks
53
+
54
+ The included *adapters* connect Rack with existing Ruby web frameworks:
55
+ * Camping
56
+
57
+ These frameworks include Rack adapters in their distributions:
58
+ * Camping
59
+ * Coset
60
+ * Halcyon
61
+ * Mack
62
+ * Maveric
63
+ * Merb
64
+ * Racktools::SimpleApplication
65
+ * Ramaze
66
+ * Ruby on Rails
67
+ * Rum
68
+ * Sinatra
69
+ * Sin
70
+ * Vintage
71
+ * Waves
72
+ * Wee
73
+
74
+ Current links to these projects can be found at
75
+ http://wiki.ramaze.net/Home#other-frameworks
76
+
77
+ == Available middleware
78
+
79
+ Between the server and the framework, Rack can be customized to your
80
+ applications needs using middleware, for example:
81
+ * Rack::URLMap, to route to multiple applications inside the same process.
82
+ * Rack::CommonLogger, for creating Apache-style logfiles.
83
+ * Rack::ShowException, for catching unhandled exceptions and
84
+ presenting them in a nice and helpful way with clickable backtrace.
85
+ * Rack::File, for serving static files.
86
+ * ...many others!
87
+
88
+ All these components use the same interface, which is described in
89
+ detail in the Rack specification. These optional components can be
90
+ used in any way you wish.
91
+
92
+ == Convenience
93
+
94
+ If you want to develop outside of existing frameworks, implement your
95
+ own ones, or develop middleware, Rack provides many helpers to create
96
+ Rack applications quickly and without doing the same web stuff all
97
+ over:
98
+ * Rack::Request, which also provides query string parsing and
99
+ multipart handling.
100
+ * Rack::Response, for convenient generation of HTTP replies and
101
+ cookie handling.
102
+ * Rack::MockRequest and Rack::MockResponse for efficient and quick
103
+ testing of Rack application without real HTTP round-trips.
104
+
105
+ == rack-contrib
106
+
107
+ The plethora of useful middleware created the need for a project that
108
+ collects fresh Rack middleware. rack-contrib includes a variety of
109
+ add-on components for Rack and it is easy to contribute new modules.
110
+
111
+ * http://github.com/rack/rack-contrib
112
+
113
+ == rackup
114
+
115
+ rackup is a useful tool for running Rack applications, which uses the
116
+ Rack::Builder DSL to configure middleware and build up applications
117
+ easily.
118
+
119
+ rackup automatically figures out the environment it is run in, and
120
+ runs your application as FastCGI, CGI, or standalone with Mongrel or
121
+ WEBrick---all from the same configuration.
122
+
123
+ == Quick start
124
+
125
+ Try the lobster!
126
+
127
+ Either with the embedded WEBrick starter:
128
+
129
+ ruby -Ilib lib/rack/lobster.rb
130
+
131
+ Or with rackup:
132
+
133
+ bin/rackup -Ilib example/lobster.ru
134
+
135
+ By default, the lobster is found at http://localhost:9292.
136
+
137
+ == Installing with RubyGems
138
+
139
+ A Gem of Rack is available. You can install it with:
140
+
141
+ gem install rack
142
+
143
+ I also provide a local mirror of the gems (and development snapshots)
144
+ at my site:
145
+
146
+ gem install rack --source http://chneukirchen.org/releases/gems/
147
+
148
+ == Running the tests
149
+
150
+ Testing Rack requires the test/spec testing framework:
151
+
152
+ gem install test-spec
153
+
154
+ There are two rake-based test tasks:
155
+
156
+ rake test tests all the fast tests (no Handlers or Adapters)
157
+ rake fulltest runs all the tests
158
+
159
+ The fast testsuite has no dependencies outside of the core Ruby
160
+ installation and test-spec.
161
+
162
+ To run the test suite completely, you need:
163
+
164
+ * camping
165
+ * fcgi
166
+ * memcache-client
167
+ * mongrel
168
+ * ruby-openid
169
+ * thin
170
+
171
+ The full set of tests test FCGI access with lighttpd (on port
172
+ 9203) so you will need lighttpd installed as well as the FCGI
173
+ libraries and the fcgi gem:
174
+
175
+ Download and install lighttpd:
176
+
177
+ http://www.lighttpd.net/download
178
+
179
+ Installing the FCGI libraries:
180
+
181
+ curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
182
+ tar xzvf fcgi-2.4.0.tar.gz
183
+ cd fcgi-2.4.0
184
+ ./configure --prefix=/usr/local
185
+ make
186
+ sudo make install
187
+ cd ..
188
+
189
+ Installing the Ruby fcgi gem:
190
+
191
+ gem install fcgi
192
+
193
+ Furthermore, to test Memcache sessions, you need memcached (will be
194
+ run on port 11211) and memcache-client installed.
195
+
196
+ == History
197
+
198
+ * March 3rd, 2007: First public release 0.1.
199
+
200
+ * May 16th, 2007: Second public release 0.2.
201
+ * HTTP Basic authentication.
202
+ * Cookie Sessions.
203
+ * Static file handler.
204
+ * Improved Rack::Request.
205
+ * Improved Rack::Response.
206
+ * Added Rack::ShowStatus, for better default error messages.
207
+ * Bug fixes in the Camping adapter.
208
+ * Removed Rails adapter, was too alpha.
209
+
210
+ * February 26th, 2008: Third public release 0.3.
211
+ * LiteSpeed handler, by Adrian Madrid.
212
+ * SCGI handler, by Jeremy Evans.
213
+ * Pool sessions, by blink.
214
+ * OpenID authentication, by blink.
215
+ * :Port and :File options for opening FastCGI sockets, by blink.
216
+ * Last-Modified HTTP header for Rack::File, by blink.
217
+ * Rack::Builder#use now accepts blocks, by Corey Jewett.
218
+ (See example/protectedlobster.ru)
219
+ * HTTP status 201 can contain a Content-Type and a body now.
220
+ * Many bugfixes, especially related to Cookie handling.
221
+
222
+ * August 21st, 2008: Fourth public release 0.4.
223
+ * New middleware, Rack::Deflater, by Christoffer Sawicki.
224
+ * OpenID authentication now needs ruby-openid 2.
225
+ * New Memcache sessions, by blink.
226
+ * Explicit EventedMongrel handler, by Joshua Peek <josh@joshpeek.com>
227
+ * Rack::Reloader is not loaded in rackup development mode.
228
+ * rackup can daemonize with -D.
229
+ * Many bugfixes, especially for pool sessions, URLMap, thread safety
230
+ and tempfile handling.
231
+ * Improved tests.
232
+ * Rack moved to Git.
233
+
234
+ * January 6th, 2009: Fifth public release 0.9.
235
+ * Rack is now managed by the Rack Core Team.
236
+ * Rack::Lint is stricter and follows the HTTP RFCs more closely.
237
+ * Added ConditionalGet middleware.
238
+ * Added ContentLength middleware.
239
+ * Added Deflater middleware.
240
+ * Added Head middleware.
241
+ * Added MethodOverride middleware.
242
+ * Rack::Mime now provides popular MIME-types and their extension.
243
+ * Mongrel Header now streams.
244
+ * Added Thin handler.
245
+ * Official support for swiftiplied Mongrel.
246
+ * Secure cookies.
247
+ * Made HeaderHash case-preserving.
248
+ * Many bugfixes and small improvements.
249
+
250
+ * January 9th, 2009: Sixth public release 0.9.1.
251
+ * Fix directory traversal exploits in Rack::File and Rack::Directory.
252
+
253
+ * April 25th, 2009: Seventh public release 1.0.0.
254
+ * SPEC change: Rack::VERSION has been pushed to [1,0].
255
+ * SPEC change: header values must be Strings now, split on "\n".
256
+ * SPEC change: Content-Length can be missing, in this case chunked transfer
257
+ encoding is used.
258
+ * SPEC change: rack.input must be rewindable and support reading into
259
+ a buffer, wrap with Rack::RewindableInput if it isn't.
260
+ * SPEC change: rack.session is now specified.
261
+ * SPEC change: Bodies can now additionally respond to #to_path with
262
+ a filename to be served.
263
+ * NOTE: String bodies break in 1.9, use an Array consisting of a
264
+ single String instead.
265
+ * New middleware Rack::Lock.
266
+ * New middleware Rack::ContentType.
267
+ * Rack::Reloader has been rewritten.
268
+ * Major update to Rack::Auth::OpenID.
269
+ * Support for nested parameter parsing in Rack::Response.
270
+ * Support for redirects in Rack::Response.
271
+ * HttpOnly cookie support in Rack::Response.
272
+ * The Rakefile has been rewritten.
273
+ * Many bugfixes and small improvements.
274
+
275
+ == Contact
276
+
277
+ Please mail bugs, suggestions and patches to
278
+ <mailto:rack-devel@googlegroups.com>.
279
+
280
+ Mailing list archives are available at
281
+ <http://groups.google.com/group/rack-devel>.
282
+
283
+ There is a bug tracker at <http://rack.lighthouseapp.com/>.
284
+
285
+ Git repository (send Git patches to the mailing list):
286
+ * http://github.com/rack/rack
287
+ * http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack.git
288
+
289
+ You are also welcome to join the #rack channel on irc.freenode.net.
290
+
291
+ == Thanks
292
+
293
+ The Rack Core Team, consisting of
294
+
295
+ * Christian Neukirchen (chneukirchen)
296
+ * James Tucker (raggi)
297
+ * Josh Peek (josh)
298
+ * Michael Fellinger (manveru)
299
+ * Ryan Tomayko (rtomayko)
300
+ * Scytrin dai Kinthra (scytrin)
301
+
302
+ would like to thank:
303
+
304
+ * Adrian Madrid, for the LiteSpeed handler.
305
+ * Christoffer Sawicki, for the first Rails adapter and Rack::Deflater.
306
+ * Tim Fletcher, for the HTTP authentication code.
307
+ * Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
308
+ * Armin Ronacher, for the logo and racktools.
309
+ * Aredridel, Ben Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd,
310
+ Tom Robinson, Phil Hagelberg, and S. Brent Faulkner for bug fixing
311
+ and other improvements.
312
+ * Brian Candler, for Rack::ContentType.
313
+ * Graham Batty, for improved handler loading.
314
+ * Stephen Bannasch, for bug reports and documentation.
315
+ * Gary Wright, for proposing a better Rack::Response interface.
316
+ * Jonathan Buch, for improvements regarding Rack::Response.
317
+ * Armin Röhrl, for tracking down bugs in the Cookie generator.
318
+ * Alexander Kellett for testing the Gem and reviewing the announcement.
319
+ * Marcus Rückert, for help with configuring and debugging lighttpd.
320
+ * The WSGI team for the well-done and documented work they've done and
321
+ Rack builds up on.
322
+ * All bug reporters and patch contributers not mentioned above.
323
+
324
+ == Copyright
325
+
326
+ Copyright (C) 2007, 2008, 2009 Christian Neukirchen <http://purl.org/net/chneukirchen>
327
+
328
+ Permission is hereby granted, free of charge, to any person obtaining a copy
329
+ of this software and associated documentation files (the "Software"), to
330
+ deal in the Software without restriction, including without limitation the
331
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
332
+ sell copies of the Software, and to permit persons to whom the Software is
333
+ furnished to do so, subject to the following conditions:
334
+
335
+ The above copyright notice and this permission notice shall be included in
336
+ all copies or substantial portions of the Software.
337
+
338
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
339
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
340
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
341
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
342
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
343
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
344
+
345
+ == Links
346
+
347
+ Rack:: <http://rack.rubyforge.org/>
348
+ Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
349
+ Official Rack repositories:: <http://github.com/rack>
350
+ rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
351
+
352
+ Christian Neukirchen:: <http://chneukirchen.org/>
353
+
@@ -0,0 +1,164 @@
1
+ # Rakefile for Rack. -*-ruby-*-
2
+ require 'rake/rdoctask'
3
+ require 'rake/testtask'
4
+
5
+
6
+ desc "Run all the tests"
7
+ task :default => [:test]
8
+
9
+
10
+ desc "Make an archive as .tar.gz"
11
+ task :dist => [:chmod, :changelog, :rdoc, "SPEC", "rack.gemspec"] do
12
+ FileUtils.touch("RDOX")
13
+ sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
14
+ sh "pax -waf #{release}.tar -s ':^:#{release}/:' RDOX SPEC ChangeLog doc rack.gemspec"
15
+ sh "gzip -f -9 #{release}.tar"
16
+ end
17
+
18
+ desc "Make an official release"
19
+ task :officialrelease do
20
+ puts "Official build for #{release}..."
21
+ sh "rm -rf stage"
22
+ sh "git clone --shared . stage"
23
+ sh "cd stage && rake officialrelease_really"
24
+ sh "mv stage/#{release}.tar.gz stage/#{release}.gem ."
25
+ end
26
+
27
+ task :officialrelease_really => [:fulltest, "RDOX", "SPEC", :dist, :gem] do
28
+ sh "sha1sum #{release}.tar.gz #{release}.gem"
29
+ end
30
+
31
+
32
+ def version
33
+ abort "You need to pass VERSION=... to build packages." unless ENV["VERSION"]
34
+ ENV["VERSION"]
35
+ end
36
+
37
+ def release
38
+ "rack-#{version}"
39
+ end
40
+
41
+ def manifest
42
+ `git ls-files`.split("\n")
43
+ end
44
+
45
+
46
+ desc "Make binaries executable"
47
+ task :chmod do
48
+ Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
49
+ Dir["test/cgi/test*"].each { |binary| File.chmod(0775, binary) }
50
+ end
51
+
52
+ desc "Generate a ChangeLog"
53
+ task :changelog do
54
+ File.open("ChangeLog", "w") { |out|
55
+ `git log -z`.split("\0").map { |chunk|
56
+ author = chunk[/Author: (.*)/, 1].strip
57
+ date = chunk[/Date: (.*)/, 1].strip
58
+ desc, detail = $'.strip.split("\n", 2)
59
+ detail ||= ""
60
+ detail = detail.gsub(/.*darcs-hash:.*/, '')
61
+ detail.rstrip!
62
+ out.puts "#{date} #{author}"
63
+ out.puts " * #{desc.strip}"
64
+ out.puts detail unless detail.empty?
65
+ out.puts
66
+ }
67
+ }
68
+ end
69
+
70
+
71
+ desc "Generate RDox"
72
+ task "RDOX" do
73
+ sh "specrb -Ilib:test -a --rdox >RDOX"
74
+ end
75
+
76
+ desc "Generate Rack Specification"
77
+ task "SPEC" do
78
+ File.open("SPEC", "wb") { |file|
79
+ IO.foreach("lib/rack/lint.rb") { |line|
80
+ if line =~ /## (.*)/
81
+ file.puts $1
82
+ end
83
+ }
84
+ }
85
+ end
86
+
87
+ desc "Run all the fast tests"
88
+ task :test do
89
+ sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS'] || '-t "^(?!Rack::Handler|Rack::Adapter|Rack::Session::Memcache|Rack::Auth::OpenID)"'}"
90
+ end
91
+
92
+ desc "Run all the tests"
93
+ task :fulltest => [:chmod] do
94
+ sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
95
+ end
96
+
97
+ begin
98
+ require 'rubygems'
99
+ rescue LoadError
100
+ # Too bad.
101
+ else
102
+ task "rack.gemspec" do
103
+ spec = Gem::Specification.new do |s|
104
+ s.name = "rack"
105
+ s.version = version
106
+ s.platform = Gem::Platform::RUBY
107
+ s.summary = "a modular Ruby webserver interface"
108
+
109
+ s.description = <<-EOF
110
+ Rack provides minimal, modular and adaptable interface for developing
111
+ web applications in Ruby. By wrapping HTTP requests and responses in
112
+ the simplest way possible, it unifies and distills the API for web
113
+ servers, web frameworks, and software in between (the so-called
114
+ middleware) into a single method call.
115
+
116
+ Also see http://rack.rubyforge.org.
117
+ EOF
118
+
119
+ s.files = manifest + %w(rack.gemspec)
120
+ s.bindir = 'bin'
121
+ s.executables << 'rackup'
122
+ s.require_path = 'lib'
123
+ s.has_rdoc = true
124
+ s.extra_rdoc_files = ['README', 'KNOWN-ISSUES']
125
+ s.test_files = Dir['test/{test,spec}_*.rb']
126
+
127
+ s.author = 'Christian Neukirchen'
128
+ s.email = 'chneukirchen@gmail.com'
129
+ s.homepage = 'http://rack.rubyforge.org'
130
+ s.rubyforge_project = 'rack'
131
+
132
+ s.add_development_dependency 'test-spec'
133
+
134
+ s.add_development_dependency 'camping'
135
+ s.add_development_dependency 'fcgi'
136
+ s.add_development_dependency 'memcache-client'
137
+ s.add_development_dependency 'mongrel'
138
+ s.add_development_dependency 'ruby-openid', '~> 2.0.0'
139
+ s.add_development_dependency 'thin'
140
+ end
141
+
142
+ File.open("rack.gemspec", "w") { |f| f << spec.to_ruby }
143
+ end
144
+
145
+ task :gem => ["rack.gemspec", "SPEC"] do
146
+ FileUtils.touch("RDOX")
147
+ sh "gem build rack.gemspec"
148
+ end
149
+ end
150
+
151
+ desc "Generate RDoc documentation"
152
+ task :rdoc do
153
+ sh(*%w{rdoc --line-numbers --main README
154
+ --title 'Rack\ Documentation' --charset utf-8 -U -o doc} +
155
+ %w{README KNOWN-ISSUES SPEC RDOX} +
156
+ Dir["lib/**/*.rb"])
157
+ end
158
+
159
+ task :pushsite => [:rdoc] do
160
+ sh "cd site && git gc"
161
+ sh "rsync -avz doc/ chneukirchen@rack.rubyforge.org:/var/www/gforge-projects/rack/doc/"
162
+ sh "rsync -avz site/ chneukirchen@rack.rubyforge.org:/var/www/gforge-projects/rack/"
163
+ sh "cd site && git push"
164
+ end