diff --git a/config/environment.rb b/config/environment.rb index bdd2af73..78c9c636 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -26,6 +26,8 @@ Rails::Initializer.run do |config| config.gem "soap4r", :lib => false config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice' config.gem 'sanitize' + config.gem 'rack', :version => '1.1.0' + config.gem 'will_paginate', :version => '~> 2.3.15' config.action_controller.use_accept_header = true diff --git a/vendor/gems/rack-1.0.1/.specification b/vendor/gems/rack-1.0.1/.specification deleted file mode 100644 index bd748ee1..00000000 --- a/vendor/gems/rack-1.0.1/.specification +++ /dev/null @@ -1,278 +0,0 @@ ---- !ruby/object:Gem::Specification -name: rack -version: !ruby/object:Gem::Version - version: 1.0.1 -platform: ruby -authors: -- Christian Neukirchen -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-10-17 00:00:00 -04:00 -default_executable: rackup -dependencies: -- !ruby/object:Gem::Dependency - name: test-spec - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: camping - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: fcgi - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: memcache-client - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: mongrel - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: ruby-openid - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ~> - - !ruby/object:Gem::Version - version: 2.0.0 - version: -- !ruby/object:Gem::Dependency - name: thin - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -description: Rack provides minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call. Also see http://rack.rubyforge.org. -email: chneukirchen@gmail.com -executables: -- rackup -extensions: [] - -extra_rdoc_files: -- README -- SPEC -- RDOX -- KNOWN-ISSUES -files: -- COPYING -- KNOWN-ISSUES -- README -- Rakefile -- bin/rackup -- contrib/rack_logo.svg -- example/lobster.ru -- example/protectedlobster.rb -- example/protectedlobster.ru -- lib/rack.rb -- lib/rack/adapter/camping.rb -- lib/rack/auth/abstract/handler.rb -- lib/rack/auth/abstract/request.rb -- lib/rack/auth/basic.rb -- lib/rack/auth/digest/md5.rb -- lib/rack/auth/digest/nonce.rb -- lib/rack/auth/digest/params.rb -- lib/rack/auth/digest/request.rb -- lib/rack/auth/openid.rb -- lib/rack/builder.rb -- lib/rack/cascade.rb -- lib/rack/chunked.rb -- lib/rack/commonlogger.rb -- lib/rack/conditionalget.rb -- lib/rack/content_length.rb -- lib/rack/content_type.rb -- lib/rack/deflater.rb -- lib/rack/directory.rb -- lib/rack/file.rb -- lib/rack/handler.rb -- lib/rack/handler/cgi.rb -- lib/rack/handler/evented_mongrel.rb -- lib/rack/handler/fastcgi.rb -- lib/rack/handler/lsws.rb -- lib/rack/handler/mongrel.rb -- lib/rack/handler/scgi.rb -- lib/rack/handler/swiftiplied_mongrel.rb -- lib/rack/handler/thin.rb -- lib/rack/handler/webrick.rb -- lib/rack/head.rb -- lib/rack/lint.rb -- lib/rack/lobster.rb -- lib/rack/lock.rb -- lib/rack/methodoverride.rb -- lib/rack/mime.rb -- lib/rack/mock.rb -- lib/rack/recursive.rb -- lib/rack/reloader.rb -- lib/rack/request.rb -- lib/rack/response.rb -- lib/rack/rewindable_input.rb -- lib/rack/session/abstract/id.rb -- lib/rack/session/cookie.rb -- lib/rack/session/memcache.rb -- lib/rack/session/pool.rb -- lib/rack/showexceptions.rb -- lib/rack/showstatus.rb -- lib/rack/static.rb -- lib/rack/urlmap.rb -- lib/rack/utils.rb -- test/cgi/lighttpd.conf -- test/cgi/test -- test/cgi/test.fcgi -- test/cgi/test.ru -- test/multipart/binary -- test/multipart/empty -- test/multipart/ie -- test/multipart/nested -- test/multipart/none -- test/multipart/semicolon -- test/multipart/text -- test/spec_rack_auth_basic.rb -- test/spec_rack_auth_digest.rb -- test/spec_rack_auth_openid.rb -- test/spec_rack_builder.rb -- test/spec_rack_camping.rb -- test/spec_rack_cascade.rb -- test/spec_rack_cgi.rb -- test/spec_rack_chunked.rb -- test/spec_rack_commonlogger.rb -- test/spec_rack_conditionalget.rb -- test/spec_rack_content_length.rb -- test/spec_rack_content_type.rb -- test/spec_rack_deflater.rb -- test/spec_rack_directory.rb -- test/spec_rack_fastcgi.rb -- test/spec_rack_file.rb -- test/spec_rack_handler.rb -- test/spec_rack_head.rb -- test/spec_rack_lint.rb -- test/spec_rack_lobster.rb -- test/spec_rack_lock.rb -- test/spec_rack_methodoverride.rb -- test/spec_rack_mock.rb -- test/spec_rack_mongrel.rb -- test/spec_rack_recursive.rb -- test/spec_rack_request.rb -- test/spec_rack_response.rb -- test/spec_rack_rewindable_input.rb -- test/spec_rack_session_cookie.rb -- test/spec_rack_session_memcache.rb -- test/spec_rack_session_pool.rb -- test/spec_rack_showexceptions.rb -- test/spec_rack_showstatus.rb -- test/spec_rack_static.rb -- test/spec_rack_thin.rb -- test/spec_rack_urlmap.rb -- test/spec_rack_utils.rb -- test/spec_rack_webrick.rb -- test/testrequest.rb -- test/unregistered_handler/rack/handler/unregistered.rb -- test/unregistered_handler/rack/handler/unregistered_long_one.rb -- SPEC -- RDOX -- rack.gemspec -has_rdoc: true -homepage: http://rack.rubyforge.org -licenses: [] - -post_install_message: -rdoc_options: [] - -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: rack -rubygems_version: 1.3.5 -signing_key: -specification_version: 2 -summary: a modular Ruby webserver interface -test_files: -- test/spec_rack_auth_basic.rb -- test/spec_rack_auth_digest.rb -- test/spec_rack_auth_openid.rb -- test/spec_rack_builder.rb -- test/spec_rack_camping.rb -- test/spec_rack_cascade.rb -- test/spec_rack_cgi.rb -- test/spec_rack_chunked.rb -- test/spec_rack_commonlogger.rb -- test/spec_rack_conditionalget.rb -- test/spec_rack_content_length.rb -- test/spec_rack_content_type.rb -- test/spec_rack_deflater.rb -- test/spec_rack_directory.rb -- test/spec_rack_fastcgi.rb -- test/spec_rack_file.rb -- test/spec_rack_handler.rb -- test/spec_rack_head.rb -- test/spec_rack_lint.rb -- test/spec_rack_lobster.rb -- test/spec_rack_lock.rb -- test/spec_rack_methodoverride.rb -- test/spec_rack_mock.rb -- test/spec_rack_mongrel.rb -- test/spec_rack_recursive.rb -- test/spec_rack_request.rb -- test/spec_rack_response.rb -- test/spec_rack_rewindable_input.rb -- test/spec_rack_session_cookie.rb -- test/spec_rack_session_memcache.rb -- test/spec_rack_session_pool.rb -- test/spec_rack_showexceptions.rb -- test/spec_rack_showstatus.rb -- test/spec_rack_static.rb -- test/spec_rack_thin.rb -- test/spec_rack_urlmap.rb -- test/spec_rack_utils.rb -- test/spec_rack_webrick.rb diff --git a/vendor/gems/rack-1.0.1/COPYING b/vendor/gems/rack-1.0.1/COPYING deleted file mode 100644 index 11b4c6e0..00000000 --- a/vendor/gems/rack-1.0.1/COPYING +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2007, 2008, 2009 Christian Neukirchen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/gems/rack-1.0.1/KNOWN-ISSUES b/vendor/gems/rack-1.0.1/KNOWN-ISSUES deleted file mode 100644 index 790199bd..00000000 --- a/vendor/gems/rack-1.0.1/KNOWN-ISSUES +++ /dev/null @@ -1,18 +0,0 @@ -= Known issues with Rack and Web servers - -* Lighttpd sets wrong SCRIPT_NAME and PATH_INFO if you mount your - FastCGI app at "/". This can be fixed by using this middleware: - - class LighttpdScriptNameFix - def initialize(app) - @app = app - end - - def call(env) - env["PATH_INFO"] = env["SCRIPT_NAME"].to_s + env["PATH_INFO"].to_s - env["SCRIPT_NAME"] = "" - @app.call(env) - end - end - - Of course, use this only when your app runs at "/". diff --git a/vendor/gems/rack-1.0.1/RDOX b/vendor/gems/rack-1.0.1/RDOX deleted file mode 100644 index 8b95b0cb..00000000 --- a/vendor/gems/rack-1.0.1/RDOX +++ /dev/null @@ -1,428 +0,0 @@ - -== Rack::Auth::Basic -* should challenge correctly when no credentials are specified -* should rechallenge if incorrect credentials are specified -* should return application output if correct credentials are specified -* should return 400 Bad Request if different auth scheme used -* realm as optional constructor arg - -== Rack::Auth::Digest::MD5 -* should challenge when no credentials are specified -* should return application output if correct credentials given -* should return application output if correct credentials given (hashed passwords) -* should rechallenge if incorrect username given -* should rechallenge if incorrect password given -* should rechallenge with stale parameter if nonce is stale -* should return 400 Bad Request if incorrect qop given -* should return 400 Bad Request if incorrect uri given -* should return 400 Bad Request if different auth scheme used -* should not require credentials for unprotected path -* should challenge when no credentials are specified for protected path -* should return application output if correct credentials given for protected path -* should return application output if correct credentials given for POST -* should return application output if correct credentials given for PUT (using method override of POST) -* realm as optional constructor arg - -== Rack::Auth::OpenID -* realm uri should be valid -* should be able to check if a uri is within the realm (empty) -* return_to should be valid -* extensions should have required constants defined -* extensions should have Request and Response defined and inherit from OpenID::Extension - -== Rack::Builder -* chains apps by default -* has implicit #to_app -* supports blocks on use -* has explicit #to_app -* apps are initialized once - -== Rack::Adapter::Camping -* works with GET -* works with POST - -== Rack::Cascade -* should dispatch onward on 404 by default -* should dispatch onward on whatever is passed -* should fail if empty -* should append new app - -== Rack::Handler::CGI -* startup (empty) -* should respond -* should be a lighttpd -* should have rack headers -* should have CGI headers on GET -* should have CGI headers on POST -* should support HTTP auth -* should set status -* shutdown - -== Rack::Chunked -* chunks responses with no Content-Length -* chunks empty bodies properly -* does not modify response when Content-Length header present -* does not modify response when client is HTTP/1.0 -* does not modify response when Transfer-Encoding header already present -* does not modify response when status code is 100 -* does not modify response when status code is 204 -* does not modify response when status code is 304 - -== Rack::CommonLogger -* should log to rack.errors by default -* should log to anything with << - -== Rack::ConditionalGet -* should set a 304 status and truncate body when If-Modified-Since hits -* should set a 304 status and truncate body when If-None-Match hits -* should not affect non-GET/HEAD requests - -== Rack::ContentLength -* sets Content-Length on String bodies if none is set -* sets Content-Length on Array bodies if none is set -* does not set Content-Length on variable length bodies -* does not change Content-Length if it is already set -* does not set Content-Length on 304 responses -* does not set Content-Length when Transfer-Encoding is chunked - -== Rack::ContentType -* sets Content-Type to default text/html if none is set -* sets Content-Type to chosen default if none is set -* does not change Content-Type if it is already set -* case insensitive detection of Content-Type - -== Rack::Deflater -* should be able to deflate bodies that respond to each -* should be able to deflate String bodies -* should be able to gzip bodies that respond to each -* should be able to fallback to no deflation -* should be able to skip when there is no response entity body -* should handle the lack of an acceptable encoding -* should handle gzip response with Last-Modified header -* should do nothing when no-transform Cache-Control directive present - -== Rack::Directory -* serves directory indices -* passes to app if file found -* serves uri with URL encoded filenames -* does not allow directory traversal -* 404s if it can't find the file - -== Rack::Handler::FastCGI -* startup (empty) -* should respond -* should be a lighttpd -* should have rack headers -* should have CGI headers on GET -* should have CGI headers on POST -* should support HTTP auth -* should set status -* shutdown - -== Rack::File -* serves files -* sets Last-Modified header -* serves files with URL encoded filenames -* does not allow directory traversal -* does not allow directory traversal with encoded periods -* 404s if it can't find the file -* detects SystemCallErrors -* returns bodies that respond to #to_path - -== Rack::Handler -* has registered default handlers -* handler that doesn't exist should raise a NameError -* should get unregistered, but already required, handler by name -* should register custom handler -* should not need registration for properly coded handlers even if not already required - -== Rack::Head -* response (empty) -* passes GET, POST, PUT, DELETE, OPTIONS, TRACE requests -* removes body from HEAD requests - -== Rack::Lint -* passes valid request -* notices fatal errors -* notices environment errors -* notices input errors -* notices error errors -* notices status errors -* notices header errors -* notices content-type errors -* notices content-length errors -* notices body errors -* notices input handling errors -* notices error handling errors -* notices HEAD errors -* passes valid read calls - -== Rack::Lint::InputWrapper -* delegates :size to underlying IO object -* delegates :rewind to underlying IO object - -== Rack::Lobster::LambdaLobster -* should be a single lambda -* should look like a lobster -* should be flippable - -== Rack::Lobster -* should look like a lobster -* should be flippable -* should provide crashing for testing purposes - -== Rack::Lock -* should call synchronize on lock -* should set multithread flag to false -* should reset original multithread flag when exiting lock - -== Rack::MethodOverride -* should not affect GET requests -* _method parameter should modify REQUEST_METHOD for POST requests -* X-HTTP-Method-Override header should modify REQUEST_METHOD for POST requests -* should not modify REQUEST_METHOD if the method is unknown -* should not modify REQUEST_METHOD when _method is nil -* should store the original REQUEST_METHOD prior to overriding - -== Rack::MockRequest -* should return a MockResponse -* should be able to only return the environment -* should provide sensible defaults -* should allow GET/POST/PUT/DELETE -* should set content length -* should allow posting -* should use all parts of an URL -* should behave valid according to the Rack spec - -== Rack::MockResponse -* should provide access to the HTTP status -* should provide access to the HTTP headers -* should provide access to the HTTP body -* should provide access to the Rack errors -* should optionally make Rack errors fatal - -== Rack::Handler::Mongrel -* should respond -* should be a Mongrel -* should have rack headers -* should have CGI headers on GET -* should have CGI headers on POST -* should support HTTP auth -* should set status -* should provide a .run -* should provide a .run that maps a hash -* should provide a .run that maps a urlmap -* should provide a .run that maps a urlmap restricting by host -* should stream #each part of the response - -== Rack::Recursive -* should allow for subrequests -* should raise error on requests not below the app -* should support forwarding - -== Rack::Request -* wraps the rack variables -* can figure out the correct host -* can parse the query string -* can parse POST data -* can parse POST data with explicit content type -* does not parse POST data when media type is not form-data -* rewinds input after parsing POST data -* cleans up Safari's ajax POST body -* can get value by key from params with #[] -* can set value to key on params with #[]= -* values_at answers values by keys in order given -* referrer should be extracted correct -* can cache, but invalidates the cache -* can figure out if called via XHR -* can parse cookies -* parses cookies according to RFC 2109 -* provides setters -* provides the original env -* can restore the URL -* can restore the full path -* can handle multiple media type parameters -* can parse multipart form data -* can parse big multipart form data -* can detect invalid multipart form data -* shouldn't try to interpret binary as utf8 -* should work around buggy 1.8.* Tempfile equality -* does conform to the Rack spec -* should parse Accept-Encoding correctly -* should provide ip information -* should allow subclass request to be instantiated after parent request -* should allow parent request to be instantiated after subclass request - -== Rack::Response -* has sensible default values -* can be written to -* can set and read headers -* can set cookies -* formats the Cookie expiration date accordingly to RFC 2109 -* can set secure cookies -* can set http only cookies -* can delete cookies -* can do redirects -* has a useful constructor -* has a constructor that can take a block -* doesn't return invalid responses -* knows if it's empty -* should provide access to the HTTP status -* should provide access to the HTTP headers -* does not add or change Content-Length when #finish()ing -* updates Content-Length when body appended to using #write - -== Rack::RewindableInput -=== given an IO object that is already rewindable -* should be able to handle to read() -* should be able to handle to read(nil) -* should be able to handle to read(length) -* should be able to handle to read(length, buffer) -* should be able to handle to read(nil, buffer) -* should rewind to the beginning when #rewind is called -* should be able to handle gets -* should be able to handle each -* should not buffer into a Tempfile if no data has been read yet -* should buffer into a Tempfile when data has been consumed for the first time -* should close the underlying tempfile upon calling #close -* should be possibel to call #close when no data has been buffered yet (empty) -* should be possible to call #close multiple times (empty) -=== given an IO object that is not rewindable -* should be able to handle to read() -* should be able to handle to read(nil) -* should be able to handle to read(length) -* should be able to handle to read(length, buffer) -* should be able to handle to read(nil, buffer) -* should rewind to the beginning when #rewind is called -* should be able to handle gets -* should be able to handle each -* should not buffer into a Tempfile if no data has been read yet -* should buffer into a Tempfile when data has been consumed for the first time -* should close the underlying tempfile upon calling #close -* should be possibel to call #close when no data has been buffered yet (empty) -* should be possible to call #close multiple times (empty) -=== given an IO object whose rewind method raises Errno::ESPIPE -* should be able to handle to read() -* should be able to handle to read(nil) -* should be able to handle to read(length) -* should be able to handle to read(length, buffer) -* should be able to handle to read(nil, buffer) -* should rewind to the beginning when #rewind is called -* should be able to handle gets -* should be able to handle each -* should not buffer into a Tempfile if no data has been read yet -* should buffer into a Tempfile when data has been consumed for the first time -* should close the underlying tempfile upon calling #close -* should be possibel to call #close when no data has been buffered yet (empty) -* should be possible to call #close multiple times (empty) - -== Rack::Session::Cookie -* creates a new cookie -* loads from a cookie -* survives broken cookies -* barks on too big cookies -* creates a new cookie with integrity hash -* loads from a cookie wih integrity hash -* ignores tampered with session cookies - -== Rack::Session::Memcache -* MemCache can connect to existing server (empty) -* faults on no connection -* creates a new cookie -* determines session from a cookie -* survives nonexistant cookies -* maintains freshness -* deletes cookies with :drop option -* provides new session id with :renew option -* omits cookie with :defer option -* multithread: should cleanly merge sessions (empty) - -== Rack::Session::Pool -* creates a new cookie -* determines session from a cookie -* survives nonexistant cookies -* deletes cookies with :drop option -* provides new session id with :renew option -* omits cookie with :defer option -* multithread: should merge sessions (empty) - -== Rack::ShowExceptions -* catches exceptions - -== Rack::ShowStatus -* should provide a default status message -* should let the app provide additional information -* should not replace existing messages -* should pass on original headers -* should replace existing messages if there is detail - -== Rack::Static -* serves files -* 404s if url root is known but it can't find the file -* calls down the chain if url root is not known - -== Rack::Handler::Thin -* should respond -* should be a Thin -* should have rack headers -* should have CGI headers on GET -* should have CGI headers on POST -* should support HTTP auth -* should set status - -== Rack::URLMap -* dispatches paths correctly -* dispatches hosts correctly -* should be nestable -* should route root apps correctly - -== Rack::Utils -* should escape correctly -* should escape correctly for multibyte characters -* should unescape correctly -* should parse query strings correctly -* should parse nested query strings correctly -* should build query strings correctly -* should figure out which encodings are acceptable -* should return the bytesize of String - -== Rack::Utils::HeaderHash -* should retain header case -* should check existence of keys case insensitively -* should merge case-insensitively -* should overwrite case insensitively and assume the new key's case -* should be converted to real Hash -* should convert Array values to Strings when converting to Hash -* should be able to delete the given key case-sensitively -* should be able to delete the given key case-insensitively -* should return the deleted value when #delete is called on an existing key -* should return nil when #delete is called on a non-existant key - -== Rack::Utils::Context -* should set context correctly -* should alter app on recontexting -* should run different apps - -== Rack::Utils::Multipart -* should return nil if content type is not multipart -* should parse multipart upload with text file -* should parse multipart upload with nested parameters -* should parse multipart upload with binary file -* should parse multipart upload with empty file -* should parse multipart upload with filename with semicolons -* should not include file params if no file was selected -* should parse IE multipart upload and clean up filename -* rewinds input after parsing upload - -== Rack::Handler::WEBrick -* should respond -* should be a WEBrick -* should have rack headers -* should have CGI headers on GET -* should have CGI headers on POST -* should support HTTP auth -* should set status -* should correctly set cookies -* should provide a .run - -335 specifications, 13 empty (1196 requirements), 0 failures diff --git a/vendor/gems/rack-1.0.1/README b/vendor/gems/rack-1.0.1/README deleted file mode 100644 index c58009ff..00000000 --- a/vendor/gems/rack-1.0.1/README +++ /dev/null @@ -1,364 +0,0 @@ -= Rack, a modular Ruby webserver interface - -Rack provides a minimal, modular and adaptable interface for developing -web applications in Ruby. By wrapping HTTP requests and responses in -the simplest way possible, it unifies and distills the API for web -servers, web frameworks, and software in between (the so-called -middleware) into a single method call. - -The exact details of this are described in the Rack specification, -which all Rack applications should conform to. - -== Specification changes in this release - -With Rack 1.0, the Rack specification (found in SPEC) changed in the -following backward-incompatible ways. This was done to properly -support Ruby 1.9 and to deprecate some problematic techniques: - -* Rack::VERSION has been pushed to [1,0]. -* Header values must be Strings now, split on "\n". -* rack.input must be rewindable and support reading into a buffer, - wrap with Rack::RewindableInput if it isn't. -* Content-Length can be missing, in this case chunked transfer - encoding is used. -* Bodies can now additionally respond to #to_path with a filename to - be served. -* String bodies are deprecated and will not work with Ruby 1.9, use an - Array with a single String instead. -* rack.session is now specified. - -== Supported web servers - -The included *handlers* connect all kinds of web servers to Rack: -* Mongrel -* EventedMongrel -* SwiftipliedMongrel -* WEBrick -* FCGI -* CGI -* SCGI -* LiteSpeed -* Thin - -These web servers include Rack handlers in their distributions: -* Ebb -* Fuzed -* Phusion Passenger (which is mod_rack for Apache and for nginx) -* Unicorn - -Any valid Rack app will run the same on all these handlers, without -changing anything. - -== Supported web frameworks - -The included *adapters* connect Rack with existing Ruby web frameworks: -* Camping - -These frameworks include Rack adapters in their distributions: -* Camping -* Coset -* Halcyon -* Mack -* Maveric -* Merb -* Racktools::SimpleApplication -* Ramaze -* Ruby on Rails -* Rum -* Sinatra -* Sin -* Vintage -* Waves -* Wee - -Current links to these projects can be found at -http://wiki.ramaze.net/Home#other-frameworks - -== Available middleware - -Between the server and the framework, Rack can be customized to your -applications needs using middleware, for example: -* Rack::URLMap, to route to multiple applications inside the same process. -* Rack::CommonLogger, for creating Apache-style logfiles. -* Rack::ShowException, for catching unhandled exceptions and - presenting them in a nice and helpful way with clickable backtrace. -* Rack::File, for serving static files. -* ...many others! - -All these components use the same interface, which is described in -detail in the Rack specification. These optional components can be -used in any way you wish. - -== Convenience - -If you want to develop outside of existing frameworks, implement your -own ones, or develop middleware, Rack provides many helpers to create -Rack applications quickly and without doing the same web stuff all -over: -* Rack::Request, which also provides query string parsing and - multipart handling. -* Rack::Response, for convenient generation of HTTP replies and - cookie handling. -* Rack::MockRequest and Rack::MockResponse for efficient and quick - testing of Rack application without real HTTP round-trips. - -== rack-contrib - -The plethora of useful middleware created the need for a project that -collects fresh Rack middleware. rack-contrib includes a variety of -add-on components for Rack and it is easy to contribute new modules. - -* http://github.com/rack/rack-contrib - -== rackup - -rackup is a useful tool for running Rack applications, which uses the -Rack::Builder DSL to configure middleware and build up applications -easily. - -rackup automatically figures out the environment it is run in, and -runs your application as FastCGI, CGI, or standalone with Mongrel or -WEBrick---all from the same configuration. - -== Quick start - -Try the lobster! - -Either with the embedded WEBrick starter: - - ruby -Ilib lib/rack/lobster.rb - -Or with rackup: - - bin/rackup -Ilib example/lobster.ru - -By default, the lobster is found at http://localhost:9292. - -== Installing with RubyGems - -A Gem of Rack is available. You can install it with: - - gem install rack - -I also provide a local mirror of the gems (and development snapshots) -at my site: - - gem install rack --source http://chneukirchen.org/releases/gems/ - -== Running the tests - -Testing Rack requires the test/spec testing framework: - - gem install test-spec - -There are two rake-based test tasks: - - rake test tests all the fast tests (no Handlers or Adapters) - rake fulltest runs all the tests - -The fast testsuite has no dependencies outside of the core Ruby -installation and test-spec. - -To run the test suite completely, you need: - - * camping - * fcgi - * memcache-client - * mongrel - * ruby-openid - * thin - -The full set of tests test FCGI access with lighttpd (on port -9203) so you will need lighttpd installed as well as the FCGI -libraries and the fcgi gem: - -Download and install lighttpd: - - http://www.lighttpd.net/download - -Installing the FCGI libraries: - - curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz - tar xzvf fcgi-2.4.0.tar.gz - cd fcgi-2.4.0 - ./configure --prefix=/usr/local - make - sudo make install - cd .. - -Installing the Ruby fcgi gem: - - gem install fcgi - -Furthermore, to test Memcache sessions, you need memcached (will be -run on port 11211) and memcache-client installed. - -== History - -* March 3rd, 2007: First public release 0.1. - -* May 16th, 2007: Second public release 0.2. - * HTTP Basic authentication. - * Cookie Sessions. - * Static file handler. - * Improved Rack::Request. - * Improved Rack::Response. - * Added Rack::ShowStatus, for better default error messages. - * Bug fixes in the Camping adapter. - * Removed Rails adapter, was too alpha. - -* February 26th, 2008: Third public release 0.3. - * LiteSpeed handler, by Adrian Madrid. - * SCGI handler, by Jeremy Evans. - * Pool sessions, by blink. - * OpenID authentication, by blink. - * :Port and :File options for opening FastCGI sockets, by blink. - * Last-Modified HTTP header for Rack::File, by blink. - * Rack::Builder#use now accepts blocks, by Corey Jewett. - (See example/protectedlobster.ru) - * HTTP status 201 can contain a Content-Type and a body now. - * Many bugfixes, especially related to Cookie handling. - -* August 21st, 2008: Fourth public release 0.4. - * New middleware, Rack::Deflater, by Christoffer Sawicki. - * OpenID authentication now needs ruby-openid 2. - * New Memcache sessions, by blink. - * Explicit EventedMongrel handler, by Joshua Peek - * Rack::Reloader is not loaded in rackup development mode. - * rackup can daemonize with -D. - * Many bugfixes, especially for pool sessions, URLMap, thread safety - and tempfile handling. - * Improved tests. - * Rack moved to Git. - -* January 6th, 2009: Fifth public release 0.9. - * Rack is now managed by the Rack Core Team. - * Rack::Lint is stricter and follows the HTTP RFCs more closely. - * Added ConditionalGet middleware. - * Added ContentLength middleware. - * Added Deflater middleware. - * Added Head middleware. - * Added MethodOverride middleware. - * Rack::Mime now provides popular MIME-types and their extension. - * Mongrel Header now streams. - * Added Thin handler. - * Official support for swiftiplied Mongrel. - * Secure cookies. - * Made HeaderHash case-preserving. - * Many bugfixes and small improvements. - -* January 9th, 2009: Sixth public release 0.9.1. - * Fix directory traversal exploits in Rack::File and Rack::Directory. - -* April 25th, 2009: Seventh public release 1.0.0. - * SPEC change: Rack::VERSION has been pushed to [1,0]. - * SPEC change: header values must be Strings now, split on "\n". - * SPEC change: Content-Length can be missing, in this case chunked transfer - encoding is used. - * SPEC change: rack.input must be rewindable and support reading into - a buffer, wrap with Rack::RewindableInput if it isn't. - * SPEC change: rack.session is now specified. - * SPEC change: Bodies can now additionally respond to #to_path with - a filename to be served. - * NOTE: String bodies break in 1.9, use an Array consisting of a - single String instead. - * New middleware Rack::Lock. - * New middleware Rack::ContentType. - * Rack::Reloader has been rewritten. - * Major update to Rack::Auth::OpenID. - * Support for nested parameter parsing in Rack::Response. - * Support for redirects in Rack::Response. - * HttpOnly cookie support in Rack::Response. - * The Rakefile has been rewritten. - * Many bugfixes and small improvements. - -* October 18th, 2009: Eighth public release 1.0.1. - * Bump remainder of rack.versions. - * Support the pure Ruby FCGI implementation. - * Fix for form names containing "=": split first then unescape components - * Fixes the handling of the filename parameter with semicolons in names. - * Add anchor to nested params parsing regexp to prevent stack overflows - * Use more compatible gzip write api instead of "<<". - * Make sure that Reloader doesn't break when executed via ruby -e - * Make sure WEBrick respects the :Host option - * Many Ruby 1.9 fixes. - -== Contact - -Please mail bugs, suggestions and patches to -. - -Mailing list archives are available at -. - -There is a bug tracker at . - -Git repository (send Git patches to the mailing list): -* http://github.com/rack/rack -* http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack.git - -You are also welcome to join the #rack channel on irc.freenode.net. - -== Thanks - -The Rack Core Team, consisting of - -* Christian Neukirchen (chneukirchen) -* James Tucker (raggi) -* Josh Peek (josh) -* Michael Fellinger (manveru) -* Ryan Tomayko (rtomayko) -* Scytrin dai Kinthra (scytrin) - -would like to thank: - -* Adrian Madrid, for the LiteSpeed handler. -* Christoffer Sawicki, for the first Rails adapter and Rack::Deflater. -* Tim Fletcher, for the HTTP authentication code. -* Luc Heinrich for the Cookie sessions, the static file handler and bugfixes. -* Armin Ronacher, for the logo and racktools. -* Aredridel, Ben Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd, - Tom Robinson, Phil Hagelberg, and S. Brent Faulkner for bug fixing - and other improvements. -* Brian Candler, for Rack::ContentType. -* Graham Batty, for improved handler loading. -* Stephen Bannasch, for bug reports and documentation. -* Gary Wright, for proposing a better Rack::Response interface. -* Jonathan Buch, for improvements regarding Rack::Response. -* Armin Röhrl, for tracking down bugs in the Cookie generator. -* Alexander Kellett for testing the Gem and reviewing the announcement. -* Marcus Rückert, for help with configuring and debugging lighttpd. -* The WSGI team for the well-done and documented work they've done and - Rack builds up on. -* All bug reporters and patch contributers not mentioned above. - -== Copyright - -Copyright (C) 2007, 2008, 2009 Christian Neukirchen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -== Links - -Rack:: -Rack's Rubyforge project:: -Official Rack repositories:: -rack-devel mailing list:: - -Christian Neukirchen:: - diff --git a/vendor/gems/rack-1.0.1/Rakefile b/vendor/gems/rack-1.0.1/Rakefile deleted file mode 100644 index c88f7aff..00000000 --- a/vendor/gems/rack-1.0.1/Rakefile +++ /dev/null @@ -1,164 +0,0 @@ -# Rakefile for Rack. -*-ruby-*- -require 'rake/rdoctask' -require 'rake/testtask' - - -desc "Run all the tests" -task :default => [:test] - - -desc "Make an archive as .tar.gz" -task :dist => [:chmod, :changelog, :rdoc, "SPEC", "rack.gemspec"] do - FileUtils.touch("RDOX") - sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar" - sh "pax -waf #{release}.tar -s ':^:#{release}/:' RDOX SPEC ChangeLog doc rack.gemspec" - sh "gzip -f -9 #{release}.tar" -end - -desc "Make an official release" -task :officialrelease do - puts "Official build for #{release}..." - sh "rm -rf stage" - sh "git clone --shared . stage" - sh "cd stage && rake officialrelease_really" - sh "mv stage/#{release}.tar.gz stage/#{release}.gem ." -end - -task :officialrelease_really => [:fulltest, "RDOX", "SPEC", :dist, :gem] do - sh "sha1sum #{release}.tar.gz #{release}.gem" -end - - -def version - abort "You need to pass VERSION=... to build packages." unless ENV["VERSION"] - ENV["VERSION"] -end - -def release - "rack-#{version}" -end - -def manifest - `git ls-files`.split("\n") -end - - -desc "Make binaries executable" -task :chmod do - Dir["bin/*"].each { |binary| File.chmod(0775, binary) } - Dir["test/cgi/test*"].each { |binary| File.chmod(0775, binary) } -end - -desc "Generate a ChangeLog" -task :changelog do - File.open("ChangeLog", "w") { |out| - `git log -z`.split("\0").map { |chunk| - author = chunk[/Author: (.*)/, 1].strip - date = chunk[/Date: (.*)/, 1].strip - desc, detail = $'.strip.split("\n", 2) - detail ||= "" - detail = detail.gsub(/.*darcs-hash:.*/, '') - detail.rstrip! - out.puts "#{date} #{author}" - out.puts " * #{desc.strip}" - out.puts detail unless detail.empty? - out.puts - } - } -end - - -desc "Generate RDox" -task "RDOX" do - sh "specrb -Ilib:test -a --rdox >RDOX" -end - -desc "Generate Rack Specification" -task "SPEC" do - File.open("SPEC", "wb") { |file| - IO.foreach("lib/rack/lint.rb") { |line| - if line =~ /## (.*)/ - file.puts $1 - end - } - } -end - -desc "Run all the fast tests" -task :test do - sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS'] || '-t "^(?!Rack::Handler|Rack::Adapter|Rack::Session::Memcache|Rack::Auth::OpenID)"'}" -end - -desc "Run all the tests" -task :fulltest => [:chmod] do - sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}" -end - -begin - require 'rubygems' -rescue LoadError - # Too bad. -else - task "rack.gemspec" do - spec = Gem::Specification.new do |s| - s.name = "rack" - s.version = version - s.platform = Gem::Platform::RUBY - s.summary = "a modular Ruby webserver interface" - - s.description = <<-EOF -Rack provides minimal, modular and adaptable interface for developing -web applications in Ruby. By wrapping HTTP requests and responses in -the simplest way possible, it unifies and distills the API for web -servers, web frameworks, and software in between (the so-called -middleware) into a single method call. - -Also see http://rack.rubyforge.org. - EOF - - s.files = manifest + %w(SPEC RDOX rack.gemspec) - s.bindir = 'bin' - s.executables << 'rackup' - s.require_path = 'lib' - s.has_rdoc = true - s.extra_rdoc_files = ['README', 'SPEC', 'RDOX', 'KNOWN-ISSUES'] - s.test_files = Dir['test/{test,spec}_*.rb'] - - s.author = 'Christian Neukirchen' - s.email = 'chneukirchen@gmail.com' - s.homepage = 'http://rack.rubyforge.org' - s.rubyforge_project = 'rack' - - s.add_development_dependency 'test-spec' - - s.add_development_dependency 'camping' - s.add_development_dependency 'fcgi' - s.add_development_dependency 'memcache-client' - s.add_development_dependency 'mongrel' - s.add_development_dependency 'ruby-openid', '~> 2.0.0' - s.add_development_dependency 'thin' - end - - File.open("rack.gemspec", "w") { |f| f << spec.to_ruby } - end - - task :gem => ["rack.gemspec", "SPEC"] do - FileUtils.touch("RDOX") - sh "gem build rack.gemspec" - end -end - -desc "Generate RDoc documentation" -task :rdoc do - sh(*%w{rdoc --line-numbers --main README - --title 'Rack\ Documentation' --charset utf-8 -U -o doc} + - %w{README KNOWN-ISSUES SPEC RDOX} + - Dir["lib/**/*.rb"]) -end - -task :pushsite => [:rdoc] do - sh "cd site && git gc" - sh "rsync -avz doc/ chneukirchen@rack.rubyforge.org:/var/www/gforge-projects/rack/doc/" - sh "rsync -avz site/ chneukirchen@rack.rubyforge.org:/var/www/gforge-projects/rack/" - sh "cd site && git push" -end diff --git a/vendor/gems/rack-1.0.1/SPEC b/vendor/gems/rack-1.0.1/SPEC deleted file mode 100644 index e4d252ec..00000000 --- a/vendor/gems/rack-1.0.1/SPEC +++ /dev/null @@ -1,164 +0,0 @@ -This specification aims to formalize the Rack protocol. You -can (and should) use Rack::Lint to enforce it. -When you develop middleware, be sure to add a Lint before and -after to catch all mistakes. -= Rack applications -A Rack application is an Ruby object (not a class) that -responds to +call+. -It takes exactly one argument, the *environment* -and returns an Array of exactly three values: -The *status*, -the *headers*, -and the *body*. -== The Environment -The environment must be an true instance of Hash (no -subclassing allowed) that includes CGI-like headers. -The application is free to modify the environment. -The environment is required to include these variables -(adopted from PEP333), except when they'd be empty, but see -below. -REQUEST_METHOD:: The HTTP request method, such as - "GET" or "POST". This cannot ever - be an empty string, and so is - always required. -SCRIPT_NAME:: The initial portion of the request - URL's "path" that corresponds to the - application object, so that the - application knows its virtual - "location". This may be an empty - string, if the application corresponds - to the "root" of the server. -PATH_INFO:: The remainder of the request URL's - "path", designating the virtual - "location" of the request's target - within the application. This may be an - empty string, if the request URL targets - the application root and does not have a - trailing slash. This value may be - percent-encoded when I originating from - a URL. -QUERY_STRING:: The portion of the request URL that - follows the ?, if any. May be - empty, but is always required! -SERVER_NAME, SERVER_PORT:: When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL. Note, however, that HTTP_HOST, if present, should be used in preference to SERVER_NAME for reconstructing the request URL. SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required. -HTTP_ Variables:: Variables corresponding to the - client-supplied HTTP request - headers (i.e., variables whose - names begin with HTTP_). The - presence or absence of these - variables should correspond with - the presence or absence of the - appropriate HTTP header in the - request. -In addition to this, the Rack environment must include these -Rack-specific variables: -rack.version:: The Array [1,0], representing this version of Rack. -rack.url_scheme:: +http+ or +https+, depending on the request URL. -rack.input:: See below, the input stream. -rack.errors:: See below, the error stream. -rack.multithread:: true if the application object may be simultaneously invoked by another thread in the same process, false otherwise. -rack.multiprocess:: true if an equivalent application object may be simultaneously invoked by another process, false otherwise. -rack.run_once:: true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar). -Additional environment specifications have approved to -standardized middleware APIs. None of these are required to -be implemented by the server. -rack.session:: A hash like interface for storing request session data. - The store must implement: - store(key, value) (aliased as []=); - fetch(key, default = nil) (aliased as []); - delete(key); - clear; -The server or the application can store their own data in the -environment, too. The keys must contain at least one dot, -and should be prefixed uniquely. The prefix rack. -is reserved for use with the Rack core distribution and other -accepted specifications and must not be used otherwise. -The environment must not contain the keys -HTTP_CONTENT_TYPE or HTTP_CONTENT_LENGTH -(use the versions without HTTP_). -The CGI keys (named without a period) must have String values. -There are the following restrictions: -* rack.version must be an array of Integers. -* rack.url_scheme must either be +http+ or +https+. -* There must be a valid input stream in rack.input. -* There must be a valid error stream in rack.errors. -* The REQUEST_METHOD must be a valid token. -* The SCRIPT_NAME, if non-empty, must start with / -* The PATH_INFO, if non-empty, must start with / -* The CONTENT_LENGTH, if given, must consist of digits only. -* One of SCRIPT_NAME or PATH_INFO must be - set. PATH_INFO should be / if - SCRIPT_NAME is empty. - SCRIPT_NAME never should be /, but instead be empty. -=== The Input Stream -The input stream is an IO-like object which contains the raw HTTP -POST data. -When applicable, its external encoding must be "ASCII-8BIT" and it -must be opened in binary mode, for Ruby 1.9 compatibility. -The input stream must respond to +gets+, +each+, +read+ and +rewind+. -* +gets+ must be called without arguments and return a string, - or +nil+ on EOF. -* +read+ behaves like IO#read. Its signature is read([length, [buffer]]). - If given, +length+ must be an non-negative Integer (>= 0) or +nil+, and +buffer+ must - be a String and may not be nil. If +length+ is given and not nil, then this method - reads at most +length+ bytes from the input stream. If +length+ is not given or nil, - then this method reads all data until EOF. - When EOF is reached, this method returns nil if +length+ is given and not nil, or "" - if +length+ is not given or is nil. - If +buffer+ is given, then the read data will be placed into +buffer+ instead of a - newly created String object. -* +each+ must be called without arguments and only yield Strings. -* +rewind+ must be called without arguments. It rewinds the input - stream back to the beginning. It must not raise Errno::ESPIPE: - that is, it may not be a pipe or a socket. Therefore, handler - developers must buffer the input data into some rewindable object - if the underlying input stream is not rewindable. -* +close+ must never be called on the input stream. -=== The Error Stream -The error stream must respond to +puts+, +write+ and +flush+. -* +puts+ must be called with a single argument that responds to +to_s+. -* +write+ must be called with a single argument that is a String. -* +flush+ must be called without arguments and must be called - in order to make the error appear for sure. -* +close+ must never be called on the error stream. -== The Response -=== The Status -This is an HTTP status. When parsed as integer (+to_i+), it must be -greater than or equal to 100. -=== The Headers -The header must respond to +each+, and yield values of key and value. -The header keys must be Strings. -The header must not contain a +Status+ key, -contain keys with : or newlines in their name, -contain keys names that end in - or _, -but only contain keys that consist of -letters, digits, _ or - and start with a letter. -The values of the header must be Strings, -consisting of lines (for multiple header values, e.g. multiple -Set-Cookie values) seperated by "\n". -The lines must not contain characters below 037. -=== The Content-Type -There must be a Content-Type, except when the -+Status+ is 1xx, 204 or 304, in which case there must be none -given. -=== The Content-Length -There must not be a Content-Length header when the -+Status+ is 1xx, 204 or 304. -=== The Body -The Body must respond to +each+ -and must only yield String values. -The Body itself should not be an instance of String, as this will -break in Ruby 1.9. -If the Body responds to +close+, it will be called after iteration. -If the Body responds to +to_path+, it must return a String -identifying the location of a file whose contents are identical -to that produced by calling +each+; this may be used by the -server as an alternative, possibly more efficient way to -transport the response. -The Body commonly is an Array of Strings, the application -instance itself, or a File-like object. -== Thanks -Some parts of this specification are adopted from PEP333: Python -Web Server Gateway Interface -v1.0 (http://www.python.org/dev/peps/pep-0333/). I'd like to thank -everyone involved in that effort. diff --git a/vendor/gems/rack-1.0.1/bin/rackup b/vendor/gems/rack-1.0.1/bin/rackup deleted file mode 100755 index 8e4df15e..00000000 --- a/vendor/gems/rack-1.0.1/bin/rackup +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/env ruby -# -*- ruby -*- - -$LOAD_PATH.unshift File.expand_path("#{__FILE__}/../../lib") -autoload :Rack, 'rack' - -require 'optparse' - -automatic = false -server = nil -env = "development" -daemonize = false -pid = nil -options = {:Port => 9292, :Host => "0.0.0.0", :AccessLog => []} - -# Don't evaluate CGI ISINDEX parameters. -# http://hoohoo.ncsa.uiuc.edu/cgi/cl.html -ARGV.clear if ENV.include?("REQUEST_METHOD") - -opts = OptionParser.new("", 24, ' ') { |opts| - opts.banner = "Usage: rackup [ruby options] [rack options] [rackup config]" - - opts.separator "" - opts.separator "Ruby options:" - - lineno = 1 - opts.on("-e", "--eval LINE", "evaluate a LINE of code") { |line| - eval line, TOPLEVEL_BINDING, "-e", lineno - lineno += 1 - } - - opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") { - $DEBUG = true - } - opts.on("-w", "--warn", "turn warnings on for your script") { - $-w = true - } - - opts.on("-I", "--include PATH", - "specify $LOAD_PATH (may be used more than once)") { |path| - $LOAD_PATH.unshift(*path.split(":")) - } - - opts.on("-r", "--require LIBRARY", - "require the library, before executing your script") { |library| - require library - } - - opts.separator "" - opts.separator "Rack options:" - opts.on("-s", "--server SERVER", "serve using SERVER (webrick/mongrel)") { |s| - server = s - } - - opts.on("-o", "--host HOST", "listen on HOST (default: 0.0.0.0)") { |host| - options[:Host] = host - } - - opts.on("-p", "--port PORT", "use PORT (default: 9292)") { |port| - options[:Port] = port - } - - opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e| - env = e - } - - opts.on("-D", "--daemonize", "run daemonized in the background") { |d| - daemonize = d ? true : false - } - - opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f| - pid = File.expand_path(f) - } - - opts.separator "" - opts.separator "Common options:" - - opts.on_tail("-h", "--help", "Show this message") do - puts opts - exit - end - - opts.on_tail("--version", "Show version") do - puts "Rack #{Rack.version}" - exit - end - - opts.parse! ARGV -} - -require 'pp' if $DEBUG - -config = ARGV[0] || "config.ru" -if !File.exist? config - abort "configuration #{config} not found" -end - -if config =~ /\.ru$/ - cfgfile = File.read(config) - if cfgfile[/^#\\(.*)/] - opts.parse! $1.split(/\s+/) - end - inner_app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app", - nil, config -else - require config - inner_app = Object.const_get(File.basename(config, '.rb').capitalize) -end - -unless server = Rack::Handler.get(server) - # Guess. - if ENV.include?("PHP_FCGI_CHILDREN") - server = Rack::Handler::FastCGI - - # We already speak FastCGI - options.delete :File - options.delete :Port - elsif ENV.include?("REQUEST_METHOD") - server = Rack::Handler::CGI - else - begin - server = Rack::Handler::Mongrel - rescue LoadError => e - server = Rack::Handler::WEBrick - end - end -end - -p server if $DEBUG - -case env -when "development" - app = Rack::Builder.new { - use Rack::CommonLogger, $stderr unless server.name =~ /CGI/ - use Rack::ShowExceptions - use Rack::Lint - run inner_app - }.to_app - -when "deployment" - app = Rack::Builder.new { - use Rack::CommonLogger, $stderr unless server.name =~ /CGI/ - run inner_app - }.to_app - -when "none" - app = inner_app - -end - -if $DEBUG - pp app - pp inner_app -end - -if daemonize - if RUBY_VERSION < "1.9" - exit if fork - Process.setsid - exit if fork - Dir.chdir "/" - File.umask 0000 - STDIN.reopen "/dev/null" - STDOUT.reopen "/dev/null", "a" - STDERR.reopen "/dev/null", "a" - else - Process.daemon - end - - if pid - File.open(pid, 'w'){ |f| f.write("#{Process.pid}") } - at_exit { File.delete(pid) if File.exist?(pid) } - end -end - -server.run app, options diff --git a/vendor/gems/rack-1.0.1/contrib/rack_logo.svg b/vendor/gems/rack-1.0.1/contrib/rack_logo.svg deleted file mode 100644 index 905dcd32..00000000 --- a/vendor/gems/rack-1.0.1/contrib/rack_logo.svg +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - diff --git a/vendor/gems/rack-1.0.1/example/lobster.ru b/vendor/gems/rack-1.0.1/example/lobster.ru deleted file mode 100644 index cc7ffcae..00000000 --- a/vendor/gems/rack-1.0.1/example/lobster.ru +++ /dev/null @@ -1,4 +0,0 @@ -require 'rack/lobster' - -use Rack::ShowExceptions -run Rack::Lobster.new diff --git a/vendor/gems/rack-1.0.1/example/protectedlobster.rb b/vendor/gems/rack-1.0.1/example/protectedlobster.rb deleted file mode 100644 index 108b9d05..00000000 --- a/vendor/gems/rack-1.0.1/example/protectedlobster.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rack' -require 'rack/lobster' - -lobster = Rack::Lobster.new - -protected_lobster = Rack::Auth::Basic.new(lobster) do |username, password| - 'secret' == password -end - -protected_lobster.realm = 'Lobster 2.0' - -pretty_protected_lobster = Rack::ShowStatus.new(Rack::ShowExceptions.new(protected_lobster)) - -Rack::Handler::WEBrick.run pretty_protected_lobster, :Port => 9292 diff --git a/vendor/gems/rack-1.0.1/example/protectedlobster.ru b/vendor/gems/rack-1.0.1/example/protectedlobster.ru deleted file mode 100644 index b0da62f0..00000000 --- a/vendor/gems/rack-1.0.1/example/protectedlobster.ru +++ /dev/null @@ -1,8 +0,0 @@ -require 'rack/lobster' - -use Rack::ShowExceptions -use Rack::Auth::Basic, "Lobster 2.0" do |username, password| - 'secret' == password -end - -run Rack::Lobster.new diff --git a/vendor/gems/rack-1.0.1/lib/rack.rb b/vendor/gems/rack-1.0.1/lib/rack.rb deleted file mode 100644 index 371d0156..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack.rb +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (C) 2007, 2008, 2009 Christian Neukirchen -# -# Rack is freely distributable under the terms of an MIT-style license. -# See COPYING or http://www.opensource.org/licenses/mit-license.php. - -path = File.expand_path(File.dirname(__FILE__)) -$:.unshift(path) unless $:.include?(path) - - -# The Rack main module, serving as a namespace for all core Rack -# modules and classes. -# -# All modules meant for use in your application are autoloaded here, -# so it should be enough just to require rack.rb in your code. - -module Rack - # The Rack protocol version number implemented. - VERSION = [1,0] - - # Return the Rack protocol version as a dotted string. - def self.version - VERSION.join(".") - end - - # Return the Rack release as a dotted string. - def self.release - "1.0" - end - - autoload :Builder, "rack/builder" - autoload :Cascade, "rack/cascade" - autoload :Chunked, "rack/chunked" - autoload :CommonLogger, "rack/commonlogger" - autoload :ConditionalGet, "rack/conditionalget" - autoload :ContentLength, "rack/content_length" - autoload :ContentType, "rack/content_type" - autoload :File, "rack/file" - autoload :Deflater, "rack/deflater" - autoload :Directory, "rack/directory" - autoload :ForwardRequest, "rack/recursive" - autoload :Handler, "rack/handler" - autoload :Head, "rack/head" - autoload :Lint, "rack/lint" - autoload :Lock, "rack/lock" - autoload :MethodOverride, "rack/methodoverride" - autoload :Mime, "rack/mime" - autoload :Recursive, "rack/recursive" - autoload :Reloader, "rack/reloader" - autoload :ShowExceptions, "rack/showexceptions" - autoload :ShowStatus, "rack/showstatus" - autoload :Static, "rack/static" - autoload :URLMap, "rack/urlmap" - autoload :Utils, "rack/utils" - - autoload :MockRequest, "rack/mock" - autoload :MockResponse, "rack/mock" - - autoload :Request, "rack/request" - autoload :Response, "rack/response" - - module Auth - autoload :Basic, "rack/auth/basic" - autoload :AbstractRequest, "rack/auth/abstract/request" - autoload :AbstractHandler, "rack/auth/abstract/handler" - autoload :OpenID, "rack/auth/openid" - module Digest - autoload :MD5, "rack/auth/digest/md5" - autoload :Nonce, "rack/auth/digest/nonce" - autoload :Params, "rack/auth/digest/params" - autoload :Request, "rack/auth/digest/request" - end - end - - module Session - autoload :Cookie, "rack/session/cookie" - autoload :Pool, "rack/session/pool" - autoload :Memcache, "rack/session/memcache" - end - - # *Adapters* connect Rack with third party web frameworks. - # - # Rack includes an adapter for Camping, see README for other - # frameworks supporting Rack in their code bases. - # - # Refer to the submodules for framework-specific calling details. - - module Adapter - autoload :Camping, "rack/adapter/camping" - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/adapter/camping.rb b/vendor/gems/rack-1.0.1/lib/rack/adapter/camping.rb deleted file mode 100644 index 63bc787f..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/adapter/camping.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Rack - module Adapter - class Camping - def initialize(app) - @app = app - end - - def call(env) - env["PATH_INFO"] ||= "" - env["SCRIPT_NAME"] ||= "" - controller = @app.run(env['rack.input'], env) - h = controller.headers - h.each_pair do |k,v| - if v.kind_of? URI - h[k] = v.to_s - end - end - [controller.status, controller.headers, [controller.body.to_s]] - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/auth/abstract/handler.rb b/vendor/gems/rack-1.0.1/lib/rack/auth/abstract/handler.rb deleted file mode 100644 index 214df629..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/auth/abstract/handler.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Rack - module Auth - # Rack::Auth::AbstractHandler implements common authentication functionality. - # - # +realm+ should be set for all handlers. - - class AbstractHandler - - attr_accessor :realm - - def initialize(app, realm=nil, &authenticator) - @app, @realm, @authenticator = app, realm, authenticator - end - - - private - - def unauthorized(www_authenticate = challenge) - return [ 401, - { 'Content-Type' => 'text/plain', - 'Content-Length' => '0', - 'WWW-Authenticate' => www_authenticate.to_s }, - [] - ] - end - - def bad_request - return [ 400, - { 'Content-Type' => 'text/plain', - 'Content-Length' => '0' }, - [] - ] - end - - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/auth/abstract/request.rb b/vendor/gems/rack-1.0.1/lib/rack/auth/abstract/request.rb deleted file mode 100644 index 1d9ccec6..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/auth/abstract/request.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Rack - module Auth - class AbstractRequest - - def initialize(env) - @env = env - end - - def provided? - !authorization_key.nil? - end - - def parts - @parts ||= @env[authorization_key].split(' ', 2) - end - - def scheme - @scheme ||= parts.first.downcase.to_sym - end - - def params - @params ||= parts.last - end - - - private - - AUTHORIZATION_KEYS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION'] - - def authorization_key - @authorization_key ||= AUTHORIZATION_KEYS.detect { |key| @env.has_key?(key) } - end - - end - - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/auth/basic.rb b/vendor/gems/rack-1.0.1/lib/rack/auth/basic.rb deleted file mode 100644 index 95572246..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/auth/basic.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'rack/auth/abstract/handler' -require 'rack/auth/abstract/request' - -module Rack - module Auth - # Rack::Auth::Basic implements HTTP Basic Authentication, as per RFC 2617. - # - # Initialize with the Rack application that you want protecting, - # and a block that checks if a username and password pair are valid. - # - # See also: example/protectedlobster.rb - - class Basic < AbstractHandler - - def call(env) - auth = Basic::Request.new(env) - - return unauthorized unless auth.provided? - - return bad_request unless auth.basic? - - if valid?(auth) - env['REMOTE_USER'] = auth.username - - return @app.call(env) - end - - unauthorized - end - - - private - - def challenge - 'Basic realm="%s"' % realm - end - - def valid?(auth) - @authenticator.call(*auth.credentials) - end - - class Request < Auth::AbstractRequest - def basic? - :basic == scheme - end - - def credentials - @credentials ||= params.unpack("m*").first.split(/:/, 2) - end - - def username - credentials.first - end - end - - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/auth/digest/md5.rb b/vendor/gems/rack-1.0.1/lib/rack/auth/digest/md5.rb deleted file mode 100644 index e579dc96..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/auth/digest/md5.rb +++ /dev/null @@ -1,124 +0,0 @@ -require 'rack/auth/abstract/handler' -require 'rack/auth/digest/request' -require 'rack/auth/digest/params' -require 'rack/auth/digest/nonce' -require 'digest/md5' - -module Rack - module Auth - module Digest - # Rack::Auth::Digest::MD5 implements the MD5 algorithm version of - # HTTP Digest Authentication, as per RFC 2617. - # - # Initialize with the [Rack] application that you want protecting, - # and a block that looks up a plaintext password for a given username. - # - # +opaque+ needs to be set to a constant base64/hexadecimal string. - # - class MD5 < AbstractHandler - - attr_accessor :opaque - - attr_writer :passwords_hashed - - def initialize(*args) - super - @passwords_hashed = nil - end - - def passwords_hashed? - !!@passwords_hashed - end - - def call(env) - auth = Request.new(env) - - unless auth.provided? - return unauthorized - end - - if !auth.digest? || !auth.correct_uri? || !valid_qop?(auth) - return bad_request - end - - if valid?(auth) - if auth.nonce.stale? - return unauthorized(challenge(:stale => true)) - else - env['REMOTE_USER'] = auth.username - - return @app.call(env) - end - end - - unauthorized - end - - - private - - QOP = 'auth'.freeze - - def params(hash = {}) - Params.new do |params| - params['realm'] = realm - params['nonce'] = Nonce.new.to_s - params['opaque'] = H(opaque) - params['qop'] = QOP - - hash.each { |k, v| params[k] = v } - end - end - - def challenge(hash = {}) - "Digest #{params(hash)}" - end - - def valid?(auth) - valid_opaque?(auth) && valid_nonce?(auth) && valid_digest?(auth) - end - - def valid_qop?(auth) - QOP == auth.qop - end - - def valid_opaque?(auth) - H(opaque) == auth.opaque - end - - def valid_nonce?(auth) - auth.nonce.valid? - end - - def valid_digest?(auth) - digest(auth, @authenticator.call(auth.username)) == auth.response - end - - def md5(data) - ::Digest::MD5.hexdigest(data) - end - - alias :H :md5 - - def KD(secret, data) - H([secret, data] * ':') - end - - def A1(auth, password) - [ auth.username, auth.realm, password ] * ':' - end - - def A2(auth) - [ auth.method, auth.uri ] * ':' - end - - def digest(auth, password) - password_hash = passwords_hashed? ? password : H(A1(auth, password)) - - KD(password_hash, [ auth.nonce, auth.nc, auth.cnonce, QOP, H(A2(auth)) ] * ':') - end - - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/auth/digest/nonce.rb b/vendor/gems/rack-1.0.1/lib/rack/auth/digest/nonce.rb deleted file mode 100644 index dbe109f2..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/auth/digest/nonce.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'digest/md5' - -module Rack - module Auth - module Digest - # Rack::Auth::Digest::Nonce is the default nonce generator for the - # Rack::Auth::Digest::MD5 authentication handler. - # - # +private_key+ needs to set to a constant string. - # - # +time_limit+ can be optionally set to an integer (number of seconds), - # to limit the validity of the generated nonces. - - class Nonce - - class << self - attr_accessor :private_key, :time_limit - end - - def self.parse(string) - new(*string.unpack("m*").first.split(' ', 2)) - end - - def initialize(timestamp = Time.now, given_digest = nil) - @timestamp, @given_digest = timestamp.to_i, given_digest - end - - def to_s - [([ @timestamp, digest ] * ' ')].pack("m*").strip - end - - def digest - ::Digest::MD5.hexdigest([ @timestamp, self.class.private_key ] * ':') - end - - def valid? - digest == @given_digest - end - - def stale? - !self.class.time_limit.nil? && (@timestamp - Time.now.to_i) < self.class.time_limit - end - - def fresh? - !stale? - end - - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/auth/digest/params.rb b/vendor/gems/rack-1.0.1/lib/rack/auth/digest/params.rb deleted file mode 100644 index 730e2efd..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/auth/digest/params.rb +++ /dev/null @@ -1,55 +0,0 @@ -module Rack - module Auth - module Digest - class Params < Hash - - def self.parse(str) - split_header_value(str).inject(new) do |header, param| - k, v = param.split('=', 2) - header[k] = dequote(v) - header - end - end - - def self.dequote(str) # From WEBrick::HTTPUtils - ret = (/\A"(.*)"\Z/ =~ str) ? $1 : str.dup - ret.gsub!(/\\(.)/, "\\1") - ret - end - - def self.split_header_value(str) - str.scan( /(\w+\=(?:"[^\"]+"|[^,]+))/n ).collect{ |v| v[0] } - end - - def initialize - super - - yield self if block_given? - end - - def [](k) - super k.to_s - end - - def []=(k, v) - super k.to_s, v.to_s - end - - UNQUOTED = ['qop', 'nc', 'stale'] - - def to_s - inject([]) do |parts, (k, v)| - parts << "#{k}=" + (UNQUOTED.include?(k) ? v.to_s : quote(v)) - parts - end.join(', ') - end - - def quote(str) # From WEBrick::HTTPUtils - '"' << str.gsub(/[\\\"]/o, "\\\1") << '"' - end - - end - end - end -end - diff --git a/vendor/gems/rack-1.0.1/lib/rack/auth/digest/request.rb b/vendor/gems/rack-1.0.1/lib/rack/auth/digest/request.rb deleted file mode 100644 index a8aa3bf9..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/auth/digest/request.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'rack/auth/abstract/request' -require 'rack/auth/digest/params' -require 'rack/auth/digest/nonce' - -module Rack - module Auth - module Digest - class Request < Auth::AbstractRequest - - def method - @env['rack.methodoverride.original_method'] || @env['REQUEST_METHOD'] - end - - def digest? - :digest == scheme - end - - def correct_uri? - (@env['SCRIPT_NAME'].to_s + @env['PATH_INFO'].to_s) == uri - end - - def nonce - @nonce ||= Nonce.parse(params['nonce']) - end - - def params - @params ||= Params.parse(parts.last) - end - - def method_missing(sym) - if params.has_key? key = sym.to_s - return params[key] - end - super - end - - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/auth/openid.rb b/vendor/gems/rack-1.0.1/lib/rack/auth/openid.rb deleted file mode 100644 index c5f6a514..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/auth/openid.rb +++ /dev/null @@ -1,480 +0,0 @@ -# AUTHOR: blink ; blink#ruby-lang@irc.freenode.net - -gem 'ruby-openid', '~> 2' if defined? Gem -require 'rack/request' -require 'rack/utils' -require 'rack/auth/abstract/handler' -require 'uri' -require 'openid' #gem -require 'openid/extension' #gem -require 'openid/store/memory' #gem - -module Rack - class Request - def openid_request - @env['rack.auth.openid.request'] - end - - def openid_response - @env['rack.auth.openid.response'] - end - end - - module Auth - - # Rack::Auth::OpenID provides a simple method for setting up an OpenID - # Consumer. It requires the ruby-openid library from janrain to operate, - # as well as a rack method of session management. - # - # The ruby-openid home page is at http://openidenabled.com/ruby-openid/. - # - # The OpenID specifications can be found at - # http://openid.net/specs/openid-authentication-1_1.html - # and - # http://openid.net/specs/openid-authentication-2_0.html. Documentation - # for published OpenID extensions and related topics can be found at - # http://openid.net/developers/specs/. - # - # It is recommended to read through the OpenID spec, as well as - # ruby-openid's documentation, to understand what exactly goes on. However - # a setup as simple as the presented examples is enough to provide - # Consumer functionality. - # - # This library strongly intends to utilize the OpenID 2.0 features of the - # ruby-openid library, which provides OpenID 1.0 compatiblity. - # - # NOTE: Due to the amount of data that this library stores in the - # session, Rack::Session::Cookie may fault. - - class OpenID - - class NoSession < RuntimeError; end - class BadExtension < RuntimeError; end - # Required for ruby-openid - ValidStatus = [:success, :setup_needed, :cancel, :failure] - - # = Arguments - # - # The first argument is the realm, identifying the site they are trusting - # with their identity. This is required, also treated as the trust_root - # in OpenID 1.x exchanges. - # - # The optional second argument is a hash of options. - # - # == Options - # - # :return_to defines the url to return to after the client - # authenticates with the openid service provider. This url should point - # to where Rack::Auth::OpenID is mounted. If :return_to is not - # provided, return_to will be the current url which allows flexibility - # with caveats. - # - # :session_key defines the key to the session hash in the env. - # It defaults to 'rack.session'. - # - # :openid_param defines at what key in the request parameters to - # find the identifier to resolve. As per the 2.0 spec, the default is - # 'openid_identifier'. - # - # :store defined what OpenID Store to use for persistant - # information. By default a Store::Memory will be used. - # - # :immediate as true will make initial requests to be of an - # immediate type. This is false by default. See OpenID specification - # documentation. - # - # :extensions should be a hash of openid extension - # implementations. The key should be the extension main module, the value - # should be an array of arguments for extension::Request.new. - # The hash is iterated over and passed to #add_extension for processing. - # Please see #add_extension for further documentation. - # - # == Examples - # - # simple_oid = OpenID.new('http://mysite.com/') - # - # return_oid = OpenID.new('http://mysite.com/', { - # :return_to => 'http://mysite.com/openid' - # }) - # - # complex_oid = OpenID.new('http://mysite.com/', - # :immediate => true, - # :extensions => { - # ::OpenID::SReg => [['email'],['nickname']] - # } - # ) - # - # = Advanced - # - # Most of the functionality of this library is encapsulated such that - # expansion and overriding functions isn't difficult nor tricky. - # Alternately, to avoid opening up singleton objects or subclassing, a - # wrapper rack middleware can be composed to act upon Auth::OpenID's - # responses. See #check and #finish for locations of pertinent data. - # - # == Responses - # - # To change the responses that Auth::OpenID returns, override the methods - # #redirect, #bad_request, #unauthorized, #access_denied, and - # #foreign_server_failure. - # - # Additionally #confirm_post_params is used when the URI would exceed - # length limits on a GET request when doing the initial verification - # request. - # - # == Processing - # - # To change methods of processing completed transactions, override the - # methods #success, #setup_needed, #cancel, and #failure. Please ensure - # the returned object is a rack compatible response. - # - # The first argument is an OpenID::Response, the second is a - # Rack::Request of the current request, the last is the hash used in - # ruby-openid handling, which can be found manually at - # env['rack.session'][:openid]. - # - # This is useful if you wanted to expand the processing done, such as - # setting up user accounts. - # - # oid_app = Rack::Auth::OpenID.new realm, :return_to => return_to - # def oid_app.success oid, request, session - # user = Models::User[oid.identity_url] - # user ||= Models::User.create_from_openid oid - # request['rack.session'][:user] = user.id - # redirect MyApp.site_home - # end - # - # site_map['/openid'] = oid_app - # map = Rack::URLMap.new site_map - # ... - - def initialize(realm, options={}) - realm = URI(realm) - raise ArgumentError, "Invalid realm: #{realm}" \ - unless realm.absolute? \ - and realm.fragment.nil? \ - and realm.scheme =~ /^https?$/ \ - and realm.host =~ /^(\*\.)?#{URI::REGEXP::PATTERN::URIC_NO_SLASH}+/ - realm.path = '/' if realm.path.empty? - @realm = realm.to_s - - if ruri = options[:return_to] - ruri = URI(ruri) - raise ArgumentError, "Invalid return_to: #{ruri}" \ - unless ruri.absolute? \ - and ruri.scheme =~ /^https?$/ \ - and ruri.fragment.nil? - raise ArgumentError, "return_to #{ruri} not within realm #{realm}" \ - unless self.within_realm?(ruri) - @return_to = ruri.to_s - end - - @session_key = options[:session_key] || 'rack.session' - @openid_param = options[:openid_param] || 'openid_identifier' - @store = options[:store] || ::OpenID::Store::Memory.new - @immediate = !!options[:immediate] - - @extensions = {} - if extensions = options.delete(:extensions) - extensions.each do |ext, args| - add_extension ext, *args - end - end - - # Undocumented, semi-experimental - @anonymous = !!options[:anonymous] - end - - attr_reader :realm, :return_to, :session_key, :openid_param, :store, - :immediate, :extensions - - # Sets up and uses session data at :openid within the session. - # Errors in this setup will raise a NoSession exception. - # - # If the parameter 'openid.mode' is set, which implies a followup from - # the openid server, processing is passed to #finish and the result is - # returned. However, if there is no appropriate openid information in the - # session, a 400 error is returned. - # - # If the parameter specified by options[:openid_param] is - # present, processing is passed to #check and the result is returned. - # - # If neither of these conditions are met, #unauthorized is called. - - def call(env) - env['rack.auth.openid'] = self - env_session = env[@session_key] - unless env_session and env_session.is_a?(Hash) - raise NoSession, 'No compatible session' - end - # let us work in our own namespace... - session = (env_session[:openid] ||= {}) - unless session and session.is_a?(Hash) - raise NoSession, 'Incompatible openid session' - end - - request = Rack::Request.new(env) - consumer = ::OpenID::Consumer.new(session, @store) - - if mode = request.GET['openid.mode'] - if session.key?(:openid_param) - finish(consumer, session, request) - else - bad_request - end - elsif request.GET[@openid_param] - check(consumer, session, request) - else - unauthorized - end - end - - # As the first part of OpenID consumer action, #check retrieves the data - # required for completion. - # - # If all parameters fit within the max length of a URI, a 303 redirect - # will be returned. Otherwise #confirm_post_params will be called. - # - # Any messages from OpenID's request are logged to env['rack.errors'] - # - # env['rack.auth.openid.request'] is the openid checkid request - # instance. - # - # session[:openid_param] is set to the openid identifier - # provided by the user. - # - # session[:return_to] is set to the return_to uri given to the - # identity provider. - - def check(consumer, session, req) - oid = consumer.begin(req.GET[@openid_param], @anonymous) - req.env['rack.auth.openid.request'] = oid - req.env['rack.errors'].puts(oid.message) - p oid if $DEBUG - - ## Extension support - extensions.each do |ext,args| - oid.add_extension(ext::Request.new(*args)) - end - - session[:openid_param] = req.GET[openid_param] - return_to_uri = return_to ? return_to : req.url - session[:return_to] = return_to_uri - immediate = session.key?(:setup_needed) ? false : immediate - - if oid.send_redirect?(realm, return_to_uri, immediate) - uri = oid.redirect_url(realm, return_to_uri, immediate) - redirect(uri) - else - confirm_post_params(oid, realm, return_to_uri, immediate) - end - rescue ::OpenID::DiscoveryFailure => e - # thrown from inside OpenID::Consumer#begin by yadis stuff - req.env['rack.errors'].puts([e.message, *e.backtrace]*"\n") - return foreign_server_failure - end - - # This is the final portion of authentication. - # If successful, a redirect to the realm is be returned. - # Data gathered from extensions are stored in session[:openid] with the - # extension's namespace uri as the key. - # - # Any messages from OpenID's response are logged to env['rack.errors'] - # - # env['rack.auth.openid.response'] will contain the openid - # response. - - def finish(consumer, session, req) - oid = consumer.complete(req.GET, req.url) - req.env['rack.auth.openid.response'] = oid - req.env['rack.errors'].puts(oid.message) - p oid if $DEBUG - - raise unless ValidStatus.include?(oid.status) - __send__(oid.status, oid, req, session) - end - - # The first argument should be the main extension module. - # The extension module should contain the constants: - # * class Request, should have OpenID::Extension as an ancestor - # * class Response, should have OpenID::Extension as an ancestor - # * string NS_URI, which defining the namespace of the extension - # - # All trailing arguments will be passed to extension::Request.new in - # #check. - # The openid response will be passed to - # extension::Response#from_success_response, #get_extension_args will be - # called on the result to attain the gathered data. - # - # This method returns the key at which the response data will be found in - # the session, which is the namespace uri by default. - - def add_extension(ext, *args) - raise BadExtension unless valid_extension?(ext) - extensions[ext] = args - return ext::NS_URI - end - - # Checks the validitity, in the context of usage, of a submitted - # extension. - - def valid_extension?(ext) - if not %w[NS_URI Request Response].all?{|c| ext.const_defined?(c) } - raise ArgumentError, 'Extension is missing constants.' - elsif not ext::Response.respond_to?(:from_success_response) - raise ArgumentError, 'Response is missing required method.' - end - return true - rescue - return false - end - - # Checks the provided uri to ensure it'd be considered within the realm. - # is currently not compatible with wildcard realms. - - def within_realm? uri - uri = URI.parse(uri.to_s) - realm = URI.parse(self.realm) - return false unless uri.absolute? - return false unless uri.path[0, realm.path.size] == realm.path - return false unless uri.host == realm.host or realm.host[/^\*\./] - # for wildcard support, is awkward with URI limitations - realm_match = Regexp.escape(realm.host). - sub(/^\*\./,"^#{URI::REGEXP::PATTERN::URIC_NO_SLASH}+.")+'$' - return false unless uri.host.match(realm_match) - return true - end - alias_method :include?, :within_realm? - - protected - - ### These methods define some of the boilerplate responses. - - # Returns an html form page for posting to an Identity Provider if the - # GET request would exceed the upper URI length limit. - - def confirm_post_params(oid, realm, return_to, immediate) - Rack::Response.new.finish do |r| - r.write 'Confirm...' - r.write oid.form_markup(realm, return_to, immediate) - r.write '' - end - end - - # Returns a 303 redirect with the destination of that provided by the - # argument. - - def redirect(uri) - [ 303, {'Content-Length'=>'0', 'Content-Type'=>'text/plain', - 'Location' => uri}, - [] ] - end - - # Returns an empty 400 response. - - def bad_request - [ 400, {'Content-Type'=>'text/plain', 'Content-Length'=>'0'}, - [''] ] - end - - # Returns a basic unauthorized 401 response. - - def unauthorized - [ 401, {'Content-Type' => 'text/plain', 'Content-Length' => '13'}, - ['Unauthorized.'] ] - end - - # Returns a basic access denied 403 response. - - def access_denied - [ 403, {'Content-Type' => 'text/plain', 'Content-Length' => '14'}, - ['Access denied.'] ] - end - - # Returns a 503 response to be used if communication with the remote - # OpenID server fails. - - def foreign_server_failure - [ 503, {'Content-Type'=>'text/plain', 'Content-Length' => '23'}, - ['Foreign server failure.'] ] - end - - private - - ### These methods are called after a transaction is completed, depending - # on its outcome. These should all return a rack compatible response. - # You'd want to override these to provide additional functionality. - - # Called to complete processing on a successful transaction. - # Within the openid session, :openid_identity and :openid_identifier are - # set to the user friendly and the standard representation of the - # validated identity. All other data in the openid session is cleared. - - def success(oid, request, session) - session.clear - session[:openid_identity] = oid.display_identifier - session[:openid_identifier] = oid.identity_url - extensions.keys.each do |ext| - label = ext.name[/[^:]+$/].downcase - response = ext::Response.from_success_response(oid) - session[label] = response.data - end - redirect(realm) - end - - # Called if the Identity Provider indicates further setup by the user is - # required. - # The identifier is retrived from the openid session at :openid_param. - # And :setup_needed is set to true to prevent looping. - - def setup_needed(oid, request, session) - identifier = session[:openid_param] - session[:setup_needed] = true - redirect req.script_name + '?' + openid_param + '=' + identifier - end - - # Called if the user indicates they wish to cancel identification. - # Data within openid session is cleared. - - def cancel(oid, request, session) - session.clear - access_denied - end - - # Called if the Identity Provider indicates the user is unable to confirm - # their identity. Data within the openid session is left alone, in case - # of swarm auth attacks. - - def failure(oid, request, session) - unauthorized - end - end - - # A class developed out of the request to use OpenID as an authentication - # middleware. The request will be sent to the OpenID instance unless the - # block evaluates to true. For example in rackup, you can use it as such: - # - # use Rack::Session::Pool - # use Rack::Auth::OpenIDAuth, realm, openid_options do |env| - # env['rack.session'][:authkey] == a_string - # end - # run RackApp - # - # Or simply: - # - # app = Rack::Auth::OpenIDAuth.new app, realm, openid_options, &auth - - class OpenIDAuth < Rack::Auth::AbstractHandler - attr_reader :oid - def initialize(app, realm, options={}, &auth) - @oid = OpenID.new(realm, options) - super(app, &auth) - end - - def call(env) - to = auth.call(env) ? @app : @oid - to.call env - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/builder.rb b/vendor/gems/rack-1.0.1/lib/rack/builder.rb deleted file mode 100644 index 295235e5..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/builder.rb +++ /dev/null @@ -1,63 +0,0 @@ -module Rack - # Rack::Builder implements a small DSL to iteratively construct Rack - # applications. - # - # Example: - # - # app = Rack::Builder.new { - # use Rack::CommonLogger - # use Rack::ShowExceptions - # map "/lobster" do - # use Rack::Lint - # run Rack::Lobster.new - # end - # } - # - # Or - # - # app = Rack::Builder.app do - # use Rack::CommonLogger - # lambda { |env| [200, {'Content-Type' => 'text/plain'}, 'OK'] } - # end - # - # +use+ adds a middleware to the stack, +run+ dispatches to an application. - # You can use +map+ to construct a Rack::URLMap in a convenient way. - - class Builder - def initialize(&block) - @ins = [] - instance_eval(&block) if block_given? - end - - def self.app(&block) - self.new(&block).to_app - end - - def use(middleware, *args, &block) - @ins << lambda { |app| middleware.new(app, *args, &block) } - end - - def run(app) - @ins << app #lambda { |nothing| app } - end - - def map(path, &block) - if @ins.last.kind_of? Hash - @ins.last[path] = self.class.new(&block).to_app - else - @ins << {} - map(path, &block) - end - end - - def to_app - @ins[-1] = Rack::URLMap.new(@ins.last) if Hash === @ins.last - inner_app = @ins.last - @ins[0...-1].reverse.inject(inner_app) { |a, e| e.call(a) } - end - - def call(env) - to_app.call(env) - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/cascade.rb b/vendor/gems/rack-1.0.1/lib/rack/cascade.rb deleted file mode 100644 index a038aa11..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/cascade.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Rack - # Rack::Cascade tries an request on several apps, and returns the - # first response that is not 404 (or in a list of configurable - # status codes). - - class Cascade - attr_reader :apps - - def initialize(apps, catch=404) - @apps = apps - @catch = [*catch] - end - - def call(env) - status = headers = body = nil - raise ArgumentError, "empty cascade" if @apps.empty? - @apps.each { |app| - begin - status, headers, body = app.call(env) - break unless @catch.include?(status.to_i) - end - } - [status, headers, body] - end - - def add app - @apps << app - end - - def include? app - @apps.include? app - end - - alias_method :<<, :add - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/chunked.rb b/vendor/gems/rack-1.0.1/lib/rack/chunked.rb deleted file mode 100644 index 280d89dd..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/chunked.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'rack/utils' - -module Rack - - # Middleware that applies chunked transfer encoding to response bodies - # when the response does not include a Content-Length header. - class Chunked - include Rack::Utils - - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - headers = HeaderHash.new(headers) - - if env['HTTP_VERSION'] == 'HTTP/1.0' || - STATUS_WITH_NO_ENTITY_BODY.include?(status) || - headers['Content-Length'] || - headers['Transfer-Encoding'] - [status, headers.to_hash, body] - else - dup.chunk(status, headers, body) - end - end - - def chunk(status, headers, body) - @body = body - headers.delete('Content-Length') - headers['Transfer-Encoding'] = 'chunked' - [status, headers.to_hash, self] - end - - def each - term = "\r\n" - @body.each do |chunk| - size = bytesize(chunk) - next if size == 0 - yield [size.to_s(16), term, chunk, term].join - end - yield ["0", term, "", term].join - end - - def close - @body.close if @body.respond_to?(:close) - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/commonlogger.rb b/vendor/gems/rack-1.0.1/lib/rack/commonlogger.rb deleted file mode 100644 index 5e68ac62..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/commonlogger.rb +++ /dev/null @@ -1,61 +0,0 @@ -module Rack - # Rack::CommonLogger forwards every request to an +app+ given, and - # logs a line in the Apache common log format to the +logger+, or - # rack.errors by default. - - class CommonLogger - def initialize(app, logger=nil) - @app = app - @logger = logger - end - - def call(env) - dup._call(env) - end - - def _call(env) - @env = env - @logger ||= self - @time = Time.now - @status, @header, @body = @app.call(env) - [@status, @header, self] - end - - def close - @body.close if @body.respond_to? :close - end - - # By default, log to rack.errors. - def <<(str) - @env["rack.errors"].write(str) - @env["rack.errors"].flush - end - - def each - length = 0 - @body.each { |part| - length += part.size - yield part - } - - @now = Time.now - - # Common Log Format: http://httpd.apache.org/docs/1.3/logs.html#common - # lilith.local - - [07/Aug/2006 23:58:02] "GET / HTTP/1.1" 500 - - # %{%s - %s [%s] "%s %s%s %s" %d %s\n} % - @logger << %{%s - %s [%s] "%s %s%s %s" %d %s %0.4f\n} % - [ - @env['HTTP_X_FORWARDED_FOR'] || @env["REMOTE_ADDR"] || "-", - @env["REMOTE_USER"] || "-", - @now.strftime("%d/%b/%Y %H:%M:%S"), - @env["REQUEST_METHOD"], - @env["PATH_INFO"], - @env["QUERY_STRING"].empty? ? "" : "?"+@env["QUERY_STRING"], - @env["HTTP_VERSION"], - @status.to_s[0..3], - (length.zero? ? "-" : length.to_s), - @now - @time - ] - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/conditionalget.rb b/vendor/gems/rack-1.0.1/lib/rack/conditionalget.rb deleted file mode 100644 index 046ebdb0..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/conditionalget.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'rack/utils' - -module Rack - - # Middleware that enables conditional GET using If-None-Match and - # If-Modified-Since. The application should set either or both of the - # Last-Modified or Etag response headers according to RFC 2616. When - # either of the conditions is met, the response body is set to be zero - # length and the response status is set to 304 Not Modified. - # - # Applications that defer response body generation until the body's each - # message is received will avoid response body generation completely when - # a conditional GET matches. - # - # Adapted from Michael Klishin's Merb implementation: - # http://github.com/wycats/merb-core/tree/master/lib/merb-core/rack/middleware/conditional_get.rb - class ConditionalGet - def initialize(app) - @app = app - end - - def call(env) - return @app.call(env) unless %w[GET HEAD].include?(env['REQUEST_METHOD']) - - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - if etag_matches?(env, headers) || modified_since?(env, headers) - status = 304 - headers.delete('Content-Type') - headers.delete('Content-Length') - body = [] - end - [status, headers, body] - end - - private - def etag_matches?(env, headers) - etag = headers['Etag'] and etag == env['HTTP_IF_NONE_MATCH'] - end - - def modified_since?(env, headers) - last_modified = headers['Last-Modified'] and - last_modified == env['HTTP_IF_MODIFIED_SINCE'] - end - end - -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/content_length.rb b/vendor/gems/rack-1.0.1/lib/rack/content_length.rb deleted file mode 100644 index 1e56d438..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/content_length.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'rack/utils' - -module Rack - # Sets the Content-Length header on responses with fixed-length bodies. - class ContentLength - include Rack::Utils - - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - headers = HeaderHash.new(headers) - - if !STATUS_WITH_NO_ENTITY_BODY.include?(status) && - !headers['Content-Length'] && - !headers['Transfer-Encoding'] && - (body.respond_to?(:to_ary) || body.respond_to?(:to_str)) - - body = [body] if body.respond_to?(:to_str) # rack 0.4 compat - length = body.to_ary.inject(0) { |len, part| len + bytesize(part) } - headers['Content-Length'] = length.to_s - end - - [status, headers, body] - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/content_type.rb b/vendor/gems/rack-1.0.1/lib/rack/content_type.rb deleted file mode 100644 index 0c1e1ca3..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/content_type.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rack/utils' - -module Rack - - # Sets the Content-Type header on responses which don't have one. - # - # Builder Usage: - # use Rack::ContentType, "text/plain" - # - # When no content type argument is provided, "text/html" is assumed. - class ContentType - def initialize(app, content_type = "text/html") - @app, @content_type = app, content_type - end - - def call(env) - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - headers['Content-Type'] ||= @content_type - [status, headers.to_hash, body] - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/deflater.rb b/vendor/gems/rack-1.0.1/lib/rack/deflater.rb deleted file mode 100644 index ad0f5316..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/deflater.rb +++ /dev/null @@ -1,96 +0,0 @@ -require "zlib" -require "stringio" -require "time" # for Time.httpdate -require 'rack/utils' - -module Rack - class Deflater - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - - # Skip compressing empty entity body responses and responses with - # no-transform set. - if Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status) || - headers['Cache-Control'].to_s =~ /\bno-transform\b/ - return [status, headers, body] - end - - request = Request.new(env) - - encoding = Utils.select_best_encoding(%w(gzip deflate identity), - request.accept_encoding) - - # Set the Vary HTTP header. - vary = headers["Vary"].to_s.split(",").map { |v| v.strip } - unless vary.include?("*") || vary.include?("Accept-Encoding") - headers["Vary"] = vary.push("Accept-Encoding").join(",") - end - - case encoding - when "gzip" - headers['Content-Encoding'] = "gzip" - headers.delete('Content-Length') - mtime = headers.key?("Last-Modified") ? - Time.httpdate(headers["Last-Modified"]) : Time.now - [status, headers, GzipStream.new(body, mtime)] - when "deflate" - headers['Content-Encoding'] = "deflate" - headers.delete('Content-Length') - [status, headers, DeflateStream.new(body)] - when "identity" - [status, headers, body] - when nil - message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found." - [406, {"Content-Type" => "text/plain", "Content-Length" => message.length.to_s}, [message]] - end - end - - class GzipStream - def initialize(body, mtime) - @body = body - @mtime = mtime - end - - def each(&block) - @writer = block - gzip =::Zlib::GzipWriter.new(self) - gzip.mtime = @mtime - @body.each { |part| gzip.write(part) } - @body.close if @body.respond_to?(:close) - gzip.close - @writer = nil - end - - def write(data) - @writer.call(data) - end - end - - class DeflateStream - DEFLATE_ARGS = [ - Zlib::DEFAULT_COMPRESSION, - # drop the zlib header which causes both Safari and IE to choke - -Zlib::MAX_WBITS, - Zlib::DEF_MEM_LEVEL, - Zlib::DEFAULT_STRATEGY - ] - - def initialize(body) - @body = body - end - - def each - deflater = ::Zlib::Deflate.new(*DEFLATE_ARGS) - @body.each { |part| yield deflater.deflate(part) } - @body.close if @body.respond_to?(:close) - yield deflater.finish - nil - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/directory.rb b/vendor/gems/rack-1.0.1/lib/rack/directory.rb deleted file mode 100644 index acdd3029..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/directory.rb +++ /dev/null @@ -1,153 +0,0 @@ -require 'time' -require 'rack/utils' -require 'rack/mime' - -module Rack - # Rack::Directory serves entries below the +root+ given, according to the - # path info of the Rack request. If a directory is found, the file's contents - # will be presented in an html based index. If a file is found, the env will - # be passed to the specified +app+. - # - # If +app+ is not specified, a Rack::File of the same +root+ will be used. - - class Directory - DIR_FILE = "%s%s%s%s" - DIR_PAGE = <<-PAGE - - %s - - - -

%s

-
- - - - - - - -%s -
NameSizeTypeLast Modified
-
- - PAGE - - attr_reader :files - attr_accessor :root, :path - - def initialize(root, app=nil) - @root = F.expand_path(root) - @app = app || Rack::File.new(@root) - end - - def call(env) - dup._call(env) - end - - F = ::File - - def _call(env) - @env = env - @script_name = env['SCRIPT_NAME'] - @path_info = Utils.unescape(env['PATH_INFO']) - - if forbidden = check_forbidden - forbidden - else - @path = F.join(@root, @path_info) - list_path - end - end - - def check_forbidden - return unless @path_info.include? ".." - - body = "Forbidden\n" - size = Rack::Utils.bytesize(body) - return [403, {"Content-Type" => "text/plain","Content-Length" => size.to_s}, [body]] - end - - def list_directory - @files = [['../','Parent Directory','','','']] - glob = F.join(@path, '*') - - Dir[glob].sort.each do |node| - stat = stat(node) - next unless stat - basename = F.basename(node) - ext = F.extname(node) - - url = F.join(@script_name, @path_info, basename) - size = stat.size - type = stat.directory? ? 'directory' : Mime.mime_type(ext) - size = stat.directory? ? '-' : filesize_format(size) - mtime = stat.mtime.httpdate - url << '/' if stat.directory? - basename << '/' if stat.directory? - - @files << [ url, basename, size, type, mtime ] - end - - return [ 200, {'Content-Type'=>'text/html; charset=utf-8'}, self ] - end - - def stat(node, max = 10) - F.stat(node) - rescue Errno::ENOENT, Errno::ELOOP - return nil - end - - # TODO: add correct response if not readable, not sure if 404 is the best - # option - def list_path - @stat = F.stat(@path) - - if @stat.readable? - return @app.call(@env) if @stat.file? - return list_directory if @stat.directory? - else - raise Errno::ENOENT, 'No such file or directory' - end - - rescue Errno::ENOENT, Errno::ELOOP - return entity_not_found - end - - def entity_not_found - body = "Entity not found: #{@path_info}\n" - size = Rack::Utils.bytesize(body) - return [404, {"Content-Type" => "text/plain", "Content-Length" => size.to_s}, [body]] - end - - def each - show_path = @path.sub(/^#{@root}/,'') - files = @files.map{|f| DIR_FILE % f }*"\n" - page = DIR_PAGE % [ show_path, show_path , files ] - page.each_line{|l| yield l } - end - - # Stolen from Ramaze - - FILESIZE_FORMAT = [ - ['%.1fT', 1 << 40], - ['%.1fG', 1 << 30], - ['%.1fM', 1 << 20], - ['%.1fK', 1 << 10], - ] - - def filesize_format(int) - FILESIZE_FORMAT.each do |format, size| - return format % (int.to_f / size) if int >= size - end - - int.to_s + 'B' - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/file.rb b/vendor/gems/rack-1.0.1/lib/rack/file.rb deleted file mode 100644 index fe62bd6b..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/file.rb +++ /dev/null @@ -1,88 +0,0 @@ -require 'time' -require 'rack/utils' -require 'rack/mime' - -module Rack - # Rack::File serves files below the +root+ given, according to the - # path info of the Rack request. - # - # Handlers can detect if bodies are a Rack::File, and use mechanisms - # like sendfile on the +path+. - - class File - attr_accessor :root - attr_accessor :path - - alias :to_path :path - - def initialize(root) - @root = root - end - - def call(env) - dup._call(env) - end - - F = ::File - - def _call(env) - @path_info = Utils.unescape(env["PATH_INFO"]) - return forbidden if @path_info.include? ".." - - @path = F.join(@root, @path_info) - - begin - if F.file?(@path) && F.readable?(@path) - serving - else - raise Errno::EPERM - end - rescue SystemCallError - not_found - end - end - - def forbidden - body = "Forbidden\n" - [403, {"Content-Type" => "text/plain", - "Content-Length" => body.size.to_s}, - [body]] - end - - # NOTE: - # We check via File::size? whether this file provides size info - # via stat (e.g. /proc files often don't), otherwise we have to - # figure it out by reading the whole file into memory. And while - # we're at it we also use this as body then. - - def serving - if size = F.size?(@path) - body = self - else - body = [F.read(@path)] - size = Utils.bytesize(body.first) - end - - [200, { - "Last-Modified" => F.mtime(@path).httpdate, - "Content-Type" => Mime.mime_type(F.extname(@path), 'text/plain'), - "Content-Length" => size.to_s - }, body] - end - - def not_found - body = "File not found: #{@path_info}\n" - [404, {"Content-Type" => "text/plain", - "Content-Length" => body.size.to_s}, - [body]] - end - - def each - F.open(@path, "rb") { |file| - while part = file.read(8192) - yield part - end - } - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler.rb b/vendor/gems/rack-1.0.1/lib/rack/handler.rb deleted file mode 100644 index 5624a1e7..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler.rb +++ /dev/null @@ -1,69 +0,0 @@ -module Rack - # *Handlers* connect web servers with Rack. - # - # Rack includes Handlers for Mongrel, WEBrick, FastCGI, CGI, SCGI - # and LiteSpeed. - # - # Handlers usually are activated by calling MyHandler.run(myapp). - # A second optional hash can be passed to include server-specific - # configuration. - module Handler - def self.get(server) - return unless server - server = server.to_s - - if klass = @handlers[server] - obj = Object - klass.split("::").each { |x| obj = obj.const_get(x) } - obj - else - try_require('rack/handler', server) - const_get(server) - end - end - - # Transforms server-name constants to their canonical form as filenames, - # then tries to require them but silences the LoadError if not found - # - # Naming convention: - # - # Foo # => 'foo' - # FooBar # => 'foo_bar.rb' - # FooBAR # => 'foobar.rb' - # FOObar # => 'foobar.rb' - # FOOBAR # => 'foobar.rb' - # FooBarBaz # => 'foo_bar_baz.rb' - def self.try_require(prefix, const_name) - file = const_name.gsub(/^[A-Z]+/) { |pre| pre.downcase }. - gsub(/[A-Z]+[^A-Z]/, '_\&').downcase - - require(::File.join(prefix, file)) - rescue LoadError - end - - def self.register(server, klass) - @handlers ||= {} - @handlers[server] = klass - end - - autoload :CGI, "rack/handler/cgi" - autoload :FastCGI, "rack/handler/fastcgi" - autoload :Mongrel, "rack/handler/mongrel" - autoload :EventedMongrel, "rack/handler/evented_mongrel" - autoload :SwiftipliedMongrel, "rack/handler/swiftiplied_mongrel" - autoload :WEBrick, "rack/handler/webrick" - autoload :LSWS, "rack/handler/lsws" - autoload :SCGI, "rack/handler/scgi" - autoload :Thin, "rack/handler/thin" - - register 'cgi', 'Rack::Handler::CGI' - register 'fastcgi', 'Rack::Handler::FastCGI' - register 'mongrel', 'Rack::Handler::Mongrel' - register 'emongrel', 'Rack::Handler::EventedMongrel' - register 'smongrel', 'Rack::Handler::SwiftipliedMongrel' - register 'webrick', 'Rack::Handler::WEBrick' - register 'lsws', 'Rack::Handler::LSWS' - register 'scgi', 'Rack::Handler::SCGI' - register 'thin', 'Rack::Handler::Thin' - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/cgi.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/cgi.rb deleted file mode 100644 index f45f3d73..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/cgi.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'rack/content_length' - -module Rack - module Handler - class CGI - def self.run(app, options=nil) - serve app - end - - def self.serve(app) - app = ContentLength.new(app) - - env = ENV.to_hash - env.delete "HTTP_CONTENT_LENGTH" - - env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" - - env.update({"rack.version" => [1,0], - "rack.input" => $stdin, - "rack.errors" => $stderr, - - "rack.multithread" => false, - "rack.multiprocess" => true, - "rack.run_once" => true, - - "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http" - }) - - env["QUERY_STRING"] ||= "" - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["REQUEST_PATH"] ||= "/" - - status, headers, body = app.call(env) - begin - send_headers status, headers - send_body body - ensure - body.close if body.respond_to? :close - end - end - - def self.send_headers(status, headers) - STDOUT.print "Status: #{status}\r\n" - headers.each { |k, vs| - vs.split("\n").each { |v| - STDOUT.print "#{k}: #{v}\r\n" - } - } - STDOUT.print "\r\n" - STDOUT.flush - end - - def self.send_body(body) - body.each { |part| - STDOUT.print part - STDOUT.flush - } - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/evented_mongrel.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/evented_mongrel.rb deleted file mode 100644 index 0f5cbf72..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/evented_mongrel.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'swiftcore/evented_mongrel' - -module Rack - module Handler - class EventedMongrel < Handler::Mongrel - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/fastcgi.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/fastcgi.rb deleted file mode 100644 index 1739d659..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/fastcgi.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'fcgi' -require 'socket' -require 'rack/content_length' -require 'rack/rewindable_input' - -if defined? FCGI::Stream - class FCGI::Stream - alias _rack_read_without_buffer read - - def read(n, buffer=nil) - buf = _rack_read_without_buffer n - buffer.replace(buf.to_s) if buffer - buf - end - end -end - -module Rack - module Handler - class FastCGI - def self.run(app, options={}) - file = options[:File] and STDIN.reopen(UNIXServer.new(file)) - port = options[:Port] and STDIN.reopen(TCPServer.new(port)) - FCGI.each { |request| - serve request, app - } - end - - def self.serve(request, app) - app = Rack::ContentLength.new(app) - - env = request.env - env.delete "HTTP_CONTENT_LENGTH" - - env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" - - rack_input = RewindableInput.new(request.in) - - env.update({"rack.version" => [1,0], - "rack.input" => rack_input, - "rack.errors" => request.err, - - "rack.multithread" => false, - "rack.multiprocess" => true, - "rack.run_once" => false, - - "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http" - }) - - env["QUERY_STRING"] ||= "" - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["REQUEST_PATH"] ||= "/" - env.delete "PATH_INFO" if env["PATH_INFO"] == "" - env.delete "CONTENT_TYPE" if env["CONTENT_TYPE"] == "" - env.delete "CONTENT_LENGTH" if env["CONTENT_LENGTH"] == "" - - begin - status, headers, body = app.call(env) - begin - send_headers request.out, status, headers - send_body request.out, body - ensure - body.close if body.respond_to? :close - end - ensure - rack_input.close - request.finish - end - end - - def self.send_headers(out, status, headers) - out.print "Status: #{status}\r\n" - headers.each { |k, vs| - vs.split("\n").each { |v| - out.print "#{k}: #{v}\r\n" - } - } - out.print "\r\n" - out.flush - end - - def self.send_body(out, body) - body.each { |part| - out.print part - out.flush - } - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/lsws.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/lsws.rb deleted file mode 100644 index b4ddf4bb..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/lsws.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'lsapi' -require 'rack/content_length' - -module Rack - module Handler - class LSWS - def self.run(app, options=nil) - while LSAPI.accept != nil - serve app - end - end - def self.serve(app) - app = Rack::ContentLength.new(app) - - env = ENV.to_hash - env.delete "HTTP_CONTENT_LENGTH" - env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" - - rack_input = RewindableInput.new($stdin.read.to_s) - - env.update( - "rack.version" => [1,0], - "rack.input" => rack_input, - "rack.errors" => $stderr, - "rack.multithread" => false, - "rack.multiprocess" => true, - "rack.run_once" => false, - "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http" - ) - - env["QUERY_STRING"] ||= "" - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["REQUEST_PATH"] ||= "/" - status, headers, body = app.call(env) - begin - send_headers status, headers - send_body body - ensure - body.close if body.respond_to? :close - end - end - def self.send_headers(status, headers) - print "Status: #{status}\r\n" - headers.each { |k, vs| - vs.split("\n").each { |v| - print "#{k}: #{v}\r\n" - } - } - print "\r\n" - STDOUT.flush - end - def self.send_body(body) - body.each { |part| - print part - STDOUT.flush - } - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/mongrel.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/mongrel.rb deleted file mode 100644 index 7b448261..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/mongrel.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'mongrel' -require 'stringio' -require 'rack/content_length' -require 'rack/chunked' - -module Rack - module Handler - class Mongrel < ::Mongrel::HttpHandler - def self.run(app, options={}) - server = ::Mongrel::HttpServer.new(options[:Host] || '0.0.0.0', - options[:Port] || 8080) - # Acts like Rack::URLMap, utilizing Mongrel's own path finding methods. - # Use is similar to #run, replacing the app argument with a hash of - # { path=>app, ... } or an instance of Rack::URLMap. - if options[:map] - if app.is_a? Hash - app.each do |path, appl| - path = '/'+path unless path[0] == ?/ - server.register(path, Rack::Handler::Mongrel.new(appl)) - end - elsif app.is_a? URLMap - app.instance_variable_get(:@mapping).each do |(host, path, appl)| - next if !host.nil? && !options[:Host].nil? && options[:Host] != host - path = '/'+path unless path[0] == ?/ - server.register(path, Rack::Handler::Mongrel.new(appl)) - end - else - raise ArgumentError, "first argument should be a Hash or URLMap" - end - else - server.register('/', Rack::Handler::Mongrel.new(app)) - end - yield server if block_given? - server.run.join - end - - def initialize(app) - @app = Rack::Chunked.new(Rack::ContentLength.new(app)) - end - - def process(request, response) - env = {}.replace(request.params) - env.delete "HTTP_CONTENT_TYPE" - env.delete "HTTP_CONTENT_LENGTH" - - env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/" - - rack_input = request.body || StringIO.new('') - rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) - - env.update({"rack.version" => [1,0], - "rack.input" => rack_input, - "rack.errors" => $stderr, - - "rack.multithread" => true, - "rack.multiprocess" => false, # ??? - "rack.run_once" => false, - - "rack.url_scheme" => "http", - }) - env["QUERY_STRING"] ||= "" - env.delete "PATH_INFO" if env["PATH_INFO"] == "" - - status, headers, body = @app.call(env) - - begin - response.status = status.to_i - response.send_status(nil) - - headers.each { |k, vs| - vs.split("\n").each { |v| - response.header[k] = v - } - } - response.send_header - - body.each { |part| - response.write part - response.socket.flush - } - ensure - body.close if body.respond_to? :close - end - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/scgi.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/scgi.rb deleted file mode 100644 index bd860a5d..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/scgi.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'scgi' -require 'stringio' -require 'rack/content_length' -require 'rack/chunked' - -module Rack - module Handler - class SCGI < ::SCGI::Processor - attr_accessor :app - - def self.run(app, options=nil) - new(options.merge(:app=>app, - :host=>options[:Host], - :port=>options[:Port], - :socket=>options[:Socket])).listen - end - - def initialize(settings = {}) - @app = Rack::Chunked.new(Rack::ContentLength.new(settings[:app])) - @log = Object.new - def @log.info(*args); end - def @log.error(*args); end - super(settings) - end - - def process_request(request, input_body, socket) - env = {}.replace(request) - env.delete "HTTP_CONTENT_TYPE" - env.delete "HTTP_CONTENT_LENGTH" - env["REQUEST_PATH"], env["QUERY_STRING"] = env["REQUEST_URI"].split('?', 2) - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["PATH_INFO"] = env["REQUEST_PATH"] - env["QUERY_STRING"] ||= "" - env["SCRIPT_NAME"] = "" - - rack_input = StringIO.new(input_body) - rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) - - env.update({"rack.version" => [1,0], - "rack.input" => rack_input, - "rack.errors" => $stderr, - "rack.multithread" => true, - "rack.multiprocess" => true, - "rack.run_once" => false, - - "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http" - }) - status, headers, body = app.call(env) - begin - socket.write("Status: #{status}\r\n") - headers.each do |k, vs| - vs.split("\n").each { |v| socket.write("#{k}: #{v}\r\n")} - end - socket.write("\r\n") - body.each {|s| socket.write(s)} - ensure - body.close if body.respond_to? :close - end - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/swiftiplied_mongrel.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/swiftiplied_mongrel.rb deleted file mode 100644 index 4bafd0b9..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/swiftiplied_mongrel.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'swiftcore/swiftiplied_mongrel' - -module Rack - module Handler - class SwiftipliedMongrel < Handler::Mongrel - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/thin.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/thin.rb deleted file mode 100644 index 3d4fedff..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/thin.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "thin" -require "rack/content_length" -require "rack/chunked" - -module Rack - module Handler - class Thin - def self.run(app, options={}) - app = Rack::Chunked.new(Rack::ContentLength.new(app)) - server = ::Thin::Server.new(options[:Host] || '0.0.0.0', - options[:Port] || 8080, - app) - yield server if block_given? - server.start - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/handler/webrick.rb b/vendor/gems/rack-1.0.1/lib/rack/handler/webrick.rb deleted file mode 100644 index 5b9ae740..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/handler/webrick.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'webrick' -require 'stringio' -require 'rack/content_length' - -module Rack - module Handler - class WEBrick < ::WEBrick::HTTPServlet::AbstractServlet - def self.run(app, options={}) - options[:BindAddress] = options.delete(:Host) if options[:Host] - server = ::WEBrick::HTTPServer.new(options) - server.mount "/", Rack::Handler::WEBrick, app - trap(:INT) { server.shutdown } - yield server if block_given? - server.start - end - - def initialize(server, app) - super server - @app = Rack::ContentLength.new(app) - end - - def service(req, res) - env = req.meta_vars - env.delete_if { |k, v| v.nil? } - - rack_input = StringIO.new(req.body.to_s) - rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) - - env.update({"rack.version" => [1,0], - "rack.input" => rack_input, - "rack.errors" => $stderr, - - "rack.multithread" => true, - "rack.multiprocess" => false, - "rack.run_once" => false, - - "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http" - }) - - env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] - env["QUERY_STRING"] ||= "" - env["REQUEST_PATH"] ||= "/" - if env["PATH_INFO"] == "" - env.delete "PATH_INFO" - else - path, n = req.request_uri.path, env["SCRIPT_NAME"].length - env["PATH_INFO"] = path[n, path.length-n] - end - - status, headers, body = @app.call(env) - begin - res.status = status.to_i - headers.each { |k, vs| - if k.downcase == "set-cookie" - res.cookies.concat vs.split("\n") - else - vs.split("\n").each { |v| - res[k] = v - } - end - } - body.each { |part| - res.body << part - } - ensure - body.close if body.respond_to? :close - end - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/head.rb b/vendor/gems/rack-1.0.1/lib/rack/head.rb deleted file mode 100644 index deab822a..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/head.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Rack - -class Head - def initialize(app) - @app = app - end - - def call(env) - status, headers, body = @app.call(env) - - if env["REQUEST_METHOD"] == "HEAD" - [status, headers, []] - else - [status, headers, body] - end - end -end - -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/lint.rb b/vendor/gems/rack-1.0.1/lib/rack/lint.rb deleted file mode 100644 index 796807a0..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/lint.rb +++ /dev/null @@ -1,546 +0,0 @@ -require 'rack/utils' - -module Rack - # Rack::Lint validates your application and the requests and - # responses according to the Rack spec. - - class Lint - def initialize(app) - @app = app - end - - # :stopdoc: - - class LintError < RuntimeError; end - module Assertion - def assert(message, &block) - unless block.call - raise LintError, message - end - end - end - include Assertion - - ## This specification aims to formalize the Rack protocol. You - ## can (and should) use Rack::Lint to enforce it. - ## - ## When you develop middleware, be sure to add a Lint before and - ## after to catch all mistakes. - - ## = Rack applications - - ## A Rack application is an Ruby object (not a class) that - ## responds to +call+. - def call(env=nil) - dup._call(env) - end - - def _call(env) - ## It takes exactly one argument, the *environment* - assert("No env given") { env } - check_env env - - env['rack.input'] = InputWrapper.new(env['rack.input']) - env['rack.errors'] = ErrorWrapper.new(env['rack.errors']) - - ## and returns an Array of exactly three values: - status, headers, @body = @app.call(env) - ## The *status*, - check_status status - ## the *headers*, - check_headers headers - ## and the *body*. - check_content_type status, headers - check_content_length status, headers, env - [status, headers, self] - end - - ## == The Environment - def check_env(env) - ## The environment must be an true instance of Hash (no - ## subclassing allowed) that includes CGI-like headers. - ## The application is free to modify the environment. - assert("env #{env.inspect} is not a Hash, but #{env.class}") { - env.instance_of? Hash - } - - ## - ## The environment is required to include these variables - ## (adopted from PEP333), except when they'd be empty, but see - ## below. - - ## REQUEST_METHOD:: The HTTP request method, such as - ## "GET" or "POST". This cannot ever - ## be an empty string, and so is - ## always required. - - ## SCRIPT_NAME:: The initial portion of the request - ## URL's "path" that corresponds to the - ## application object, so that the - ## application knows its virtual - ## "location". This may be an empty - ## string, if the application corresponds - ## to the "root" of the server. - - ## PATH_INFO:: The remainder of the request URL's - ## "path", designating the virtual - ## "location" of the request's target - ## within the application. This may be an - ## empty string, if the request URL targets - ## the application root and does not have a - ## trailing slash. This value may be - ## percent-encoded when I originating from - ## a URL. - - ## QUERY_STRING:: The portion of the request URL that - ## follows the ?, if any. May be - ## empty, but is always required! - - ## SERVER_NAME, SERVER_PORT:: When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL. Note, however, that HTTP_HOST, if present, should be used in preference to SERVER_NAME for reconstructing the request URL. SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required. - - ## HTTP_ Variables:: Variables corresponding to the - ## client-supplied HTTP request - ## headers (i.e., variables whose - ## names begin with HTTP_). The - ## presence or absence of these - ## variables should correspond with - ## the presence or absence of the - ## appropriate HTTP header in the - ## request. - - ## In addition to this, the Rack environment must include these - ## Rack-specific variables: - - ## rack.version:: The Array [1,0], representing this version of Rack. - ## rack.url_scheme:: +http+ or +https+, depending on the request URL. - ## rack.input:: See below, the input stream. - ## rack.errors:: See below, the error stream. - ## rack.multithread:: true if the application object may be simultaneously invoked by another thread in the same process, false otherwise. - ## rack.multiprocess:: true if an equivalent application object may be simultaneously invoked by another process, false otherwise. - ## rack.run_once:: true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar). - ## - - ## Additional environment specifications have approved to - ## standardized middleware APIs. None of these are required to - ## be implemented by the server. - - ## rack.session:: A hash like interface for storing request session data. - ## The store must implement: - if session = env['rack.session'] - ## store(key, value) (aliased as []=); - assert("session #{session.inspect} must respond to store and []=") { - session.respond_to?(:store) && session.respond_to?(:[]=) - } - - ## fetch(key, default = nil) (aliased as []); - assert("session #{session.inspect} must respond to fetch and []") { - session.respond_to?(:fetch) && session.respond_to?(:[]) - } - - ## delete(key); - assert("session #{session.inspect} must respond to delete") { - session.respond_to?(:delete) - } - - ## clear; - assert("session #{session.inspect} must respond to clear") { - session.respond_to?(:clear) - } - end - - ## The server or the application can store their own data in the - ## environment, too. The keys must contain at least one dot, - ## and should be prefixed uniquely. The prefix rack. - ## is reserved for use with the Rack core distribution and other - ## accepted specifications and must not be used otherwise. - ## - - %w[REQUEST_METHOD SERVER_NAME SERVER_PORT - QUERY_STRING - rack.version rack.input rack.errors - rack.multithread rack.multiprocess rack.run_once].each { |header| - assert("env missing required key #{header}") { env.include? header } - } - - ## The environment must not contain the keys - ## HTTP_CONTENT_TYPE or HTTP_CONTENT_LENGTH - ## (use the versions without HTTP_). - %w[HTTP_CONTENT_TYPE HTTP_CONTENT_LENGTH].each { |header| - assert("env contains #{header}, must use #{header[5,-1]}") { - not env.include? header - } - } - - ## The CGI keys (named without a period) must have String values. - env.each { |key, value| - next if key.include? "." # Skip extensions - assert("env variable #{key} has non-string value #{value.inspect}") { - value.instance_of? String - } - } - - ## - ## There are the following restrictions: - - ## * rack.version must be an array of Integers. - assert("rack.version must be an Array, was #{env["rack.version"].class}") { - env["rack.version"].instance_of? Array - } - ## * rack.url_scheme must either be +http+ or +https+. - assert("rack.url_scheme unknown: #{env["rack.url_scheme"].inspect}") { - %w[http https].include? env["rack.url_scheme"] - } - - ## * There must be a valid input stream in rack.input. - check_input env["rack.input"] - ## * There must be a valid error stream in rack.errors. - check_error env["rack.errors"] - - ## * The REQUEST_METHOD must be a valid token. - assert("REQUEST_METHOD unknown: #{env["REQUEST_METHOD"]}") { - env["REQUEST_METHOD"] =~ /\A[0-9A-Za-z!\#$%&'*+.^_`|~-]+\z/ - } - - ## * The SCRIPT_NAME, if non-empty, must start with / - assert("SCRIPT_NAME must start with /") { - !env.include?("SCRIPT_NAME") || - env["SCRIPT_NAME"] == "" || - env["SCRIPT_NAME"] =~ /\A\// - } - ## * The PATH_INFO, if non-empty, must start with / - assert("PATH_INFO must start with /") { - !env.include?("PATH_INFO") || - env["PATH_INFO"] == "" || - env["PATH_INFO"] =~ /\A\// - } - ## * The CONTENT_LENGTH, if given, must consist of digits only. - assert("Invalid CONTENT_LENGTH: #{env["CONTENT_LENGTH"]}") { - !env.include?("CONTENT_LENGTH") || env["CONTENT_LENGTH"] =~ /\A\d+\z/ - } - - ## * One of SCRIPT_NAME or PATH_INFO must be - ## set. PATH_INFO should be / if - ## SCRIPT_NAME is empty. - assert("One of SCRIPT_NAME or PATH_INFO must be set (make PATH_INFO '/' if SCRIPT_NAME is empty)") { - env["SCRIPT_NAME"] || env["PATH_INFO"] - } - ## SCRIPT_NAME never should be /, but instead be empty. - assert("SCRIPT_NAME cannot be '/', make it '' and PATH_INFO '/'") { - env["SCRIPT_NAME"] != "/" - } - end - - ## === The Input Stream - ## - ## The input stream is an IO-like object which contains the raw HTTP - ## POST data. - def check_input(input) - ## When applicable, its external encoding must be "ASCII-8BIT" and it - ## must be opened in binary mode, for Ruby 1.9 compatibility. - assert("rack.input #{input} does not have ASCII-8BIT as its external encoding") { - input.external_encoding.name == "ASCII-8BIT" - } if input.respond_to?(:external_encoding) - assert("rack.input #{input} is not opened in binary mode") { - input.binmode? - } if input.respond_to?(:binmode?) - - ## The input stream must respond to +gets+, +each+, +read+ and +rewind+. - [:gets, :each, :read, :rewind].each { |method| - assert("rack.input #{input} does not respond to ##{method}") { - input.respond_to? method - } - } - end - - class InputWrapper - include Assertion - - def initialize(input) - @input = input - end - - def size - @input.size - end - - ## * +gets+ must be called without arguments and return a string, - ## or +nil+ on EOF. - def gets(*args) - assert("rack.input#gets called with arguments") { args.size == 0 } - v = @input.gets - assert("rack.input#gets didn't return a String") { - v.nil? or v.instance_of? String - } - v - end - - ## * +read+ behaves like IO#read. Its signature is read([length, [buffer]]). - ## If given, +length+ must be an non-negative Integer (>= 0) or +nil+, and +buffer+ must - ## be a String and may not be nil. If +length+ is given and not nil, then this method - ## reads at most +length+ bytes from the input stream. If +length+ is not given or nil, - ## then this method reads all data until EOF. - ## When EOF is reached, this method returns nil if +length+ is given and not nil, or "" - ## if +length+ is not given or is nil. - ## If +buffer+ is given, then the read data will be placed into +buffer+ instead of a - ## newly created String object. - def read(*args) - assert("rack.input#read called with too many arguments") { - args.size <= 2 - } - if args.size >= 1 - assert("rack.input#read called with non-integer and non-nil length") { - args.first.kind_of?(Integer) || args.first.nil? - } - assert("rack.input#read called with a negative length") { - args.first.nil? || args.first >= 0 - } - end - if args.size >= 2 - assert("rack.input#read called with non-String buffer") { - args[1].kind_of?(String) - } - end - - v = @input.read(*args) - - assert("rack.input#read didn't return nil or a String") { - v.nil? or v.instance_of? String - } - if args[0].nil? - assert("rack.input#read(nil) returned nil on EOF") { - !v.nil? - } - end - - v - end - - ## * +each+ must be called without arguments and only yield Strings. - def each(*args) - assert("rack.input#each called with arguments") { args.size == 0 } - @input.each { |line| - assert("rack.input#each didn't yield a String") { - line.instance_of? String - } - yield line - } - end - - ## * +rewind+ must be called without arguments. It rewinds the input - ## stream back to the beginning. It must not raise Errno::ESPIPE: - ## that is, it may not be a pipe or a socket. Therefore, handler - ## developers must buffer the input data into some rewindable object - ## if the underlying input stream is not rewindable. - def rewind(*args) - assert("rack.input#rewind called with arguments") { args.size == 0 } - assert("rack.input#rewind raised Errno::ESPIPE") { - begin - @input.rewind - true - rescue Errno::ESPIPE - false - end - } - end - - ## * +close+ must never be called on the input stream. - def close(*args) - assert("rack.input#close must not be called") { false } - end - end - - ## === The Error Stream - def check_error(error) - ## The error stream must respond to +puts+, +write+ and +flush+. - [:puts, :write, :flush].each { |method| - assert("rack.error #{error} does not respond to ##{method}") { - error.respond_to? method - } - } - end - - class ErrorWrapper - include Assertion - - def initialize(error) - @error = error - end - - ## * +puts+ must be called with a single argument that responds to +to_s+. - def puts(str) - @error.puts str - end - - ## * +write+ must be called with a single argument that is a String. - def write(str) - assert("rack.errors#write not called with a String") { str.instance_of? String } - @error.write str - end - - ## * +flush+ must be called without arguments and must be called - ## in order to make the error appear for sure. - def flush - @error.flush - end - - ## * +close+ must never be called on the error stream. - def close(*args) - assert("rack.errors#close must not be called") { false } - end - end - - ## == The Response - - ## === The Status - def check_status(status) - ## This is an HTTP status. When parsed as integer (+to_i+), it must be - ## greater than or equal to 100. - assert("Status must be >=100 seen as integer") { status.to_i >= 100 } - end - - ## === The Headers - def check_headers(header) - ## The header must respond to +each+, and yield values of key and value. - assert("headers object should respond to #each, but doesn't (got #{header.class} as headers)") { - header.respond_to? :each - } - header.each { |key, value| - ## The header keys must be Strings. - assert("header key must be a string, was #{key.class}") { - key.instance_of? String - } - ## The header must not contain a +Status+ key, - assert("header must not contain Status") { key.downcase != "status" } - ## contain keys with : or newlines in their name, - assert("header names must not contain : or \\n") { key !~ /[:\n]/ } - ## contain keys names that end in - or _, - assert("header names must not end in - or _") { key !~ /[-_]\z/ } - ## but only contain keys that consist of - ## letters, digits, _ or - and start with a letter. - assert("invalid header name: #{key}") { key =~ /\A[a-zA-Z][a-zA-Z0-9_-]*\z/ } - - ## The values of the header must be Strings, - assert("a header value must be a String, but the value of " + - "'#{key}' is a #{value.class}") { value.kind_of? String } - ## consisting of lines (for multiple header values, e.g. multiple - ## Set-Cookie values) seperated by "\n". - value.split("\n").each { |item| - ## The lines must not contain characters below 037. - assert("invalid header value #{key}: #{item.inspect}") { - item !~ /[\000-\037]/ - } - } - } - end - - ## === The Content-Type - def check_content_type(status, headers) - headers.each { |key, value| - ## There must be a Content-Type, except when the - ## +Status+ is 1xx, 204 or 304, in which case there must be none - ## given. - if key.downcase == "content-type" - assert("Content-Type header found in #{status} response, not allowed") { - not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i - } - return - end - } - assert("No Content-Type header found") { - Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i - } - end - - ## === The Content-Length - def check_content_length(status, headers, env) - headers.each { |key, value| - if key.downcase == 'content-length' - ## There must not be a Content-Length header when the - ## +Status+ is 1xx, 204 or 304. - assert("Content-Length header found in #{status} response, not allowed") { - not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i - } - - bytes = 0 - string_body = true - - if @body.respond_to?(:to_ary) - @body.each { |part| - unless part.kind_of?(String) - string_body = false - break - end - - bytes += Rack::Utils.bytesize(part) - } - - if env["REQUEST_METHOD"] == "HEAD" - assert("Response body was given for HEAD request, but should be empty") { - bytes == 0 - } - else - if string_body - assert("Content-Length header was #{value}, but should be #{bytes}") { - value == bytes.to_s - } - end - end - end - - return - end - } - end - - ## === The Body - def each - @closed = false - ## The Body must respond to +each+ - @body.each { |part| - ## and must only yield String values. - assert("Body yielded non-string value #{part.inspect}") { - part.instance_of? String - } - yield part - } - ## - ## The Body itself should not be an instance of String, as this will - ## break in Ruby 1.9. - ## - ## If the Body responds to +close+, it will be called after iteration. - # XXX howto: assert("Body has not been closed") { @closed } - - - ## - ## If the Body responds to +to_path+, it must return a String - ## identifying the location of a file whose contents are identical - ## to that produced by calling +each+; this may be used by the - ## server as an alternative, possibly more efficient way to - ## transport the response. - - if @body.respond_to?(:to_path) - assert("The file identified by body.to_path does not exist") { - ::File.exist? @body.to_path - } - end - - ## - ## The Body commonly is an Array of Strings, the application - ## instance itself, or a File-like object. - end - - def close - @closed = true - @body.close if @body.respond_to?(:close) - end - - # :startdoc: - - end -end - -## == Thanks -## Some parts of this specification are adopted from PEP333: Python -## Web Server Gateway Interface -## v1.0 (http://www.python.org/dev/peps/pep-0333/). I'd like to thank -## everyone involved in that effort. diff --git a/vendor/gems/rack-1.0.1/lib/rack/lobster.rb b/vendor/gems/rack-1.0.1/lib/rack/lobster.rb deleted file mode 100644 index f63f419a..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/lobster.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'zlib' - -require 'rack/request' -require 'rack/response' - -module Rack - # Paste has a Pony, Rack has a Lobster! - class Lobster - LobsterString = Zlib::Inflate.inflate("eJx9kEEOwyAMBO99xd7MAcytUhPlJyj2 - P6jy9i4k9EQyGAnBarEXeCBqSkntNXsi/ZCvC48zGQoZKikGrFMZvgS5ZHd+aGWVuWwhVF0 - t1drVmiR42HcWNz5w3QanT+2gIvTVCiE1lm1Y0eU4JGmIIbaKwextKn8rvW+p5PIwFl8ZWJ - I8jyiTlhTcYXkekJAzTyYN6E08A+dk8voBkAVTJQ==".delete("\n ").unpack("m*")[0]) - - LambdaLobster = lambda { |env| - if env["QUERY_STRING"].include?("flip") - lobster = LobsterString.split("\n"). - map { |line| line.ljust(42).reverse }. - join("\n") - href = "?" - else - lobster = LobsterString - href = "?flip" - end - - content = ["Lobstericious!", - "
", lobster, "
", - "flip!"] - length = content.inject(0) { |a,e| a+e.size }.to_s - [200, {"Content-Type" => "text/html", "Content-Length" => length}, content] - } - - def call(env) - req = Request.new(env) - if req.GET["flip"] == "left" - lobster = LobsterString.split("\n"). - map { |line| line.ljust(42).reverse }. - join("\n") - href = "?flip=right" - elsif req.GET["flip"] == "crash" - raise "Lobster crashed" - else - lobster = LobsterString - href = "?flip=left" - end - - res = Response.new - res.write "Lobstericious!" - res.write "
"
-      res.write lobster
-      res.write "
" - res.write "

flip!

" - res.write "

crash!

" - res.finish - end - - end -end - -if $0 == __FILE__ - require 'rack' - require 'rack/showexceptions' - Rack::Handler::WEBrick.run \ - Rack::ShowExceptions.new(Rack::Lint.new(Rack::Lobster.new)), - :Port => 9292 -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/lock.rb b/vendor/gems/rack-1.0.1/lib/rack/lock.rb deleted file mode 100644 index 93238528..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/lock.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Rack - class Lock - FLAG = 'rack.multithread'.freeze - - def initialize(app, lock = Mutex.new) - @app, @lock = app, lock - end - - def call(env) - old, env[FLAG] = env[FLAG], false - @lock.synchronize { @app.call(env) } - ensure - env[FLAG] = old - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/methodoverride.rb b/vendor/gems/rack-1.0.1/lib/rack/methodoverride.rb deleted file mode 100644 index 0eed29f4..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/methodoverride.rb +++ /dev/null @@ -1,27 +0,0 @@ -module Rack - class MethodOverride - HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS) - - METHOD_OVERRIDE_PARAM_KEY = "_method".freeze - HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze - - def initialize(app) - @app = app - end - - def call(env) - if env["REQUEST_METHOD"] == "POST" - req = Request.new(env) - method = req.POST[METHOD_OVERRIDE_PARAM_KEY] || - env[HTTP_METHOD_OVERRIDE_HEADER] - method = method.to_s.upcase - if HTTP_METHODS.include?(method) - env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"] - env["REQUEST_METHOD"] = method - end - end - - @app.call(env) - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/mime.rb b/vendor/gems/rack-1.0.1/lib/rack/mime.rb deleted file mode 100644 index 5a6a73a9..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/mime.rb +++ /dev/null @@ -1,204 +0,0 @@ -module Rack - module Mime - # Returns String with mime type if found, otherwise use +fallback+. - # +ext+ should be filename extension in the '.ext' format that - # File.extname(file) returns. - # +fallback+ may be any object - # - # Also see the documentation for MIME_TYPES - # - # Usage: - # Rack::Mime.mime_type('.foo') - # - # This is a shortcut for: - # Rack::Mime::MIME_TYPES.fetch('.foo', 'application/octet-stream') - - def mime_type(ext, fallback='application/octet-stream') - MIME_TYPES.fetch(ext, fallback) - end - module_function :mime_type - - # List of most common mime-types, selected various sources - # according to their usefulness in a webserving scope for Ruby - # users. - # - # To amend this list with your local mime.types list you can use: - # - # require 'webrick/httputils' - # list = WEBrick::HTTPUtils.load_mime_types('/etc/mime.types') - # Rack::Mime::MIME_TYPES.merge!(list) - # - # To add the list mongrel provides, use: - # - # require 'mongrel/handlers' - # Rack::Mime::MIME_TYPES.merge!(Mongrel::DirHandler::MIME_TYPES) - - MIME_TYPES = { - ".3gp" => "video/3gpp", - ".a" => "application/octet-stream", - ".ai" => "application/postscript", - ".aif" => "audio/x-aiff", - ".aiff" => "audio/x-aiff", - ".asc" => "application/pgp-signature", - ".asf" => "video/x-ms-asf", - ".asm" => "text/x-asm", - ".asx" => "video/x-ms-asf", - ".atom" => "application/atom+xml", - ".au" => "audio/basic", - ".avi" => "video/x-msvideo", - ".bat" => "application/x-msdownload", - ".bin" => "application/octet-stream", - ".bmp" => "image/bmp", - ".bz2" => "application/x-bzip2", - ".c" => "text/x-c", - ".cab" => "application/vnd.ms-cab-compressed", - ".cc" => "text/x-c", - ".chm" => "application/vnd.ms-htmlhelp", - ".class" => "application/octet-stream", - ".com" => "application/x-msdownload", - ".conf" => "text/plain", - ".cpp" => "text/x-c", - ".crt" => "application/x-x509-ca-cert", - ".css" => "text/css", - ".csv" => "text/csv", - ".cxx" => "text/x-c", - ".deb" => "application/x-debian-package", - ".der" => "application/x-x509-ca-cert", - ".diff" => "text/x-diff", - ".djv" => "image/vnd.djvu", - ".djvu" => "image/vnd.djvu", - ".dll" => "application/x-msdownload", - ".dmg" => "application/octet-stream", - ".doc" => "application/msword", - ".dot" => "application/msword", - ".dtd" => "application/xml-dtd", - ".dvi" => "application/x-dvi", - ".ear" => "application/java-archive", - ".eml" => "message/rfc822", - ".eps" => "application/postscript", - ".exe" => "application/x-msdownload", - ".f" => "text/x-fortran", - ".f77" => "text/x-fortran", - ".f90" => "text/x-fortran", - ".flv" => "video/x-flv", - ".for" => "text/x-fortran", - ".gem" => "application/octet-stream", - ".gemspec" => "text/x-script.ruby", - ".gif" => "image/gif", - ".gz" => "application/x-gzip", - ".h" => "text/x-c", - ".hh" => "text/x-c", - ".htm" => "text/html", - ".html" => "text/html", - ".ico" => "image/vnd.microsoft.icon", - ".ics" => "text/calendar", - ".ifb" => "text/calendar", - ".iso" => "application/octet-stream", - ".jar" => "application/java-archive", - ".java" => "text/x-java-source", - ".jnlp" => "application/x-java-jnlp-file", - ".jpeg" => "image/jpeg", - ".jpg" => "image/jpeg", - ".js" => "application/javascript", - ".json" => "application/json", - ".log" => "text/plain", - ".m3u" => "audio/x-mpegurl", - ".m4v" => "video/mp4", - ".man" => "text/troff", - ".mathml" => "application/mathml+xml", - ".mbox" => "application/mbox", - ".mdoc" => "text/troff", - ".me" => "text/troff", - ".mid" => "audio/midi", - ".midi" => "audio/midi", - ".mime" => "message/rfc822", - ".mml" => "application/mathml+xml", - ".mng" => "video/x-mng", - ".mov" => "video/quicktime", - ".mp3" => "audio/mpeg", - ".mp4" => "video/mp4", - ".mp4v" => "video/mp4", - ".mpeg" => "video/mpeg", - ".mpg" => "video/mpeg", - ".ms" => "text/troff", - ".msi" => "application/x-msdownload", - ".odp" => "application/vnd.oasis.opendocument.presentation", - ".ods" => "application/vnd.oasis.opendocument.spreadsheet", - ".odt" => "application/vnd.oasis.opendocument.text", - ".ogg" => "application/ogg", - ".p" => "text/x-pascal", - ".pas" => "text/x-pascal", - ".pbm" => "image/x-portable-bitmap", - ".pdf" => "application/pdf", - ".pem" => "application/x-x509-ca-cert", - ".pgm" => "image/x-portable-graymap", - ".pgp" => "application/pgp-encrypted", - ".pkg" => "application/octet-stream", - ".pl" => "text/x-script.perl", - ".pm" => "text/x-script.perl-module", - ".png" => "image/png", - ".pnm" => "image/x-portable-anymap", - ".ppm" => "image/x-portable-pixmap", - ".pps" => "application/vnd.ms-powerpoint", - ".ppt" => "application/vnd.ms-powerpoint", - ".ps" => "application/postscript", - ".psd" => "image/vnd.adobe.photoshop", - ".py" => "text/x-script.python", - ".qt" => "video/quicktime", - ".ra" => "audio/x-pn-realaudio", - ".rake" => "text/x-script.ruby", - ".ram" => "audio/x-pn-realaudio", - ".rar" => "application/x-rar-compressed", - ".rb" => "text/x-script.ruby", - ".rdf" => "application/rdf+xml", - ".roff" => "text/troff", - ".rpm" => "application/x-redhat-package-manager", - ".rss" => "application/rss+xml", - ".rtf" => "application/rtf", - ".ru" => "text/x-script.ruby", - ".s" => "text/x-asm", - ".sgm" => "text/sgml", - ".sgml" => "text/sgml", - ".sh" => "application/x-sh", - ".sig" => "application/pgp-signature", - ".snd" => "audio/basic", - ".so" => "application/octet-stream", - ".svg" => "image/svg+xml", - ".svgz" => "image/svg+xml", - ".swf" => "application/x-shockwave-flash", - ".t" => "text/troff", - ".tar" => "application/x-tar", - ".tbz" => "application/x-bzip-compressed-tar", - ".tcl" => "application/x-tcl", - ".tex" => "application/x-tex", - ".texi" => "application/x-texinfo", - ".texinfo" => "application/x-texinfo", - ".text" => "text/plain", - ".tif" => "image/tiff", - ".tiff" => "image/tiff", - ".torrent" => "application/x-bittorrent", - ".tr" => "text/troff", - ".txt" => "text/plain", - ".vcf" => "text/x-vcard", - ".vcs" => "text/x-vcalendar", - ".vrml" => "model/vrml", - ".war" => "application/java-archive", - ".wav" => "audio/x-wav", - ".wma" => "audio/x-ms-wma", - ".wmv" => "video/x-ms-wmv", - ".wmx" => "video/x-ms-wmx", - ".wrl" => "model/vrml", - ".wsdl" => "application/wsdl+xml", - ".xbm" => "image/x-xbitmap", - ".xhtml" => "application/xhtml+xml", - ".xls" => "application/vnd.ms-excel", - ".xml" => "application/xml", - ".xpm" => "image/x-xpixmap", - ".xsl" => "application/xml", - ".xslt" => "application/xslt+xml", - ".yaml" => "text/yaml", - ".yml" => "text/yaml", - ".zip" => "application/zip", - } - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/mock.rb b/vendor/gems/rack-1.0.1/lib/rack/mock.rb deleted file mode 100644 index c34a2d7a..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/mock.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'uri' -require 'stringio' -require 'rack/lint' -require 'rack/utils' -require 'rack/response' - -module Rack - # Rack::MockRequest helps testing your Rack application without - # actually using HTTP. - # - # After performing a request on a URL with get/post/put/delete, it - # returns a MockResponse with useful helper methods for effective - # testing. - # - # You can pass a hash with additional configuration to the - # get/post/put/delete. - # :input:: A String or IO-like to be used as rack.input. - # :fatal:: Raise a FatalWarning if the app writes to rack.errors. - # :lint:: If true, wrap the application in a Rack::Lint. - - class MockRequest - class FatalWarning < RuntimeError - end - - class FatalWarner - def puts(warning) - raise FatalWarning, warning - end - - def write(warning) - raise FatalWarning, warning - end - - def flush - end - - def string - "" - end - end - - DEFAULT_ENV = { - "rack.version" => [1,0], - "rack.input" => StringIO.new, - "rack.errors" => StringIO.new, - "rack.multithread" => true, - "rack.multiprocess" => true, - "rack.run_once" => false, - } - - def initialize(app) - @app = app - end - - def get(uri, opts={}) request("GET", uri, opts) end - def post(uri, opts={}) request("POST", uri, opts) end - def put(uri, opts={}) request("PUT", uri, opts) end - def delete(uri, opts={}) request("DELETE", uri, opts) end - - def request(method="GET", uri="", opts={}) - env = self.class.env_for(uri, opts.merge(:method => method)) - - if opts[:lint] - app = Rack::Lint.new(@app) - else - app = @app - end - - errors = env["rack.errors"] - MockResponse.new(*(app.call(env) + [errors])) - end - - # Return the Rack environment used for a request to +uri+. - def self.env_for(uri="", opts={}) - uri = URI(uri) - env = DEFAULT_ENV.dup - - env["REQUEST_METHOD"] = opts[:method] || "GET" - env["SERVER_NAME"] = uri.host || "example.org" - env["SERVER_PORT"] = uri.port ? uri.port.to_s : "80" - env["QUERY_STRING"] = uri.query.to_s - env["PATH_INFO"] = (!uri.path || uri.path.empty?) ? "/" : uri.path - env["rack.url_scheme"] = uri.scheme || "http" - - env["SCRIPT_NAME"] = opts[:script_name] || "" - - if opts[:fatal] - env["rack.errors"] = FatalWarner.new - else - env["rack.errors"] = StringIO.new - end - - opts[:input] ||= "" - if String === opts[:input] - rack_input = StringIO.new(opts[:input]) - else - rack_input = opts[:input] - end - - rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) - env['rack.input'] = rack_input - - env["CONTENT_LENGTH"] ||= env["rack.input"].length.to_s - - opts.each { |field, value| - env[field] = value if String === field - } - - env - end - end - - # Rack::MockResponse provides useful helpers for testing your apps. - # Usually, you don't create the MockResponse on your own, but use - # MockRequest. - - class MockResponse - def initialize(status, headers, body, errors=StringIO.new("")) - @status = status.to_i - - @original_headers = headers - @headers = Rack::Utils::HeaderHash.new - headers.each { |field, values| - @headers[field] = values - @headers[field] = "" if values.empty? - } - - @body = "" - body.each { |part| @body << part } - - @errors = errors.string - end - - # Status - attr_reader :status - - # Headers - attr_reader :headers, :original_headers - - def [](field) - headers[field] - end - - - # Body - attr_reader :body - - def =~(other) - @body =~ other - end - - def match(other) - @body.match other - end - - - # Errors - attr_accessor :errors - - - include Response::Helpers - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/recursive.rb b/vendor/gems/rack-1.0.1/lib/rack/recursive.rb deleted file mode 100644 index bf8b9659..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/recursive.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'uri' - -module Rack - # Rack::ForwardRequest gets caught by Rack::Recursive and redirects - # the current request to the app at +url+. - # - # raise ForwardRequest.new("/not-found") - # - - class ForwardRequest < Exception - attr_reader :url, :env - - def initialize(url, env={}) - @url = URI(url) - @env = env - - @env["PATH_INFO"] = @url.path - @env["QUERY_STRING"] = @url.query if @url.query - @env["HTTP_HOST"] = @url.host if @url.host - @env["HTTP_PORT"] = @url.port if @url.port - @env["rack.url_scheme"] = @url.scheme if @url.scheme - - super "forwarding to #{url}" - end - end - - # Rack::Recursive allows applications called down the chain to - # include data from other applications (by using - # rack['rack.recursive.include'][...] or raise a - # ForwardRequest to redirect internally. - - class Recursive - def initialize(app) - @app = app - end - - def call(env) - @script_name = env["SCRIPT_NAME"] - @app.call(env.merge('rack.recursive.include' => method(:include))) - rescue ForwardRequest => req - call(env.merge(req.env)) - end - - def include(env, path) - unless path.index(@script_name) == 0 && (path[@script_name.size] == ?/ || - path[@script_name.size].nil?) - raise ArgumentError, "can only include below #{@script_name}, not #{path}" - end - - env = env.merge("PATH_INFO" => path, "SCRIPT_NAME" => @script_name, - "REQUEST_METHOD" => "GET", - "CONTENT_LENGTH" => "0", "CONTENT_TYPE" => "", - "rack.input" => StringIO.new("")) - @app.call(env) - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/reloader.rb b/vendor/gems/rack-1.0.1/lib/rack/reloader.rb deleted file mode 100644 index a9c566f7..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/reloader.rb +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com -# All files in this distribution are subject to the terms of the Ruby license. - -require 'pathname' - -module Rack - - # High performant source reloader - # - # This class acts as Rack middleware. - # - # What makes it especially suited for use in a production environment is that - # any file will only be checked once and there will only be made one system - # call stat(2). - # - # Please note that this will not reload files in the background, it does so - # only when actively called. - # - # It is performing a check/reload cycle at the start of every request, but - # also respects a cool down time, during which nothing will be done. - class Reloader - def initialize(app, cooldown = 10, backend = Stat) - @app = app - @cooldown = cooldown - @last = (Time.now - cooldown) - @cache = {} - @mtimes = {} - - extend backend - end - - def call(env) - if @cooldown and Time.now > @last + @cooldown - if Thread.list.size > 1 - Thread.exclusive{ reload! } - else - reload! - end - - @last = Time.now - end - - @app.call(env) - end - - def reload!(stderr = $stderr) - rotation do |file, mtime| - previous_mtime = @mtimes[file] ||= mtime - safe_load(file, mtime, stderr) if mtime > previous_mtime - end - end - - # A safe Kernel::load, issuing the hooks depending on the results - def safe_load(file, mtime, stderr = $stderr) - load(file) - stderr.puts "#{self.class}: reloaded `#{file}'" - file - rescue LoadError, SyntaxError => ex - stderr.puts ex - ensure - @mtimes[file] = mtime - end - - module Stat - def rotation - files = [$0, *$LOADED_FEATURES].uniq - paths = ['./', *$LOAD_PATH].uniq - - files.map{|file| - next if file =~ /\.(so|bundle)$/ # cannot reload compiled files - - found, stat = figure_path(file, paths) - next unless found && stat && mtime = stat.mtime - - @cache[file] = found - - yield(found, mtime) - }.compact - end - - # Takes a relative or absolute +file+ name, a couple possible +paths+ that - # the +file+ might reside in. Returns the full path and File::Stat for the - # path. - def figure_path(file, paths) - found = @cache[file] - found = file if !found and Pathname.new(file).absolute? - found, stat = safe_stat(found) - return found, stat if found - - paths.find do |possible_path| - path = ::File.join(possible_path, file) - found, stat = safe_stat(path) - return ::File.expand_path(found), stat if found - end - end - - def safe_stat(file) - return unless file - stat = ::File.stat(file) - return file, stat if stat.file? - rescue Errno::ENOENT, Errno::ENOTDIR - @cache.delete(file) and false - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/request.rb b/vendor/gems/rack-1.0.1/lib/rack/request.rb deleted file mode 100644 index 2f64bd6c..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/request.rb +++ /dev/null @@ -1,246 +0,0 @@ -require 'rack/utils' - -module Rack - # Rack::Request provides a convenient interface to a Rack - # environment. It is stateless, the environment +env+ passed to the - # constructor will be directly modified. - # - # req = Rack::Request.new(env) - # req.post? - # req.params["data"] - # - # The environment hash passed will store a reference to the Request object - # instantiated so that it will only instantiate if an instance of the Request - # object doesn't already exist. - - class Request - # The environment of the request. - attr_reader :env - - def initialize(env) - @env = env - end - - def body; @env["rack.input"] end - def scheme; @env["rack.url_scheme"] end - def script_name; @env["SCRIPT_NAME"].to_s end - def path_info; @env["PATH_INFO"].to_s end - def port; @env["SERVER_PORT"].to_i end - def request_method; @env["REQUEST_METHOD"] end - def query_string; @env["QUERY_STRING"].to_s end - def content_length; @env['CONTENT_LENGTH'] end - def content_type; @env['CONTENT_TYPE'] end - def session; @env['rack.session'] ||= {} end - def session_options; @env['rack.session.options'] ||= {} end - - # The media type (type/subtype) portion of the CONTENT_TYPE header - # without any media type parameters. e.g., when CONTENT_TYPE is - # "text/plain;charset=utf-8", the media-type is "text/plain". - # - # For more information on the use of media types in HTTP, see: - # http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7 - def media_type - content_type && content_type.split(/\s*[;,]\s*/, 2).first.downcase - end - - # The media type parameters provided in CONTENT_TYPE as a Hash, or - # an empty Hash if no CONTENT_TYPE or media-type parameters were - # provided. e.g., when the CONTENT_TYPE is "text/plain;charset=utf-8", - # this method responds with the following Hash: - # { 'charset' => 'utf-8' } - def media_type_params - return {} if content_type.nil? - content_type.split(/\s*[;,]\s*/)[1..-1]. - collect { |s| s.split('=', 2) }. - inject({}) { |hash,(k,v)| hash[k.downcase] = v ; hash } - end - - # The character set of the request body if a "charset" media type - # parameter was given, or nil if no "charset" was specified. Note - # that, per RFC2616, text/* media types that specify no explicit - # charset are to be considered ISO-8859-1. - def content_charset - media_type_params['charset'] - end - - def host - # Remove port number. - (@env["HTTP_HOST"] || @env["SERVER_NAME"]).to_s.gsub(/:\d+\z/, '') - end - - def script_name=(s); @env["SCRIPT_NAME"] = s.to_s end - def path_info=(s); @env["PATH_INFO"] = s.to_s end - - def get?; request_method == "GET" end - def post?; request_method == "POST" end - def put?; request_method == "PUT" end - def delete?; request_method == "DELETE" end - def head?; request_method == "HEAD" end - - # The set of form-data media-types. Requests that do not indicate - # one of the media types presents in this list will not be eligible - # for form-data / param parsing. - FORM_DATA_MEDIA_TYPES = [ - nil, - 'application/x-www-form-urlencoded', - 'multipart/form-data' - ] - - # The set of media-types. Requests that do not indicate - # one of the media types presents in this list will not be eligible - # for param parsing like soap attachments or generic multiparts - PARSEABLE_DATA_MEDIA_TYPES = [ - 'multipart/related', - 'multipart/mixed' - ] - - # Determine whether the request body contains form-data by checking - # the request media_type against registered form-data media-types: - # "application/x-www-form-urlencoded" and "multipart/form-data". The - # list of form-data media types can be modified through the - # +FORM_DATA_MEDIA_TYPES+ array. - def form_data? - FORM_DATA_MEDIA_TYPES.include?(media_type) - end - - # Determine whether the request body contains data by checking - # the request media_type against registered parse-data media-types - def parseable_data? - PARSEABLE_DATA_MEDIA_TYPES.include?(media_type) - end - - # Returns the data recieved in the query string. - def GET - if @env["rack.request.query_string"] == query_string - @env["rack.request.query_hash"] - else - @env["rack.request.query_string"] = query_string - @env["rack.request.query_hash"] = - Utils.parse_nested_query(query_string) - end - end - - # Returns the data recieved in the request body. - # - # This method support both application/x-www-form-urlencoded and - # multipart/form-data. - def POST - if @env["rack.request.form_input"].eql? @env["rack.input"] - @env["rack.request.form_hash"] - elsif form_data? || parseable_data? - @env["rack.request.form_input"] = @env["rack.input"] - unless @env["rack.request.form_hash"] = - Utils::Multipart.parse_multipart(env) - form_vars = @env["rack.input"].read - - # Fix for Safari Ajax postings that always append \0 - form_vars.sub!(/\0\z/, '') - - @env["rack.request.form_vars"] = form_vars - @env["rack.request.form_hash"] = Utils.parse_nested_query(form_vars) - - @env["rack.input"].rewind - end - @env["rack.request.form_hash"] - else - {} - end - end - - # The union of GET and POST data. - def params - self.put? ? self.GET : self.GET.update(self.POST) - rescue EOFError => e - self.GET - end - - # shortcut for request.params[key] - def [](key) - params[key.to_s] - end - - # shortcut for request.params[key] = value - def []=(key, value) - params[key.to_s] = value - end - - # like Hash#values_at - def values_at(*keys) - keys.map{|key| params[key] } - end - - # the referer of the client or '/' - def referer - @env['HTTP_REFERER'] || '/' - end - alias referrer referer - - - def cookies - return {} unless @env["HTTP_COOKIE"] - - if @env["rack.request.cookie_string"] == @env["HTTP_COOKIE"] - @env["rack.request.cookie_hash"] - else - @env["rack.request.cookie_string"] = @env["HTTP_COOKIE"] - # According to RFC 2109: - # If multiple cookies satisfy the criteria above, they are ordered in - # the Cookie header such that those with more specific Path attributes - # precede those with less specific. Ordering with respect to other - # attributes (e.g., Domain) is unspecified. - @env["rack.request.cookie_hash"] = - Utils.parse_query(@env["rack.request.cookie_string"], ';,').inject({}) {|h,(k,v)| - h[k] = Array === v ? v.first : v - h - } - end - end - - def xhr? - @env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest" - end - - # Tries to return a remake of the original request URL as a string. - def url - url = scheme + "://" - url << host - - if scheme == "https" && port != 443 || - scheme == "http" && port != 80 - url << ":#{port}" - end - - url << fullpath - - url - end - - def path - script_name + path_info - end - - def fullpath - query_string.empty? ? path : "#{path}?#{query_string}" - end - - def accept_encoding - @env["HTTP_ACCEPT_ENCODING"].to_s.split(/,\s*/).map do |part| - m = /^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$/.match(part) # From WEBrick - - if m - [m[1], (m[2] || 1.0).to_f] - else - raise "Invalid value for Accept-Encoding: #{part.inspect}" - end - end - end - - def ip - if addr = @env['HTTP_X_FORWARDED_FOR'] - addr.split(',').last.strip - else - @env['REMOTE_ADDR'] - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/response.rb b/vendor/gems/rack-1.0.1/lib/rack/response.rb deleted file mode 100644 index 28b4d830..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/response.rb +++ /dev/null @@ -1,183 +0,0 @@ -require 'rack/request' -require 'rack/utils' - -module Rack - # Rack::Response provides a convenient interface to create a Rack - # response. - # - # It allows setting of headers and cookies, and provides useful - # defaults (a OK response containing HTML). - # - # You can use Response#write to iteratively generate your response, - # but note that this is buffered by Rack::Response until you call - # +finish+. +finish+ however can take a block inside which calls to - # +write+ are syncronous with the Rack response. - # - # Your application's +call+ should end returning Response#finish. - - class Response - attr_accessor :length - - def initialize(body=[], status=200, header={}, &block) - @status = status - @header = Utils::HeaderHash.new({"Content-Type" => "text/html"}. - merge(header)) - - @writer = lambda { |x| @body << x } - @block = nil - @length = 0 - - @body = [] - - if body.respond_to? :to_str - write body.to_str - elsif body.respond_to?(:each) - body.each { |part| - write part.to_s - } - else - raise TypeError, "stringable or iterable required" - end - - yield self if block_given? - end - - attr_reader :header - attr_accessor :status, :body - - def [](key) - header[key] - end - - def []=(key, value) - header[key] = value - end - - def set_cookie(key, value) - case value - when Hash - domain = "; domain=" + value[:domain] if value[:domain] - path = "; path=" + value[:path] if value[:path] - # According to RFC 2109, we need dashes here. - # N.B.: cgi.rb uses spaces... - expires = "; expires=" + value[:expires].clone.gmtime. - strftime("%a, %d-%b-%Y %H:%M:%S GMT") if value[:expires] - secure = "; secure" if value[:secure] - httponly = "; HttpOnly" if value[:httponly] - value = value[:value] - end - value = [value] unless Array === value - cookie = Utils.escape(key) + "=" + - value.map { |v| Utils.escape v }.join("&") + - "#{domain}#{path}#{expires}#{secure}#{httponly}" - - case self["Set-Cookie"] - when Array - self["Set-Cookie"] << cookie - when String - self["Set-Cookie"] = [self["Set-Cookie"], cookie] - when nil - self["Set-Cookie"] = cookie - end - end - - def delete_cookie(key, value={}) - unless Array === self["Set-Cookie"] - self["Set-Cookie"] = [self["Set-Cookie"]].compact - end - - self["Set-Cookie"].reject! { |cookie| - cookie =~ /\A#{Utils.escape(key)}=/ - } - - set_cookie(key, - {:value => '', :path => nil, :domain => nil, - :expires => Time.at(0) }.merge(value)) - end - - def redirect(target, status=302) - self.status = status - self["Location"] = target - end - - def finish(&block) - @block = block - - if [204, 304].include?(status.to_i) - header.delete "Content-Type" - [status.to_i, header.to_hash, []] - else - [status.to_i, header.to_hash, self] - end - end - alias to_a finish # For *response - - def each(&callback) - @body.each(&callback) - @writer = callback - @block.call(self) if @block - end - - # Append to body and update Content-Length. - # - # NOTE: Do not mix #write and direct #body access! - # - def write(str) - s = str.to_s - @length += Rack::Utils.bytesize(s) - @writer.call s - - header["Content-Length"] = @length.to_s - str - end - - def close - body.close if body.respond_to?(:close) - end - - def empty? - @block == nil && @body.empty? - end - - alias headers header - - module Helpers - def invalid?; @status < 100 || @status >= 600; end - - def informational?; @status >= 100 && @status < 200; end - def successful?; @status >= 200 && @status < 300; end - def redirection?; @status >= 300 && @status < 400; end - def client_error?; @status >= 400 && @status < 500; end - def server_error?; @status >= 500 && @status < 600; end - - def ok?; @status == 200; end - def forbidden?; @status == 403; end - def not_found?; @status == 404; end - - def redirect?; [301, 302, 303, 307].include? @status; end - def empty?; [201, 204, 304].include? @status; end - - # Headers - attr_reader :headers, :original_headers - - def include?(header) - !!headers[header] - end - - def content_type - headers["Content-Type"] - end - - def content_length - cl = headers["Content-Length"] - cl ? cl.to_i : cl - end - - def location - headers["Location"] - end - end - - include Helpers - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb b/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb deleted file mode 100644 index accd96be..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'tempfile' - -module Rack - # Class which can make any IO object rewindable, including non-rewindable ones. It does - # this by buffering the data into a tempfile, which is rewindable. - # - # rack.input is required to be rewindable, so if your input stream IO is non-rewindable - # by nature (e.g. a pipe or a socket) then you can wrap it in an object of this class - # to easily make it rewindable. - # - # Don't forget to call #close when you're done. This frees up temporary resources that - # RewindableInput uses, though it does *not* close the original IO object. - class RewindableInput - def initialize(io) - @io = io - @rewindable_io = nil - @unlinked = false - end - - def gets - make_rewindable unless @rewindable_io - @rewindable_io.gets - end - - def read(*args) - make_rewindable unless @rewindable_io - @rewindable_io.read(*args) - end - - def each(&block) - make_rewindable unless @rewindable_io - @rewindable_io.each(&block) - end - - def rewind - make_rewindable unless @rewindable_io - @rewindable_io.rewind - end - - # Closes this RewindableInput object without closing the originally - # wrapped IO oject. Cleans up any temporary resources that this RewindableInput - # has created. - # - # This method may be called multiple times. It does nothing on subsequent calls. - def close - if @rewindable_io - if @unlinked - @rewindable_io.close - else - @rewindable_io.close! - end - @rewindable_io = nil - end - end - - private - - # Ruby's Tempfile class has a bug. Subclass it and fix it. - class Tempfile < ::Tempfile - def _close - @tmpfile.close if @tmpfile - @data[1] = nil if @data - @tmpfile = nil - end - end - - def make_rewindable - # Buffer all data into a tempfile. Since this tempfile is private to this - # RewindableInput object, we chmod it so that nobody else can read or write - # it. On POSIX filesystems we also unlink the file so that it doesn't - # even have a file entry on the filesystem anymore, though we can still - # access it because we have the file handle open. - @rewindable_io = Tempfile.new('RackRewindableInput') - @rewindable_io.chmod(0000) - @rewindable_io.set_encoding(Encoding::BINARY) if @rewindable_io.respond_to?(:set_encoding) - @rewindable_io.binmode - if filesystem_has_posix_semantics? - @rewindable_io.unlink - @unlinked = true - end - - buffer = "" - while @io.read(1024 * 4, buffer) - entire_buffer_written_out = false - while !entire_buffer_written_out - written = @rewindable_io.write(buffer) - entire_buffer_written_out = written == buffer.size - if !entire_buffer_written_out - buffer.slice!(0 .. written - 1) - end - end - end - @rewindable_io.rewind - end - - def filesystem_has_posix_semantics? - RUBY_PLATFORM !~ /(mswin|mingw|cygwin|java)/ - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/session/abstract/id.rb b/vendor/gems/rack-1.0.1/lib/rack/session/abstract/id.rb deleted file mode 100644 index 218144c1..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/session/abstract/id.rb +++ /dev/null @@ -1,142 +0,0 @@ -# AUTHOR: blink ; blink#ruby-lang@irc.freenode.net -# bugrep: Andreas Zehnder - -require 'time' -require 'rack/request' -require 'rack/response' - -module Rack - - module Session - - module Abstract - - # ID sets up a basic framework for implementing an id based sessioning - # service. Cookies sent to the client for maintaining sessions will only - # contain an id reference. Only #get_session and #set_session are - # required to be overwritten. - # - # All parameters are optional. - # * :key determines the name of the cookie, by default it is - # 'rack.session' - # * :path, :domain, :expire_after, :secure, and :httponly set the related - # cookie options as by Rack::Response#add_cookie - # * :defer will not set a cookie in the response. - # * :renew (implementation dependent) will prompt the generation of a new - # session id, and migration of data to be referenced at the new id. If - # :defer is set, it will be overridden and the cookie will be set. - # * :sidbits sets the number of bits in length that a generated session - # id will be. - # - # These options can be set on a per request basis, at the location of - # env['rack.session.options']. Additionally the id of the session can be - # found within the options hash at the key :id. It is highly not - # recommended to change its value. - # - # Is Rack::Utils::Context compatible. - - class ID - DEFAULT_OPTIONS = { - :path => '/', - :domain => nil, - :expire_after => nil, - :secure => false, - :httponly => true, - :defer => false, - :renew => false, - :sidbits => 128 - } - - attr_reader :key, :default_options - def initialize(app, options={}) - @app = app - @key = options[:key] || "rack.session" - @default_options = self.class::DEFAULT_OPTIONS.merge(options) - end - - def call(env) - context(env) - end - - def context(env, app=@app) - load_session(env) - status, headers, body = app.call(env) - commit_session(env, status, headers, body) - end - - private - - # Generate a new session id using Ruby #rand. The size of the - # session id is controlled by the :sidbits option. - # Monkey patch this to use custom methods for session id generation. - - def generate_sid - "%0#{@default_options[:sidbits] / 4}x" % - rand(2**@default_options[:sidbits] - 1) - end - - # Extracts the session id from provided cookies and passes it and the - # environment to #get_session. It then sets the resulting session into - # 'rack.session', and places options and session metadata into - # 'rack.session.options'. - - def load_session(env) - request = Rack::Request.new(env) - session_id = request.cookies[@key] - - begin - session_id, session = get_session(env, session_id) - env['rack.session'] = session - rescue - env['rack.session'] = Hash.new - end - - env['rack.session.options'] = @default_options. - merge(:id => session_id) - end - - # Acquires the session from the environment and the session id from - # the session options and passes them to #set_session. If successful - # and the :defer option is not true, a cookie will be added to the - # response with the session's id. - - def commit_session(env, status, headers, body) - session = env['rack.session'] - options = env['rack.session.options'] - session_id = options[:id] - - if not session_id = set_session(env, session_id, session, options) - env["rack.errors"].puts("Warning! #{self.class.name} failed to save session. Content dropped.") - [status, headers, body] - elsif options[:defer] and not options[:renew] - env["rack.errors"].puts("Defering cookie for #{session_id}") if $VERBOSE - [status, headers, body] - else - cookie = Hash.new - cookie[:value] = session_id - cookie[:expires] = Time.now + options[:expire_after] unless options[:expire_after].nil? - response = Rack::Response.new(body, status, headers) - response.set_cookie(@key, cookie.merge(options)) - response.to_a - end - end - - # All thread safety and session retrival proceedures should occur here. - # Should return [session_id, session]. - # If nil is provided as the session id, generation of a new valid id - # should occur within. - - def get_session(env, sid) - raise '#get_session not implemented.' - end - - # All thread safety and session storage proceedures should occur here. - # Should return true or false dependant on whether or not the session - # was saved or not. - def set_session(env, sid, session, options) - raise '#set_session not implemented.' - end - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/session/cookie.rb b/vendor/gems/rack-1.0.1/lib/rack/session/cookie.rb deleted file mode 100644 index eace9bd0..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/session/cookie.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'openssl' -require 'rack/request' -require 'rack/response' - -module Rack - - module Session - - # Rack::Session::Cookie provides simple cookie based session management. - # The session is a Ruby Hash stored as base64 encoded marshalled data - # set to :key (default: rack.session). - # When the secret key is set, cookie data is checked for data integrity. - # - # Example: - # - # use Rack::Session::Cookie, :key => 'rack.session', - # :domain => 'foo.com', - # :path => '/', - # :expire_after => 2592000, - # :secret => 'change_me' - # - # All parameters are optional. - - class Cookie - - def initialize(app, options={}) - @app = app - @key = options[:key] || "rack.session" - @secret = options[:secret] - @default_options = {:domain => nil, - :path => "/", - :expire_after => nil}.merge(options) - end - - def call(env) - load_session(env) - status, headers, body = @app.call(env) - commit_session(env, status, headers, body) - end - - private - - def load_session(env) - request = Rack::Request.new(env) - session_data = request.cookies[@key] - - if @secret && session_data - session_data, digest = session_data.split("--") - session_data = nil unless digest == generate_hmac(session_data) - end - - begin - session_data = session_data.unpack("m*").first - session_data = Marshal.load(session_data) - env["rack.session"] = session_data - rescue - env["rack.session"] = Hash.new - end - - env["rack.session.options"] = @default_options.dup - end - - def commit_session(env, status, headers, body) - session_data = Marshal.dump(env["rack.session"]) - session_data = [session_data].pack("m*") - - if @secret - session_data = "#{session_data}--#{generate_hmac(session_data)}" - end - - if session_data.size > (4096 - @key.size) - env["rack.errors"].puts("Warning! Rack::Session::Cookie data size exceeds 4K. Content dropped.") - [status, headers, body] - else - options = env["rack.session.options"] - cookie = Hash.new - cookie[:value] = session_data - cookie[:expires] = Time.now + options[:expire_after] unless options[:expire_after].nil? - response = Rack::Response.new(body, status, headers) - response.set_cookie(@key, cookie.merge(options)) - response.to_a - end - end - - def generate_hmac(data) - OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, @secret, data) - end - - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/session/memcache.rb b/vendor/gems/rack-1.0.1/lib/rack/session/memcache.rb deleted file mode 100644 index 4a65cbf3..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/session/memcache.rb +++ /dev/null @@ -1,109 +0,0 @@ -# AUTHOR: blink ; blink#ruby-lang@irc.freenode.net - -require 'rack/session/abstract/id' -require 'memcache' - -module Rack - module Session - # Rack::Session::Memcache provides simple cookie based session management. - # Session data is stored in memcached. The corresponding session key is - # maintained in the cookie. - # You may treat Session::Memcache as you would Session::Pool with the - # following caveats. - # - # * Setting :expire_after to 0 would note to the Memcache server to hang - # onto the session data until it would drop it according to it's own - # specifications. However, the cookie sent to the client would expire - # immediately. - # - # Note that memcache does drop data before it may be listed to expire. For - # a full description of behaviour, please see memcache's documentation. - - class Memcache < Abstract::ID - attr_reader :mutex, :pool - DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge \ - :namespace => 'rack:session', - :memcache_server => 'localhost:11211' - - def initialize(app, options={}) - super - - @mutex = Mutex.new - @pool = MemCache. - new @default_options[:memcache_server], @default_options - raise 'No memcache servers' unless @pool.servers.any?{|s|s.alive?} - end - - def generate_sid - loop do - sid = super - break sid unless @pool.get(sid, true) - end - end - - def get_session(env, sid) - session = @pool.get(sid) if sid - @mutex.lock if env['rack.multithread'] - unless sid and session - env['rack.errors'].puts("Session '#{sid.inspect}' not found, initializing...") if $VERBOSE and not sid.nil? - session = {} - sid = generate_sid - ret = @pool.add sid, session - raise "Session collision on '#{sid.inspect}'" unless /^STORED/ =~ ret - end - session.instance_variable_set('@old', {}.merge(session)) - return [sid, session] - rescue MemCache::MemCacheError, Errno::ECONNREFUSED # MemCache server cannot be contacted - warn "#{self} is unable to find server." - warn $!.inspect - return [ nil, {} ] - ensure - @mutex.unlock if env['rack.multithread'] - end - - def set_session(env, session_id, new_session, options) - expiry = options[:expire_after] - expiry = expiry.nil? ? 0 : expiry + 1 - - @mutex.lock if env['rack.multithread'] - session = @pool.get(session_id) || {} - if options[:renew] or options[:drop] - @pool.delete session_id - return false if options[:drop] - session_id = generate_sid - @pool.add session_id, 0 # so we don't worry about cache miss on #set - end - old_session = new_session.instance_variable_get('@old') || {} - session = merge_sessions session_id, old_session, new_session, session - @pool.set session_id, session, expiry - return session_id - rescue MemCache::MemCacheError, Errno::ECONNREFUSED # MemCache server cannot be contacted - warn "#{self} is unable to find server." - warn $!.inspect - return false - ensure - @mutex.unlock if env['rack.multithread'] - end - - private - - def merge_sessions sid, old, new, cur=nil - cur ||= {} - unless Hash === old and Hash === new - warn 'Bad old or new sessions provided.' - return cur - end - - delete = old.keys - new.keys - warn "//@#{sid}: delete #{delete*','}" if $VERBOSE and not delete.empty? - delete.each{|k| cur.delete k } - - update = new.keys.select{|k| new[k] != old[k] } - warn "//@#{sid}: update #{update*','}" if $VERBOSE and not update.empty? - update.each{|k| cur[k] = new[k] } - - cur - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/session/pool.rb b/vendor/gems/rack-1.0.1/lib/rack/session/pool.rb deleted file mode 100644 index f6f87408..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/session/pool.rb +++ /dev/null @@ -1,100 +0,0 @@ -# AUTHOR: blink ; blink#ruby-lang@irc.freenode.net -# THANKS: -# apeiros, for session id generation, expiry setup, and threadiness -# sergio, threadiness and bugreps - -require 'rack/session/abstract/id' -require 'thread' - -module Rack - module Session - # Rack::Session::Pool provides simple cookie based session management. - # Session data is stored in a hash held by @pool. - # In the context of a multithreaded environment, sessions being - # committed to the pool is done in a merging manner. - # - # The :drop option is available in rack.session.options if you with to - # explicitly remove the session from the session cache. - # - # Example: - # myapp = MyRackApp.new - # sessioned = Rack::Session::Pool.new(myapp, - # :domain => 'foo.com', - # :expire_after => 2592000 - # ) - # Rack::Handler::WEBrick.run sessioned - - class Pool < Abstract::ID - attr_reader :mutex, :pool - DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge :drop => false - - def initialize(app, options={}) - super - @pool = Hash.new - @mutex = Mutex.new - end - - def generate_sid - loop do - sid = super - break sid unless @pool.key? sid - end - end - - def get_session(env, sid) - session = @pool[sid] if sid - @mutex.lock if env['rack.multithread'] - unless sid and session - env['rack.errors'].puts("Session '#{sid.inspect}' not found, initializing...") if $VERBOSE and not sid.nil? - session = {} - sid = generate_sid - @pool.store sid, session - end - session.instance_variable_set('@old', {}.merge(session)) - return [sid, session] - ensure - @mutex.unlock if env['rack.multithread'] - end - - def set_session(env, session_id, new_session, options) - @mutex.lock if env['rack.multithread'] - session = @pool[session_id] - if options[:renew] or options[:drop] - @pool.delete session_id - return false if options[:drop] - session_id = generate_sid - @pool.store session_id, 0 - end - old_session = new_session.instance_variable_get('@old') || {} - session = merge_sessions session_id, old_session, new_session, session - @pool.store session_id, session - return session_id - rescue - warn "#{new_session.inspect} has been lost." - warn $!.inspect - ensure - @mutex.unlock if env['rack.multithread'] - end - - private - - def merge_sessions sid, old, new, cur=nil - cur ||= {} - unless Hash === old and Hash === new - warn 'Bad old or new sessions provided.' - return cur - end - - delete = old.keys - new.keys - warn "//@#{sid}: dropping #{delete*','}" if $DEBUG and not delete.empty? - delete.each{|k| cur.delete k } - - update = new.keys.select{|k| new[k] != old[k] } - warn "//@#{sid}: updating #{update*','}" if $DEBUG and not update.empty? - update.each{|k| cur[k] = new[k] } - - cur - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/showexceptions.rb b/vendor/gems/rack-1.0.1/lib/rack/showexceptions.rb deleted file mode 100644 index 697bc41f..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/showexceptions.rb +++ /dev/null @@ -1,349 +0,0 @@ -require 'ostruct' -require 'erb' -require 'rack/request' -require 'rack/utils' - -module Rack - # Rack::ShowExceptions catches all exceptions raised from the app it - # wraps. It shows a useful backtrace with the sourcefile and - # clickable context, the whole Rack environment and the request - # data. - # - # Be careful when you use this on public-facing sites as it could - # reveal information helpful to attackers. - - class ShowExceptions - CONTEXT = 7 - - def initialize(app) - @app = app - @template = ERB.new(TEMPLATE) - end - - def call(env) - @app.call(env) - rescue StandardError, LoadError, SyntaxError => e - backtrace = pretty(env, e) - [500, - {"Content-Type" => "text/html", - "Content-Length" => backtrace.join.size.to_s}, - backtrace] - end - - def pretty(env, exception) - req = Rack::Request.new(env) - path = (req.script_name + req.path_info).squeeze("/") - - frames = exception.backtrace.map { |line| - frame = OpenStruct.new - if line =~ /(.*?):(\d+)(:in `(.*)')?/ - frame.filename = $1 - frame.lineno = $2.to_i - frame.function = $4 - - begin - lineno = frame.lineno-1 - lines = ::File.readlines(frame.filename) - frame.pre_context_lineno = [lineno-CONTEXT, 0].max - frame.pre_context = lines[frame.pre_context_lineno...lineno] - frame.context_line = lines[lineno].chomp - frame.post_context_lineno = [lineno+CONTEXT, lines.size].min - frame.post_context = lines[lineno+1..frame.post_context_lineno] - rescue - end - - frame - else - nil - end - }.compact - - env["rack.errors"].puts "#{exception.class}: #{exception.message}" - env["rack.errors"].puts exception.backtrace.map { |l| "\t" + l } - env["rack.errors"].flush - - [@template.result(binding)] - end - - def h(obj) # :nodoc: - case obj - when String - Utils.escape_html(obj) - else - Utils.escape_html(obj.inspect) - end - end - - # :stopdoc: - -# adapted from Django -# Copyright (c) 2005, the Lawrence Journal-World -# Used under the modified BSD license: -# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 -TEMPLATE = <<'HTML' - - - - - - <%=h exception.class %> at <%=h path %> - - - - - -
-

<%=h exception.class %> at <%=h path %>

-

<%=h exception.message %>

- - - - - - -
Ruby<%=h frames.first.filename %>: in <%=h frames.first.function %>, line <%=h frames.first.lineno %>
Web<%=h req.request_method %> <%=h(req.host + path)%>
- -

Jump to:

- -
- -
-

Traceback (innermost first)

-
    -<% frames.each { |frame| %> -
  • - <%=h frame.filename %>: in <%=h frame.function %> - - <% if frame.context_line %> -
    - <% if frame.pre_context %> -
      - <% frame.pre_context.each { |line| %> -
    1. <%=h line %>
    2. - <% } %> -
    - <% end %> - -
      -
    1. <%=h frame.context_line %>...
    - - <% if frame.post_context %> -
      - <% frame.post_context.each { |line| %> -
    1. <%=h line %>
    2. - <% } %> -
    - <% end %> -
    - <% end %> -
  • -<% } %> -
-
- -
-

Request information

- -

GET

- <% unless req.GET.empty? %> - - - - - - - - - <% req.GET.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
VariableValue
<%=h key %>
<%=h val.inspect %>
- <% else %> -

No GET data.

- <% end %> - -

POST

- <% unless req.POST.empty? %> - - - - - - - - - <% req.POST.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
VariableValue
<%=h key %>
<%=h val.inspect %>
- <% else %> -

No POST data.

- <% end %> - - - - <% unless req.cookies.empty? %> - - - - - - - - - <% req.cookies.each { |key, val| %> - - - - - <% } %> - -
VariableValue
<%=h key %>
<%=h val.inspect %>
- <% else %> -

No cookie data.

- <% end %> - -

Rack ENV

- - - - - - - - - <% env.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
VariableValue
<%=h key %>
<%=h val %>
- -
- -
-

- You're seeing this error because you use Rack::ShowExceptions. -

-
- - - -HTML - - # :startdoc: - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/showstatus.rb b/vendor/gems/rack-1.0.1/lib/rack/showstatus.rb deleted file mode 100644 index 28258c7c..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/showstatus.rb +++ /dev/null @@ -1,106 +0,0 @@ -require 'erb' -require 'rack/request' -require 'rack/utils' - -module Rack - # Rack::ShowStatus catches all empty responses the app it wraps and - # replaces them with a site explaining the error. - # - # Additional details can be put into rack.showstatus.detail - # and will be shown as HTML. If such details exist, the error page - # is always rendered, even if the reply was not empty. - - class ShowStatus - def initialize(app) - @app = app - @template = ERB.new(TEMPLATE) - end - - def call(env) - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - empty = headers['Content-Length'].to_i <= 0 - - # client or server error, or explicit message - if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"] - req = Rack::Request.new(env) - message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s - detail = env["rack.showstatus.detail"] || message - body = @template.result(binding) - size = Rack::Utils.bytesize(body) - [status, headers.merge("Content-Type" => "text/html", "Content-Length" => size.to_s), [body]] - else - [status, headers, body] - end - end - - def h(obj) # :nodoc: - case obj - when String - Utils.escape_html(obj) - else - Utils.escape_html(obj.inspect) - end - end - - # :stopdoc: - -# adapted from Django -# Copyright (c) 2005, the Lawrence Journal-World -# Used under the modified BSD license: -# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 -TEMPLATE = <<'HTML' - - - - - <%=h message %> at <%=h req.script_name + req.path_info %> - - - - -
-

<%=h message %> (<%= status.to_i %>)

- - - - - - - - - -
Request Method:<%=h req.request_method %>
Request URL:<%=h req.url %>
-
-
-

<%= detail %>

-
- -
-

- You're seeing this error because you use Rack::ShowStatus. -

-
- - -HTML - - # :startdoc: - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/static.rb b/vendor/gems/rack-1.0.1/lib/rack/static.rb deleted file mode 100644 index 168e8f83..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/static.rb +++ /dev/null @@ -1,38 +0,0 @@ -module Rack - - # The Rack::Static middleware intercepts requests for static files - # (javascript files, images, stylesheets, etc) based on the url prefixes - # passed in the options, and serves them using a Rack::File object. This - # allows a Rack stack to serve both static and dynamic content. - # - # Examples: - # use Rack::Static, :urls => ["/media"] - # will serve all requests beginning with /media from the "media" folder - # located in the current directory (ie media/*). - # - # use Rack::Static, :urls => ["/css", "/images"], :root => "public" - # will serve all requests beginning with /css or /images from the folder - # "public" in the current directory (ie public/css/* and public/images/*) - - class Static - - def initialize(app, options={}) - @app = app - @urls = options[:urls] || ["/favicon.ico"] - root = options[:root] || Dir.pwd - @file_server = Rack::File.new(root) - end - - def call(env) - path = env["PATH_INFO"] - can_serve = @urls.any? { |url| path.index(url) == 0 } - - if can_serve - @file_server.call(env) - else - @app.call(env) - end - end - - end -end diff --git a/vendor/gems/rack-1.0.1/lib/rack/urlmap.rb b/vendor/gems/rack-1.0.1/lib/rack/urlmap.rb deleted file mode 100644 index fcf6616c..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/urlmap.rb +++ /dev/null @@ -1,55 +0,0 @@ -module Rack - # Rack::URLMap takes a hash mapping urls or paths to apps, and - # dispatches accordingly. Support for HTTP/1.1 host names exists if - # the URLs start with http:// or https://. - # - # URLMap modifies the SCRIPT_NAME and PATH_INFO such that the part - # relevant for dispatch is in the SCRIPT_NAME, and the rest in the - # PATH_INFO. This should be taken care of when you need to - # reconstruct the URL in order to create links. - # - # URLMap dispatches in such a way that the longest paths are tried - # first, since they are most specific. - - class URLMap - def initialize(map = {}) - remap(map) - end - - def remap(map) - @mapping = map.map { |location, app| - if location =~ %r{\Ahttps?://(.*?)(/.*)} - host, location = $1, $2 - else - host = nil - end - - unless location[0] == ?/ - raise ArgumentError, "paths need to start with /" - end - location = location.chomp('/') - - [host, location, app] - }.sort_by { |(h, l, a)| [h ? -h.size : (-1.0 / 0.0), -l.size] } # Longest path first - end - - def call(env) - path = env["PATH_INFO"].to_s.squeeze("/") - script_name = env['SCRIPT_NAME'] - hHost, sName, sPort = env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT') - @mapping.each { |host, location, app| - next unless (hHost == host || sName == host \ - || (host.nil? && (hHost == sName || hHost == sName+':'+sPort))) - next unless location == path[0, location.size] - next unless path[location.size] == nil || path[location.size] == ?/ - - return app.call( - env.merge( - 'SCRIPT_NAME' => (script_name + location), - 'PATH_INFO' => path[location.size..-1])) - } - [404, {"Content-Type" => "text/plain"}, ["Not Found: #{path}"]] - end - end -end - diff --git a/vendor/gems/rack-1.0.1/lib/rack/utils.rb b/vendor/gems/rack-1.0.1/lib/rack/utils.rb deleted file mode 100644 index d54c928c..00000000 --- a/vendor/gems/rack-1.0.1/lib/rack/utils.rb +++ /dev/null @@ -1,401 +0,0 @@ -# -*- encoding: binary -*- - -require 'set' -require 'tempfile' - -module Rack - # Rack::Utils contains a grab-bag of useful methods for writing web - # applications adopted from all kinds of Ruby libraries. - - module Utils - # Performs URI escaping so that you can construct proper - # query strings faster. Use this rather than the cgi.rb - # version since it's faster. (Stolen from Camping). - def escape(s) - s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) { - '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase - }.tr(' ', '+') - end - module_function :escape - - # Unescapes a URI escaped string. (Stolen from Camping). - def unescape(s) - s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){ - [$1.delete('%')].pack('H*') - } - end - module_function :unescape - - DEFAULT_SEP = /[&;] */n - - # Stolen from Mongrel, with some small modifications: - # Parses a query string by breaking it up at the '&' - # and ';' characters. You can also use this to parse - # cookies by changing the characters used in the second - # parameter (which defaults to '&;'). - def parse_query(qs, d = nil) - params = {} - - (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p| - k, v = p.split('=', 2).map { |x| unescape(x) } - - if cur = params[k] - if cur.class == Array - params[k] << v - else - params[k] = [cur, v] - end - else - params[k] = v - end - end - - return params - end - module_function :parse_query - - def parse_nested_query(qs, d = nil) - params = {} - - (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p| - k, v = unescape(p).split('=', 2) - normalize_params(params, k, v) - end - - return params - end - module_function :parse_nested_query - - def normalize_params(params, name, v = nil) - name =~ %r(\A[\[\]]*([^\[\]]+)\]*) - k = $1 || '' - after = $' || '' - - return if k.empty? - - if after == "" - params[k] = v - elsif after == "[]" - params[k] ||= [] - raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array) - params[k] << v - elsif after =~ %r(^\[\]\[([^\[\]]+)\]$) || after =~ %r(^\[\](.+)$) - child_key = $1 - params[k] ||= [] - raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array) - if params[k].last.is_a?(Hash) && !params[k].last.key?(child_key) - normalize_params(params[k].last, child_key, v) - else - params[k] << normalize_params({}, child_key, v) - end - else - params[k] ||= {} - raise TypeError, "expected Hash (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Hash) - params[k] = normalize_params(params[k], after, v) - end - - return params - end - module_function :normalize_params - - def build_query(params) - params.map { |k, v| - if v.class == Array - build_query(v.map { |x| [k, x] }) - else - "#{escape(k)}=#{escape(v)}" - end - }.join("&") - end - module_function :build_query - - # Escape ampersands, brackets and quotes to their HTML/XML entities. - def escape_html(string) - string.to_s.gsub("&", "&"). - gsub("<", "<"). - gsub(">", ">"). - gsub("'", "'"). - gsub('"', """) - end - module_function :escape_html - - def select_best_encoding(available_encodings, accept_encoding) - # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html - - expanded_accept_encoding = - accept_encoding.map { |m, q| - if m == "*" - (available_encodings - accept_encoding.map { |m2, _| m2 }).map { |m2| [m2, q] } - else - [[m, q]] - end - }.inject([]) { |mem, list| - mem + list - } - - encoding_candidates = expanded_accept_encoding.sort_by { |_, q| -q }.map { |m, _| m } - - unless encoding_candidates.include?("identity") - encoding_candidates.push("identity") - end - - expanded_accept_encoding.find_all { |m, q| - q == 0.0 - }.each { |m, _| - encoding_candidates.delete(m) - } - - return (encoding_candidates & available_encodings)[0] - end - module_function :select_best_encoding - - # Return the bytesize of String; uses String#length under Ruby 1.8 and - # String#bytesize under 1.9. - if ''.respond_to?(:bytesize) - def bytesize(string) - string.bytesize - end - else - def bytesize(string) - string.size - end - end - module_function :bytesize - - # Context allows the use of a compatible middleware at different points - # in a request handling stack. A compatible middleware must define - # #context which should take the arguments env and app. The first of which - # would be the request environment. The second of which would be the rack - # application that the request would be forwarded to. - class Context - attr_reader :for, :app - - def initialize(app_f, app_r) - raise 'running context does not respond to #context' unless app_f.respond_to? :context - @for, @app = app_f, app_r - end - - def call(env) - @for.context(env, @app) - end - - def recontext(app) - self.class.new(@for, app) - end - - def context(env, app=@app) - recontext(app).call(env) - end - end - - # A case-insensitive Hash that preserves the original case of a - # header when set. - class HeaderHash < Hash - def initialize(hash={}) - @names = {} - hash.each { |k, v| self[k] = v } - end - - def to_hash - inject({}) do |hash, (k,v)| - if v.respond_to? :to_ary - hash[k] = v.to_ary.join("\n") - else - hash[k] = v - end - hash - end - end - - def [](k) - super @names[k.downcase] - end - - def []=(k, v) - delete k - @names[k.downcase] = k - super k, v - end - - def delete(k) - super @names.delete(k.downcase) - end - - def include?(k) - @names.has_key? k.downcase - end - - alias_method :has_key?, :include? - alias_method :member?, :include? - alias_method :key?, :include? - - def merge!(other) - other.each { |k, v| self[k] = v } - self - end - - def merge(other) - hash = dup - hash.merge! other - end - end - - # Every standard HTTP code mapped to the appropriate message. - # Stolen from Mongrel. - HTTP_STATUS_CODES = { - 100 => 'Continue', - 101 => 'Switching Protocols', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Large', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported' - } - - # Responses with HTTP status codes that should not have an entity body - STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 304) - - # A multipart form data parser, adapted from IOWA. - # - # Usually, Rack::Request#POST takes care of calling this. - - module Multipart - EOL = "\r\n" - - def self.parse_multipart(env) - unless env['CONTENT_TYPE'] =~ - %r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|n - nil - else - boundary = "--#{$1}" - - params = {} - buf = "" - content_length = env['CONTENT_LENGTH'].to_i - input = env['rack.input'] - input.rewind - - boundary_size = Utils.bytesize(boundary) + EOL.size - bufsize = 16384 - - content_length -= boundary_size - - read_buffer = '' - - status = input.read(boundary_size, read_buffer) - raise EOFError, "bad content body" unless status == boundary + EOL - - rx = /(?:#{EOL})?#{Regexp.quote boundary}(#{EOL}|--)/n - - loop { - head = nil - body = '' - filename = content_type = name = nil - - until head && buf =~ rx - if !head && i = buf.index(EOL+EOL) - head = buf.slice!(0, i+2) # First \r\n - buf.slice!(0, 2) # Second \r\n - - filename = head[/Content-Disposition:.* filename=(?:"((?:\\.|[^\"])*)"|([^;\s]*))/ni, 1] - content_type = head[/Content-Type: (.*)#{EOL}/ni, 1] - name = head[/Content-Disposition:.*\s+name="?([^\";]*)"?/ni, 1] || head[/Content-ID:\s*([^#{EOL}]*)/ni, 1] - - if content_type || filename - body = Tempfile.new("RackMultipart") - body.binmode if body.respond_to?(:binmode) - end - - next - end - - # Save the read body part. - if head && (boundary_size+4 < buf.size) - body << buf.slice!(0, buf.size - (boundary_size+4)) - end - - c = input.read(bufsize < content_length ? bufsize : content_length, read_buffer) - raise EOFError, "bad content body" if c.nil? || c.empty? - buf << c - content_length -= c.size - end - - # Save the rest. - if i = buf.index(rx) - body << buf.slice!(0, i) - buf.slice!(0, boundary_size+2) - - content_length = -1 if $1 == "--" - end - - if filename == "" - # filename is blank which means no file has been selected - data = nil - elsif filename - body.rewind - - # Take the basename of the upload's original filename. - # This handles the full Windows paths given by Internet Explorer - # (and perhaps other broken user agents) without affecting - # those which give the lone filename. - filename =~ /^(?:.*[:\\\/])?(.*)/m - filename = $1 - - data = {:filename => filename, :type => content_type, - :name => name, :tempfile => body, :head => head} - elsif !filename && content_type - body.rewind - - # Generic multipart cases, not coming from a form - data = {:type => content_type, - :name => name, :tempfile => body, :head => head} - else - data = body - end - - Utils.normalize_params(params, name, data) unless data.nil? - - break if buf.empty? || content_length == -1 - } - - input.rewind - - params - end - end - end - end -end diff --git a/vendor/gems/rack-1.0.1/rack.gemspec b/vendor/gems/rack-1.0.1/rack.gemspec deleted file mode 100644 index 2640997b..00000000 --- a/vendor/gems/rack-1.0.1/rack.gemspec +++ /dev/null @@ -1,54 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{rack} - s.version = "1.0.1" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Christian Neukirchen"] - s.date = %q{2009-10-18} - s.default_executable = %q{rackup} - s.description = %q{Rack provides minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call. Also see http://rack.rubyforge.org.} - s.email = %q{chneukirchen@gmail.com} - s.executables = ["rackup"] - s.extra_rdoc_files = ["README", "SPEC", "RDOX", "KNOWN-ISSUES"] - s.files = ["COPYING", "KNOWN-ISSUES", "README", "Rakefile", "bin/rackup", "contrib/rack_logo.svg", "example/lobster.ru", "example/protectedlobster.rb", "example/protectedlobster.ru", "lib/rack.rb", "lib/rack/adapter/camping.rb", "lib/rack/auth/abstract/handler.rb", "lib/rack/auth/abstract/request.rb", "lib/rack/auth/basic.rb", "lib/rack/auth/digest/md5.rb", "lib/rack/auth/digest/nonce.rb", "lib/rack/auth/digest/params.rb", "lib/rack/auth/digest/request.rb", "lib/rack/auth/openid.rb", "lib/rack/builder.rb", "lib/rack/cascade.rb", "lib/rack/chunked.rb", "lib/rack/commonlogger.rb", "lib/rack/conditionalget.rb", "lib/rack/content_length.rb", "lib/rack/content_type.rb", "lib/rack/deflater.rb", "lib/rack/directory.rb", "lib/rack/file.rb", "lib/rack/handler.rb", "lib/rack/handler/cgi.rb", "lib/rack/handler/evented_mongrel.rb", "lib/rack/handler/fastcgi.rb", "lib/rack/handler/lsws.rb", "lib/rack/handler/mongrel.rb", "lib/rack/handler/scgi.rb", "lib/rack/handler/swiftiplied_mongrel.rb", "lib/rack/handler/thin.rb", "lib/rack/handler/webrick.rb", "lib/rack/head.rb", "lib/rack/lint.rb", "lib/rack/lobster.rb", "lib/rack/lock.rb", "lib/rack/methodoverride.rb", "lib/rack/mime.rb", "lib/rack/mock.rb", "lib/rack/recursive.rb", "lib/rack/reloader.rb", "lib/rack/request.rb", "lib/rack/response.rb", "lib/rack/rewindable_input.rb", "lib/rack/session/abstract/id.rb", "lib/rack/session/cookie.rb", "lib/rack/session/memcache.rb", "lib/rack/session/pool.rb", "lib/rack/showexceptions.rb", "lib/rack/showstatus.rb", "lib/rack/static.rb", "lib/rack/urlmap.rb", "lib/rack/utils.rb", "test/cgi/lighttpd.conf", "test/cgi/test", "test/cgi/test.fcgi", "test/cgi/test.ru", "test/multipart/binary", "test/multipart/empty", "test/multipart/ie", "test/multipart/nested", "test/multipart/none", "test/multipart/semicolon", "test/multipart/text", "test/spec_rack_auth_basic.rb", "test/spec_rack_auth_digest.rb", "test/spec_rack_auth_openid.rb", "test/spec_rack_builder.rb", "test/spec_rack_camping.rb", "test/spec_rack_cascade.rb", "test/spec_rack_cgi.rb", "test/spec_rack_chunked.rb", "test/spec_rack_commonlogger.rb", "test/spec_rack_conditionalget.rb", "test/spec_rack_content_length.rb", "test/spec_rack_content_type.rb", "test/spec_rack_deflater.rb", "test/spec_rack_directory.rb", "test/spec_rack_fastcgi.rb", "test/spec_rack_file.rb", "test/spec_rack_handler.rb", "test/spec_rack_head.rb", "test/spec_rack_lint.rb", "test/spec_rack_lobster.rb", "test/spec_rack_lock.rb", "test/spec_rack_methodoverride.rb", "test/spec_rack_mock.rb", "test/spec_rack_mongrel.rb", "test/spec_rack_recursive.rb", "test/spec_rack_request.rb", "test/spec_rack_response.rb", "test/spec_rack_rewindable_input.rb", "test/spec_rack_session_cookie.rb", "test/spec_rack_session_memcache.rb", "test/spec_rack_session_pool.rb", "test/spec_rack_showexceptions.rb", "test/spec_rack_showstatus.rb", "test/spec_rack_static.rb", "test/spec_rack_thin.rb", "test/spec_rack_urlmap.rb", "test/spec_rack_utils.rb", "test/spec_rack_webrick.rb", "test/testrequest.rb", "test/unregistered_handler/rack/handler/unregistered.rb", "test/unregistered_handler/rack/handler/unregistered_long_one.rb", "SPEC", "RDOX", "rack.gemspec"] - s.has_rdoc = true - s.homepage = %q{http://rack.rubyforge.org} - s.require_paths = ["lib"] - s.rubyforge_project = %q{rack} - s.rubygems_version = %q{1.3.1} - s.summary = %q{a modular Ruby webserver interface} - s.test_files = ["test/spec_rack_auth_basic.rb", "test/spec_rack_auth_digest.rb", "test/spec_rack_auth_openid.rb", "test/spec_rack_builder.rb", "test/spec_rack_camping.rb", "test/spec_rack_cascade.rb", "test/spec_rack_cgi.rb", "test/spec_rack_chunked.rb", "test/spec_rack_commonlogger.rb", "test/spec_rack_conditionalget.rb", "test/spec_rack_content_length.rb", "test/spec_rack_content_type.rb", "test/spec_rack_deflater.rb", "test/spec_rack_directory.rb", "test/spec_rack_fastcgi.rb", "test/spec_rack_file.rb", "test/spec_rack_handler.rb", "test/spec_rack_head.rb", "test/spec_rack_lint.rb", "test/spec_rack_lobster.rb", "test/spec_rack_lock.rb", "test/spec_rack_methodoverride.rb", "test/spec_rack_mock.rb", "test/spec_rack_mongrel.rb", "test/spec_rack_recursive.rb", "test/spec_rack_request.rb", "test/spec_rack_response.rb", "test/spec_rack_rewindable_input.rb", "test/spec_rack_session_cookie.rb", "test/spec_rack_session_memcache.rb", "test/spec_rack_session_pool.rb", "test/spec_rack_showexceptions.rb", "test/spec_rack_showstatus.rb", "test/spec_rack_static.rb", "test/spec_rack_thin.rb", "test/spec_rack_urlmap.rb", "test/spec_rack_utils.rb", "test/spec_rack_webrick.rb"] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, ["~> 2.0.0"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, ["~> 2.0.0"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, ["~> 2.0.0"]) - s.add_dependency(%q, [">= 0"]) - end -end diff --git a/vendor/gems/rack-1.0.1/test/cgi/lighttpd.conf b/vendor/gems/rack-1.0.1/test/cgi/lighttpd.conf deleted file mode 100644 index 889726c6..00000000 --- a/vendor/gems/rack-1.0.1/test/cgi/lighttpd.conf +++ /dev/null @@ -1,20 +0,0 @@ -server.modules = ("mod_fastcgi", "mod_cgi") -server.document-root = "." -server.errorlog = "lighttpd.errors" -server.port = 9203 - -server.event-handler = "select" - -cgi.assign = ("/test" => "", -# ".ru" => "" - ) - -fastcgi.server = ("test.fcgi" => ("localhost" => - ("min-procs" => 1, - "socket" => "/tmp/rack-test-fcgi", - "bin-path" => "test.fcgi")), - "test.ru" => ("localhost" => - ("min-procs" => 1, - "socket" => "/tmp/rack-test-ru-fcgi", - "bin-path" => "test.ru")), - ) diff --git a/vendor/gems/rack-1.0.1/test/cgi/test b/vendor/gems/rack-1.0.1/test/cgi/test deleted file mode 100755 index e4837a4e..00000000 --- a/vendor/gems/rack-1.0.1/test/cgi/test +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env ruby -# -*- ruby -*- - -$: << File.join(File.dirname(__FILE__), "..", "..", "lib") - -require 'rack' -require '../testrequest' - -Rack::Handler::CGI.run(Rack::Lint.new(TestRequest.new)) diff --git a/vendor/gems/rack-1.0.1/test/cgi/test.fcgi b/vendor/gems/rack-1.0.1/test/cgi/test.fcgi deleted file mode 100755 index 5e104fc9..00000000 --- a/vendor/gems/rack-1.0.1/test/cgi/test.fcgi +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby -# -*- ruby -*- - -$:.unshift '../../lib' -require 'rack' -require '../testrequest' - -Rack::Handler::FastCGI.run(Rack::Lint.new(TestRequest.new)) diff --git a/vendor/gems/rack-1.0.1/test/cgi/test.ru b/vendor/gems/rack-1.0.1/test/cgi/test.ru deleted file mode 100755 index 4054b886..00000000 --- a/vendor/gems/rack-1.0.1/test/cgi/test.ru +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env ../../bin/rackup -#\ -E deployment -I ../../lib -# -*- ruby -*- - -require '../testrequest' - -run TestRequest.new diff --git a/vendor/gems/rack-1.0.1/test/multipart/binary b/vendor/gems/rack-1.0.1/test/multipart/binary deleted file mode 100644 index a3bd67c4..00000000 Binary files a/vendor/gems/rack-1.0.1/test/multipart/binary and /dev/null differ diff --git a/vendor/gems/rack-1.0.1/test/multipart/empty b/vendor/gems/rack-1.0.1/test/multipart/empty deleted file mode 100644 index f0f79835..00000000 --- a/vendor/gems/rack-1.0.1/test/multipart/empty +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="submit-name" - -Larry ---AaB03x -Content-Disposition: form-data; name="files"; filename="file1.txt" -Content-Type: text/plain - - ---AaB03x-- diff --git a/vendor/gems/rack-1.0.1/test/multipart/ie b/vendor/gems/rack-1.0.1/test/multipart/ie deleted file mode 100644 index eae06ab5..00000000 --- a/vendor/gems/rack-1.0.1/test/multipart/ie +++ /dev/null @@ -1,6 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="files"; filename="C:\Documents and Settings\Administrator\Desktop\file1.txt" -Content-Type: text/plain - -contents ---AaB03x-- diff --git a/vendor/gems/rack-1.0.1/test/multipart/nested b/vendor/gems/rack-1.0.1/test/multipart/nested deleted file mode 100644 index 51978824..00000000 --- a/vendor/gems/rack-1.0.1/test/multipart/nested +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo[submit-name]" - -Larry ---AaB03x -Content-Disposition: form-data; name="foo[files]"; filename="file1.txt" -Content-Type: text/plain - -contents ---AaB03x-- diff --git a/vendor/gems/rack-1.0.1/test/multipart/none b/vendor/gems/rack-1.0.1/test/multipart/none deleted file mode 100644 index d66f4730..00000000 --- a/vendor/gems/rack-1.0.1/test/multipart/none +++ /dev/null @@ -1,9 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="submit-name" - -Larry ---AaB03x -Content-Disposition: form-data; name="files"; filename="" - - ---AaB03x-- diff --git a/vendor/gems/rack-1.0.1/test/multipart/semicolon b/vendor/gems/rack-1.0.1/test/multipart/semicolon deleted file mode 100644 index 00fd68ab..00000000 --- a/vendor/gems/rack-1.0.1/test/multipart/semicolon +++ /dev/null @@ -1,6 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="files"; filename="fi;le1.txt" -Content-Type: text/plain - -contents ---AaB03x-- \ No newline at end of file diff --git a/vendor/gems/rack-1.0.1/test/multipart/text b/vendor/gems/rack-1.0.1/test/multipart/text deleted file mode 100644 index b83d3821..00000000 --- a/vendor/gems/rack-1.0.1/test/multipart/text +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="submit-name" - -Larry ---AaB03x -Content-Disposition: form-data; name="files"; filename="file1.txt" -Content-Type: text/plain - -contents ---AaB03x-- \ No newline at end of file diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_auth_basic.rb b/vendor/gems/rack-1.0.1/test/spec_rack_auth_basic.rb deleted file mode 100644 index 0176efc8..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_auth_basic.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'test/spec' - -require 'rack/auth/basic' -require 'rack/mock' - -context 'Rack::Auth::Basic' do - - def realm - 'WallysWorld' - end - - def unprotected_app - lambda { |env| [ 200, {'Content-Type' => 'text/plain'}, ["Hi #{env['REMOTE_USER']}"] ] } - end - - def protected_app - app = Rack::Auth::Basic.new(unprotected_app) { |username, password| 'Boss' == username } - app.realm = realm - app - end - - setup do - @request = Rack::MockRequest.new(protected_app) - end - - def request_with_basic_auth(username, password, &block) - request 'HTTP_AUTHORIZATION' => 'Basic ' + ["#{username}:#{password}"].pack("m*"), &block - end - - def request(headers = {}) - yield @request.get('/', headers) - end - - def assert_basic_auth_challenge(response) - response.should.be.a.client_error - response.status.should.equal 401 - response.should.include 'WWW-Authenticate' - response.headers['WWW-Authenticate'].should =~ /Basic realm="#{Regexp.escape(realm)}"/ - response.body.should.be.empty - end - - specify 'should challenge correctly when no credentials are specified' do - request do |response| - assert_basic_auth_challenge response - end - end - - specify 'should rechallenge if incorrect credentials are specified' do - request_with_basic_auth 'joe', 'password' do |response| - assert_basic_auth_challenge response - end - end - - specify 'should return application output if correct credentials are specified' do - request_with_basic_auth 'Boss', 'password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Boss' - end - end - - specify 'should return 400 Bad Request if different auth scheme used' do - request 'HTTP_AUTHORIZATION' => 'Digest params' do |response| - response.should.be.a.client_error - response.status.should.equal 400 - response.should.not.include 'WWW-Authenticate' - end - end - - specify 'realm as optional constructor arg' do - app = Rack::Auth::Basic.new(unprotected_app, realm) { true } - assert_equal realm, app.realm - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_auth_digest.rb b/vendor/gems/rack-1.0.1/test/spec_rack_auth_digest.rb deleted file mode 100644 index a980acc8..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_auth_digest.rb +++ /dev/null @@ -1,226 +0,0 @@ -require 'test/spec' - -require 'rack/auth/digest/md5' -require 'rack/mock' - -context 'Rack::Auth::Digest::MD5' do - - def realm - 'WallysWorld' - end - - def unprotected_app - lambda do |env| - [ 200, {'Content-Type' => 'text/plain'}, ["Hi #{env['REMOTE_USER']}"] ] - end - end - - def protected_app - app = Rack::Auth::Digest::MD5.new(unprotected_app) do |username| - { 'Alice' => 'correct-password' }[username] - end - app.realm = realm - app.opaque = 'this-should-be-secret' - app - end - - def protected_app_with_hashed_passwords - app = Rack::Auth::Digest::MD5.new(unprotected_app) do |username| - username == 'Alice' ? Digest::MD5.hexdigest("Alice:#{realm}:correct-password") : nil - end - app.realm = realm - app.opaque = 'this-should-be-secret' - app.passwords_hashed = true - app - end - - def partially_protected_app - Rack::URLMap.new({ - '/' => unprotected_app, - '/protected' => protected_app - }) - end - - def protected_app_with_method_override - Rack::MethodOverride.new(protected_app) - end - - setup do - @request = Rack::MockRequest.new(protected_app) - end - - def request(method, path, headers = {}, &block) - response = @request.request(method, path, headers) - block.call(response) if block - return response - end - - class MockDigestRequest - def initialize(params) - @params = params - end - def method_missing(sym) - if @params.has_key? k = sym.to_s - return @params[k] - end - super - end - def method - @params['method'] - end - def response(password) - Rack::Auth::Digest::MD5.new(nil).send :digest, self, password - end - end - - def request_with_digest_auth(method, path, username, password, options = {}, &block) - request_options = {} - request_options[:input] = options.delete(:input) if options.include? :input - - response = request(method, path, request_options) - - return response unless response.status == 401 - - if wait = options.delete(:wait) - sleep wait - end - - challenge = response['WWW-Authenticate'].split(' ', 2).last - - params = Rack::Auth::Digest::Params.parse(challenge) - - params['username'] = username - params['nc'] = '00000001' - params['cnonce'] = 'nonsensenonce' - params['uri'] = path - - params['method'] = method - - params.update options - - params['response'] = MockDigestRequest.new(params).response(password) - - request(method, path, request_options.merge('HTTP_AUTHORIZATION' => "Digest #{params}"), &block) - end - - def assert_digest_auth_challenge(response) - response.should.be.a.client_error - response.status.should.equal 401 - response.should.include 'WWW-Authenticate' - response.headers['WWW-Authenticate'].should =~ /^Digest / - response.body.should.be.empty - end - - def assert_bad_request(response) - response.should.be.a.client_error - response.status.should.equal 400 - response.should.not.include 'WWW-Authenticate' - end - - specify 'should challenge when no credentials are specified' do - request 'GET', '/' do |response| - assert_digest_auth_challenge response - end - end - - specify 'should return application output if correct credentials given' do - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'should return application output if correct credentials given (hashed passwords)' do - @request = Rack::MockRequest.new(protected_app_with_hashed_passwords) - - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'should rechallenge if incorrect username given' do - request_with_digest_auth 'GET', '/', 'Bob', 'correct-password' do |response| - assert_digest_auth_challenge response - end - end - - specify 'should rechallenge if incorrect password given' do - request_with_digest_auth 'GET', '/', 'Alice', 'wrong-password' do |response| - assert_digest_auth_challenge response - end - end - - specify 'should rechallenge with stale parameter if nonce is stale' do - begin - Rack::Auth::Digest::Nonce.time_limit = 1 - - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', :wait => 2 do |response| - assert_digest_auth_challenge response - response.headers['WWW-Authenticate'].should =~ /\bstale=true\b/ - end - ensure - Rack::Auth::Digest::Nonce.time_limit = nil - end - end - - specify 'should return 400 Bad Request if incorrect qop given' do - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'qop' => 'auth-int' do |response| - assert_bad_request response - end - end - - specify 'should return 400 Bad Request if incorrect uri given' do - request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'uri' => '/foo' do |response| - assert_bad_request response - end - end - - specify 'should return 400 Bad Request if different auth scheme used' do - request 'GET', '/', 'HTTP_AUTHORIZATION' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' do |response| - assert_bad_request response - end - end - - specify 'should not require credentials for unprotected path' do - @request = Rack::MockRequest.new(partially_protected_app) - request 'GET', '/' do |response| - response.should.be.ok - end - end - - specify 'should challenge when no credentials are specified for protected path' do - @request = Rack::MockRequest.new(partially_protected_app) - request 'GET', '/protected' do |response| - assert_digest_auth_challenge response - end - end - - specify 'should return application output if correct credentials given for protected path' do - @request = Rack::MockRequest.new(partially_protected_app) - request_with_digest_auth 'GET', '/protected', 'Alice', 'correct-password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'should return application output if correct credentials given for POST' do - request_with_digest_auth 'POST', '/', 'Alice', 'correct-password' do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'should return application output if correct credentials given for PUT (using method override of POST)' do - @request = Rack::MockRequest.new(protected_app_with_method_override) - request_with_digest_auth 'POST', '/', 'Alice', 'correct-password', :input => "_method=put" do |response| - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Alice' - end - end - - specify 'realm as optional constructor arg' do - app = Rack::Auth::Digest::MD5.new(unprotected_app, realm) { true } - assert_equal realm, app.realm - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_auth_openid.rb b/vendor/gems/rack-1.0.1/test/spec_rack_auth_openid.rb deleted file mode 100644 index ba248445..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_auth_openid.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'test/spec' - -begin -# requires the ruby-openid gem -require 'rack/auth/openid' - -context "Rack::Auth::OpenID" do - OID = Rack::Auth::OpenID - host = 'host' - subd = 'sub.host' - wild = '*.host' - path = 'path' - long = 'path/long' - scheme = 'http://' - realm = scheme+host+'/'+path - - specify 'realm uri should be valid' do - lambda{OID.new('/'+path)}.should.raise ArgumentError - lambda{OID.new('/'+long)}.should.raise ArgumentError - lambda{OID.new(scheme+host)}.should.not.raise - lambda{OID.new(scheme+host+'/')}.should.not.raise - lambda{OID.new(scheme+host+'/'+path)}.should.not.raise - lambda{OID.new(scheme+subd)}.should.not.raise - lambda{OID.new(scheme+subd+'/')}.should.not.raise - lambda{OID.new(scheme+subd+'/'+path)}.should.not.raise - end - - specify 'should be able to check if a uri is within the realm' do - end - - specify 'return_to should be valid' do - uri = '/'+path - lambda{OID.new(realm, :return_to=>uri)}.should.raise ArgumentError - uri = '/'+long - lambda{OID.new(realm, :return_to=>uri)}.should.raise ArgumentError - uri = scheme+host - lambda{OID.new(realm, :return_to=>uri)}.should.raise ArgumentError - uri = scheme+host+'/'+path - lambda{OID.new(realm, :return_to=>uri)}.should.not.raise - uri = scheme+subd+'/'+path - lambda{OID.new(realm, :return_to=>uri)}.should.raise ArgumentError - uri = scheme+host+'/'+long - lambda{OID.new(realm, :return_to=>uri)}.should.not.raise - uri = scheme+subd+'/'+long - lambda{OID.new(realm, :return_to=>uri)}.should.raise ArgumentError - end - - specify 'extensions should have required constants defined' do - badext = Rack::Auth::OpenID::BadExtension - ext = Object.new - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - ext = Module.new - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - ext::Request = nil - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - ext::Response = nil - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - ext::NS_URI = nil - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - end - - specify 'extensions should have Request and Response defined and inherit from OpenID::Extension' do - $-w, w = nil, $-w # yuck - badext = Rack::Auth::OpenID::BadExtension - ext = Module.new - ext::Request = nil - ext::Response = nil - ext::NS_URI = nil - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - ext::Request = Class.new() - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - ext::Response = Class.new() - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - ext::Request = Class.new(::OpenID::Extension) - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - ext::Response = Class.new(::OpenID::Extension) - lambda{OID.new(realm).add_extension(ext)}.should.raise(badext) - $-w = w - end -end - -rescue LoadError - $stderr.puts "Skipping Rack::Auth::OpenID tests (ruby-openid 2 is required). `gem install ruby-openid` and try again." -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_builder.rb b/vendor/gems/rack-1.0.1/test/spec_rack_builder.rb deleted file mode 100644 index 3fad9810..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_builder.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'test/spec' - -require 'rack/builder' -require 'rack/mock' -require 'rack/showexceptions' -require 'rack/auth/basic' - -context "Rack::Builder" do - specify "chains apps by default" do - app = Rack::Builder.new do - use Rack::ShowExceptions - run lambda { |env| raise "bzzzt" } - end.to_app - - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - end - - specify "has implicit #to_app" do - app = Rack::Builder.new do - use Rack::ShowExceptions - run lambda { |env| raise "bzzzt" } - end - - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - end - - specify "supports blocks on use" do - app = Rack::Builder.new do - use Rack::ShowExceptions - use Rack::Auth::Basic do |username, password| - 'secret' == password - end - - run lambda { |env| [200, {}, ['Hi Boss']] } - end - - response = Rack::MockRequest.new(app).get("/") - response.should.be.client_error - response.status.should.equal 401 - - # with auth... - response = Rack::MockRequest.new(app).get("/", - 'HTTP_AUTHORIZATION' => 'Basic ' + ["joe:secret"].pack("m*")) - response.status.should.equal 200 - response.body.to_s.should.equal 'Hi Boss' - end - - specify "has explicit #to_app" do - app = Rack::Builder.app do - use Rack::ShowExceptions - run lambda { |env| raise "bzzzt" } - end - - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - Rack::MockRequest.new(app).get("/").should.be.server_error - end - - specify "apps are initialized once" do - app = Rack::Builder.new do - class AppClass - def initialize - @called = 0 - end - def call(env) - raise "bzzzt" if @called > 0 - @called += 1 - [200, {'Content-Type' => 'text/plain'}, ['OK']] - end - end - - use Rack::ShowExceptions - run AppClass.new - end - - Rack::MockRequest.new(app).get("/").status.should.equal 200 - Rack::MockRequest.new(app).get("/").should.be.server_error - end - -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_camping.rb b/vendor/gems/rack-1.0.1/test/spec_rack_camping.rb deleted file mode 100644 index bed11710..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_camping.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'test/spec' -require 'stringio' -require 'uri' - -begin - require 'rack/mock' - - $-w, w = nil, $-w # yuck - require 'camping' - require 'rack/adapter/camping' - - Camping.goes :CampApp - module CampApp - module Controllers - class HW < R('/') - def get - @headers["X-Served-By"] = URI("http://rack.rubyforge.org") - "Camping works!" - end - - def post - "Data: #{input.foo}" - end - end - end - end - $-w = w - - context "Rack::Adapter::Camping" do - specify "works with GET" do - res = Rack::MockRequest.new(Rack::Adapter::Camping.new(CampApp)). - get("/") - - res.should.be.ok - res["Content-Type"].should.equal "text/html" - res["X-Served-By"].should.equal "http://rack.rubyforge.org" - - res.body.should.equal "Camping works!" - end - - specify "works with POST" do - res = Rack::MockRequest.new(Rack::Adapter::Camping.new(CampApp)). - post("/", :input => "foo=bar") - - res.should.be.ok - res.body.should.equal "Data: bar" - end - end -rescue LoadError - $stderr.puts "Skipping Rack::Adapter::Camping tests (Camping is required). `gem install camping` and try again." -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_cascade.rb b/vendor/gems/rack-1.0.1/test/spec_rack_cascade.rb deleted file mode 100644 index 3c0f3be3..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_cascade.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'test/spec' - -require 'rack/cascade' -require 'rack/mock' - -require 'rack/urlmap' -require 'rack/file' - -context "Rack::Cascade" do - docroot = File.expand_path(File.dirname(__FILE__)) - app1 = Rack::File.new(docroot) - - app2 = Rack::URLMap.new("/crash" => lambda { |env| raise "boom" }) - - app3 = Rack::URLMap.new("/foo" => lambda { |env| - [200, { "Content-Type" => "text/plain"}, [""]]}) - - specify "should dispatch onward on 404 by default" do - cascade = Rack::Cascade.new([app1, app2, app3]) - Rack::MockRequest.new(cascade).get("/cgi/test").should.be.ok - Rack::MockRequest.new(cascade).get("/foo").should.be.ok - Rack::MockRequest.new(cascade).get("/toobad").should.be.not_found - Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.forbidden - end - - specify "should dispatch onward on whatever is passed" do - cascade = Rack::Cascade.new([app1, app2, app3], [404, 403]) - Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.not_found - end - - specify "should fail if empty" do - lambda { Rack::MockRequest.new(Rack::Cascade.new([])).get("/") }. - should.raise(ArgumentError) - end - - specify "should append new app" do - cascade = Rack::Cascade.new([], [404, 403]) - lambda { Rack::MockRequest.new(cascade).get('/cgi/test') }. - should.raise(ArgumentError) - cascade << app2 - Rack::MockRequest.new(cascade).get('/cgi/test').should.be.not_found - Rack::MockRequest.new(cascade).get('/cgi/../bla').should.be.not_found - cascade << app1 - Rack::MockRequest.new(cascade).get('/cgi/test').should.be.ok - Rack::MockRequest.new(cascade).get('/cgi/../bla').should.be.forbidden - Rack::MockRequest.new(cascade).get('/foo').should.be.not_found - cascade << app3 - Rack::MockRequest.new(cascade).get('/foo').should.be.ok - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_cgi.rb b/vendor/gems/rack-1.0.1/test/spec_rack_cgi.rb deleted file mode 100644 index 818fabdf..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_cgi.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'test/spec' -require 'testrequest' - -context "Rack::Handler::CGI" do - include TestRequest::Helpers - - setup do - @host = '0.0.0.0' - @port = 9203 - end - - # Keep this first. - specify "startup" do - $pid = fork { - Dir.chdir(File.join(File.dirname(__FILE__), "..", "test", "cgi")) - exec "lighttpd -D -f lighttpd.conf" - } - end - - specify "should respond" do - sleep 1 - lambda { - GET("/test") - }.should.not.raise - end - - specify "should be a lighttpd" do - GET("/test") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /lighttpd/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal @port.to_s - response["SERVER_NAME"].should =~ @host - end - - specify "should have rack headers" do - GET("/test") - response["rack.version"].should.equal [1,0] - response["rack.multithread"].should.be false - response["rack.multiprocess"].should.be true - response["rack.run_once"].should.be true - end - - specify "should have CGI headers on GET" do - GET("/test") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.be.nil - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "/foo" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - # Keep this last. - specify "shutdown" do - Process.kill 15, $pid - Process.wait($pid).should.equal $pid - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_chunked.rb b/vendor/gems/rack-1.0.1/test/spec_rack_chunked.rb deleted file mode 100644 index 39eea482..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_chunked.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'rack/mock' -require 'rack/chunked' -require 'rack/utils' - -context "Rack::Chunked" do - - before do - @env = Rack::MockRequest. - env_for('/', 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => 'GET') - end - - specify 'chunks responses with no Content-Length' do - app = lambda { |env| [200, {}, ['Hello', ' ', 'World!']] } - response = Rack::MockResponse.new(*Rack::Chunked.new(app).call(@env)) - response.headers.should.not.include 'Content-Length' - response.headers['Transfer-Encoding'].should.equal 'chunked' - response.body.should.equal "5\r\nHello\r\n1\r\n \r\n6\r\nWorld!\r\n0\r\n\r\n" - end - - specify 'chunks empty bodies properly' do - app = lambda { |env| [200, {}, []] } - response = Rack::MockResponse.new(*Rack::Chunked.new(app).call(@env)) - response.headers.should.not.include 'Content-Length' - response.headers['Transfer-Encoding'].should.equal 'chunked' - response.body.should.equal "0\r\n\r\n" - end - - specify 'does not modify response when Content-Length header present' do - app = lambda { |env| [200, {'Content-Length'=>'12'}, ['Hello', ' ', 'World!']] } - status, headers, body = Rack::Chunked.new(app).call(@env) - status.should.equal 200 - headers.should.not.include 'Transfer-Encoding' - headers.should.include 'Content-Length' - body.join.should.equal 'Hello World!' - end - - specify 'does not modify response when client is HTTP/1.0' do - app = lambda { |env| [200, {}, ['Hello', ' ', 'World!']] } - @env['HTTP_VERSION'] = 'HTTP/1.0' - status, headers, body = Rack::Chunked.new(app).call(@env) - status.should.equal 200 - headers.should.not.include 'Transfer-Encoding' - body.join.should.equal 'Hello World!' - end - - specify 'does not modify response when Transfer-Encoding header already present' do - app = lambda { |env| [200, {'Transfer-Encoding' => 'identity'}, ['Hello', ' ', 'World!']] } - status, headers, body = Rack::Chunked.new(app).call(@env) - status.should.equal 200 - headers['Transfer-Encoding'].should.equal 'identity' - body.join.should.equal 'Hello World!' - end - - [100, 204, 304].each do |status_code| - specify "does not modify response when status code is #{status_code}" do - app = lambda { |env| [status_code, {}, []] } - status, headers, body = Rack::Chunked.new(app).call(@env) - status.should.equal status_code - headers.should.not.include 'Transfer-Encoding' - end - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_commonlogger.rb b/vendor/gems/rack-1.0.1/test/spec_rack_commonlogger.rb deleted file mode 100644 index ba03b78a..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_commonlogger.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'test/spec' -require 'stringio' - -require 'rack/commonlogger' -require 'rack/lobster' -require 'rack/mock' - -context "Rack::CommonLogger" do - app = lambda { |env| - [200, - {"Content-Type" => "text/html"}, - ["foo"]]} - - specify "should log to rack.errors by default" do - log = StringIO.new - res = Rack::MockRequest.new(Rack::CommonLogger.new(app)).get("/") - - res.errors.should.not.be.empty - res.errors.should =~ /GET / - res.errors.should =~ / 200 / # status - res.errors.should =~ / 3 / # length - end - - specify "should log to anything with <<" do - log = "" - res = Rack::MockRequest.new(Rack::CommonLogger.new(app, log)).get("/") - - log.should =~ /GET / - log.should =~ / 200 / # status - log.should =~ / 3 / # length - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_conditionalget.rb b/vendor/gems/rack-1.0.1/test/spec_rack_conditionalget.rb deleted file mode 100644 index ca34cc92..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_conditionalget.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'test/spec' -require 'time' - -require 'rack/mock' -require 'rack/conditionalget' - -context "Rack::ConditionalGet" do - specify "should set a 304 status and truncate body when If-Modified-Since hits" do - timestamp = Time.now.httpdate - app = Rack::ConditionalGet.new(lambda { |env| - [200, {'Last-Modified'=>timestamp}, ['TEST']] }) - - response = Rack::MockRequest.new(app). - get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp) - - response.status.should.equal 304 - response.body.should.be.empty - end - - specify "should set a 304 status and truncate body when If-None-Match hits" do - app = Rack::ConditionalGet.new(lambda { |env| - [200, {'Etag'=>'1234'}, ['TEST']] }) - - response = Rack::MockRequest.new(app). - get("/", 'HTTP_IF_NONE_MATCH' => '1234') - - response.status.should.equal 304 - response.body.should.be.empty - end - - specify "should not affect non-GET/HEAD requests" do - app = Rack::ConditionalGet.new(lambda { |env| - [200, {'Etag'=>'1234'}, ['TEST']] }) - - response = Rack::MockRequest.new(app). - post("/", 'HTTP_IF_NONE_MATCH' => '1234') - - response.status.should.equal 200 - response.body.should.equal 'TEST' - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_content_length.rb b/vendor/gems/rack-1.0.1/test/spec_rack_content_length.rb deleted file mode 100644 index 7db9345f..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_content_length.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'rack/mock' -require 'rack/content_length' - -context "Rack::ContentLength" do - specify "sets Content-Length on String bodies if none is set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal '13' - end - - specify "sets Content-Length on Array bodies if none is set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal '13' - end - - specify "does not set Content-Length on variable length bodies" do - body = lambda { "Hello World!" } - def body.each ; yield call ; end - - app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.be.nil - end - - specify "does not change Content-Length if it is already set" do - app = lambda { |env| [200, {'Content-Type' => 'text/plain', 'Content-Length' => '1'}, "Hello, World!"] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal '1' - end - - specify "does not set Content-Length on 304 responses" do - app = lambda { |env| [304, {'Content-Type' => 'text/plain'}, []] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal nil - end - - specify "does not set Content-Length when Transfer-Encoding is chunked" do - app = lambda { |env| [200, {'Transfer-Encoding' => 'chunked'}, []] } - response = Rack::ContentLength.new(app).call({}) - response[1]['Content-Length'].should.equal nil - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_content_type.rb b/vendor/gems/rack-1.0.1/test/spec_rack_content_type.rb deleted file mode 100644 index 9975b94d..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_content_type.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rack/mock' -require 'rack/content_type' - -context "Rack::ContentType" do - specify "sets Content-Type to default text/html if none is set" do - app = lambda { |env| [200, {}, "Hello, World!"] } - status, headers, body = Rack::ContentType.new(app).call({}) - headers['Content-Type'].should.equal 'text/html' - end - - specify "sets Content-Type to chosen default if none is set" do - app = lambda { |env| [200, {}, "Hello, World!"] } - status, headers, body = - Rack::ContentType.new(app, 'application/octet-stream').call({}) - headers['Content-Type'].should.equal 'application/octet-stream' - end - - specify "does not change Content-Type if it is already set" do - app = lambda { |env| [200, {'Content-Type' => 'foo/bar'}, "Hello, World!"] } - status, headers, body = Rack::ContentType.new(app).call({}) - headers['Content-Type'].should.equal 'foo/bar' - end - - specify "case insensitive detection of Content-Type" do - app = lambda { |env| [200, {'CONTENT-Type' => 'foo/bar'}, "Hello, World!"] } - status, headers, body = Rack::ContentType.new(app).call({}) - headers.to_a.select { |k,v| k.downcase == "content-type" }. - should.equal [["CONTENT-Type","foo/bar"]] - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_deflater.rb b/vendor/gems/rack-1.0.1/test/spec_rack_deflater.rb deleted file mode 100644 index c9bb3189..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_deflater.rb +++ /dev/null @@ -1,127 +0,0 @@ -require 'test/spec' - -require 'rack/mock' -require 'rack/deflater' -require 'stringio' -require 'time' # for Time#httpdate - -context "Rack::Deflater" do - def build_response(status, body, accept_encoding, headers = {}) - body = [body] if body.respond_to? :to_str - app = lambda { |env| [status, {}, body] } - request = Rack::MockRequest.env_for("", headers.merge("HTTP_ACCEPT_ENCODING" => accept_encoding)) - response = Rack::Deflater.new(app).call(request) - - return response - end - - specify "should be able to deflate bodies that respond to each" do - body = Object.new - class << body; def each; yield("foo"); yield("bar"); end; end - - response = build_response(200, body, "deflate") - - response[0].should.equal(200) - response[1].should.equal({ - "Content-Encoding" => "deflate", - "Vary" => "Accept-Encoding" - }) - buf = '' - response[2].each { |part| buf << part } - buf.should.equal("K\313\317OJ,\002\000") - end - - # TODO: This is really just a special case of the above... - specify "should be able to deflate String bodies" do - response = build_response(200, "Hello world!", "deflate") - - response[0].should.equal(200) - response[1].should.equal({ - "Content-Encoding" => "deflate", - "Vary" => "Accept-Encoding" - }) - buf = '' - response[2].each { |part| buf << part } - buf.should.equal("\363H\315\311\311W(\317/\312IQ\004\000") - end - - specify "should be able to gzip bodies that respond to each" do - body = Object.new - class << body; def each; yield("foo"); yield("bar"); end; end - - response = build_response(200, body, "gzip") - - response[0].should.equal(200) - response[1].should.equal({ - "Content-Encoding" => "gzip", - "Vary" => "Accept-Encoding", - }) - - buf = '' - response[2].each { |part| buf << part } - io = StringIO.new(buf) - gz = Zlib::GzipReader.new(io) - gz.read.should.equal("foobar") - gz.close - end - - specify "should be able to fallback to no deflation" do - response = build_response(200, "Hello world!", "superzip") - - response[0].should.equal(200) - response[1].should.equal({ "Vary" => "Accept-Encoding" }) - response[2].should.equal(["Hello world!"]) - end - - specify "should be able to skip when there is no response entity body" do - response = build_response(304, [], "gzip") - - response[0].should.equal(304) - response[1].should.equal({}) - response[2].should.equal([]) - end - - specify "should handle the lack of an acceptable encoding" do - response1 = build_response(200, "Hello world!", "identity;q=0", "PATH_INFO" => "/") - response1[0].should.equal(406) - response1[1].should.equal({"Content-Type" => "text/plain", "Content-Length" => "71"}) - response1[2].should.equal(["An acceptable encoding for the requested resource / could not be found."]) - - response2 = build_response(200, "Hello world!", "identity;q=0", "SCRIPT_NAME" => "/foo", "PATH_INFO" => "/bar") - response2[0].should.equal(406) - response2[1].should.equal({"Content-Type" => "text/plain", "Content-Length" => "78"}) - response2[2].should.equal(["An acceptable encoding for the requested resource /foo/bar could not be found."]) - end - - specify "should handle gzip response with Last-Modified header" do - last_modified = Time.now.httpdate - - app = lambda { |env| [200, { "Last-Modified" => last_modified }, ["Hello World!"]] } - request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip") - response = Rack::Deflater.new(app).call(request) - - response[0].should.equal(200) - response[1].should.equal({ - "Content-Encoding" => "gzip", - "Vary" => "Accept-Encoding", - "Last-Modified" => last_modified - }) - - buf = '' - response[2].each { |part| buf << part } - io = StringIO.new(buf) - gz = Zlib::GzipReader.new(io) - gz.read.should.equal("Hello World!") - gz.close - end - - specify "should do nothing when no-transform Cache-Control directive present" do - app = lambda { |env| [200, {'Cache-Control' => 'no-transform'}, ['Hello World!']] } - request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip") - response = Rack::Deflater.new(app).call(request) - - response[0].should.equal(200) - response[1].should.not.include "Content-Encoding" - response[2].join.should.equal("Hello World!") - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_directory.rb b/vendor/gems/rack-1.0.1/test/spec_rack_directory.rb deleted file mode 100644 index 540c728d..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_directory.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'test/spec' - -require 'rack/directory' -require 'rack/lint' - -require 'rack/mock' - -context "Rack::Directory" do - DOCROOT = File.expand_path(File.dirname(__FILE__)) - FILE_CATCH = proc{|env| [200, {'Content-Type'=>'text/plain', "Content-Length" => "7"}, ['passed!']] } - app = Rack::Directory.new DOCROOT, FILE_CATCH - - specify "serves directory indices" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/") - - res.should.be.ok - res.should =~ // - end - - specify "passes to app if file found" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/test") - - res.should.be.ok - res.should =~ /passed!/ - end - - specify "serves uri with URL encoded filenames" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/%63%67%69/") # "/cgi/test" - - res.should.be.ok - res.should =~ // - - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/%74%65%73%74") # "/cgi/test" - - res.should.be.ok - res.should =~ /passed!/ - end - - specify "does not allow directory traversal" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/../test") - - res.should.be.forbidden - - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/%2E%2E/test") - - res.should.be.forbidden - end - - specify "404s if it can't find the file" do - res = Rack::MockRequest.new(Rack::Lint.new(app)). - get("/cgi/blubb") - - res.should.be.not_found - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_fastcgi.rb b/vendor/gems/rack-1.0.1/test/spec_rack_fastcgi.rb deleted file mode 100644 index 69478de5..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_fastcgi.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'test/spec' -require 'testrequest' - -context "Rack::Handler::FastCGI" do - include TestRequest::Helpers - - setup do - @host = '0.0.0.0' - @port = 9203 - end - - # Keep this first. - specify "startup" do - $pid = fork { - Dir.chdir(File.join(File.dirname(__FILE__), "..", "test", "cgi")) - exec "lighttpd -D -f lighttpd.conf" - } - end - - specify "should respond" do - sleep 1 - lambda { - GET("/test.fcgi") - }.should.not.raise - end - - specify "should be a lighttpd" do - GET("/test.fcgi") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /lighttpd/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal @port.to_s - response["SERVER_NAME"].should =~ @host - end - - specify "should have rack headers" do - GET("/test.fcgi") - response["rack.version"].should.equal [1,0] - response["rack.multithread"].should.be false - response["rack.multiprocess"].should.be true - response["rack.run_once"].should.be false - end - - specify "should have CGI headers on GET" do - GET("/test.fcgi") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test.fcgi" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.be.nil - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test.fcgi/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test.fcgi" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "/foo" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/test.fcgi", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["SCRIPT_NAME"].should.equal "/test.fcgi" - response["REQUEST_PATH"].should.equal "/" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test.fcgi", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test.fcgi?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - # Keep this last. - specify "shutdown" do - Process.kill 15, $pid - Process.wait($pid).should.equal $pid - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_file.rb b/vendor/gems/rack-1.0.1/test/spec_rack_file.rb deleted file mode 100644 index 1e6771ab..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_file.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'test/spec' - -require 'rack/file' -require 'rack/lint' - -require 'rack/mock' - -context "Rack::File" do - DOCROOT = File.expand_path(File.dirname(__FILE__)) - - specify "serves files" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/test") - - res.should.be.ok - res.should =~ /ruby/ - end - - specify "sets Last-Modified header" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/test") - - path = File.join(DOCROOT, "/cgi/test") - - res.should.be.ok - res["Last-Modified"].should.equal File.mtime(path).httpdate - end - - specify "serves files with URL encoded filenames" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/%74%65%73%74") # "/cgi/test" - - res.should.be.ok - res.should =~ /ruby/ - end - - specify "does not allow directory traversal" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/../test") - - res.should.be.forbidden - end - - specify "does not allow directory traversal with encoded periods" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/%2E%2E/README") - - res.should.be.forbidden - end - - specify "404s if it can't find the file" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi/blubb") - - res.should.be.not_found - end - - specify "detects SystemCallErrors" do - res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). - get("/cgi") - - res.should.be.not_found - end - - specify "returns bodies that respond to #to_path" do - env = Rack::MockRequest.env_for("/cgi/test") - status, headers, body = Rack::File.new(DOCROOT).call(env) - - path = File.join(DOCROOT, "/cgi/test") - - status.should.equal 200 - body.should.respond_to :to_path - body.to_path.should.equal path - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_handler.rb b/vendor/gems/rack-1.0.1/test/spec_rack_handler.rb deleted file mode 100644 index fcf19b78..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_handler.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'test/spec' - -require 'rack/handler' - -class Rack::Handler::Lobster; end -class RockLobster; end - -context "Rack::Handler" do - specify "has registered default handlers" do - Rack::Handler.get('cgi').should.equal Rack::Handler::CGI - Rack::Handler.get('fastcgi').should.equal Rack::Handler::FastCGI - Rack::Handler.get('mongrel').should.equal Rack::Handler::Mongrel - Rack::Handler.get('webrick').should.equal Rack::Handler::WEBrick - end - - specify "handler that doesn't exist should raise a NameError" do - lambda { - Rack::Handler.get('boom') - }.should.raise(NameError) - end - - specify "should get unregistered, but already required, handler by name" do - Rack::Handler.get('Lobster').should.equal Rack::Handler::Lobster - end - - specify "should register custom handler" do - Rack::Handler.register('rock_lobster', 'RockLobster') - Rack::Handler.get('rock_lobster').should.equal RockLobster - end - - specify "should not need registration for properly coded handlers even if not already required" do - begin - $:.push "test/unregistered_handler" - Rack::Handler.get('Unregistered').should.equal Rack::Handler::Unregistered - lambda { - Rack::Handler.get('UnRegistered') - }.should.raise(NameError) - Rack::Handler.get('UnregisteredLongOne').should.equal Rack::Handler::UnregisteredLongOne - ensure - $:.delete "test/unregistered_handler" - end - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_head.rb b/vendor/gems/rack-1.0.1/test/spec_rack_head.rb deleted file mode 100644 index 48d3f81f..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_head.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rack/head' -require 'rack/mock' - -context "Rack::Head" do - def test_response(headers = {}) - app = lambda { |env| [200, {"Content-type" => "test/plain", "Content-length" => "3"}, ["foo"]] } - request = Rack::MockRequest.env_for("/", headers) - response = Rack::Head.new(app).call(request) - - return response - end - - specify "passes GET, POST, PUT, DELETE, OPTIONS, TRACE requests" do - %w[GET POST PUT DELETE OPTIONS TRACE].each do |type| - resp = test_response("REQUEST_METHOD" => type) - - resp[0].should.equal(200) - resp[1].should.equal({"Content-type" => "test/plain", "Content-length" => "3"}) - resp[2].should.equal(["foo"]) - end - end - - specify "removes body from HEAD requests" do - resp = test_response("REQUEST_METHOD" => "HEAD") - - resp[0].should.equal(200) - resp[1].should.equal({"Content-type" => "test/plain", "Content-length" => "3"}) - resp[2].should.equal([]) - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_lint.rb b/vendor/gems/rack-1.0.1/test/spec_rack_lint.rb deleted file mode 100644 index 880a07ee..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_lint.rb +++ /dev/null @@ -1,521 +0,0 @@ -require 'test/spec' -require 'stringio' - -require 'rack/lint' -require 'rack/mock' - -context "Rack::Lint" do - def env(*args) - Rack::MockRequest.env_for("/", *args) - end - - specify "passes valid request" do - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "test/plain", "Content-length" => "3"}, ["foo"]] - }).call(env({})) - }.should.not.raise - end - - specify "notices fatal errors" do - lambda { Rack::Lint.new(nil).call }.should.raise(Rack::Lint::LintError). - message.should.match(/No env given/) - end - - specify "notices environment errors" do - lambda { Rack::Lint.new(nil).call 5 }.should.raise(Rack::Lint::LintError). - message.should.match(/not a Hash/) - - lambda { - e = env - e.delete("REQUEST_METHOD") - Rack::Lint.new(nil).call(e) - }.should.raise(Rack::Lint::LintError). - message.should.match(/missing required key REQUEST_METHOD/) - - lambda { - e = env - e.delete("SERVER_NAME") - Rack::Lint.new(nil).call(e) - }.should.raise(Rack::Lint::LintError). - message.should.match(/missing required key SERVER_NAME/) - - - lambda { - Rack::Lint.new(nil).call(env("HTTP_CONTENT_TYPE" => "text/plain")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/contains HTTP_CONTENT_TYPE/) - - lambda { - Rack::Lint.new(nil).call(env("HTTP_CONTENT_LENGTH" => "42")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/contains HTTP_CONTENT_LENGTH/) - - lambda { - Rack::Lint.new(nil).call(env("FOO" => Object.new)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/non-string value/) - - lambda { - Rack::Lint.new(nil).call(env("rack.version" => "0.2")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must be an Array/) - - lambda { - Rack::Lint.new(nil).call(env("rack.url_scheme" => "gopher")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/url_scheme unknown/) - - lambda { - Rack::Lint.new(nil).call(env("rack.session" => [])) - }.should.raise(Rack::Lint::LintError). - message.should.equal("session [] must respond to store and []=") - - lambda { - Rack::Lint.new(nil).call(env("REQUEST_METHOD" => "FUCKUP?")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/REQUEST_METHOD/) - - lambda { - Rack::Lint.new(nil).call(env("SCRIPT_NAME" => "howdy")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must start with/) - - lambda { - Rack::Lint.new(nil).call(env("PATH_INFO" => "../foo")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must start with/) - - lambda { - Rack::Lint.new(nil).call(env("CONTENT_LENGTH" => "xcii")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/Invalid CONTENT_LENGTH/) - - lambda { - e = env - e.delete("PATH_INFO") - e.delete("SCRIPT_NAME") - Rack::Lint.new(nil).call(e) - }.should.raise(Rack::Lint::LintError). - message.should.match(/One of .* must be set/) - - lambda { - Rack::Lint.new(nil).call(env("SCRIPT_NAME" => "/")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/cannot be .* make it ''/) - end - - specify "notices input errors" do - lambda { - Rack::Lint.new(nil).call(env("rack.input" => "")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/does not respond to #gets/) - - lambda { - input = Object.new - def input.binmode? - false - end - Rack::Lint.new(nil).call(env("rack.input" => input)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/is not opened in binary mode/) - - lambda { - input = Object.new - def input.external_encoding - result = Object.new - def result.name - "US-ASCII" - end - result - end - Rack::Lint.new(nil).call(env("rack.input" => input)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/does not have ASCII-8BIT as its external encoding/) - end - - specify "notices error errors" do - lambda { - Rack::Lint.new(nil).call(env("rack.errors" => "")) - }.should.raise(Rack::Lint::LintError). - message.should.match(/does not respond to #puts/) - end - - specify "notices status errors" do - lambda { - Rack::Lint.new(lambda { |env| - ["cc", {}, ""] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must be >=100 seen as integer/) - - lambda { - Rack::Lint.new(lambda { |env| - [42, {}, ""] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must be >=100 seen as integer/) - end - - specify "notices header errors" do - lambda { - Rack::Lint.new(lambda { |env| - [200, Object.new, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("headers object should respond to #each, but doesn't (got Object as headers)") - - lambda { - Rack::Lint.new(lambda { |env| - [200, {true=>false}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("header key must be a string, was TrueClass") - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Status" => "404"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must not contain Status/) - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-Type:" => "text/plain"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must not contain :/) - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-" => "text/plain"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/must not end/) - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"..%%quark%%.." => "text/plain"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("invalid header name: ..%%quark%%..") - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Foo" => Object.new}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("a header value must be a String, but the value of 'Foo' is a Object") - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Foo" => [1, 2, 3]}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.equal("a header value must be a String, but the value of 'Foo' is a Array") - - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Foo-Bar" => "text\000plain"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/invalid header/) - - # line ends (010) should be allowed in header values. - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Foo-Bar" => "one\ntwo\nthree", "Content-Length" => "0", "Content-Type" => "text/plain" }, []] - }).call(env({})) - }.should.not.raise(Rack::Lint::LintError) - end - - specify "notices content-type errors" do - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/No Content-Type/) - - [100, 101, 204, 304].each do |status| - lambda { - Rack::Lint.new(lambda { |env| - [status, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/Content-Type header found/) - end - end - - specify "notices content-length errors" do - [100, 101, 204, 304].each do |status| - lambda { - Rack::Lint.new(lambda { |env| - [status, {"Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/Content-Length header found/) - end - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "text/plain", "Content-Length" => "1"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/Content-Length header was 1, but should be 0/) - end - - specify "notices body errors" do - lambda { - status, header, body = Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "text/plain","Content-length" => "3"}, [1,2,3]] - }).call(env({})) - body.each { |part| } - }.should.raise(Rack::Lint::LintError). - message.should.match(/yielded non-string/) - end - - specify "notices input handling errors" do - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].gets("\r\n") - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/gets called with arguments/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(1, 2, 3) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with too many arguments/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read("foo") - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with non-integer and non-nil length/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(-1) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with a negative length/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(nil, nil) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with non-String buffer/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(nil, 1) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read called with non-String buffer/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].rewind(0) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/rewind called with arguments/) - - weirdio = Object.new - class << weirdio - def gets - 42 - end - - def read - 23 - end - - def each - yield 23 - yield 42 - end - - def rewind - raise Errno::ESPIPE, "Errno::ESPIPE" - end - end - - eof_weirdio = Object.new - class << eof_weirdio - def gets - nil - end - - def read(*args) - nil - end - - def each - end - - def rewind - end - end - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].gets - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/gets didn't return a String/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].each { |x| } - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/each didn't yield a String/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read didn't return nil or a String/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => eof_weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/read\(nil\) returned nil on EOF/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].rewind - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env("rack.input" => weirdio)) - }.should.raise(Rack::Lint::LintError). - message.should.match(/rewind raised Errno::ESPIPE/) - - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].close - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/close must not be called/) - end - - specify "notices error handling errors" do - lambda { - Rack::Lint.new(lambda { |env| - env["rack.errors"].write(42) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/write not called with a String/) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.errors"].close - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/close must not be called/) - end - - specify "notices HEAD errors" do - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "test/plain", "Content-length" => "3"}, []] - }).call(env({"REQUEST_METHOD" => "HEAD"})) - }.should.not.raise - - lambda { - Rack::Lint.new(lambda { |env| - [200, {"Content-type" => "test/plain", "Content-length" => "3"}, ["foo"]] - }).call(env({"REQUEST_METHOD" => "HEAD"})) - }.should.raise(Rack::Lint::LintError). - message.should.match(/body was given for HEAD/) - end - - specify "passes valid read calls" do - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new("hello world")})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(0) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new("hello world")})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(1) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new("hello world")})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(nil) - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new("hello world")})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(nil, '') - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new("hello world")})) - }.should.not.raise(Rack::Lint::LintError) - - lambda { - Rack::Lint.new(lambda { |env| - env["rack.input"].read(1, '') - [201, {"Content-type" => "text/plain", "Content-length" => "0"}, []] - }).call(env({"rack.input" => StringIO.new("hello world")})) - }.should.not.raise(Rack::Lint::LintError) - end -end - -context "Rack::Lint::InputWrapper" do - specify "delegates :size to underlying IO object" do - class IOMock - def size - 101 - end - end - - wrapper = Rack::Lint::InputWrapper.new(IOMock.new) - wrapper.size.should == 101 - end - - specify "delegates :rewind to underlying IO object" do - io = StringIO.new("123") - wrapper = Rack::Lint::InputWrapper.new(io) - wrapper.read.should.equal "123" - wrapper.read.should.equal "" - wrapper.rewind - wrapper.read.should.equal "123" - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_lobster.rb b/vendor/gems/rack-1.0.1/test/spec_rack_lobster.rb deleted file mode 100644 index 7be267a2..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_lobster.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'test/spec' - -require 'rack/lobster' -require 'rack/mock' - -context "Rack::Lobster::LambdaLobster" do - specify "should be a single lambda" do - Rack::Lobster::LambdaLobster.should.be.kind_of Proc - end - - specify "should look like a lobster" do - res = Rack::MockRequest.new(Rack::Lobster::LambdaLobster).get("/") - res.should.be.ok - res.body.should.include "(,(,,(,,,(" - res.body.should.include "?flip" - end - - specify "should be flippable" do - res = Rack::MockRequest.new(Rack::Lobster::LambdaLobster).get("/?flip") - res.should.be.ok - res.body.should.include "(,,,(,,(,(" - end -end - -context "Rack::Lobster" do - specify "should look like a lobster" do - res = Rack::MockRequest.new(Rack::Lobster.new).get("/") - res.should.be.ok - res.body.should.include "(,(,,(,,,(" - res.body.should.include "?flip" - res.body.should.include "crash" - end - - specify "should be flippable" do - res = Rack::MockRequest.new(Rack::Lobster.new).get("/?flip=left") - res.should.be.ok - res.body.should.include "(,,,(,,(,(" - end - - specify "should provide crashing for testing purposes" do - lambda { - Rack::MockRequest.new(Rack::Lobster.new).get("/?flip=crash") - }.should.raise - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_lock.rb b/vendor/gems/rack-1.0.1/test/spec_rack_lock.rb deleted file mode 100644 index 18af2b23..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_lock.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'test/spec' - -require 'rack/mock' -require 'rack/lock' - -context "Rack::Lock" do - class Lock - attr_reader :synchronized - - def initialize - @synchronized = false - end - - def synchronize - @synchronized = true - yield - end - end - - specify "should call synchronize on lock" do - lock = Lock.new - env = Rack::MockRequest.env_for("/") - app = Rack::Lock.new(lambda { |env| }, lock) - lock.synchronized.should.equal false - app.call(env) - lock.synchronized.should.equal true - end - - specify "should set multithread flag to false" do - app = Rack::Lock.new(lambda { |env| env['rack.multithread'] }) - app.call(Rack::MockRequest.env_for("/")).should.equal false - end - - specify "should reset original multithread flag when exiting lock" do - app = Rack::Lock.new(lambda { |env| env }) - app.call(Rack::MockRequest.env_for("/"))['rack.multithread'].should.equal true - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_methodoverride.rb b/vendor/gems/rack-1.0.1/test/spec_rack_methodoverride.rb deleted file mode 100644 index 57452394..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_methodoverride.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'test/spec' - -require 'rack/mock' -require 'rack/methodoverride' -require 'stringio' - -context "Rack::MethodOverride" do - specify "should not affect GET requests" do - env = Rack::MockRequest.env_for("/?_method=delete", :method => "GET") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "GET" - end - - specify "_method parameter should modify REQUEST_METHOD for POST requests" do - env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=put") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "PUT" - end - - specify "X-HTTP-Method-Override header should modify REQUEST_METHOD for POST requests" do - env = Rack::MockRequest.env_for("/", - :method => "POST", - "HTTP_X_HTTP_METHOD_OVERRIDE" => "PUT" - ) - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "PUT" - end - - specify "should not modify REQUEST_METHOD if the method is unknown" do - env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=foo") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "POST" - end - - specify "should not modify REQUEST_METHOD when _method is nil" do - env = Rack::MockRequest.env_for("/", :method => "POST", :input => "foo=bar") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["REQUEST_METHOD"].should.equal "POST" - end - - specify "should store the original REQUEST_METHOD prior to overriding" do - env = Rack::MockRequest.env_for("/", - :method => "POST", - :input => "_method=options") - app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) }) - req = app.call(env) - - req.env["rack.methodoverride.original_method"].should.equal "POST" - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_mock.rb b/vendor/gems/rack-1.0.1/test/spec_rack_mock.rb deleted file mode 100644 index 9c392a28..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_mock.rb +++ /dev/null @@ -1,157 +0,0 @@ -require 'yaml' -require 'rack/mock' -require 'rack/request' -require 'rack/response' - -app = lambda { |env| - req = Rack::Request.new(env) - - env["mock.postdata"] = env["rack.input"].read - if req.GET["error"] - env["rack.errors"].puts req.GET["error"] - env["rack.errors"].flush - end - - Rack::Response.new(env.to_yaml, - req.GET["status"] || 200, - "Content-Type" => "text/yaml").finish -} - -context "Rack::MockRequest" do - specify "should return a MockResponse" do - res = Rack::MockRequest.new(app).get("") - res.should.be.kind_of Rack::MockResponse - end - - specify "should be able to only return the environment" do - env = Rack::MockRequest.env_for("") - env.should.be.kind_of Hash - env.should.include "rack.version" - end - - specify "should provide sensible defaults" do - res = Rack::MockRequest.new(app).request - - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - env["SERVER_NAME"].should.equal "example.org" - env["SERVER_PORT"].should.equal "80" - env["QUERY_STRING"].should.equal "" - env["PATH_INFO"].should.equal "/" - env["SCRIPT_NAME"].should.equal "" - env["rack.url_scheme"].should.equal "http" - env["mock.postdata"].should.be.empty - end - - specify "should allow GET/POST/PUT/DELETE" do - res = Rack::MockRequest.new(app).get("", :input => "foo") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - - res = Rack::MockRequest.new(app).post("", :input => "foo") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "POST" - - res = Rack::MockRequest.new(app).put("", :input => "foo") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "PUT" - - res = Rack::MockRequest.new(app).delete("", :input => "foo") - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "DELETE" - - Rack::MockRequest.env_for("/", :method => "OPTIONS")["REQUEST_METHOD"]. - should.equal "OPTIONS" - end - - specify "should set content length" do - env = Rack::MockRequest.env_for("/", :input => "foo") - env["CONTENT_LENGTH"].should.equal "3" - end - - specify "should allow posting" do - res = Rack::MockRequest.new(app).get("", :input => "foo") - env = YAML.load(res.body) - env["mock.postdata"].should.equal "foo" - - res = Rack::MockRequest.new(app).post("", :input => StringIO.new("foo")) - env = YAML.load(res.body) - env["mock.postdata"].should.equal "foo" - end - - specify "should use all parts of an URL" do - res = Rack::MockRequest.new(app). - get("https://bla.example.org:9292/meh/foo?bar") - res.should.be.kind_of Rack::MockResponse - - env = YAML.load(res.body) - env["REQUEST_METHOD"].should.equal "GET" - env["SERVER_NAME"].should.equal "bla.example.org" - env["SERVER_PORT"].should.equal "9292" - env["QUERY_STRING"].should.equal "bar" - env["PATH_INFO"].should.equal "/meh/foo" - env["rack.url_scheme"].should.equal "https" - end - - specify "should behave valid according to the Rack spec" do - lambda { - res = Rack::MockRequest.new(app). - get("https://bla.example.org:9292/meh/foo?bar", :lint => true) - }.should.not.raise(Rack::Lint::LintError) - end -end - -context "Rack::MockResponse" do - specify "should provide access to the HTTP status" do - res = Rack::MockRequest.new(app).get("") - res.should.be.successful - res.should.be.ok - - res = Rack::MockRequest.new(app).get("/?status=404") - res.should.not.be.successful - res.should.be.client_error - res.should.be.not_found - - res = Rack::MockRequest.new(app).get("/?status=501") - res.should.not.be.successful - res.should.be.server_error - - res = Rack::MockRequest.new(app).get("/?status=307") - res.should.be.redirect - - res = Rack::MockRequest.new(app).get("/?status=201", :lint => true) - res.should.be.empty - end - - specify "should provide access to the HTTP headers" do - res = Rack::MockRequest.new(app).get("") - res.should.include "Content-Type" - res.headers["Content-Type"].should.equal "text/yaml" - res.original_headers["Content-Type"].should.equal "text/yaml" - res["Content-Type"].should.equal "text/yaml" - res.content_type.should.equal "text/yaml" - res.content_length.should.be 401 # needs change often. - res.location.should.be.nil - end - - specify "should provide access to the HTTP body" do - res = Rack::MockRequest.new(app).get("") - res.body.should =~ /rack/ - res.should =~ /rack/ - res.should.match(/rack/) - res.should.satisfy { |r| r.match(/rack/) } - end - - specify "should provide access to the Rack errors" do - res = Rack::MockRequest.new(app).get("/?error=foo", :lint => true) - res.should.be.ok - res.errors.should.not.be.empty - res.errors.should.include "foo" - end - - specify "should optionally make Rack errors fatal" do - lambda { - Rack::MockRequest.new(app).get("/?error=foo", :fatal => true) - }.should.raise(Rack::MockRequest::FatalWarning) - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_mongrel.rb b/vendor/gems/rack-1.0.1/test/spec_rack_mongrel.rb deleted file mode 100644 index d73e884c..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_mongrel.rb +++ /dev/null @@ -1,189 +0,0 @@ -require 'test/spec' - -begin -require 'rack/handler/mongrel' -require 'rack/urlmap' -require 'rack/lint' -require 'testrequest' -require 'timeout' - -Thread.abort_on_exception = true -$tcp_defer_accept_opts = nil -$tcp_cork_opts = nil - -context "Rack::Handler::Mongrel" do - include TestRequest::Helpers - - setup do - server = Mongrel::HttpServer.new(@host='0.0.0.0', @port=9201) - server.register('/test', - Rack::Handler::Mongrel.new(Rack::Lint.new(TestRequest.new))) - server.register('/stream', - Rack::Handler::Mongrel.new(Rack::Lint.new(StreamingRequest))) - @acc = server.run - end - - specify "should respond" do - lambda { - GET("/test") - }.should.not.raise - end - - specify "should be a Mongrel" do - GET("/test") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /Mongrel/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal "9201" - response["SERVER_NAME"].should.equal "0.0.0.0" - end - - specify "should have rack headers" do - GET("/test") - response["rack.version"].should.equal [1,0] - response["rack.multithread"].should.be true - response["rack.multiprocess"].should.be false - response["rack.run_once"].should.be false - end - - specify "should have CGI headers on GET" do - GET("/test") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/test" - response["PATH_INFO"].should.be.nil - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/test/foo" - response["PATH_INFO"].should.equal "/foo" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/test" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - specify "should provide a .run" do - block_ran = false - Thread.new { - Rack::Handler::Mongrel.run(lambda {}, {:Port => 9211}) { |server| - server.should.be.kind_of Mongrel::HttpServer - block_ran = true - } - } - sleep 1 - block_ran.should.be true - end - - specify "should provide a .run that maps a hash" do - block_ran = false - Thread.new { - map = {'/'=>lambda{},'/foo'=>lambda{}} - Rack::Handler::Mongrel.run(map, :map => true, :Port => 9221) { |server| - server.should.be.kind_of Mongrel::HttpServer - server.classifier.uris.size.should.be 2 - server.classifier.uris.should.not.include '/arf' - server.classifier.uris.should.include '/' - server.classifier.uris.should.include '/foo' - block_ran = true - } - } - sleep 1 - block_ran.should.be true - end - - specify "should provide a .run that maps a urlmap" do - block_ran = false - Thread.new { - map = Rack::URLMap.new({'/'=>lambda{},'/bar'=>lambda{}}) - Rack::Handler::Mongrel.run(map, {:map => true, :Port => 9231}) { |server| - server.should.be.kind_of Mongrel::HttpServer - server.classifier.uris.size.should.be 2 - server.classifier.uris.should.not.include '/arf' - server.classifier.uris.should.include '/' - server.classifier.uris.should.include '/bar' - block_ran = true - } - } - sleep 1 - block_ran.should.be true - end - - specify "should provide a .run that maps a urlmap restricting by host" do - block_ran = false - Thread.new { - map = Rack::URLMap.new({ - '/' => lambda{}, - '/foo' => lambda{}, - '/bar' => lambda{}, - 'http://localhost/' => lambda{}, - 'http://localhost/bar' => lambda{}, - 'http://falsehost/arf' => lambda{}, - 'http://falsehost/qux' => lambda{} - }) - opt = {:map => true, :Port => 9241, :Host => 'localhost'} - Rack::Handler::Mongrel.run(map, opt) { |server| - server.should.be.kind_of Mongrel::HttpServer - server.classifier.uris.should.include '/' - server.classifier.handler_map['/'].size.should.be 2 - server.classifier.uris.should.include '/foo' - server.classifier.handler_map['/foo'].size.should.be 1 - server.classifier.uris.should.include '/bar' - server.classifier.handler_map['/bar'].size.should.be 2 - server.classifier.uris.should.not.include '/qux' - server.classifier.uris.should.not.include '/arf' - server.classifier.uris.size.should.be 3 - block_ran = true - } - } - sleep 1 - block_ran.should.be true - end - - specify "should stream #each part of the response" do - body = '' - begin - Timeout.timeout(1) do - Net::HTTP.start(@host, @port) do |http| - get = Net::HTTP::Get.new('/stream') - http.request(get) do |response| - response.read_body { |part| body << part } - end - end - end - rescue Timeout::Error - end - body.should.not.be.empty - end - - teardown do - @acc.raise Mongrel::StopServer - end -end - -rescue LoadError - $stderr.puts "Skipping Rack::Handler::Mongrel tests (Mongrel is required). `gem install mongrel` and try again." -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_recursive.rb b/vendor/gems/rack-1.0.1/test/spec_rack_recursive.rb deleted file mode 100644 index afc1a0d9..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_recursive.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'test/spec' - -require 'rack/recursive' -require 'rack/urlmap' -require 'rack/response' -require 'rack/mock' - -context "Rack::Recursive" do - setup do - - @app1 = lambda { |env| - res = Rack::Response.new - res["X-Path-Info"] = env["PATH_INFO"] - res["X-Query-String"] = env["QUERY_STRING"] - res.finish do |res| - res.write "App1" - end - } - - @app2 = lambda { |env| - Rack::Response.new.finish do |res| - res.write "App2" - _, _, body = env['rack.recursive.include'].call(env, "/app1") - body.each { |b| - res.write b - } - end - } - - @app3 = lambda { |env| - raise Rack::ForwardRequest.new("/app1") - } - - @app4 = lambda { |env| - raise Rack::ForwardRequest.new("http://example.org/app1/quux?meh") - } - - end - - specify "should allow for subrequests" do - res = Rack::MockRequest.new(Rack::Recursive.new( - Rack::URLMap.new("/app1" => @app1, - "/app2" => @app2))). - get("/app2") - - res.should.be.ok - res.body.should.equal "App2App1" - end - - specify "should raise error on requests not below the app" do - app = Rack::URLMap.new("/app1" => @app1, - "/app" => Rack::Recursive.new( - Rack::URLMap.new("/1" => @app1, - "/2" => @app2))) - - lambda { - Rack::MockRequest.new(app).get("/app/2") - }.should.raise(ArgumentError). - message.should =~ /can only include below/ - end - - specify "should support forwarding" do - app = Rack::Recursive.new(Rack::URLMap.new("/app1" => @app1, - "/app3" => @app3, - "/app4" => @app4)) - - res = Rack::MockRequest.new(app).get("/app3") - res.should.be.ok - res.body.should.equal "App1" - - res = Rack::MockRequest.new(app).get("/app4") - res.should.be.ok - res.body.should.equal "App1" - res["X-Path-Info"].should.equal "/quux" - res["X-Query-String"].should.equal "meh" - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_request.rb b/vendor/gems/rack-1.0.1/test/spec_rack_request.rb deleted file mode 100644 index 74e2f00a..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_request.rb +++ /dev/null @@ -1,504 +0,0 @@ -require 'test/spec' -require 'stringio' - -require 'rack/request' -require 'rack/mock' - -context "Rack::Request" do - specify "wraps the rack variables" do - req = Rack::Request.new(Rack::MockRequest.env_for("http://example.com:8080/")) - - req.body.should.respond_to? :gets - req.scheme.should.equal "http" - req.request_method.should.equal "GET" - - req.should.be.get - req.should.not.be.post - req.should.not.be.put - req.should.not.be.delete - req.should.not.be.head - - req.script_name.should.equal "" - req.path_info.should.equal "/" - req.query_string.should.equal "" - - req.host.should.equal "example.com" - req.port.should.equal 8080 - - req.content_length.should.equal "0" - req.content_type.should.be.nil - end - - specify "can figure out the correct host" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", "HTTP_HOST" => "www2.example.org") - req.host.should.equal "www2.example.org" - - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", "SERVER_NAME" => "example.org:9292") - req.host.should.equal "example.org" - - env = Rack::MockRequest.env_for("/") - env.delete("SERVER_NAME") - req = Rack::Request.new(env) - req.host.should.equal "" - end - - specify "can parse the query string" do - req = Rack::Request.new(Rack::MockRequest.env_for("/?foo=bar&quux=bla")) - req.query_string.should.equal "foo=bar&quux=bla" - req.GET.should.equal "foo" => "bar", "quux" => "bla" - req.POST.should.be.empty - req.params.should.equal "foo" => "bar", "quux" => "bla" - end - - specify "can parse POST data" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/?foo=quux", :input => "foo=bar&quux=bla") - req.content_type.should.be.nil - req.media_type.should.be.nil - req.query_string.should.equal "foo=quux" - req.GET.should.equal "foo" => "quux" - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.params.should.equal "foo" => "bar", "quux" => "bla" - end - - specify "can parse POST data with explicit content type" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => 'application/x-www-form-urlencoded;foo=bar', - :input => "foo=bar&quux=bla") - req.content_type.should.equal 'application/x-www-form-urlencoded;foo=bar' - req.media_type.should.equal 'application/x-www-form-urlencoded' - req.media_type_params['foo'].should.equal 'bar' - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.params.should.equal "foo" => "bar", "quux" => "bla" - end - - specify "does not parse POST data when media type is not form-data" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/?foo=quux", - "CONTENT_TYPE" => 'text/plain;charset=utf-8', - :input => "foo=bar&quux=bla") - req.content_type.should.equal 'text/plain;charset=utf-8' - req.media_type.should.equal 'text/plain' - req.media_type_params['charset'].should.equal 'utf-8' - req.POST.should.be.empty - req.params.should.equal "foo" => "quux" - req.body.read.should.equal "foo=bar&quux=bla" - end - - specify "rewinds input after parsing POST data" do - input = StringIO.new("foo=bar&quux=bla") - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => 'application/x-www-form-urlencoded;foo=bar', - :input => input) - req.params.should.equal "foo" => "bar", "quux" => "bla" - input.read.should.equal "foo=bar&quux=bla" - end - - specify "cleans up Safari's ajax POST body" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", :input => "foo=bar&quux=bla\0") - req.POST.should.equal "foo" => "bar", "quux" => "bla" - end - - specify "can get value by key from params with #[]" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("?foo=quux") - req['foo'].should.equal 'quux' - req[:foo].should.equal 'quux' - end - - specify "can set value to key on params with #[]=" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("?foo=duh") - req['foo'].should.equal 'duh' - req[:foo].should.equal 'duh' - req.params.should.equal 'foo' => 'duh' - - req['foo'] = 'bar' - req.params.should.equal 'foo' => 'bar' - req['foo'].should.equal 'bar' - req[:foo].should.equal 'bar' - - req[:foo] = 'jaz' - req.params.should.equal 'foo' => 'jaz' - req['foo'].should.equal 'jaz' - req[:foo].should.equal 'jaz' - end - - specify "values_at answers values by keys in order given" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("?foo=baz&wun=der&bar=ful") - req.values_at('foo').should.equal ['baz'] - req.values_at('foo', 'wun').should.equal ['baz', 'der'] - req.values_at('bar', 'foo', 'wun').should.equal ['ful', 'baz', 'der'] - end - - specify "referrer should be extracted correct" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", "HTTP_REFERER" => "/some/path") - req.referer.should.equal "/some/path" - - req = Rack::Request.new \ - Rack::MockRequest.env_for("/") - req.referer.should.equal "/" - end - - specify "can cache, but invalidates the cache" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/?foo=quux", :input => "foo=bar&quux=bla") - req.GET.should.equal "foo" => "quux" - req.GET.should.equal "foo" => "quux" - req.env["QUERY_STRING"] = "bla=foo" - req.GET.should.equal "bla" => "foo" - req.GET.should.equal "bla" => "foo" - - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.POST.should.equal "foo" => "bar", "quux" => "bla" - req.env["rack.input"] = StringIO.new("foo=bla&quux=bar") - req.POST.should.equal "foo" => "bla", "quux" => "bar" - req.POST.should.equal "foo" => "bla", "quux" => "bar" - end - - specify "can figure out if called via XHR" do - req = Rack::Request.new(Rack::MockRequest.env_for("")) - req.should.not.be.xhr - - req = Rack::Request.new \ - Rack::MockRequest.env_for("", "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest") - req.should.be.xhr - end - - specify "can parse cookies" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("", "HTTP_COOKIE" => "foo=bar;quux=h&m") - req.cookies.should.equal "foo" => "bar", "quux" => "h&m" - req.cookies.should.equal "foo" => "bar", "quux" => "h&m" - req.env.delete("HTTP_COOKIE") - req.cookies.should.equal({}) - end - - specify "parses cookies according to RFC 2109" do - req = Rack::Request.new \ - Rack::MockRequest.env_for('', 'HTTP_COOKIE' => 'foo=bar;foo=car') - req.cookies.should.equal 'foo' => 'bar' - end - - specify "provides setters" do - req = Rack::Request.new(e=Rack::MockRequest.env_for("")) - req.script_name.should.equal "" - req.script_name = "/foo" - req.script_name.should.equal "/foo" - e["SCRIPT_NAME"].should.equal "/foo" - - req.path_info.should.equal "/" - req.path_info = "/foo" - req.path_info.should.equal "/foo" - e["PATH_INFO"].should.equal "/foo" - end - - specify "provides the original env" do - req = Rack::Request.new(e=Rack::MockRequest.env_for("")) - req.env.should.be e - end - - specify "can restore the URL" do - Rack::Request.new(Rack::MockRequest.env_for("")).url. - should.equal "http://example.org/" - Rack::Request.new(Rack::MockRequest.env_for("", "SCRIPT_NAME" => "/foo")).url. - should.equal "http://example.org/foo/" - Rack::Request.new(Rack::MockRequest.env_for("/foo")).url. - should.equal "http://example.org/foo" - Rack::Request.new(Rack::MockRequest.env_for("?foo")).url. - should.equal "http://example.org/?foo" - Rack::Request.new(Rack::MockRequest.env_for("http://example.org:8080/")).url. - should.equal "http://example.org:8080/" - Rack::Request.new(Rack::MockRequest.env_for("https://example.org/")).url. - should.equal "https://example.org/" - - Rack::Request.new(Rack::MockRequest.env_for("https://example.com:8080/foo?foo")).url. - should.equal "https://example.com:8080/foo?foo" - end - - specify "can restore the full path" do - Rack::Request.new(Rack::MockRequest.env_for("")).fullpath. - should.equal "/" - Rack::Request.new(Rack::MockRequest.env_for("", "SCRIPT_NAME" => "/foo")).fullpath. - should.equal "/foo/" - Rack::Request.new(Rack::MockRequest.env_for("/foo")).fullpath. - should.equal "/foo" - Rack::Request.new(Rack::MockRequest.env_for("?foo")).fullpath. - should.equal "/?foo" - Rack::Request.new(Rack::MockRequest.env_for("http://example.org:8080/")).fullpath. - should.equal "/" - Rack::Request.new(Rack::MockRequest.env_for("https://example.org/")).fullpath. - should.equal "/" - - Rack::Request.new(Rack::MockRequest.env_for("https://example.com:8080/foo?foo")).fullpath. - should.equal "/foo?foo" - end - - specify "can handle multiple media type parameters" do - req = Rack::Request.new \ - Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => 'text/plain; foo=BAR,baz=bizzle dizzle;BLING=bam') - req.should.not.be.form_data - req.media_type_params.should.include 'foo' - req.media_type_params['foo'].should.equal 'BAR' - req.media_type_params.should.include 'baz' - req.media_type_params['baz'].should.equal 'bizzle dizzle' - req.media_type_params.should.not.include 'BLING' - req.media_type_params.should.include 'bling' - req.media_type_params['bling'].should.equal 'bam' - end - - specify "can parse multipart form data" do - # Adapted from RFC 1867. - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - req.POST.should.include "fileupload" - req.POST.should.include "reply" - - req.should.be.form_data - req.content_length.should.equal input.size - req.media_type.should.equal 'multipart/form-data' - req.media_type_params.should.include 'boundary' - req.media_type_params['boundary'].should.equal 'AaB03x' - - req.POST["reply"].should.equal "yes" - - f = req.POST["fileupload"] - f.should.be.kind_of Hash - f[:type].should.equal "image/jpeg" - f[:filename].should.equal "dj.jpg" - f.should.include :tempfile - f[:tempfile].size.should.equal 76 - end - - specify "can parse big multipart form data" do - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - req.POST["huge"][:tempfile].size.should.equal 32768 - req.POST["mean"][:tempfile].size.should.equal 10 - req.POST["mean"][:tempfile].read.should.equal "--AaB03xha" - end - - specify "can detect invalid multipart form data" do - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - lambda { req.POST }.should.raise(EOFError) - - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - lambda { req.POST }.should.raise(EOFError) - - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - lambda { req.POST }.should.raise(EOFError) - end - - specify "shouldn't try to interpret binary as utf8" do - begin - original_kcode = $KCODE - $KCODE='UTF8' - - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => input) - - lambda{req.POST}.should.not.raise(EOFError) - req.POST["fileupload"][:tempfile].size.should.equal 4 - ensure - $KCODE = original_kcode - end - end - - - specify "should work around buggy 1.8.* Tempfile equality" do - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size, - :input => rack_input) - - lambda {req.POST}.should.not.raise - lambda {req.POST}.should.blaming("input re-processed!").not.raise - end - - specify "does conform to the Rack spec" do - app = lambda { |env| - content = Rack::Request.new(env).POST["file"].inspect - size = content.respond_to?(:bytesize) ? content.bytesize : content.size - [200, {"Content-Type" => "text/html", "Content-Length" => size.to_s}, [content]] - } - - input = < "multipart/form-data, boundary=AaB03x", - "CONTENT_LENGTH" => input.size.to_s, "rack.input" => StringIO.new(input) - - res.should.be.ok - end - - specify "should parse Accept-Encoding correctly" do - parser = lambda do |x| - Rack::Request.new(Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => x)).accept_encoding - end - - parser.call(nil).should.equal([]) - - parser.call("compress, gzip").should.equal([["compress", 1.0], ["gzip", 1.0]]) - parser.call("").should.equal([]) - parser.call("*").should.equal([["*", 1.0]]) - parser.call("compress;q=0.5, gzip;q=1.0").should.equal([["compress", 0.5], ["gzip", 1.0]]) - parser.call("gzip;q=1.0, identity; q=0.5, *;q=0").should.equal([["gzip", 1.0], ["identity", 0.5], ["*", 0] ]) - - lambda { parser.call("gzip ; q=1.0") }.should.raise(RuntimeError) - end - - specify 'should provide ip information' do - app = lambda { |env| - request = Rack::Request.new(env) - response = Rack::Response.new - response.write request.ip - response.finish - } - - mock = Rack::MockRequest.new(Rack::Lint.new(app)) - res = mock.get '/', 'REMOTE_ADDR' => '123.123.123.123' - res.body.should.equal '123.123.123.123' - - res = mock.get '/', - 'REMOTE_ADDR' => '123.123.123.123', - 'HTTP_X_FORWARDED_FOR' => '234.234.234.234' - - res.body.should.equal '234.234.234.234' - - res = mock.get '/', - 'REMOTE_ADDR' => '123.123.123.123', - 'HTTP_X_FORWARDED_FOR' => '234.234.234.234,212.212.212.212' - - res.body.should.equal '212.212.212.212' - end - - class MyRequest < Rack::Request - def params - {:foo => "bar"} - end - end - - specify "should allow subclass request to be instantiated after parent request" do - env = Rack::MockRequest.env_for("/?foo=bar") - - req1 = Rack::Request.new(env) - req1.GET.should.equal "foo" => "bar" - req1.params.should.equal "foo" => "bar" - - req2 = MyRequest.new(env) - req2.GET.should.equal "foo" => "bar" - req2.params.should.equal :foo => "bar" - end - - specify "should allow parent request to be instantiated after subclass request" do - env = Rack::MockRequest.env_for("/?foo=bar") - - req1 = MyRequest.new(env) - req1.GET.should.equal "foo" => "bar" - req1.params.should.equal :foo => "bar" - - req2 = Rack::Request.new(env) - req2.GET.should.equal "foo" => "bar" - req2.params.should.equal "foo" => "bar" - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_response.rb b/vendor/gems/rack-1.0.1/test/spec_rack_response.rb deleted file mode 100644 index eb59b5c2..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_response.rb +++ /dev/null @@ -1,218 +0,0 @@ -require 'test/spec' -require 'set' - -require 'rack/response' - -context "Rack::Response" do - specify "has sensible default values" do - response = Rack::Response.new - status, header, body = response.finish - status.should.equal 200 - header.should.equal "Content-Type" => "text/html" - body.each { |part| - part.should.equal "" - } - - response = Rack::Response.new - status, header, body = *response - status.should.equal 200 - header.should.equal "Content-Type" => "text/html" - body.each { |part| - part.should.equal "" - } - end - - specify "can be written to" do - response = Rack::Response.new - - status, header, body = response.finish do - response.write "foo" - response.write "bar" - response.write "baz" - end - - parts = [] - body.each { |part| parts << part } - - parts.should.equal ["foo", "bar", "baz"] - end - - specify "can set and read headers" do - response = Rack::Response.new - response["Content-Type"].should.equal "text/html" - response["Content-Type"] = "text/plain" - response["Content-Type"].should.equal "text/plain" - end - - specify "can set cookies" do - response = Rack::Response.new - - response.set_cookie "foo", "bar" - response["Set-Cookie"].should.equal "foo=bar" - response.set_cookie "foo2", "bar2" - response["Set-Cookie"].should.equal ["foo=bar", "foo2=bar2"] - response.set_cookie "foo3", "bar3" - response["Set-Cookie"].should.equal ["foo=bar", "foo2=bar2", "foo3=bar3"] - end - - specify "formats the Cookie expiration date accordingly to RFC 2109" do - response = Rack::Response.new - - response.set_cookie "foo", {:value => "bar", :expires => Time.now+10} - response["Set-Cookie"].should.match( - /expires=..., \d\d-...-\d\d\d\d \d\d:\d\d:\d\d .../) - end - - specify "can set secure cookies" do - response = Rack::Response.new - response.set_cookie "foo", {:value => "bar", :secure => true} - response["Set-Cookie"].should.equal "foo=bar; secure" - end - - specify "can set http only cookies" do - response = Rack::Response.new - response.set_cookie "foo", {:value => "bar", :httponly => true} - response["Set-Cookie"].should.equal "foo=bar; HttpOnly" - end - - specify "can delete cookies" do - response = Rack::Response.new - response.set_cookie "foo", "bar" - response.set_cookie "foo2", "bar2" - response.delete_cookie "foo" - response["Set-Cookie"].should.equal ["foo2=bar2", - "foo=; expires=Thu, 01-Jan-1970 00:00:00 GMT"] - end - - specify "can do redirects" do - response = Rack::Response.new - response.redirect "/foo" - status, header, body = response.finish - - status.should.equal 302 - header["Location"].should.equal "/foo" - - response = Rack::Response.new - response.redirect "/foo", 307 - status, header, body = response.finish - - status.should.equal 307 - end - - specify "has a useful constructor" do - r = Rack::Response.new("foo") - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.equal "foo" - - r = Rack::Response.new(["foo", "bar"]) - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.equal "foobar" - - r = Rack::Response.new(["foo", "bar"].to_set) - r.write "foo" - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.equal "foobarfoo" - - r = Rack::Response.new([], 500) - r.status.should.equal 500 - end - - specify "has a constructor that can take a block" do - r = Rack::Response.new { |res| - res.status = 404 - res.write "foo" - } - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.equal "foo" - status.should.equal 404 - end - - specify "doesn't return invalid responses" do - r = Rack::Response.new(["foo", "bar"], 204) - status, header, body = r.finish - str = ""; body.each { |part| str << part } - str.should.be.empty - header["Content-Type"].should.equal nil - - lambda { - Rack::Response.new(Object.new) - }.should.raise(TypeError). - message.should =~ /stringable or iterable required/ - end - - specify "knows if it's empty" do - r = Rack::Response.new - r.should.be.empty - r.write "foo" - r.should.not.be.empty - - r = Rack::Response.new - r.should.be.empty - r.finish - r.should.be.empty - - r = Rack::Response.new - r.should.be.empty - r.finish { } - r.should.not.be.empty - end - - specify "should provide access to the HTTP status" do - res = Rack::Response.new - res.status = 200 - res.should.be.successful - res.should.be.ok - - res.status = 404 - res.should.not.be.successful - res.should.be.client_error - res.should.be.not_found - - res.status = 501 - res.should.not.be.successful - res.should.be.server_error - - res.status = 307 - res.should.be.redirect - end - - specify "should provide access to the HTTP headers" do - res = Rack::Response.new - res["Content-Type"] = "text/yaml" - - res.should.include "Content-Type" - res.headers["Content-Type"].should.equal "text/yaml" - res["Content-Type"].should.equal "text/yaml" - res.content_type.should.equal "text/yaml" - res.content_length.should.be.nil - res.location.should.be.nil - end - - specify "does not add or change Content-Length when #finish()ing" do - res = Rack::Response.new - res.status = 200 - res.finish - res.headers["Content-Length"].should.be.nil - - res = Rack::Response.new - res.status = 200 - res.headers["Content-Length"] = "10" - res.finish - res.headers["Content-Length"].should.equal "10" - end - - specify "updates Content-Length when body appended to using #write" do - res = Rack::Response.new - res.status = 200 - res.headers["Content-Length"].should.be.nil - res.write "Hi" - res.headers["Content-Length"].should.equal "2" - res.write " there" - res.headers["Content-Length"].should.equal "8" - end - -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_rewindable_input.rb b/vendor/gems/rack-1.0.1/test/spec_rack_rewindable_input.rb deleted file mode 100644 index 78bebfc9..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_rewindable_input.rb +++ /dev/null @@ -1,118 +0,0 @@ -require 'test/spec' -require 'stringio' -require 'rack/rewindable_input' - -shared_context "a rewindable IO object" do - setup do - @rio = Rack::RewindableInput.new(@io) - end - - teardown do - @rio.close - end - - specify "should be able to handle to read()" do - @rio.read.should.equal "hello world" - end - - specify "should be able to handle to read(nil)" do - @rio.read(nil).should.equal "hello world" - end - - specify "should be able to handle to read(length)" do - @rio.read(1).should.equal "h" - end - - specify "should be able to handle to read(length, buffer)" do - buffer = "" - result = @rio.read(1, buffer) - result.should.equal "h" - result.object_id.should.equal buffer.object_id - end - - specify "should be able to handle to read(nil, buffer)" do - buffer = "" - result = @rio.read(nil, buffer) - result.should.equal "hello world" - result.object_id.should.equal buffer.object_id - end - - specify "should rewind to the beginning when #rewind is called" do - @rio.read(1) - @rio.rewind - @rio.read.should.equal "hello world" - end - - specify "should be able to handle gets" do - @rio.gets.should == "hello world" - end - - specify "should be able to handle each" do - array = [] - @rio.each do |data| - array << data - end - array.should.equal(["hello world"]) - end - - specify "should not buffer into a Tempfile if no data has been read yet" do - @rio.instance_variable_get(:@rewindable_io).should.be.nil - end - - specify "should buffer into a Tempfile when data has been consumed for the first time" do - @rio.read(1) - tempfile = @rio.instance_variable_get(:@rewindable_io) - tempfile.should.not.be.nil - @rio.read(1) - tempfile2 = @rio.instance_variable_get(:@rewindable_io) - tempfile2.should.equal tempfile - end - - specify "should close the underlying tempfile upon calling #close" do - @rio.read(1) - tempfile = @rio.instance_variable_get(:@rewindable_io) - @rio.close - tempfile.should.be.closed - end - - specify "should be possibel to call #close when no data has been buffered yet" do - @rio.close - end - - specify "should be possible to call #close multiple times" do - @rio.close - @rio.close - end -end - -context "Rack::RewindableInput" do - context "given an IO object that is already rewindable" do - setup do - @io = StringIO.new("hello world") - end - - it_should_behave_like "a rewindable IO object" - end - - context "given an IO object that is not rewindable" do - setup do - @io = StringIO.new("hello world") - @io.instance_eval do - undef :rewind - end - end - - it_should_behave_like "a rewindable IO object" - end - - context "given an IO object whose rewind method raises Errno::ESPIPE" do - setup do - @io = StringIO.new("hello world") - def @io.rewind - raise Errno::ESPIPE, "You can't rewind this!" - end - end - - it_should_behave_like "a rewindable IO object" - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_session_cookie.rb b/vendor/gems/rack-1.0.1/test/spec_rack_session_cookie.rb deleted file mode 100644 index 3be88b43..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_session_cookie.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'test/spec' - -require 'rack/session/cookie' -require 'rack/mock' -require 'rack/response' - -context "Rack::Session::Cookie" do - incrementor = lambda { |env| - env["rack.session"]["counter"] ||= 0 - env["rack.session"]["counter"] += 1 - Rack::Response.new(env["rack.session"].inspect).to_a - } - - specify "creates a new cookie" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)).get("/") - res["Set-Cookie"].should.match("rack.session=") - res.body.should.equal '{"counter"=>1}' - end - - specify "loads from a cookie" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)).get("/") - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)). - get("/", "HTTP_COOKIE" => cookie) - res.body.should.equal '{"counter"=>2}' - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)). - get("/", "HTTP_COOKIE" => cookie) - res.body.should.equal '{"counter"=>3}' - end - - specify "survives broken cookies" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor)). - get("/", "HTTP_COOKIE" => "rack.session=blarghfasel") - res.body.should.equal '{"counter"=>1}' - end - - bigcookie = lambda { |env| - env["rack.session"]["cookie"] = "big" * 3000 - Rack::Response.new(env["rack.session"].inspect).to_a - } - - specify "barks on too big cookies" do - lambda { - Rack::MockRequest.new(Rack::Session::Cookie.new(bigcookie)). - get("/", :fatal => true) - }.should.raise(Rack::MockRequest::FatalWarning) - end - - specify "creates a new cookie with integrity hash" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')).get("/") - if RUBY_VERSION < "1.9" - res["Set-Cookie"].should.match("rack.session=BAh7BiIMY291bnRlcmkG%0A--1439b4d37b9d4b04c603848382f712d6fcd31088") - else - res["Set-Cookie"].should.match("rack.session=BAh7BkkiDGNvdW50ZXIGOg1lbmNvZGluZyINVVMtQVNDSUlpBg%3D%3D%0A--d7a6637b94d2728194a96c18484e1f7ed9074a83") - end - end - - specify "loads from a cookie wih integrity hash" do - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')).get("/") - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')). - get("/", "HTTP_COOKIE" => cookie) - res.body.should.equal '{"counter"=>2}' - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(Rack::Session::Cookie.new(incrementor, :secret => 'test')). - get("/", "HTTP_COOKIE" => cookie) - res.body.should.equal '{"counter"=>3}' - end - - specify "ignores tampered with session cookies" do - app = Rack::Session::Cookie.new(incrementor, :secret => 'test') - response1 = Rack::MockRequest.new(app).get("/") - _, digest = response1["Set-Cookie"].split("--") - tampered_with_cookie = "hackerman-was-here" + "--" + digest - response2 = Rack::MockRequest.new(app).get("/", "HTTP_COOKIE" => - tampered_with_cookie) - - # The tampered-with cookie is ignored, so we get back an identical Set-Cookie - response2["Set-Cookie"].should.equal(response1["Set-Cookie"]) - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_session_memcache.rb b/vendor/gems/rack-1.0.1/test/spec_rack_session_memcache.rb deleted file mode 100644 index 37c3d895..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_session_memcache.rb +++ /dev/null @@ -1,240 +0,0 @@ -require 'test/spec' - -begin - require 'rack/session/memcache' - require 'rack/mock' - require 'rack/response' - require 'thread' - - context "Rack::Session::Memcache" do - session_key = Rack::Session::Memcache::DEFAULT_OPTIONS[:key] - session_match = /#{session_key}=[0-9a-fA-F]+;/ - incrementor = lambda do |env| - env["rack.session"]["counter"] ||= 0 - env["rack.session"]["counter"] += 1 - Rack::Response.new(env["rack.session"].inspect).to_a - end - drop_session = proc do |env| - env['rack.session.options'][:drop] = true - incrementor.call(env) - end - renew_session = proc do |env| - env['rack.session.options'][:renew] = true - incrementor.call(env) - end - defer_session = proc do |env| - env['rack.session.options'][:defer] = true - incrementor.call(env) - end - - specify "MemCache can connect to existing server" do - test_pool = MemCache.new :namespace => 'test:rack:session' - end - - specify "faults on no connection" do - lambda do - Rack::Session::Memcache.new(incrementor, :memcache_server => '') - end.should.raise - end - - specify "creates a new cookie" do - pool = Rack::Session::Memcache.new(incrementor) - res = Rack::MockRequest.new(pool).get("/") - res["Set-Cookie"].should.match("#{session_key}=") - res.body.should.equal '{"counter"=>1}' - end - - specify "determines session from a cookie" do - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - res = req.get("/") - cookie = res["Set-Cookie"] - req.get("/", "HTTP_COOKIE" => cookie). - body.should.equal '{"counter"=>2}' - req.get("/", "HTTP_COOKIE" => cookie). - body.should.equal '{"counter"=>3}' - end - - specify "survives nonexistant cookies" do - bad_cookie = "rack.session=blarghfasel" - pool = Rack::Session::Memcache.new(incrementor) - res = Rack::MockRequest.new(pool). - get("/", "HTTP_COOKIE" => bad_cookie) - res.body.should.equal '{"counter"=>1}' - cookie = res["Set-Cookie"][session_match] - cookie.should.not.match(/#{bad_cookie}/) - end - - specify "maintains freshness" do - pool = Rack::Session::Memcache.new(incrementor, :expire_after => 3) - res = Rack::MockRequest.new(pool).get('/') - res.body.should.include '"counter"=>1' - cookie = res["Set-Cookie"] - res = Rack::MockRequest.new(pool).get('/', "HTTP_COOKIE" => cookie) - res["Set-Cookie"].should.equal cookie - res.body.should.include '"counter"=>2' - puts 'Sleeping to expire session' if $DEBUG - sleep 4 - res = Rack::MockRequest.new(pool).get('/', "HTTP_COOKIE" => cookie) - res["Set-Cookie"].should.not.equal cookie - res.body.should.include '"counter"=>1' - end - - specify "deletes cookies with :drop option" do - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - drop = Rack::Utils::Context.new(pool, drop_session) - dreq = Rack::MockRequest.new(drop) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - - res2 = dreq.get("/", "HTTP_COOKIE" => cookie) - res2["Set-Cookie"].should.equal nil - res2.body.should.equal '{"counter"=>3}' - - res3 = req.get("/", "HTTP_COOKIE" => cookie) - res3["Set-Cookie"][session_match].should.not.equal session - res3.body.should.equal '{"counter"=>1}' - end - - specify "provides new session id with :renew option" do - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - renew = Rack::Utils::Context.new(pool, renew_session) - rreq = Rack::MockRequest.new(renew) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - - res2 = rreq.get("/", "HTTP_COOKIE" => cookie) - new_cookie = res2["Set-Cookie"] - new_session = new_cookie[session_match] - new_session.should.not.equal session - res2.body.should.equal '{"counter"=>3}' - - res3 = req.get("/", "HTTP_COOKIE" => new_cookie) - res3["Set-Cookie"][session_match].should.equal new_session - res3.body.should.equal '{"counter"=>4}' - end - - specify "omits cookie with :defer option" do - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - defer = Rack::Utils::Context.new(pool, defer_session) - dreq = Rack::MockRequest.new(defer) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - - res2 = dreq.get("/", "HTTP_COOKIE" => cookie) - res2["Set-Cookie"].should.equal nil - res2.body.should.equal '{"counter"=>3}' - - res3 = req.get("/", "HTTP_COOKIE" => cookie) - res3["Set-Cookie"][session_match].should.equal session - res3.body.should.equal '{"counter"=>4}' - end - - # anyone know how to do this better? - specify "multithread: should cleanly merge sessions" do - next unless $DEBUG - warn 'Running multithread test for Session::Memcache' - pool = Rack::Session::Memcache.new(incrementor) - req = Rack::MockRequest.new(pool) - - res = req.get('/') - res.body.should.equal '{"counter"=>1}' - cookie = res["Set-Cookie"] - sess_id = cookie[/#{pool.key}=([^,;]+)/,1] - - delta_incrementor = lambda do |env| - # emulate disconjoinment of threading - env['rack.session'] = env['rack.session'].dup - Thread.stop - env['rack.session'][(Time.now.usec*rand).to_i] = true - incrementor.call(env) - end - tses = Rack::Utils::Context.new pool, delta_incrementor - treq = Rack::MockRequest.new(tses) - tnum = rand(7).to_i+5 - r = Array.new(tnum) do - Thread.new(treq) do |run| - run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) - end - end.reverse.map{|t| t.run.join.value } - r.each do |res| - res['Set-Cookie'].should.equal cookie - res.body.should.include '"counter"=>2' - end - - session = pool.pool.get(sess_id) - session.size.should.be tnum+1 # counter - session['counter'].should.be 2 # meeeh - - tnum = rand(7).to_i+5 - r = Array.new(tnum) do |i| - delta_time = proc do |env| - env['rack.session'][i] = Time.now - Thread.stop - env['rack.session'] = env['rack.session'].dup - env['rack.session'][i] -= Time.now - incrementor.call(env) - end - app = Rack::Utils::Context.new pool, time_delta - req = Rack::MockRequest.new app - Thread.new(req) do |run| - run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) - end - end.reverse.map{|t| t.run.join.value } - r.each do |res| - res['Set-Cookie'].should.equal cookie - res.body.should.include '"counter"=>3' - end - - session = pool.pool.get(sess_id) - session.size.should.be tnum+1 - session['counter'].should.be 3 - - drop_counter = proc do |env| - env['rack.session'].delete 'counter' - env['rack.session']['foo'] = 'bar' - [200, {'Content-Type'=>'text/plain'}, env['rack.session'].inspect] - end - tses = Rack::Utils::Context.new pool, drop_counter - treq = Rack::MockRequest.new(tses) - tnum = rand(7).to_i+5 - r = Array.new(tnum) do - Thread.new(treq) do |run| - run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) - end - end.reverse.map{|t| t.run.join.value } - r.each do |res| - res['Set-Cookie'].should.equal cookie - res.body.should.include '"foo"=>"bar"' - end - - session = pool.pool.get(sess_id) - session.size.should.be r.size+1 - session['counter'].should.be.nil? - session['foo'].should.equal 'bar' - end - end -rescue LoadError - $stderr.puts "Skipping Rack::Session::Memcache tests (Memcache is required). `gem install memcache-client` and try again." -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_session_pool.rb b/vendor/gems/rack-1.0.1/test/spec_rack_session_pool.rb deleted file mode 100644 index 6be382ec..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_session_pool.rb +++ /dev/null @@ -1,172 +0,0 @@ -require 'test/spec' - -require 'rack/session/pool' -require 'rack/mock' -require 'rack/response' -require 'thread' - -context "Rack::Session::Pool" do - session_key = Rack::Session::Pool::DEFAULT_OPTIONS[:key] - session_match = /#{session_key}=[0-9a-fA-F]+;/ - incrementor = lambda do |env| - env["rack.session"]["counter"] ||= 0 - env["rack.session"]["counter"] += 1 - Rack::Response.new(env["rack.session"].inspect).to_a - end - drop_session = proc do |env| - env['rack.session.options'][:drop] = true - incrementor.call(env) - end - renew_session = proc do |env| - env['rack.session.options'][:renew] = true - incrementor.call(env) - end - defer_session = proc do |env| - env['rack.session.options'][:defer] = true - incrementor.call(env) - end - - specify "creates a new cookie" do - pool = Rack::Session::Pool.new(incrementor) - res = Rack::MockRequest.new(pool).get("/") - res["Set-Cookie"].should.match session_match - res.body.should.equal '{"counter"=>1}' - end - - specify "determines session from a cookie" do - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - cookie = req.get("/")["Set-Cookie"] - req.get("/", "HTTP_COOKIE" => cookie). - body.should.equal '{"counter"=>2}' - req.get("/", "HTTP_COOKIE" => cookie). - body.should.equal '{"counter"=>3}' - end - - specify "survives nonexistant cookies" do - pool = Rack::Session::Pool.new(incrementor) - res = Rack::MockRequest.new(pool). - get("/", "HTTP_COOKIE" => "#{session_key}=blarghfasel") - res.body.should.equal '{"counter"=>1}' - end - - specify "deletes cookies with :drop option" do - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - drop = Rack::Utils::Context.new(pool, drop_session) - dreq = Rack::MockRequest.new(drop) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - pool.pool.size.should.be 1 - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - pool.pool.size.should.be 1 - - res2 = dreq.get("/", "HTTP_COOKIE" => cookie) - res2["Set-Cookie"].should.equal nil - res2.body.should.equal '{"counter"=>3}' - pool.pool.size.should.be 0 - - res3 = req.get("/", "HTTP_COOKIE" => cookie) - res3["Set-Cookie"][session_match].should.not.equal session - res3.body.should.equal '{"counter"=>1}' - pool.pool.size.should.be 1 - end - - specify "provides new session id with :renew option" do - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - renew = Rack::Utils::Context.new(pool, renew_session) - rreq = Rack::MockRequest.new(renew) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - pool.pool.size.should.be 1 - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - pool.pool.size.should.be 1 - - res2 = rreq.get("/", "HTTP_COOKIE" => cookie) - new_cookie = res2["Set-Cookie"] - new_session = new_cookie[session_match] - new_session.should.not.equal session - res2.body.should.equal '{"counter"=>3}' - pool.pool.size.should.be 1 - - res3 = req.get("/", "HTTP_COOKIE" => new_cookie) - res3["Set-Cookie"][session_match].should.equal new_session - res3.body.should.equal '{"counter"=>4}' - pool.pool.size.should.be 1 - end - - specify "omits cookie with :defer option" do - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - defer = Rack::Utils::Context.new(pool, defer_session) - dreq = Rack::MockRequest.new(defer) - - res0 = req.get("/") - session = (cookie = res0["Set-Cookie"])[session_match] - res0.body.should.equal '{"counter"=>1}' - pool.pool.size.should.be 1 - - res1 = req.get("/", "HTTP_COOKIE" => cookie) - res1["Set-Cookie"][session_match].should.equal session - res1.body.should.equal '{"counter"=>2}' - pool.pool.size.should.be 1 - - res2 = dreq.get("/", "HTTP_COOKIE" => cookie) - res2["Set-Cookie"].should.equal nil - res2.body.should.equal '{"counter"=>3}' - pool.pool.size.should.be 1 - - res3 = req.get("/", "HTTP_COOKIE" => cookie) - res3["Set-Cookie"][session_match].should.equal session - res3.body.should.equal '{"counter"=>4}' - pool.pool.size.should.be 1 - end - - # anyone know how to do this better? - specify "multithread: should merge sessions" do - next unless $DEBUG - warn 'Running multithread tests for Session::Pool' - pool = Rack::Session::Pool.new(incrementor) - req = Rack::MockRequest.new(pool) - - res = req.get('/') - res.body.should.equal '{"counter"=>1}' - cookie = res["Set-Cookie"] - sess_id = cookie[/#{pool.key}=([^,;]+)/,1] - - delta_incrementor = lambda do |env| - # emulate disconjoinment of threading - env['rack.session'] = env['rack.session'].dup - Thread.stop - env['rack.session'][(Time.now.usec*rand).to_i] = true - incrementor.call(env) - end - tses = Rack::Utils::Context.new pool, delta_incrementor - treq = Rack::MockRequest.new(tses) - tnum = rand(7).to_i+5 - r = Array.new(tnum) do - Thread.new(treq) do |run| - run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) - end - end.reverse.map{|t| t.run.join.value } - r.each do |res| - res['Set-Cookie'].should.equal cookie - res.body.should.include '"counter"=>2' - end - - session = pool.pool[sess_id] - session.size.should.be tnum+1 # counter - session['counter'].should.be 2 # meeeh - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_showexceptions.rb b/vendor/gems/rack-1.0.1/test/spec_rack_showexceptions.rb deleted file mode 100644 index bdbc1201..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_showexceptions.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test/spec' - -require 'rack/showexceptions' -require 'rack/mock' - -context "Rack::ShowExceptions" do - specify "catches exceptions" do - res = nil - req = Rack::MockRequest.new(Rack::ShowExceptions.new(lambda { |env| - raise RuntimeError - })) - lambda { - res = req.get("/") - }.should.not.raise - res.should.be.a.server_error - res.status.should.equal 500 - - res.should =~ /RuntimeError/ - res.should =~ /ShowExceptions/ - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_showstatus.rb b/vendor/gems/rack-1.0.1/test/spec_rack_showstatus.rb deleted file mode 100644 index 78700134..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_showstatus.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'test/spec' - -require 'rack/showstatus' -require 'rack/mock' - -context "Rack::ShowStatus" do - specify "should provide a default status message" do - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| - [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []] - })) - - res = req.get("/", :lint => true) - res.should.be.not_found - res.should.be.not.empty - - res["Content-Type"].should.equal("text/html") - res.should =~ /404/ - res.should =~ /Not Found/ - end - - specify "should let the app provide additional information" do - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| - env["rack.showstatus.detail"] = "gone too meta." - [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []] - })) - - res = req.get("/", :lint => true) - res.should.be.not_found - res.should.be.not.empty - - res["Content-Type"].should.equal("text/html") - res.should =~ /404/ - res.should =~ /Not Found/ - res.should =~ /too meta/ - end - - specify "should not replace existing messages" do - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| - [404, {"Content-Type" => "text/plain", "Content-Length" => "4"}, ["foo!"]] - })) - res = req.get("/", :lint => true) - res.should.be.not_found - - res.body.should == "foo!" - end - - specify "should pass on original headers" do - headers = {"WWW-Authenticate" => "Basic blah"} - - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| [401, headers, []] })) - res = req.get("/", :lint => true) - - res["WWW-Authenticate"].should.equal("Basic blah") - end - - specify "should replace existing messages if there is detail" do - req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| - env["rack.showstatus.detail"] = "gone too meta." - [404, {"Content-Type" => "text/plain", "Content-Length" => "4"}, ["foo!"]] - })) - - res = req.get("/", :lint => true) - res.should.be.not_found - res.should.be.not.empty - - res["Content-Type"].should.equal("text/html") - res["Content-Length"].should.not.equal("4") - res.should =~ /404/ - res.should =~ /too meta/ - res.body.should.not =~ /foo/ - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_static.rb b/vendor/gems/rack-1.0.1/test/spec_rack_static.rb deleted file mode 100644 index 19d2ecb7..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_static.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'test/spec' - -require 'rack/static' -require 'rack/mock' - -class DummyApp - def call(env) - [200, {}, ["Hello World"]] - end -end - -context "Rack::Static" do - root = File.expand_path(File.dirname(__FILE__)) - OPTIONS = {:urls => ["/cgi"], :root => root} - - setup do - @request = Rack::MockRequest.new(Rack::Static.new(DummyApp.new, OPTIONS)) - end - - specify "serves files" do - res = @request.get("/cgi/test") - res.should.be.ok - res.body.should =~ /ruby/ - end - - specify "404s if url root is known but it can't find the file" do - res = @request.get("/cgi/foo") - res.should.be.not_found - end - - specify "calls down the chain if url root is not known" do - res = @request.get("/something/else") - res.should.be.ok - res.body.should == "Hello World" - end - -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_thin.rb b/vendor/gems/rack-1.0.1/test/spec_rack_thin.rb deleted file mode 100644 index 324f6498..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_thin.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'test/spec' - -begin -require 'rack/handler/thin' -require 'testrequest' -require 'timeout' - -context "Rack::Handler::Thin" do - include TestRequest::Helpers - - setup do - @app = Rack::Lint.new(TestRequest.new) - @server = nil - Thin::Logging.silent = true - @thread = Thread.new do - Rack::Handler::Thin.run(@app, :Host => @host='0.0.0.0', :Port => @port=9204) do |server| - @server = server - end - end - Thread.pass until @server && @server.running? - end - - specify "should respond" do - lambda { - GET("/") - }.should.not.raise - end - - specify "should be a Thin" do - GET("/") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /thin/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal "9204" - response["SERVER_NAME"].should.equal "0.0.0.0" - end - - specify "should have rack headers" do - GET("/") - response["rack.version"].should.equal [0,3] - response["rack.multithread"].should.be false - response["rack.multiprocess"].should.be false - response["rack.run_once"].should.be false - end - - specify "should have CGI headers on GET" do - GET("/") - response["REQUEST_METHOD"].should.equal "GET" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.be.equal "/" - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["REQUEST_PATH"].should.equal "/test/foo" - response["PATH_INFO"].should.equal "/test/foo" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["REQUEST_PATH"].should.equal "/" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - teardown do - @server.stop! - @thread.kill - end -end - -rescue LoadError - $stderr.puts "Skipping Rack::Handler::Thin tests (Thin is required). `gem install thin` and try again." -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_urlmap.rb b/vendor/gems/rack-1.0.1/test/spec_rack_urlmap.rb deleted file mode 100644 index 6c4d72ac..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_urlmap.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'test/spec' - -require 'rack/urlmap' -require 'rack/mock' - -context "Rack::URLMap" do - specify "dispatches paths correctly" do - app = lambda { |env| - [200, { - 'X-ScriptName' => env['SCRIPT_NAME'], - 'X-PathInfo' => env['PATH_INFO'], - 'Content-Type' => 'text/plain' - }, [""]] - } - map = Rack::URLMap.new({ - 'http://foo.org/bar' => app, - '/foo' => app, - '/foo/bar' => app - }) - - res = Rack::MockRequest.new(map).get("/") - res.should.be.not_found - - res = Rack::MockRequest.new(map).get("/qux") - res.should.be.not_found - - res = Rack::MockRequest.new(map).get("/foo") - res.should.be.ok - res["X-ScriptName"].should.equal "/foo" - res["X-PathInfo"].should.equal "" - - res = Rack::MockRequest.new(map).get("/foo/") - res.should.be.ok - res["X-ScriptName"].should.equal "/foo" - res["X-PathInfo"].should.equal "/" - - res = Rack::MockRequest.new(map).get("/foo/bar") - res.should.be.ok - res["X-ScriptName"].should.equal "/foo/bar" - res["X-PathInfo"].should.equal "" - - res = Rack::MockRequest.new(map).get("/foo/bar/") - res.should.be.ok - res["X-ScriptName"].should.equal "/foo/bar" - res["X-PathInfo"].should.equal "/" - - res = Rack::MockRequest.new(map).get("/foo/quux", "SCRIPT_NAME" => "/bleh") - res.should.be.ok - res["X-ScriptName"].should.equal "/bleh/foo" - res["X-PathInfo"].should.equal "/quux" - - res = Rack::MockRequest.new(map).get("/bar", 'HTTP_HOST' => 'foo.org') - res.should.be.ok - res["X-ScriptName"].should.equal "/bar" - res["X-PathInfo"].should.be.empty - - res = Rack::MockRequest.new(map).get("/bar/", 'HTTP_HOST' => 'foo.org') - res.should.be.ok - res["X-ScriptName"].should.equal "/bar" - res["X-PathInfo"].should.equal '/' - end - - - specify "dispatches hosts correctly" do - map = Rack::URLMap.new("http://foo.org/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "foo.org", - "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], - }, [""]]}, - "http://subdomain.foo.org/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "subdomain.foo.org", - "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], - }, [""]]}, - "http://bar.org/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "bar.org", - "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], - }, [""]]}, - "/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "default.org", - "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], - }, [""]]} - ) - - res = Rack::MockRequest.new(map).get("/") - res.should.be.ok - res["X-Position"].should.equal "default.org" - - res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "bar.org") - res.should.be.ok - res["X-Position"].should.equal "bar.org" - - res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "foo.org") - res.should.be.ok - res["X-Position"].should.equal "foo.org" - - res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "subdomain.foo.org", "SERVER_NAME" => "foo.org") - res.should.be.ok - res["X-Position"].should.equal "subdomain.foo.org" - - res = Rack::MockRequest.new(map).get("http://foo.org/") - res.should.be.ok - res["X-Position"].should.equal "default.org" - - res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org") - res.should.be.ok - res["X-Position"].should.equal "default.org" - - res = Rack::MockRequest.new(map).get("/", - "HTTP_HOST" => "example.org:9292", - "SERVER_PORT" => "9292") - res.should.be.ok - res["X-Position"].should.equal "default.org" - end - - specify "should be nestable" do - map = Rack::URLMap.new("/foo" => - Rack::URLMap.new("/bar" => - Rack::URLMap.new("/quux" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "/foo/bar/quux", - "X-PathInfo" => env["PATH_INFO"], - "X-ScriptName" => env["SCRIPT_NAME"], - }, [""]]} - ))) - - res = Rack::MockRequest.new(map).get("/foo/bar") - res.should.be.not_found - - res = Rack::MockRequest.new(map).get("/foo/bar/quux") - res.should.be.ok - res["X-Position"].should.equal "/foo/bar/quux" - res["X-PathInfo"].should.equal "" - res["X-ScriptName"].should.equal "/foo/bar/quux" - end - - specify "should route root apps correctly" do - map = Rack::URLMap.new("/" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "root", - "X-PathInfo" => env["PATH_INFO"], - "X-ScriptName" => env["SCRIPT_NAME"] - }, [""]]}, - "/foo" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "foo", - "X-PathInfo" => env["PATH_INFO"], - "X-ScriptName" => env["SCRIPT_NAME"] - }, [""]]} - ) - - res = Rack::MockRequest.new(map).get("/foo/bar") - res.should.be.ok - res["X-Position"].should.equal "foo" - res["X-PathInfo"].should.equal "/bar" - res["X-ScriptName"].should.equal "/foo" - - res = Rack::MockRequest.new(map).get("/foo") - res.should.be.ok - res["X-Position"].should.equal "foo" - res["X-PathInfo"].should.equal "" - res["X-ScriptName"].should.equal "/foo" - - res = Rack::MockRequest.new(map).get("/bar") - res.should.be.ok - res["X-Position"].should.equal "root" - res["X-PathInfo"].should.equal "/bar" - res["X-ScriptName"].should.equal "" - - res = Rack::MockRequest.new(map).get("") - res.should.be.ok - res["X-Position"].should.equal "root" - res["X-PathInfo"].should.equal "/" - res["X-ScriptName"].should.equal "" - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_utils.rb b/vendor/gems/rack-1.0.1/test/spec_rack_utils.rb deleted file mode 100644 index f270e87e..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_utils.rb +++ /dev/null @@ -1,387 +0,0 @@ -require 'test/spec' - -require 'rack/utils' -require 'rack/lint' -require 'rack/mock' - -context "Rack::Utils" do - specify "should escape correctly" do - Rack::Utils.escape("fobar").should.equal "fo%3Co%3Ebar" - Rack::Utils.escape("a space").should.equal "a+space" - Rack::Utils.escape("q1!2\"'w$5&7/z8)?\\"). - should.equal "q1%212%22%27w%245%267%2Fz8%29%3F%5C" - end - - specify "should escape correctly for multibyte characters" do - matz_name = "\xE3\x81\xBE\xE3\x81\xA4\xE3\x82\x82\xE3\x81\xA8".unpack("a*")[0] # Matsumoto - matz_name.force_encoding("UTF-8") if matz_name.respond_to? :force_encoding - Rack::Utils.escape(matz_name).should.equal '%E3%81%BE%E3%81%A4%E3%82%82%E3%81%A8' - matz_name_sep = "\xE3\x81\xBE\xE3\x81\xA4 \xE3\x82\x82\xE3\x81\xA8".unpack("a*")[0] # Matsu moto - matz_name_sep.force_encoding("UTF-8") if matz_name_sep.respond_to? :force_encoding - Rack::Utils.escape(matz_name_sep).should.equal '%E3%81%BE%E3%81%A4+%E3%82%82%E3%81%A8' - end - - specify "should unescape correctly" do - Rack::Utils.unescape("fo%3Co%3Ebar").should.equal "fobar" - Rack::Utils.unescape("a+space").should.equal "a space" - Rack::Utils.unescape("a%20space").should.equal "a space" - Rack::Utils.unescape("q1%212%22%27w%245%267%2Fz8%29%3F%5C"). - should.equal "q1!2\"'w$5&7/z8)?\\" - end - - specify "should parse query strings correctly" do - Rack::Utils.parse_query("foo=bar").should.equal "foo" => "bar" - Rack::Utils.parse_query("foo=bar&foo=quux"). - should.equal "foo" => ["bar", "quux"] - Rack::Utils.parse_query("foo=1&bar=2"). - should.equal "foo" => "1", "bar" => "2" - Rack::Utils.parse_query("my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F"). - should.equal "my weird field" => "q1!2\"'w$5&7/z8)?" - Rack::Utils.parse_query("foo%3Dbaz=bar").should.equal "foo=baz" => "bar" - end - - specify "should parse nested query strings correctly" do - Rack::Utils.parse_nested_query("foo"). - should.equal "foo" => nil - Rack::Utils.parse_nested_query("foo="). - should.equal "foo" => "" - Rack::Utils.parse_nested_query("foo=bar"). - should.equal "foo" => "bar" - - Rack::Utils.parse_nested_query("foo=bar&foo=quux"). - should.equal "foo" => "quux" - Rack::Utils.parse_nested_query("foo&foo="). - should.equal "foo" => "" - Rack::Utils.parse_nested_query("foo=1&bar=2"). - should.equal "foo" => "1", "bar" => "2" - Rack::Utils.parse_nested_query("&foo=1&&bar=2"). - should.equal "foo" => "1", "bar" => "2" - Rack::Utils.parse_nested_query("foo&bar="). - should.equal "foo" => nil, "bar" => "" - Rack::Utils.parse_nested_query("foo=bar&baz="). - should.equal "foo" => "bar", "baz" => "" - Rack::Utils.parse_nested_query("my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F"). - should.equal "my weird field" => "q1!2\"'w$5&7/z8)?" - - Rack::Utils.parse_nested_query("foo[]"). - should.equal "foo" => [nil] - Rack::Utils.parse_nested_query("foo[]="). - should.equal "foo" => [""] - Rack::Utils.parse_nested_query("foo[]=bar"). - should.equal "foo" => ["bar"] - - Rack::Utils.parse_nested_query("foo[]=1&foo[]=2"). - should.equal "foo" => ["1", "2"] - Rack::Utils.parse_nested_query("foo=bar&baz[]=1&baz[]=2&baz[]=3"). - should.equal "foo" => "bar", "baz" => ["1", "2", "3"] - Rack::Utils.parse_nested_query("foo[]=bar&baz[]=1&baz[]=2&baz[]=3"). - should.equal "foo" => ["bar"], "baz" => ["1", "2", "3"] - - Rack::Utils.parse_nested_query("x[y][z]=1"). - should.equal "x" => {"y" => {"z" => "1"}} - Rack::Utils.parse_nested_query("x[y][z][]=1"). - should.equal "x" => {"y" => {"z" => ["1"]}} - Rack::Utils.parse_nested_query("x[y][z]=1&x[y][z]=2"). - should.equal "x" => {"y" => {"z" => "2"}} - Rack::Utils.parse_nested_query("x[y][z][]=1&x[y][z][]=2"). - should.equal "x" => {"y" => {"z" => ["1", "2"]}} - - Rack::Utils.parse_nested_query("x[y][][z]=1"). - should.equal "x" => {"y" => [{"z" => "1"}]} - Rack::Utils.parse_nested_query("x[y][][z][]=1"). - should.equal "x" => {"y" => [{"z" => ["1"]}]} - Rack::Utils.parse_nested_query("x[y][][z]=1&x[y][][w]=2"). - should.equal "x" => {"y" => [{"z" => "1", "w" => "2"}]} - - Rack::Utils.parse_nested_query("x[y][][v][w]=1"). - should.equal "x" => {"y" => [{"v" => {"w" => "1"}}]} - Rack::Utils.parse_nested_query("x[y][][z]=1&x[y][][v][w]=2"). - should.equal "x" => {"y" => [{"z" => "1", "v" => {"w" => "2"}}]} - - Rack::Utils.parse_nested_query("x[y][][z]=1&x[y][][z]=2"). - should.equal "x" => {"y" => [{"z" => "1"}, {"z" => "2"}]} - Rack::Utils.parse_nested_query("x[y][][z]=1&x[y][][w]=a&x[y][][z]=2&x[y][][w]=3"). - should.equal "x" => {"y" => [{"z" => "1", "w" => "a"}, {"z" => "2", "w" => "3"}]} - - lambda { Rack::Utils.parse_nested_query("x[y]=1&x[y]z=2") }. - should.raise(TypeError). - message.should.equal "expected Hash (got String) for param `y'" - - lambda { Rack::Utils.parse_nested_query("x[y]=1&x[]=1") }. - should.raise(TypeError). - message.should.equal "expected Array (got Hash) for param `x'" - - lambda { Rack::Utils.parse_nested_query("x[y]=1&x[y][][w]=2") }. - should.raise(TypeError). - message.should.equal "expected Array (got String) for param `y'" - end - - specify "should build query strings correctly" do - Rack::Utils.build_query("foo" => "bar").should.equal "foo=bar" - Rack::Utils.build_query("foo" => ["bar", "quux"]). - should.equal "foo=bar&foo=quux" - Rack::Utils.build_query("foo" => "1", "bar" => "2"). - should.equal "foo=1&bar=2" - Rack::Utils.build_query("my weird field" => "q1!2\"'w$5&7/z8)?"). - should.equal "my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F" - end - - specify "should figure out which encodings are acceptable" do - helper = lambda do |a, b| - request = Rack::Request.new(Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => a)) - Rack::Utils.select_best_encoding(a, b) - end - - helper.call(%w(), [["x", 1]]).should.equal(nil) - helper.call(%w(identity), [["identity", 0.0]]).should.equal(nil) - helper.call(%w(identity), [["*", 0.0]]).should.equal(nil) - - helper.call(%w(identity), [["compress", 1.0], ["gzip", 1.0]]).should.equal("identity") - - helper.call(%w(compress gzip identity), [["compress", 1.0], ["gzip", 1.0]]).should.equal("compress") - helper.call(%w(compress gzip identity), [["compress", 0.5], ["gzip", 1.0]]).should.equal("gzip") - - helper.call(%w(foo bar identity), []).should.equal("identity") - helper.call(%w(foo bar identity), [["*", 1.0]]).should.equal("foo") - helper.call(%w(foo bar identity), [["*", 1.0], ["foo", 0.9]]).should.equal("bar") - - helper.call(%w(foo bar identity), [["foo", 0], ["bar", 0]]).should.equal("identity") - helper.call(%w(foo bar baz identity), [["*", 0], ["identity", 0.1]]).should.equal("identity") - end - - specify "should return the bytesize of String" do - Rack::Utils.bytesize("FOO\xE2\x82\xAC").should.equal 6 - end -end - -context "Rack::Utils::HeaderHash" do - specify "should retain header case" do - h = Rack::Utils::HeaderHash.new("Content-MD5" => "d5ff4e2a0 ...") - h['ETag'] = 'Boo!' - h.to_hash.should.equal "Content-MD5" => "d5ff4e2a0 ...", "ETag" => 'Boo!' - end - - specify "should check existence of keys case insensitively" do - h = Rack::Utils::HeaderHash.new("Content-MD5" => "d5ff4e2a0 ...") - h.should.include 'content-md5' - h.should.not.include 'ETag' - end - - specify "should merge case-insensitively" do - h = Rack::Utils::HeaderHash.new("ETag" => 'HELLO', "content-length" => '123') - merged = h.merge("Etag" => 'WORLD', 'Content-Length' => '321', "Foo" => 'BAR') - merged.should.equal "Etag"=>'WORLD', "Content-Length"=>'321', "Foo"=>'BAR' - end - - specify "should overwrite case insensitively and assume the new key's case" do - h = Rack::Utils::HeaderHash.new("Foo-Bar" => "baz") - h["foo-bar"] = "bizzle" - h["FOO-BAR"].should.equal "bizzle" - h.length.should.equal 1 - h.to_hash.should.equal "foo-bar" => "bizzle" - end - - specify "should be converted to real Hash" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.to_hash.should.be.instance_of Hash - end - - specify "should convert Array values to Strings when converting to Hash" do - h = Rack::Utils::HeaderHash.new("foo" => ["bar", "baz"]) - h.to_hash.should.equal({ "foo" => "bar\nbaz" }) - end - - specify "should be able to delete the given key case-sensitively" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.delete("foo") - h["foo"].should.be.nil - h["FOO"].should.be.nil - end - - specify "should be able to delete the given key case-insensitively" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.delete("FOO") - h["foo"].should.be.nil - h["FOO"].should.be.nil - end - - specify "should return the deleted value when #delete is called on an existing key" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.delete("Foo").should.equal("bar") - end - - specify "should return nil when #delete is called on a non-existant key" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h.delete("Hello").should.be.nil - end -end - -context "Rack::Utils::Context" do - class ContextTest - attr_reader :app - def initialize app; @app=app; end - def call env; context env; end - def context env, app=@app; app.call(env); end - end - test_target1 = proc{|e| e.to_s+' world' } - test_target2 = proc{|e| e.to_i+2 } - test_target3 = proc{|e| nil } - test_target4 = proc{|e| [200,{'Content-Type'=>'text/plain', 'Content-Length'=>'0'},['']] } - test_app = ContextTest.new test_target4 - - specify "should set context correctly" do - test_app.app.should.equal test_target4 - c1 = Rack::Utils::Context.new(test_app, test_target1) - c1.for.should.equal test_app - c1.app.should.equal test_target1 - c2 = Rack::Utils::Context.new(test_app, test_target2) - c2.for.should.equal test_app - c2.app.should.equal test_target2 - end - - specify "should alter app on recontexting" do - c1 = Rack::Utils::Context.new(test_app, test_target1) - c2 = c1.recontext(test_target2) - c2.for.should.equal test_app - c2.app.should.equal test_target2 - c3 = c2.recontext(test_target3) - c3.for.should.equal test_app - c3.app.should.equal test_target3 - end - - specify "should run different apps" do - c1 = Rack::Utils::Context.new test_app, test_target1 - c2 = c1.recontext test_target2 - c3 = c2.recontext test_target3 - c4 = c3.recontext test_target4 - a4 = Rack::Lint.new c4 - a5 = Rack::Lint.new test_app - r1 = c1.call('hello') - r1.should.equal 'hello world' - r2 = c2.call(2) - r2.should.equal 4 - r3 = c3.call(:misc_symbol) - r3.should.be.nil - r4 = Rack::MockRequest.new(a4).get('/') - r4.status.should.be 200 - r5 = Rack::MockRequest.new(a5).get('/') - r5.status.should.be 200 - r4.body.should.equal r5.body - end -end - -context "Rack::Utils::Multipart" do - specify "should return nil if content type is not multipart" do - env = Rack::MockRequest.env_for("/", - "CONTENT_TYPE" => 'application/x-www-form-urlencoded') - Rack::Utils::Multipart.parse_multipart(env).should.equal nil - end - - specify "should parse multipart upload with text file" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:text)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:type].should.equal "text/plain" - params["files"][:filename].should.equal "file1.txt" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; filename=\"file1.txt\"\r\n" + - "Content-Type: text/plain\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.should.equal "contents" - end - - specify "should parse multipart upload with nested parameters" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:nested)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["foo"]["submit-name"].should.equal "Larry" - params["foo"]["files"][:type].should.equal "text/plain" - params["foo"]["files"][:filename].should.equal "file1.txt" - params["foo"]["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"foo[files]\"; filename=\"file1.txt\"\r\n" + - "Content-Type: text/plain\r\n" - params["foo"]["files"][:name].should.equal "foo[files]" - params["foo"]["files"][:tempfile].read.should.equal "contents" - end - - specify "should parse multipart upload with binary file" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:binary)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:type].should.equal "image/png" - params["files"][:filename].should.equal "rack-logo.png" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; filename=\"rack-logo.png\"\r\n" + - "Content-Type: image/png\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.length.should.equal 26473 - end - - specify "should parse multipart upload with empty file" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:empty)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:type].should.equal "text/plain" - params["files"][:filename].should.equal "file1.txt" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; filename=\"file1.txt\"\r\n" + - "Content-Type: text/plain\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.should.equal "" - end - - specify "should parse multipart upload with filename with semicolons" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:semicolon)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["files"][:type].should.equal "text/plain" - params["files"][:filename].should.equal "fi;le1.txt" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; filename=\"fi;le1.txt\"\r\n" + - "Content-Type: text/plain\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.should.equal "contents" - end - - specify "should not include file params if no file was selected" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:none)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"].should.equal nil - params.keys.should.not.include "files" - end - - specify "should parse IE multipart upload and clean up filename" do - env = Rack::MockRequest.env_for("/", multipart_fixture(:ie)) - params = Rack::Utils::Multipart.parse_multipart(env) - params["files"][:type].should.equal "text/plain" - params["files"][:filename].should.equal "file1.txt" - params["files"][:head].should.equal "Content-Disposition: form-data; " + - "name=\"files\"; " + - 'filename="C:\Documents and Settings\Administrator\Desktop\file1.txt"' + - "\r\nContent-Type: text/plain\r\n" - params["files"][:name].should.equal "files" - params["files"][:tempfile].read.should.equal "contents" - end - - specify "rewinds input after parsing upload" do - options = multipart_fixture(:text) - input = options[:input] - env = Rack::MockRequest.env_for("/", options) - params = Rack::Utils::Multipart.parse_multipart(env) - params["submit-name"].should.equal "Larry" - params["files"][:filename].should.equal "file1.txt" - input.read.length.should.equal 197 - end - - private - def multipart_fixture(name) - file = File.join(File.dirname(__FILE__), "multipart", name.to_s) - data = File.open(file, 'rb') { |io| io.read } - - type = "multipart/form-data; boundary=AaB03x" - length = data.respond_to?(:bytesize) ? data.bytesize : data.size - - { "CONTENT_TYPE" => type, - "CONTENT_LENGTH" => length.to_s, - :input => StringIO.new(data) } - end -end diff --git a/vendor/gems/rack-1.0.1/test/spec_rack_webrick.rb b/vendor/gems/rack-1.0.1/test/spec_rack_webrick.rb deleted file mode 100644 index 3e63ea63..00000000 --- a/vendor/gems/rack-1.0.1/test/spec_rack_webrick.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'test/spec' - -require 'rack/handler/webrick' -require 'rack/lint' -require 'rack/response' -require 'testrequest' - -Thread.abort_on_exception = true - -context "Rack::Handler::WEBrick" do - include TestRequest::Helpers - - setup do - @server = WEBrick::HTTPServer.new(:Host => @host='0.0.0.0', - :Port => @port=9202, - :Logger => WEBrick::Log.new(nil, WEBrick::BasicLog::WARN), - :AccessLog => []) - @server.mount "/test", Rack::Handler::WEBrick, - Rack::Lint.new(TestRequest.new) - Thread.new { @server.start } - trap(:INT) { @server.shutdown } - end - - specify "should respond" do - lambda { - GET("/test") - }.should.not.raise - end - - specify "should be a WEBrick" do - GET("/test") - status.should.be 200 - response["SERVER_SOFTWARE"].should =~ /WEBrick/ - response["HTTP_VERSION"].should.equal "HTTP/1.1" - response["SERVER_PROTOCOL"].should.equal "HTTP/1.1" - response["SERVER_PORT"].should.equal "9202" - response["SERVER_NAME"].should.equal "0.0.0.0" - end - - specify "should have rack headers" do - GET("/test") - response["rack.version"].should.equal [1,0] - response["rack.multithread"].should.be true - response["rack.multiprocess"].should.be false - response["rack.run_once"].should.be false - end - - specify "should have CGI headers on GET" do - GET("/test") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.be.nil - response["QUERY_STRING"].should.equal "" - response["test.postdata"].should.equal "" - - GET("/test/foo?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "/foo" - response["QUERY_STRING"].should.equal "quux=1" - - GET("/test/foo%25encoding?quux=1") - response["REQUEST_METHOD"].should.equal "GET" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["PATH_INFO"].should.equal "/foo%25encoding" - response["QUERY_STRING"].should.equal "quux=1" - end - - specify "should have CGI headers on POST" do - POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'}) - status.should.equal 200 - response["REQUEST_METHOD"].should.equal "POST" - response["SCRIPT_NAME"].should.equal "/test" - response["REQUEST_PATH"].should.equal "/" - response["QUERY_STRING"].should.equal "" - response["HTTP_X_TEST_HEADER"].should.equal "42" - response["test.postdata"].should.equal "rack-form-data=23" - end - - specify "should support HTTP auth" do - GET("/test", {:user => "ruth", :passwd => "secret"}) - response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ=" - end - - specify "should set status" do - GET("/test?secret") - status.should.equal 403 - response["rack.url_scheme"].should.equal "http" - end - - specify "should correctly set cookies" do - @server.mount "/cookie-test", Rack::Handler::WEBrick, - Rack::Lint.new(lambda { |req| - res = Rack::Response.new - res.set_cookie "one", "1" - res.set_cookie "two", "2" - res.finish - }) - - Net::HTTP.start(@host, @port) { |http| - res = http.get("/cookie-test") - res.code.to_i.should.equal 200 - res.get_fields("set-cookie").should.equal ["one=1", "two=2"] - } - end - - specify "should provide a .run" do - block_ran = false - catch(:done) { - Rack::Handler::WEBrick.run(lambda {}, - {:Port => 9210, - :Logger => WEBrick::Log.new(nil, WEBrick::BasicLog::WARN), - :AccessLog => []}) { |server| - block_ran = true - server.should.be.kind_of WEBrick::HTTPServer - @s = server - throw :done - } - } - block_ran.should.be true - @s.shutdown - end - - teardown do - @server.shutdown - end -end diff --git a/vendor/gems/rack-1.0.1/test/testrequest.rb b/vendor/gems/rack-1.0.1/test/testrequest.rb deleted file mode 100644 index 7b7190cb..00000000 --- a/vendor/gems/rack-1.0.1/test/testrequest.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'yaml' -require 'net/http' - -class TestRequest - def call(env) - status = env["QUERY_STRING"] =~ /secret/ ? 403 : 200 - env["test.postdata"] = env["rack.input"].read - body = env.to_yaml - size = body.respond_to?(:bytesize) ? body.bytesize : body.size - [status, {"Content-Type" => "text/yaml", "Content-Length" => size.to_s}, [body]] - end - - module Helpers - attr_reader :status, :response - - def GET(path, header={}) - Net::HTTP.start(@host, @port) { |http| - user = header.delete(:user) - passwd = header.delete(:passwd) - - get = Net::HTTP::Get.new(path, header) - get.basic_auth user, passwd if user && passwd - http.request(get) { |response| - @status = response.code.to_i - @response = YAML.load(response.body) - } - } - end - - def POST(path, formdata={}, header={}) - Net::HTTP.start(@host, @port) { |http| - user = header.delete(:user) - passwd = header.delete(:passwd) - - post = Net::HTTP::Post.new(path, header) - post.form_data = formdata - post.basic_auth user, passwd if user && passwd - http.request(post) { |response| - @status = response.code.to_i - @response = YAML.load(response.body) - } - } - end - end -end - -class StreamingRequest - def self.call(env) - [200, {"Content-Type" => "text/plain"}, new] - end - - def each - yield "hello there!\n" - sleep 5 - yield "that is all.\n" - end -end diff --git a/vendor/gems/rack-1.0.1/test/unregistered_handler/rack/handler/unregistered.rb b/vendor/gems/rack-1.0.1/test/unregistered_handler/rack/handler/unregistered.rb deleted file mode 100644 index 6dd9436d..00000000 --- a/vendor/gems/rack-1.0.1/test/unregistered_handler/rack/handler/unregistered.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Rack - module Handler - # this class doesn't do anything, we're just seeing if we get it. - class Unregistered - end - end -end \ No newline at end of file diff --git a/vendor/gems/rack-1.0.1/test/unregistered_handler/rack/handler/unregistered_long_one.rb b/vendor/gems/rack-1.0.1/test/unregistered_handler/rack/handler/unregistered_long_one.rb deleted file mode 100644 index 1920685f..00000000 --- a/vendor/gems/rack-1.0.1/test/unregistered_handler/rack/handler/unregistered_long_one.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Rack - module Handler - # this class doesn't do anything, we're just seeing if we get it. - class UnregisteredLongOne - end - end -end \ No newline at end of file diff --git a/vendor/plugins/will_paginate/.gitignore b/vendor/plugins/will_paginate/.gitignore deleted file mode 100644 index 2b437b91..00000000 --- a/vendor/plugins/will_paginate/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/doc -/rails -*.gem -/coverage diff --git a/vendor/plugins/will_paginate/.manifest b/vendor/plugins/will_paginate/.manifest deleted file mode 100644 index d65c5c0f..00000000 --- a/vendor/plugins/will_paginate/.manifest +++ /dev/null @@ -1,49 +0,0 @@ -CHANGELOG -LICENSE -README.rdoc -Rakefile -examples -examples/apple-circle.gif -examples/index.haml -examples/index.html -examples/pagination.css -examples/pagination.sass -init.rb -lib -lib/will_paginate -lib/will_paginate.rb -lib/will_paginate/array.rb -lib/will_paginate/collection.rb -lib/will_paginate/core_ext.rb -lib/will_paginate/finder.rb -lib/will_paginate/named_scope.rb -lib/will_paginate/named_scope_patch.rb -lib/will_paginate/version.rb -lib/will_paginate/view_helpers.rb -test -test/boot.rb -test/collection_test.rb -test/console -test/database.yml -test/finder_test.rb -test/fixtures -test/fixtures/admin.rb -test/fixtures/developer.rb -test/fixtures/developers_projects.yml -test/fixtures/project.rb -test/fixtures/projects.yml -test/fixtures/replies.yml -test/fixtures/reply.rb -test/fixtures/schema.rb -test/fixtures/topic.rb -test/fixtures/topics.yml -test/fixtures/user.rb -test/fixtures/users.yml -test/helper.rb -test/lib -test/lib/activerecord_test_case.rb -test/lib/activerecord_test_connector.rb -test/lib/load_fixtures.rb -test/lib/view_test_process.rb -test/tasks.rake -test/view_test.rb \ No newline at end of file diff --git a/vendor/plugins/will_paginate/CHANGELOG b/vendor/plugins/will_paginate/CHANGELOG deleted file mode 100644 index 19c8fb7d..00000000 --- a/vendor/plugins/will_paginate/CHANGELOG +++ /dev/null @@ -1,92 +0,0 @@ -== master - -* ActiveRecord 2.1: remove :include from count query when tables are not - referenced in :conditions - -== 2.3.2, released 2008-05-16 - -* Fixed LinkRenderer#stringified_merge by removing "return" from iterator block -* Ensure that 'href' values in pagination links are escaped URLs - -== 2.3.1, released 2008-05-04 - -* Fixed page numbers not showing with custom routes and implicit first page -* Try to use Hanna for documentation (falls back to default RDoc template if not) - -== 2.3.0, released 2008-04-29 - -* Changed LinkRenderer to receive collection, options and reference to view template NOT in - constructor, but with the #prepare method. This is a step towards supporting passing of - LinkRenderer (or subclass) instances that may be preconfigured in some way -* LinkRenderer now has #page_link and #page_span methods for easier customization of output in - subclasses -* Changed page_entries_info() method to adjust its output according to humanized class name of - collection items. Override this with :entry_name parameter (singular). - - page_entries_info(@posts) - #-> "Displaying all 12 posts" - page_entries_info(@posts, :entry_name => 'item') - #-> "Displaying all 12 items" - -== 2.2.3, released 2008-04-26 - -* will_paginate gem is no longer published on RubyForge, but on - gems.github.com: - - gem sources -a http://gems.github.com/ (you only need to do this once) - gem install mislav-will_paginate - -* extract reusable pagination testing stuff into WillPaginate::View -* rethink the page URL construction mechanizm to be more bulletproof when - combined with custom routing for page parameter -* test that anchor parameter can be used in pagination links - -== 2.2.2, released 2008-04-21 - -* Add support for page parameter in custom routes like "/foo/page/2" -* Change output of "page_entries_info" on single-page collection and erraneous - output with empty collection as reported by Tim Chater - -== 2.2.1, released 2008-04-08 - -* take less risky path when monkeypatching named_scope; fix that it no longer - requires ActiveRecord::VERSION -* use strings in "respond_to?" calls to work around a bug in acts_as_ferret - stable (ugh) -* add rake release task - - -== 2.2.0, released 2008-04-07 - -=== API changes -* Rename WillPaginate::Collection#page_count to "total_pages" for consistency. - If you implemented this interface, change your implementation accordingly. -* Remove old, deprecated style of calling Array#paginate as "paginate(page, - per_page)". If you want to specify :page, :per_page or :total_entries, use a - parameter hash. -* Rename LinkRenderer#url_options to "url_for" and drastically optimize it - -=== View changes -* Added "prev_page" and "next_page" CSS classes on previous/next page buttons -* Add examples of pagination links styling in "examples/index.html" -* Change gap in pagination links from "..." to - "". -* Add "paginated_section", a block helper that renders pagination both above and - below content in the block -* Add rel="prev|next|start" to page links - -=== Other - -* Add ability to opt-in for Rails 2.1 feature "named_scope" by calling - WillPaginate.enable_named_scope (tested in Rails 1.2.6 and 2.0.2) -* Support complex page parameters like "developers[page]" -* Move Array#paginate definition to will_paginate/array.rb. You can now easily - use pagination on arrays outside of Rails: - - gem 'will_paginate' - require 'will_paginate/array' - -* Add "paginated_each" method for iterating through every record by loading only - one page of records at the time -* Rails 2: Rescue from WillPaginate::InvalidPage error with 404 Not Found by - default diff --git a/vendor/plugins/will_paginate/LICENSE b/vendor/plugins/will_paginate/LICENSE deleted file mode 100644 index 96a48cb3..00000000 --- a/vendor/plugins/will_paginate/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2007 PJ Hyett and Mislav Marohnić - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/will_paginate/README.rdoc b/vendor/plugins/will_paginate/README.rdoc deleted file mode 100644 index 94ebdc3d..00000000 --- a/vendor/plugins/will_paginate/README.rdoc +++ /dev/null @@ -1,131 +0,0 @@ -= WillPaginate - -Pagination is just limiting the number of records displayed. Why should you let -it get in your way while developing, then? This plugin makes magic happen. Did -you ever want to be able to do just this on a model: - - Post.paginate :page => 1, :order => 'created_at DESC' - -... and then render the page links with a single view helper? Well, now you -can. - -Some resources to get you started: - -* Your mind reels with questions? Join our - {Google group}[http://groups.google.com/group/will_paginate]. -* The will_paginate project page: http://github.com/mislav/will_paginate -* How to report bugs: http://github.com/mislav/will_paginate/wikis/report-bugs -* Ryan Bates made an awesome screencast[http://railscasts.com/episodes/51], - check it out. - -== Installation - -The recommended way is that you get the gem: - - gem install mislav-will_paginate --source http://gems.github.com/ - -After that you don't need the will_paginate plugin in your Rails -application anymore. Just add a simple require to the end of -"config/environment.rb": - - gem 'mislav-will_paginate', '~> 2.2' - require 'will_paginate' - -That's it. Remember to install the gem on all machines that you are -deploying to. - -There are extensive -{installation instructions}[http://github.com/mislav/will_paginate/wikis/installation] -on {the wiki}[http://github.com/mislav/will_paginate/wikis]. - - -== Example usage - -Use a paginate finder in the controller: - - @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC' - -Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the -records. Don't forget to tell it which page you want, or it will complain! -Read more on WillPaginate::Finder::ClassMethods. - -Render the posts in your view like you would normally do. When you need to render -pagination, just stick this in: - - <%= will_paginate @posts %> - -You're done. (Copy and paste the example fancy CSS styles from the bottom.) You -can find the option list at WillPaginate::ViewHelpers. - -How does it know how much items to fetch per page? It asks your model by calling -its per_page class method. You can define it like this: - - class Post < ActiveRecord::Base - cattr_reader :per_page - @@per_page = 50 - end - -... or like this: - - class Post < ActiveRecord::Base - def self.per_page - 50 - end - end - -... or don't worry about it at all. WillPaginate defines it to be 30 by default. -But you can always specify the count explicitly when calling +paginate+: - - @posts = Post.paginate :page => params[:page], :per_page => 50 - -The +paginate+ finder wraps the original finder and returns your resultset that now has -some new properties. You can use the collection as you would with any ActiveRecord -resultset. WillPaginate view helpers also need that object to be able to render pagination: - -
    - <% for post in @posts -%> -
  1. Render `post` in some nice way.
  2. - <% end -%> -
- -

Now let's render us some pagination!

- <%= will_paginate @posts %> - -More detailed documentation: - -* WillPaginate::Finder::ClassMethods for pagination on your models; -* WillPaginate::ViewHelpers for your views. - - -== Authors and credits - -Authors:: Mislav Marohnić, PJ Hyett -Original announcement:: http://errtheblog.com/post/929 -Original PHP source:: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php - -All these people helped making will_paginate what it is now with their code -contributions or just simply awesome ideas: - -Chris Wanstrath, Dr. Nic Williams, K. Adam Christensen, Mike Garey, Bence -Golda, Matt Aimonetti, Charles Brian Quinn, Desi McAdam, James Coglan, Matijs -van Zuijlen, Maria, Brendan Ribera, Todd Willey, Bryan Helmkamp, Jan Berkel, -Lourens Naudé, Rick Olson, Russell Norris, Piotr Usewicz, Chris Eppstein. - - -== Usable pagination in the UI - -There are some CSS styles to get you started in the "examples/" directory. They -are showcased in the "examples/index.html" file. - -More reading about pagination as design pattern: - -* Pagination 101: - http://kurafire.net/log/archive/2007/06/22/pagination-101 -* Pagination gallery: - http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/ -* Pagination on Yahoo Design Pattern Library: - http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination - -Want to discuss, request features, ask questions? Join the -{Google group}[http://groups.google.com/group/will_paginate]. - diff --git a/vendor/plugins/will_paginate/Rakefile b/vendor/plugins/will_paginate/Rakefile deleted file mode 100644 index c3cf1c61..00000000 --- a/vendor/plugins/will_paginate/Rakefile +++ /dev/null @@ -1,62 +0,0 @@ -require 'rubygems' -begin - hanna_dir = '/home/mislav/projects/hanna/lib' - $:.unshift hanna_dir if File.exists? hanna_dir - require 'hanna/rdoctask' -rescue LoadError - require 'rake' - require 'rake/rdoctask' -end -load 'test/tasks.rake' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Generate RDoc documentation for the will_paginate plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG'). - include('lib/**/*.rb'). - exclude('lib/will_paginate/named_scope*'). - exclude('lib/will_paginate/array.rb'). - exclude('lib/will_paginate/version.rb') - - rdoc.main = "README.rdoc" # page to start on - rdoc.title = "will_paginate documentation" - - rdoc.rdoc_dir = 'doc' # rdoc output folder - rdoc.options << '--inline-source' << '--charset=UTF-8' - rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/' -end - -desc %{Update ".manifest" with the latest list of project filenames. Respect\ -.gitignore by excluding everything that git ignores. Update `files` and\ -`test_files` arrays in "*.gemspec" file if it's present.} -task :manifest do - list = Dir['**/*'].sort - spec_file = Dir['*.gemspec'].first - list -= [spec_file] if spec_file - - File.read('.gitignore').each_line do |glob| - glob = glob.chomp.sub(/^\//, '') - list -= Dir[glob] - list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob) - puts "excluding #{glob}" - end - - if spec_file - spec = File.read spec_file - spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do - assignment = $1 - bunch = $2 ? list.grep(/^test\//) : list - '%s%%w(%s)' % [assignment, bunch.join(' ')] - end - - File.open(spec_file, 'w') {|f| f << spec } - end - File.open('.manifest', 'w') {|f| f << list.join("\n") } -end - -task :examples do - %x(haml examples/index.haml examples/index.html) - %x(sass examples/pagination.sass examples/pagination.css) -end diff --git a/vendor/plugins/will_paginate/examples/apple-circle.gif b/vendor/plugins/will_paginate/examples/apple-circle.gif deleted file mode 100644 index df8cbf7c..00000000 Binary files a/vendor/plugins/will_paginate/examples/apple-circle.gif and /dev/null differ diff --git a/vendor/plugins/will_paginate/examples/index.haml b/vendor/plugins/will_paginate/examples/index.haml deleted file mode 100644 index fb41ac8a..00000000 --- a/vendor/plugins/will_paginate/examples/index.haml +++ /dev/null @@ -1,69 +0,0 @@ -!!! -%html -%head - %title Samples of pagination styling for will_paginate - %link{ :rel => 'stylesheet', :type => 'text/css', :href => 'pagination.css' } - %style{ :type => 'text/css' } - :sass - html - :margin 0 - :padding 0 - :background #999 - :font normal 76% "Lucida Grande", Verdana, Helvetica, sans-serif - body - :margin 2em - :padding 2em - :border 2px solid gray - :background white - :color #222 - h1 - :font-size 2em - :font-weight normal - :margin 0 0 1em 0 - h2 - :font-size 1.4em - :margin 1em 0 .5em 0 - pre - :font-size 13px - :font-family Monaco, "DejaVu Sans Mono", "Bitstream Vera Mono", "Courier New", monospace - -- pagination = '« Previous 1 3 4 5 6 7 8 9 29 30 ' -- pagination_no_page_links = '« Previous ' - -%body - %h1 Samples of pagination styling for will_paginate - %p - Find these styles in "examples/pagination.css" of will_paginate library. - There is a Sass version of it for all you sassy people. - %p - Read about good rules for pagination: - %a{ :href => 'http://kurafire.net/log/archive/2007/06/22/pagination-101' } Pagination 101 - %p - %em Warning: - page links below don't lead anywhere (so don't click on them). - - %h2 Unstyled pagination (ewww!) - %div= pagination - - %h2 Digg.com - .digg_pagination= pagination - - %h2 Digg-style, no page links - .digg_pagination= pagination_no_page_links - %p Code that renders this: - %pre= '%s' % %[<%= will_paginate @posts, :page_links => false %>].gsub('<', '<').gsub('>', '>') - - %h2 Digg-style, extra content - .digg_pagination - .page_info Displaying entries 1 - 6 of 180 in total - = pagination - %p Code that renders this: - %pre= '%s' % %[
\n
\n <%= page_entries_info @posts %>\n
\n <%= will_paginate @posts, :container => false %>\n
].gsub('<', '<').gsub('>', '>') - - %h2 Apple.com store - .apple_pagination= pagination - - %h2 Flickr.com - .flickr_pagination - = pagination - .page_info (118 photos) diff --git a/vendor/plugins/will_paginate/examples/index.html b/vendor/plugins/will_paginate/examples/index.html deleted file mode 100644 index 858f7c6f..00000000 --- a/vendor/plugins/will_paginate/examples/index.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - - Samples of pagination styling for will_paginate - - - - -

Samples of pagination styling for will_paginate

-

- Find these styles in "examples/pagination.css" of will_paginate library. - There is a Sass version of it for all you sassy people. -

-

- Read about good rules for pagination: - Pagination 101 -

-

- Warning: - page links below don't lead anywhere (so don't click on them). -

-

- Unstyled pagination (ewww!) -

-
- « Previous 1 3 4 5 6 7 8 9 29 30 -
-

Digg.com

-
- « Previous 1 3 4 5 6 7 8 9 29 30 -
-

Digg-style, no page links

-
- « Previous -
-

Code that renders this:

-
-    <%= will_paginate @posts, :page_links => false %>
-  
-

Digg-style, extra content

-
-
- Displaying entries 1 - 6 of 180 in total -
- « Previous 1 3 4 5 6 7 8 9 29 30 -
-

Code that renders this:

-
-    <div class="digg_pagination">
-      <div clas="page_info">
-        <%= page_entries_info @posts %>
-      </div>
-      <%= will_paginate @posts, :container => false %>
-    </div>
-  
-

Apple.com store

-
- « Previous 1 3 4 5 6 7 8 9 29 30 -
-

Flickr.com

-
- « Previous 1 3 4 5 6 7 8 9 29 30 -
(118 photos)
-
- diff --git a/vendor/plugins/will_paginate/examples/pagination.css b/vendor/plugins/will_paginate/examples/pagination.css deleted file mode 100644 index b55e9779..00000000 --- a/vendor/plugins/will_paginate/examples/pagination.css +++ /dev/null @@ -1,90 +0,0 @@ -.digg_pagination { - background: white; - /* self-clearing method: */ } - .digg_pagination a, .digg_pagination span { - padding: .2em .5em; - display: block; - float: left; - margin-right: 1px; } - .digg_pagination span.disabled { - color: #999; - border: 1px solid #DDD; } - .digg_pagination span.current { - font-weight: bold; - background: #2E6AB1; - color: white; - border: 1px solid #2E6AB1; } - .digg_pagination a { - text-decoration: none; - color: #105CB6; - border: 1px solid #9AAFE5; } - .digg_pagination a:hover, .digg_pagination a:focus { - color: #003; - border-color: #003; } - .digg_pagination .page_info { - background: #2E6AB1; - color: white; - padding: .4em .6em; - width: 22em; - margin-bottom: .3em; - text-align: center; } - .digg_pagination .page_info b { - color: #003; - background: #6aa6ed; - padding: .1em .25em; } - .digg_pagination:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; } - * html .digg_pagination { - height: 1%; } - *:first-child+html .digg_pagination { - overflow: hidden; } - -.apple_pagination { - background: #F1F1F1; - border: 1px solid #E5E5E5; - text-align: center; - padding: 1em; } - .apple_pagination a, .apple_pagination span { - padding: .2em .3em; } - .apple_pagination span.disabled { - color: #AAA; } - .apple_pagination span.current { - font-weight: bold; - background: transparent url(apple-circle.gif) no-repeat 50% 50%; } - .apple_pagination a { - text-decoration: none; - color: black; } - .apple_pagination a:hover, .apple_pagination a:focus { - text-decoration: underline; } - -.flickr_pagination { - text-align: center; - padding: .3em; } - .flickr_pagination a, .flickr_pagination span { - padding: .2em .5em; } - .flickr_pagination span.disabled { - color: #AAA; } - .flickr_pagination span.current { - font-weight: bold; - color: #FF0084; } - .flickr_pagination a { - border: 1px solid #DDDDDD; - color: #0063DC; - text-decoration: none; } - .flickr_pagination a:hover, .flickr_pagination a:focus { - border-color: #003366; - background: #0063DC; - color: white; } - .flickr_pagination .page_info { - color: #aaa; - padding-top: .8em; } - .flickr_pagination .prev_page, .flickr_pagination .next_page { - border-width: 2px; } - .flickr_pagination .prev_page { - margin-right: 1em; } - .flickr_pagination .next_page { - margin-left: 1em; } diff --git a/vendor/plugins/will_paginate/examples/pagination.sass b/vendor/plugins/will_paginate/examples/pagination.sass deleted file mode 100644 index 737a97be..00000000 --- a/vendor/plugins/will_paginate/examples/pagination.sass +++ /dev/null @@ -1,91 +0,0 @@ -.digg_pagination - :background white - a, span - :padding .2em .5em - :display block - :float left - :margin-right 1px - span.disabled - :color #999 - :border 1px solid #DDD - span.current - :font-weight bold - :background #2E6AB1 - :color white - :border 1px solid #2E6AB1 - a - :text-decoration none - :color #105CB6 - :border 1px solid #9AAFE5 - &:hover, &:focus - :color #003 - :border-color #003 - .page_info - :background #2E6AB1 - :color white - :padding .4em .6em - :width 22em - :margin-bottom .3em - :text-align center - b - :color #003 - :background = #2E6AB1 + 60 - :padding .1em .25em - - /* self-clearing method: - &:after - :content "." - :display block - :height 0 - :clear both - :visibility hidden - * html & - :height 1% - *:first-child+html & - :overflow hidden - -.apple_pagination - :background #F1F1F1 - :border 1px solid #E5E5E5 - :text-align center - :padding 1em - a, span - :padding .2em .3em - span.disabled - :color #AAA - span.current - :font-weight bold - :background transparent url(apple-circle.gif) no-repeat 50% 50% - a - :text-decoration none - :color black - &:hover, &:focus - :text-decoration underline - -.flickr_pagination - :text-align center - :padding .3em - a, span - :padding .2em .5em - span.disabled - :color #AAA - span.current - :font-weight bold - :color #FF0084 - a - :border 1px solid #DDDDDD - :color #0063DC - :text-decoration none - &:hover, &:focus - :border-color #003366 - :background #0063DC - :color white - .page_info - :color #aaa - :padding-top .8em - .prev_page, .next_page - :border-width 2px - .prev_page - :margin-right 1em - .next_page - :margin-left 1em diff --git a/vendor/plugins/will_paginate/init.rb b/vendor/plugins/will_paginate/init.rb deleted file mode 100644 index 838d30ec..00000000 --- a/vendor/plugins/will_paginate/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'will_paginate' diff --git a/vendor/plugins/will_paginate/lib/will_paginate.rb b/vendor/plugins/will_paginate/lib/will_paginate.rb deleted file mode 100644 index 366e39cc..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'active_support' - -# = You *will* paginate! -# -# First read about WillPaginate::Finder::ClassMethods, then see -# WillPaginate::ViewHelpers. The magical array you're handling in-between is -# WillPaginate::Collection. -# -# Happy paginating! -module WillPaginate - class << self - # shortcut for enable_actionpack; enable_activerecord - def enable - enable_actionpack - enable_activerecord - end - - # mixes in WillPaginate::ViewHelpers in ActionView::Base - def enable_actionpack - return if ActionView::Base.instance_methods.include? 'will_paginate' - require 'will_paginate/view_helpers' - ActionView::Base.class_eval { include ViewHelpers } - - if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses - ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found - end - end - - # mixes in WillPaginate::Finder in ActiveRecord::Base and classes that deal - # with associations - def enable_activerecord - return if ActiveRecord::Base.respond_to? :paginate - require 'will_paginate/finder' - ActiveRecord::Base.class_eval { include Finder } - - # support pagination on associations - a = ActiveRecord::Associations - returning([ a::AssociationCollection ]) { |classes| - # detect http://dev.rubyonrails.org/changeset/9230 - unless a::HasManyThroughAssociation.superclass == a::HasManyAssociation - classes << a::HasManyThroughAssociation - end - }.each do |klass| - klass.class_eval do - include Finder::ClassMethods - alias_method_chain :method_missing, :paginate - end - end - end - - # Enable named_scope, a feature of Rails 2.1, even if you have older Rails - # (tested on Rails 2.0.2 and 1.2.6). - # - # You can pass +false+ for +patch+ parameter to skip monkeypatching - # *associations*. Use this if you feel that named_scope broke - # has_many, has_many :through or has_and_belongs_to_many associations in - # your app. By passing +false+, you can still use named_scope in - # your models, but not through associations. - def enable_named_scope(patch = true) - return if defined? ActiveRecord::NamedScope - require 'will_paginate/named_scope' - require 'will_paginate/named_scope_patch' if patch - - ActiveRecord::Base.class_eval do - include WillPaginate::NamedScope - end - end - end - - module Deprecation #:nodoc: - extend ActiveSupport::Deprecation - - def self.warn(message, callstack = caller) - message = 'WillPaginate: ' + message.strip.gsub(/\s+/, ' ') - behavior.call(message, callstack) if behavior && !silenced? - end - - def self.silenced? - ActiveSupport::Deprecation.silenced? - end - end -end - -if defined?(Rails) and defined?(ActiveRecord) and defined?(ActionController) - WillPaginate.enable -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/array.rb b/vendor/plugins/will_paginate/lib/will_paginate/array.rb deleted file mode 100644 index d061d2be..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/array.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'will_paginate/collection' - -# http://www.desimcadam.com/archives/8 -Array.class_eval do - def paginate(options = {}) - raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options - - WillPaginate::Collection.create( - options[:page] || 1, - options[:per_page] || 30, - options[:total_entries] || self.length - ) { |pager| - pager.replace self[pager.offset, pager.per_page].to_a - } - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/collection.rb b/vendor/plugins/will_paginate/lib/will_paginate/collection.rb deleted file mode 100644 index 89d992f6..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +++ /dev/null @@ -1,145 +0,0 @@ -module WillPaginate - # = Invalid page number error - # This is an ArgumentError raised in case a page was requested that is either - # zero or negative number. You should decide how do deal with such errors in - # the controller. - # - # If you're using Rails 2, then this error will automatically get handled like - # 404 Not Found. The hook is in "will_paginate.rb": - # - # ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found - # - # If you don't like this, use your preffered method of rescuing exceptions in - # public from your controllers to handle this differently. The +rescue_from+ - # method is a nice addition to Rails 2. - # - # This error is *not* raised when a page further than the last page is - # requested. Use WillPaginate::Collection#out_of_bounds? method to - # check for those cases and manually deal with them as you see fit. - class InvalidPage < ArgumentError - def initialize(page, page_num) - super "#{page.inspect} given as value, which translates to '#{page_num}' as page number" - end - end - - # = The key to pagination - # Arrays returned from paginating finds are, in fact, instances of this little - # class. You may think of WillPaginate::Collection as an ordinary array with - # some extra properties. Those properties are used by view helpers to generate - # correct page links. - # - # WillPaginate::Collection also assists in rolling out your own pagination - # solutions: see +create+. - # - # If you are writing a library that provides a collection which you would like - # to conform to this API, you don't have to copy these methods over; simply - # make your plugin/gem dependant on the "will_paginate" gem: - # - # gem 'will_paginate' - # require 'will_paginate/collection' - # - # # now use WillPaginate::Collection directly or subclass it - class Collection < Array - attr_reader :current_page, :per_page, :total_entries, :total_pages - - # Arguments to the constructor are the current page number, per-page limit - # and the total number of entries. The last argument is optional because it - # is best to do lazy counting; in other words, count *conditionally* after - # populating the collection using the +replace+ method. - def initialize(page, per_page, total = nil) - @current_page = page.to_i - raise InvalidPage.new(page, @current_page) if @current_page < 1 - @per_page = per_page.to_i - raise ArgumentError, "`per_page` setting cannot be less than 1 (#{@per_page} given)" if @per_page < 1 - - self.total_entries = total if total - end - - # Just like +new+, but yields the object after instantiation and returns it - # afterwards. This is very useful for manual pagination: - # - # @entries = WillPaginate::Collection.create(1, 10) do |pager| - # result = Post.find(:all, :limit => pager.per_page, :offset => pager.offset) - # # inject the result array into the paginated collection: - # pager.replace(result) - # - # unless pager.total_entries - # # the pager didn't manage to guess the total count, do it manually - # pager.total_entries = Post.count - # end - # end - # - # The possibilities with this are endless. For another example, here is how - # WillPaginate used to define pagination for Array instances: - # - # Array.class_eval do - # def paginate(page = 1, per_page = 15) - # WillPaginate::Collection.create(page, per_page, size) do |pager| - # pager.replace self[pager.offset, pager.per_page].to_a - # end - # end - # end - # - # The Array#paginate API has since then changed, but this still serves as a - # fine example of WillPaginate::Collection usage. - def self.create(page, per_page, total = nil, &block) - pager = new(page, per_page, total) - yield pager - pager - end - - # Helper method that is true when someone tries to fetch a page with a - # larger number than the last page. Can be used in combination with flashes - # and redirecting. - def out_of_bounds? - current_page > total_pages - end - - # Current offset of the paginated collection. If we're on the first page, - # it is always 0. If we're on the 2nd page and there are 30 entries per page, - # the offset is 30. This property is useful if you want to render ordinals - # besides your records: simply start with offset + 1. - def offset - (current_page - 1) * per_page - end - - # current_page - 1 or nil if there is no previous page - def previous_page - current_page > 1 ? (current_page - 1) : nil - end - - # current_page + 1 or nil if there is no next page - def next_page - current_page < total_pages ? (current_page + 1) : nil - end - - def total_entries=(number) - @total_entries = number.to_i - @total_pages = (@total_entries / per_page.to_f).ceil - end - - # This is a magic wrapper for the original Array#replace method. It serves - # for populating the paginated collection after initialization. - # - # Why magic? Because it tries to guess the total number of entries judging - # by the size of given array. If it is shorter than +per_page+ limit, then we - # know we're on the last page. This trick is very useful for avoiding - # unnecessary hits to the database to do the counting after we fetched the - # data for the current page. - # - # However, after using +replace+ you should always test the value of - # +total_entries+ and set it to a proper value if it's +nil+. See the example - # in +create+. - def replace(array) - result = super - - # The collection is shorter then page limit? Rejoice, because - # then we know that we are on the last page! - if total_entries.nil? and length < per_page and (current_page == 1 or length > 0) - self.total_entries = offset + length - end - - result - end - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb b/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb deleted file mode 100644 index 32f10f50..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'set' -require 'will_paginate/array' - -unless Hash.instance_methods.include? 'except' - Hash.class_eval do - # Returns a new hash without the given keys. - def except(*keys) - rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) - reject { |key,| rejected.include?(key) } - end - - # Replaces the hash without only the given keys. - def except!(*keys) - replace(except(*keys)) - end - end -end - -unless Hash.instance_methods.include? 'slice' - Hash.class_eval do - # Returns a new hash with only the given keys. - def slice(*keys) - allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) - reject { |key,| !allowed.include?(key) } - end - - # Replaces the hash with only the given keys. - def slice!(*keys) - replace(slice(*keys)) - end - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/finder.rb b/vendor/plugins/will_paginate/lib/will_paginate/finder.rb deleted file mode 100644 index ec670eaa..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +++ /dev/null @@ -1,247 +0,0 @@ -require 'will_paginate/core_ext' - -module WillPaginate - # A mixin for ActiveRecord::Base. Provides +per_page+ class method - # and hooks things up to provide paginating finders. - # - # Find out more in WillPaginate::Finder::ClassMethods - # - module Finder - def self.included(base) - base.extend ClassMethods - class << base - alias_method_chain :method_missing, :paginate - # alias_method_chain :find_every, :paginate - define_method(:per_page) { 30 } unless respond_to?(:per_page) - end - end - - # = Paginating finders for ActiveRecord models - # - # WillPaginate adds +paginate+, +per_page+ and other methods to - # ActiveRecord::Base class methods and associations. It also hooks into - # +method_missing+ to intercept pagination calls to dynamic finders such as - # +paginate_by_user_id+ and translate them to ordinary finders - # (+find_all_by_user_id+ in this case). - # - # In short, paginating finders are equivalent to ActiveRecord finders; the - # only difference is that we start with "paginate" instead of "find" and - # that :page is required parameter: - # - # @posts = Post.paginate :all, :page => params[:page], :order => 'created_at DESC' - # - # In paginating finders, "all" is implicit. There is no sense in paginating - # a single record, right? So, you can drop the :all argument: - # - # Post.paginate(...) => Post.find :all - # Post.paginate_all_by_something => Post.find_all_by_something - # Post.paginate_by_something => Post.find_all_by_something - # - # == The importance of the :order parameter - # - # In ActiveRecord finders, :order parameter specifies columns for - # the ORDER BY clause in SQL. It is important to have it, since - # pagination only makes sense with ordered sets. Without the ORDER - # BY clause, databases aren't required to do consistent ordering when - # performing SELECT queries; this is especially true for - # PostgreSQL. - # - # Therefore, make sure you are doing ordering on a column that makes the - # most sense in the current context. Make that obvious to the user, also. - # For perfomance reasons you will also want to add an index to that column. - module ClassMethods - # This is the main paginating finder. - # - # == Special parameters for paginating finders - # * :page -- REQUIRED, but defaults to 1 if false or nil - # * :per_page -- defaults to CurrentModel.per_page (which is 30 if not overridden) - # * :total_entries -- use only if you manually count total entries - # * :count -- additional options that are passed on to +count+ - # * :finder -- name of the ActiveRecord finder used (default: "find") - # - # All other options (+conditions+, +order+, ...) are forwarded to +find+ - # and +count+ calls. - def paginate(*args, &block) - options = args.pop - page, per_page, total_entries = wp_parse_options(options) - finder = (options[:finder] || 'find').to_s - - if finder == 'find' - # an array of IDs may have been given: - total_entries ||= (Array === args.first and args.first.size) - # :all is implicit - args.unshift(:all) if args.empty? - end - - WillPaginate::Collection.create(page, per_page, total_entries) do |pager| - count_options = options.except :page, :per_page, :total_entries, :finder - find_options = count_options.except(:count).update(:offset => pager.offset, :limit => pager.per_page) - - args << find_options - # @options_from_last_find = nil - pager.replace send(finder, *args, &block) - - # magic counting for user convenience: - pager.total_entries = wp_count(count_options, args, finder) unless pager.total_entries - end - end - - # Iterates through all records by loading one page at a time. This is useful - # for migrations or any other use case where you don't want to load all the - # records in memory at once. - # - # It uses +paginate+ internally; therefore it accepts all of its options. - # You can specify a starting page with :page (default is 1). Default - # :order is "id", override if necessary. - # - # See http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord where - # Jamis Buck describes this and also uses a more efficient way for MySQL. - def paginated_each(options = {}, &block) - options = { :order => 'id', :page => 1 }.merge options - options[:page] = options[:page].to_i - options[:total_entries] = 0 # skip the individual count queries - total = 0 - - begin - collection = paginate(options) - total += collection.each(&block).size - options[:page] += 1 - end until collection.size < collection.per_page - - total - end - - # Wraps +find_by_sql+ by simply adding LIMIT and OFFSET to your SQL string - # based on the params otherwise used by paginating finds: +page+ and - # +per_page+. - # - # Example: - # - # @developers = Developer.paginate_by_sql ['select * from developers where salary > ?', 80000], - # :page => params[:page], :per_page => 3 - # - # A query for counting rows will automatically be generated if you don't - # supply :total_entries. If you experience problems with this - # generated SQL, you might want to perform the count manually in your - # application. - # - def paginate_by_sql(sql, options) - WillPaginate::Collection.create(*wp_parse_options(options)) do |pager| - query = sanitize_sql(sql) - original_query = query.dup - # add limit, offset - add_limit! query, :offset => pager.offset, :limit => pager.per_page - # perfom the find - pager.replace find_by_sql(query) - - unless pager.total_entries - count_query = original_query.sub /\bORDER\s+BY\s+[\w`,\s]+$/mi, '' - count_query = "SELECT COUNT(*) FROM (#{count_query})" - - unless ['oracle', 'oci'].include?(self.connection.adapter_name.downcase) - count_query << ' AS count_table' - end - # perform the count query - pager.total_entries = count_by_sql(count_query) - end - end - end - - def respond_to?(method, include_priv = false) #:nodoc: - case method.to_sym - when :paginate, :paginate_by_sql - true - else - super(method.to_s.sub(/^paginate/, 'find'), include_priv) - end - end - - protected - - def method_missing_with_paginate(method, *args, &block) #:nodoc: - # did somebody tried to paginate? if not, let them be - unless method.to_s.index('paginate') == 0 - return method_missing_without_paginate(method, *args, &block) - end - - # paginate finders are really just find_* with limit and offset - finder = method.to_s.sub('paginate', 'find') - finder.sub!('find', 'find_all') if finder.index('find_by_') == 0 - - options = args.pop - raise ArgumentError, 'parameter hash expected' unless options.respond_to? :symbolize_keys - options = options.dup - options[:finder] = finder - args << options - - paginate(*args, &block) - end - - # Does the not-so-trivial job of finding out the total number of entries - # in the database. It relies on the ActiveRecord +count+ method. - def wp_count(options, args, finder) - excludees = [:count, :order, :limit, :offset, :readonly] - unless options[:select] and options[:select] =~ /^\s*DISTINCT\b/i - excludees << :select # only exclude the select param if it doesn't begin with DISTINCT - end - - # count expects (almost) the same options as find - count_options = options.except *excludees - - # merge the hash found in :count - # this allows you to specify :select, :order, or anything else just for the count query - count_options.update options[:count] if options[:count] - - # we may be in a model or an association proxy - klass = (@owner and @reflection) ? @reflection.klass : self - - # forget about includes if they are irrelevant (Rails 2.1) - if count_options[:include] and - klass.private_methods.include?('references_eager_loaded_tables?') and - !klass.send(:references_eager_loaded_tables?, count_options) - count_options.delete :include - end - - # we may have to scope ... - counter = Proc.new { count(count_options) } - - count = if finder.index('find_') == 0 and klass.respond_to?(scoper = finder.sub('find', 'with')) - # scope_out adds a 'with_finder' method which acts like with_scope, if it's present - # then execute the count with the scoping provided by the with_finder - send(scoper, &counter) - elsif match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(finder) - # extract conditions from calls like "paginate_by_foo_and_bar" - attribute_names = extract_attribute_names_from_match(match) - conditions = construct_attributes_from_arguments(attribute_names, args) - with_scope(:find => { :conditions => conditions }, &counter) - else - counter.call - end - - count.respond_to?(:length) ? count.length : count - end - - def wp_parse_options(options) #:nodoc: - raise ArgumentError, 'parameter hash expected' unless options.respond_to? :symbolize_keys - options = options.symbolize_keys - raise ArgumentError, ':page parameter required' unless options.key? :page - - if options[:count] and options[:total_entries] - raise ArgumentError, ':count and :total_entries are mutually exclusive' - end - - page = options[:page] || 1 - per_page = options[:per_page] || self.per_page - total = options[:total_entries] - [page, per_page, total] - end - - private - - # def find_every_with_paginate(options) - # @options_from_last_find = options - # find_every_without_paginate(options) - # end - end - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb b/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb deleted file mode 100644 index 6f00cf76..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb +++ /dev/null @@ -1,132 +0,0 @@ -## stolen from: http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/named_scope.rb?rev=9084 - -module WillPaginate - # This is a feature backported from Rails 2.1 because of its usefullness not only with will_paginate, - # but in other aspects when managing complex conditions that you want to be reusable. - module NamedScope - # All subclasses of ActiveRecord::Base have two named_scopes: - # * all, which is similar to a find(:all) query, and - # * scoped, which allows for the creation of anonymous scopes, on the fly: - # - # Shirt.scoped(:conditions => {:color => 'red'}).scoped(:include => :washing_instructions) - # - # These anonymous scopes tend to be useful when procedurally generating complex queries, where passing - # intermediate values (scopes) around as first-class objects is convenient. - def self.included(base) - base.class_eval do - extend ClassMethods - named_scope :all - named_scope :scoped, lambda { |scope| scope } - end - end - - module ClassMethods - def scopes #:nodoc: - read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {}) - end - - # Adds a class method for retrieving and querying objects. A scope represents a narrowing of a database query, - # such as :conditions => {:color => :red}, :select => 'shirts.*', :include => :washing_instructions. - # - # class Shirt < ActiveRecord::Base - # named_scope :red, :conditions => {:color => 'red'} - # named_scope :dry_clean_only, :joins => :washing_instructions, :conditions => ['washing_instructions.dry_clean_only = ?', true] - # end - # - # The above calls to named_scope define class methods Shirt.red and Shirt.dry_clean_only. Shirt.red, - # in effect, represents the query Shirt.find(:all, :conditions => {:color => 'red'}). - # - # Unlike Shirt.find(...), however, the object returned by Shirt.red is not an Array; it resembles the association object - # constructed by a has_many declaration. For instance, you can invoke Shirt.red.find(:first), Shirt.red.count, - # Shirt.red.find(:all, :conditions => {:size => 'small'}). Also, just - # as with the association objects, name scopes acts like an Array, implementing Enumerable; Shirt.red.each(&block), - # Shirt.red.first, and Shirt.red.inject(memo, &block) all behave as if Shirt.red really were an Array. - # - # These named scopes are composable. For instance, Shirt.red.dry_clean_only will produce all shirts that are both red and dry clean only. - # Nested finds and calculations also work with these compositions: Shirt.red.dry_clean_only.count returns the number of garments - # for which these criteria obtain. Similarly with Shirt.red.dry_clean_only.average(:thread_count). - # - # All scopes are available as class methods on the ActiveRecord descendent upon which the scopes were defined. But they are also available to - # has_many associations. If, - # - # class Person < ActiveRecord::Base - # has_many :shirts - # end - # - # then elton.shirts.red.dry_clean_only will return all of Elton's red, dry clean - # only shirts. - # - # Named scopes can also be procedural. - # - # class Shirt < ActiveRecord::Base - # named_scope :colored, lambda { |color| - # { :conditions => { :color => color } } - # } - # end - # - # In this example, Shirt.colored('puce') finds all puce shirts. - # - # Named scopes can also have extensions, just as with has_many declarations: - # - # class Shirt < ActiveRecord::Base - # named_scope :red, :conditions => {:color => 'red'} do - # def dom_id - # 'red_shirts' - # end - # end - # end - # - def named_scope(name, options = {}, &block) - scopes[name] = lambda do |parent_scope, *args| - Scope.new(parent_scope, case options - when Hash - options - when Proc - options.call(*args) - end, &block) - end - (class << self; self end).instance_eval do - define_method name do |*args| - scopes[name].call(self, *args) - end - end - end - end - - class Scope #:nodoc: - attr_reader :proxy_scope, :proxy_options - [].methods.each { |m| delegate m, :to => :proxy_found unless m =~ /(^__|^nil\?|^send|class|extend|find|count|sum|average|maximum|minimum|paginate)/ } - delegate :scopes, :with_scope, :to => :proxy_scope - - def initialize(proxy_scope, options, &block) - [options[:extend]].flatten.each { |extension| extend extension } if options[:extend] - extend Module.new(&block) if block_given? - @proxy_scope, @proxy_options = proxy_scope, options.except(:extend) - end - - def reload - load_found; self - end - - protected - def proxy_found - @found || load_found - end - - private - def method_missing(method, *args, &block) - if scopes.include?(method) - scopes[method].call(self, *args) - else - with_scope :find => proxy_options do - proxy_scope.send(method, *args, &block) - end - end - end - - def load_found - @found = find(:all) - end - end - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb b/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb deleted file mode 100644 index bdc1997f..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb +++ /dev/null @@ -1,39 +0,0 @@ -## based on http://dev.rubyonrails.org/changeset/9084 - -ActiveRecord::Associations::AssociationProxy.class_eval do - protected - def with_scope(*args, &block) - @reflection.klass.send :with_scope, *args, &block - end -end - -[ ActiveRecord::Associations::AssociationCollection, - ActiveRecord::Associations::HasManyThroughAssociation ].each do |klass| - klass.class_eval do - protected - alias :method_missing_without_scopes :method_missing_without_paginate - def method_missing_without_paginate(method, *args, &block) - if @reflection.klass.scopes.include?(method) - @reflection.klass.scopes[method].call(self, *args, &block) - else - method_missing_without_scopes(method, *args, &block) - end - end - end -end - -# Rails 1.2.6 -ActiveRecord::Associations::HasAndBelongsToManyAssociation.class_eval do - protected - def method_missing(method, *args, &block) - if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) - super - elsif @reflection.klass.scopes.include?(method) - @reflection.klass.scopes[method].call(self, *args) - else - @reflection.klass.with_scope(:find => { :conditions => @finder_sql, :joins => @join_sql, :readonly => false }) do - @reflection.klass.send(method, *args, &block) - end - end - end -end if ActiveRecord::Base.respond_to? :find_first diff --git a/vendor/plugins/will_paginate/lib/will_paginate/version.rb b/vendor/plugins/will_paginate/lib/will_paginate/version.rb deleted file mode 100644 index 6bcd90d6..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module WillPaginate - module VERSION - MAJOR = 2 - MINOR = 3 - TINY = 3 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb b/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb deleted file mode 100644 index c53e44ec..00000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +++ /dev/null @@ -1,373 +0,0 @@ -require 'will_paginate/core_ext' - -module WillPaginate - # = Will Paginate view helpers - # - # Currently there is only one view helper: +will_paginate+. It renders the - # pagination links for the given collection. The helper itself is lightweight - # and serves only as a wrapper around link renderer instantiation; the - # renderer then does all the hard work of generating the HTML. - # - # == Global options for helpers - # - # Options for pagination helpers are optional and get their default values from the - # WillPaginate::ViewHelpers.pagination_options hash. You can write to this hash to - # override default options on the global level: - # - # WillPaginate::ViewHelpers.pagination_options[:prev_label] = 'Previous page' - # - # By putting this into your environment.rb you can easily translate link texts to previous - # and next pages, as well as override some other defaults to your liking. - module ViewHelpers - # default options that can be overridden on the global level - @@pagination_options = { - :class => 'pagination', - :prev_label => '« Previous', - :next_label => 'Next »', - :inner_window => 4, # links around the current page - :outer_window => 1, # links around beginning and end - :separator => ' ', # single space is friendly to spiders and non-graphic browsers - :param_name => :page, - :params => nil, - :renderer => 'WillPaginate::LinkRenderer', - :page_links => true, - :container => true - } - mattr_reader :pagination_options - - # Renders Digg/Flickr-style pagination for a WillPaginate::Collection - # object. Nil is returned if there is only one page in total; no point in - # rendering the pagination in that case... - # - # ==== Options - # * :class -- CSS class name for the generated DIV (default: "pagination") - # * :prev_label -- default: "« Previous" - # * :next_label -- default: "Next »" - # * :inner_window -- how many links are shown around the current page (default: 4) - # * :outer_window -- how many links are around the first and the last page (default: 1) - # * :separator -- string separator for page HTML elements (default: single space) - # * :param_name -- parameter name for page number in URLs (default: :page) - # * :params -- additional parameters when generating pagination links - # (eg. :controller => "foo", :action => nil) - # * :renderer -- class name, class or instance of a link renderer (default: - # WillPaginate::LinkRenderer) - # * :page_links -- when false, only previous/next links are rendered (default: true) - # * :container -- toggles rendering of the DIV container for pagination links, set to - # false only when you are rendering your own pagination markup (default: true) - # * :id -- HTML ID for the container (default: nil). Pass +true+ to have the ID - # automatically generated from the class name of objects in collection: for example, paginating - # ArticleComment models would yield an ID of "article_comments_pagination". - # - # All options beside listed ones are passed as HTML attributes to the container - # element for pagination links (the DIV). For example: - # - # <%= will_paginate @posts, :id => 'wp_posts' %> - # - # ... will result in: - # - # - # - # ==== Using the helper without arguments - # If the helper is called without passing in the collection object, it will - # try to read from the instance variable inferred by the controller name. - # For example, calling +will_paginate+ while the current controller is - # PostsController will result in trying to read from the @posts - # variable. Example: - # - # <%= will_paginate :id => true %> - # - # ... will result in @post collection getting paginated: - # - # - # - def will_paginate(collection = nil, options = {}) - options, collection = collection, nil if collection.is_a? Hash - unless collection or !controller - collection_name = "@#{controller.controller_name}" - collection = instance_variable_get(collection_name) - raise ArgumentError, "The #{collection_name} variable appears to be empty. Did you " + - "forget to pass the collection object for will_paginate?" unless collection - end - # early exit if there is nothing to render - return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) > 1 - - options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options - - # get the renderer instance - renderer = case options[:renderer] - when String - options[:renderer].to_s.constantize.new - when Class - options[:renderer].new - else - options[:renderer] - end - # render HTML for pagination - renderer.prepare collection, options, self - renderer.to_html - end - - # Wrapper for rendering pagination links at both top and bottom of a block - # of content. - # - # <% paginated_section @posts do %> - #
    - # <% for post in @posts %> - #
  1. ...
  2. - # <% end %> - #
- # <% end %> - # - # will result in: - # - # - #
    - # ... - #
- # - # - # Arguments are passed to a will_paginate call, so the same options - # apply. Don't use the :id option; otherwise you'll finish with two - # blocks of pagination links sharing the same ID (which is invalid HTML). - def paginated_section(*args, &block) - pagination = will_paginate(*args).to_s - content = pagination + capture(&block) + pagination - concat content, block.binding - end - - # Renders a helpful message with numbers of displayed vs. total entries. - # You can use this as a blueprint for your own, similar helpers. - # - # <%= page_entries_info @posts %> - # #-> Displaying posts 6 - 10 of 26 in total - # - # By default, the message will use the humanized class name of objects - # in collection: for instance, "project types" for ProjectType models. - # Override this to your liking with the :entry_name parameter: - # - # <%= page_entries_info @posts, :entry_name => 'item' %> - # #-> Displaying items 6 - 10 of 26 in total - def page_entries_info(collection, options = {}) - entry_name = options[:entry_name] || - (collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' ')) - - if collection.total_pages < 2 - case collection.size - when 0; "No #{entry_name.pluralize} found" - when 1; "Displaying 1 #{entry_name}" - else; "Displaying all #{collection.size} #{entry_name.pluralize}" - end - else - %{Displaying #{entry_name.pluralize} %d - %d of %d in total} % [ - collection.offset + 1, - collection.offset + collection.length, - collection.total_entries - ] - end - end - - def self.total_pages_for_collection(collection) #:nodoc: - if collection.respond_to?('page_count') and !collection.respond_to?('total_pages') - WillPaginate::Deprecation.warn <<-MSG - You are using a paginated collection of class #{collection.class.name} - which conforms to the old API of WillPaginate::Collection by using - `page_count`, while the current method name is `total_pages`. Please - upgrade yours or 3rd-party code that provides the paginated collection. - MSG - class << collection - def total_pages; page_count; end - end - end - collection.total_pages - end - end - - # This class does the heavy lifting of actually building the pagination - # links. It is used by +will_paginate+ helper internally. - class LinkRenderer - - # The gap in page links is represented by: - # - # - attr_accessor :gap_marker - - def initialize - @gap_marker = '' - end - - # * +collection+ is a WillPaginate::Collection instance or any other object - # that conforms to that API - # * +options+ are forwarded from +will_paginate+ view helper - # * +template+ is the reference to the template being rendered - def prepare(collection, options, template) - @collection = collection - @options = options - @template = template - - # reset values in case we're re-using this instance - @total_pages = @param_name = @url_string = nil - end - - # Process it! This method returns the complete HTML string which contains - # pagination links. Feel free to subclass LinkRenderer and change this - # method as you see fit. - def to_html - links = @options[:page_links] ? windowed_links : [] - # previous/next buttons - links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:prev_label]) - links.push page_link_or_span(@collection.next_page, 'disabled next_page', @options[:next_label]) - - html = links.join(@options[:separator]) - @options[:container] ? @template.content_tag(:div, html, html_attributes) : html - end - - # Returns the subset of +options+ this instance was initialized with that - # represent HTML attributes for the container element of pagination links. - def html_attributes - return @html_attributes if @html_attributes - @html_attributes = @options.except *(WillPaginate::ViewHelpers.pagination_options.keys - [:class]) - # pagination of Post models will have the ID of "posts_pagination" - if @options[:container] and @options[:id] === true - @html_attributes[:id] = @collection.first.class.name.underscore.pluralize + '_pagination' - end - @html_attributes - end - - protected - - # Collects link items for visible page numbers. - def windowed_links - prev = nil - - visible_page_numbers.inject [] do |links, n| - # detect gaps: - links << gap_marker if prev and n > prev + 1 - links << page_link_or_span(n, 'current') - prev = n - links - end - end - - # Calculates visible page numbers using the :inner_window and - # :outer_window options. - def visible_page_numbers - inner_window, outer_window = @options[:inner_window].to_i, @options[:outer_window].to_i - window_from = current_page - inner_window - window_to = current_page + inner_window - - # adjust lower or upper limit if other is out of bounds - if window_to > total_pages - window_from -= window_to - total_pages - window_to = total_pages - end - if window_from < 1 - window_to += 1 - window_from - window_from = 1 - window_to = total_pages if window_to > total_pages - end - - visible = (1..total_pages).to_a - left_gap = (2 + outer_window)...window_from - right_gap = (window_to + 1)...(total_pages - outer_window) - visible -= left_gap.to_a if left_gap.last - left_gap.first > 1 - visible -= right_gap.to_a if right_gap.last - right_gap.first > 1 - - visible - end - - def page_link_or_span(page, span_class, text = nil) - text ||= page.to_s - - if page and page != current_page - classnames = span_class && span_class.index(' ') && span_class.split(' ', 2).last - page_link page, text, :rel => rel_value(page), :class => classnames - else - page_span page, text, :class => span_class - end - end - - def page_link(page, text, attributes = {}) - @template.link_to text, url_for(page), attributes - end - - def page_span(page, text, attributes = {}) - @template.content_tag :span, text, attributes - end - - # Returns URL params for +page_link_or_span+, taking the current GET params - # and :params option into account. - def url_for(page) - page_one = page == 1 - unless @url_string and !page_one - @url_params = {} - # page links should preserve GET parameters - stringified_merge @url_params, @template.params if @template.request.get? - stringified_merge @url_params, @options[:params] if @options[:params] - - if complex = param_name.index(/[^\w-]/) - page_param = (defined?(CGIMethods) ? CGIMethods : ActionController::AbstractRequest). - parse_query_parameters("#{param_name}=#{page}") - - stringified_merge @url_params, page_param - else - @url_params[param_name] = page_one ? 1 : 2 - end - - url = @template.url_for(@url_params) - return url if page_one - - if complex - @url_string = url.sub(%r!((?:\?|&)#{CGI.escape param_name}=)#{page}!, '\1@') - return url - else - @url_string = url - @url_params[param_name] = 3 - @template.url_for(@url_params).split(//).each_with_index do |char, i| - if char == '3' and url[i, 1] == '2' - @url_string[i] = '@' - break - end - end - end - end - # finally! - @url_string.sub '@', page.to_s - end - - private - - def rel_value(page) - case page - when @collection.previous_page; 'prev' + (page == 1 ? ' start' : '') - when @collection.next_page; 'next' - when 1; 'start' - end - end - - def current_page - @collection.current_page - end - - def total_pages - @total_pages ||= WillPaginate::ViewHelpers.total_pages_for_collection(@collection) - end - - def param_name - @param_name ||= @options[:param_name].to_s - end - - # Recursively merge into target hash by using stringified keys from the other one - def stringified_merge(target, other) - other.each do |key, value| - key = key.to_s # this line is what it's all about! - existing = target[key] - - if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?) - stringified_merge(existing || (target[key] = {}), value) - else - target[key] = value - end - end - end - end -end diff --git a/vendor/plugins/will_paginate/test/boot.rb b/vendor/plugins/will_paginate/test/boot.rb deleted file mode 100644 index 622fc93c..00000000 --- a/vendor/plugins/will_paginate/test/boot.rb +++ /dev/null @@ -1,21 +0,0 @@ -plugin_root = File.join(File.dirname(__FILE__), '..') -version = ENV['RAILS_VERSION'] -version = nil if version and version == "" - -# first look for a symlink to a copy of the framework -if !version and framework_root = ["#{plugin_root}/rails", "#{plugin_root}/../../rails"].find { |p| File.directory? p } - puts "found framework root: #{framework_root}" - # this allows for a plugin to be tested outside of an app and without Rails gems - $:.unshift "#{framework_root}/activesupport/lib", "#{framework_root}/activerecord/lib", "#{framework_root}/actionpack/lib" -else - # simply use installed gems if available - puts "using Rails#{version ? ' ' + version : nil} gems" - require 'rubygems' - - if version - gem 'rails', version - else - gem 'actionpack' - gem 'activerecord' - end -end diff --git a/vendor/plugins/will_paginate/test/collection_test.rb b/vendor/plugins/will_paginate/test/collection_test.rb deleted file mode 100644 index b3360901..00000000 --- a/vendor/plugins/will_paginate/test/collection_test.rb +++ /dev/null @@ -1,140 +0,0 @@ -require 'helper' -require 'will_paginate/array' - -class ArrayPaginationTest < Test::Unit::TestCase - def test_simple - collection = ('a'..'e').to_a - - [{ :page => 1, :per_page => 3, :expected => %w( a b c ) }, - { :page => 2, :per_page => 3, :expected => %w( d e ) }, - { :page => 1, :per_page => 5, :expected => %w( a b c d e ) }, - { :page => 3, :per_page => 5, :expected => [] }, - ]. - each do |conditions| - expected = conditions.delete :expected - assert_equal expected, collection.paginate(conditions) - end - end - - def test_defaults - result = (1..50).to_a.paginate - assert_equal 1, result.current_page - assert_equal 30, result.size - end - - def test_deprecated_api - assert_raise(ArgumentError) { [].paginate(2) } - assert_raise(ArgumentError) { [].paginate(2, 10) } - end - - def test_total_entries_has_precedence - result = %w(a b c).paginate :total_entries => 5 - assert_equal 5, result.total_entries - end - - def test_argument_error_with_params_and_another_argument - assert_raise ArgumentError do - [].paginate({}, 5) - end - end - - def test_paginated_collection - entries = %w(a b c) - collection = create(2, 3, 10) do |pager| - assert_equal entries, pager.replace(entries) - end - - assert_equal entries, collection - assert_respond_to_all collection, %w(total_pages each offset size current_page per_page total_entries) - assert_kind_of Array, collection - assert_instance_of Array, collection.entries - assert_equal 3, collection.offset - assert_equal 4, collection.total_pages - assert !collection.out_of_bounds? - end - - def test_previous_next_pages - collection = create(1, 1, 3) - assert_nil collection.previous_page - assert_equal 2, collection.next_page - - collection = create(2, 1, 3) - assert_equal 1, collection.previous_page - assert_equal 3, collection.next_page - - collection = create(3, 1, 3) - assert_equal 2, collection.previous_page - assert_nil collection.next_page - end - - def test_out_of_bounds - entries = create(2, 3, 2){} - assert entries.out_of_bounds? - - entries = create(1, 3, 2){} - assert !entries.out_of_bounds? - end - - def test_guessing_total_count - entries = create do |pager| - # collection is shorter than limit - pager.replace array - end - assert_equal 8, entries.total_entries - - entries = create(2, 5, 10) do |pager| - # collection is shorter than limit, but we have an explicit count - pager.replace array - end - assert_equal 10, entries.total_entries - - entries = create do |pager| - # collection is the same as limit; we can't guess - pager.replace array(5) - end - assert_equal nil, entries.total_entries - - entries = create do |pager| - # collection is empty; we can't guess - pager.replace array(0) - end - assert_equal nil, entries.total_entries - - entries = create(1) do |pager| - # collection is empty and we're on page 1, - # so the whole thing must be empty, too - pager.replace array(0) - end - assert_equal 0, entries.total_entries - end - - def test_invalid_page - bad_inputs = [0, -1, nil, '', 'Schnitzel'] - - bad_inputs.each do |bad| - assert_raise(WillPaginate::InvalidPage) { create bad } - end - end - - def test_invalid_per_page_setting - assert_raise(ArgumentError) { create(1, -1) } - end - - def test_page_count_was_removed - assert_raise(NoMethodError) { create.page_count } - # It's `total_pages` now. - end - - private - def create(page = 2, limit = 5, total = nil, &block) - if block_given? - WillPaginate::Collection.create(page, limit, total, &block) - else - WillPaginate::Collection.new(page, limit, total) - end - end - - def array(size = 3) - Array.new(size) - end -end diff --git a/vendor/plugins/will_paginate/test/console b/vendor/plugins/will_paginate/test/console deleted file mode 100755 index 3f282f11..00000000 --- a/vendor/plugins/will_paginate/test/console +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby -irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' -libs = [] - -libs << 'irb/completion' -libs << File.join('lib', 'load_fixtures') - -exec "#{irb} -Ilib:test#{libs.map{ |l| " -r #{l}" }.join} --simple-prompt" diff --git a/vendor/plugins/will_paginate/test/database.yml b/vendor/plugins/will_paginate/test/database.yml deleted file mode 100644 index 7ef1e735..00000000 --- a/vendor/plugins/will_paginate/test/database.yml +++ /dev/null @@ -1,22 +0,0 @@ -sqlite3: - database: ":memory:" - adapter: sqlite3 - timeout: 500 - -sqlite2: - database: ":memory:" - adapter: sqlite2 - -mysql: - adapter: mysql - username: rails - password: mislav - encoding: utf8 - database: will_paginate_unittest - -postgres: - adapter: postgresql - username: mislav - password: mislav - database: will_paginate_unittest - min_messages: warning diff --git a/vendor/plugins/will_paginate/test/finder_test.rb b/vendor/plugins/will_paginate/test/finder_test.rb deleted file mode 100644 index 001cf3a7..00000000 --- a/vendor/plugins/will_paginate/test/finder_test.rb +++ /dev/null @@ -1,434 +0,0 @@ -require 'helper' -require 'lib/activerecord_test_case' - -require 'will_paginate' -WillPaginate.enable_activerecord -WillPaginate.enable_named_scope - -class FinderTest < ActiveRecordTestCase - fixtures :topics, :replies, :users, :projects, :developers_projects - - def test_new_methods_presence - assert_respond_to_all Topic, %w(per_page paginate paginate_by_sql) - end - - def test_simple_paginate - assert_queries(1) do - entries = Topic.paginate :page => nil - assert_equal 1, entries.current_page - assert_equal 1, entries.total_pages - assert_equal 4, entries.size - end - - assert_queries(2) do - entries = Topic.paginate :page => 2 - assert_equal 1, entries.total_pages - assert entries.empty? - end - end - - def test_parameter_api - # :page parameter in options is required! - assert_raise(ArgumentError){ Topic.paginate } - assert_raise(ArgumentError){ Topic.paginate({}) } - - # explicit :all should not break anything - assert_equal Topic.paginate(:page => nil), Topic.paginate(:all, :page => 1) - - # :count could be nil and we should still not cry - assert_nothing_raised { Topic.paginate :page => 1, :count => nil } - end - - def test_paginate_with_per_page - entries = Topic.paginate :page => 1, :per_page => 1 - assert_equal 1, entries.size - assert_equal 4, entries.total_pages - - # Developer class has explicit per_page at 10 - entries = Developer.paginate :page => 1 - assert_equal 10, entries.size - assert_equal 2, entries.total_pages - - entries = Developer.paginate :page => 1, :per_page => 5 - assert_equal 11, entries.total_entries - assert_equal 5, entries.size - assert_equal 3, entries.total_pages - end - - def test_paginate_with_order - entries = Topic.paginate :page => 1, :order => 'created_at desc' - expected = [topics(:futurama), topics(:harvey_birdman), topics(:rails), topics(:ar)].reverse - assert_equal expected, entries.to_a - assert_equal 1, entries.total_pages - end - - def test_paginate_with_conditions - entries = Topic.paginate :page => 1, :conditions => ["created_at > ?", 30.minutes.ago] - expected = [topics(:rails), topics(:ar)] - assert_equal expected, entries.to_a - assert_equal 1, entries.total_pages - end - - def test_paginate_with_include_and_conditions - entries = Topic.paginate \ - :page => 1, - :include => :replies, - :conditions => "replies.content LIKE 'Bird%' ", - :per_page => 10 - - expected = Topic.find :all, - :include => 'replies', - :conditions => "replies.content LIKE 'Bird%' ", - :limit => 10 - - assert_equal expected, entries.to_a - assert_equal 1, entries.total_entries - end - - def test_paginate_with_include_and_order - entries = nil - assert_queries(2) do - entries = Topic.paginate \ - :page => 1, - :include => :replies, - :order => 'replies.created_at asc, topics.created_at asc', - :per_page => 10 - end - - expected = Topic.find :all, - :include => 'replies', - :order => 'replies.created_at asc, topics.created_at asc', - :limit => 10 - - assert_equal expected, entries.to_a - assert_equal 4, entries.total_entries - end - - def test_paginate_associations_with_include - entries, project = nil, projects(:active_record) - - assert_nothing_raised "THIS IS A BUG in Rails 1.2.3 that was fixed in [7326]. " + - "Please upgrade to a newer version of Rails." do - entries = project.topics.paginate \ - :page => 1, - :include => :replies, - :conditions => "replies.content LIKE 'Nice%' ", - :per_page => 10 - end - - expected = Topic.find :all, - :include => 'replies', - :conditions => "project_id = #{project.id} AND replies.content LIKE 'Nice%' ", - :limit => 10 - - assert_equal expected, entries.to_a - end - - def test_paginate_associations - dhh = users :david - expected_name_ordered = [projects(:action_controller), projects(:active_record)] - expected_id_ordered = [projects(:active_record), projects(:action_controller)] - - assert_queries(2) do - # with association-specified order - entries = dhh.projects.paginate(:page => 1) - assert_equal expected_name_ordered, entries - assert_equal 2, entries.total_entries - end - - # with explicit order - entries = dhh.projects.paginate(:page => 1, :order => 'projects.id') - assert_equal expected_id_ordered, entries - assert_equal 2, entries.total_entries - - assert_nothing_raised { dhh.projects.find(:all, :order => 'projects.id', :limit => 4) } - entries = dhh.projects.paginate(:page => 1, :order => 'projects.id', :per_page => 4) - assert_equal expected_id_ordered, entries - - # has_many with implicit order - topic = Topic.find(1) - expected = [replies(:spam), replies(:witty_retort)] - assert_equal expected.map(&:id).sort, topic.replies.paginate(:page => 1).map(&:id).sort - assert_equal expected.reverse, topic.replies.paginate(:page => 1, :order => 'replies.id ASC') - end - - def test_paginate_association_extension - project = Project.find(:first) - - assert_queries(2) do - entries = project.replies.paginate_recent :page => 1 - assert_equal [replies(:brave)], entries - end - end - - def test_paginate_with_joins - entries = nil - - assert_queries(1) do - entries = Developer.paginate :page => 1, - :joins => 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id', - :conditions => 'project_id = 1' - assert_equal 2, entries.size - developer_names = entries.map &:name - assert developer_names.include?('David') - assert developer_names.include?('Jamis') - end - - assert_queries(1) do - expected = entries.to_a - entries = Developer.paginate :page => 1, - :joins => 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id', - :conditions => 'project_id = 1', :count => { :select => "users.id" } - assert_equal expected, entries.to_a - assert_equal 2, entries.total_entries - end - end - - def test_paginate_with_group - entries = nil - assert_queries(1) do - entries = Developer.paginate :page => 1, :per_page => 10, - :group => 'salary', :select => 'salary', :order => 'salary' - end - - expected = [ users(:david), users(:jamis), users(:dev_10), users(:poor_jamis) ].map(&:salary).sort - assert_equal expected, entries.map(&:salary) - end - - def test_paginate_with_dynamic_finder - expected = [replies(:witty_retort), replies(:spam)] - assert_equal expected, Reply.paginate_by_topic_id(1, :page => 1) - - entries = Developer.paginate :conditions => { :salary => 100000 }, :page => 1, :per_page => 5 - assert_equal 8, entries.total_entries - assert_equal entries, Developer.paginate_by_salary(100000, :page => 1, :per_page => 5) - - # dynamic finder + conditions - entries = Developer.paginate_by_salary(100000, :page => 1, - :conditions => ['id > ?', 6]) - assert_equal 4, entries.total_entries - assert_equal (7..10).to_a, entries.map(&:id) - - assert_raises NoMethodError do - Developer.paginate_by_inexistent_attribute 100000, :page => 1 - end - end - - def test_scoped_paginate - entries = Developer.with_poor_ones { Developer.paginate :page => 1 } - - assert_equal 2, entries.size - assert_equal 2, entries.total_entries - end - - ## named_scope ## - - def test_paginate_in_named_scope - entries = Developer.poor.paginate :page => 1, :per_page => 1 - - assert_equal 1, entries.size - assert_equal 2, entries.total_entries - end - - def test_paginate_in_named_scope_on_habtm_association - project = projects(:active_record) - assert_queries(2) do - entries = project.developers.poor.paginate :page => 1, :per_page => 1 - - assert_equal 1, entries.size, 'one developer should be found' - assert_equal 1, entries.total_entries, 'only one developer should be found' - end - end - - def test_paginate_in_named_scope_on_hmt_association - project = projects(:active_record) - expected = [replies(:brave)] - - assert_queries(2) do - entries = project.replies.recent.paginate :page => 1, :per_page => 1 - assert_equal expected, entries - assert_equal 1, entries.total_entries, 'only one reply should be found' - end - end - - def test_paginate_in_named_scope_on_has_many_association - project = projects(:active_record) - expected = [topics(:ar)] - - assert_queries(2) do - entries = project.topics.mentions_activerecord.paginate :page => 1, :per_page => 1 - assert_equal expected, entries - assert_equal 1, entries.total_entries, 'only one topic should be found' - end - end - - ## misc ## - - def test_count_and_total_entries_options_are_mutually_exclusive - e = assert_raise ArgumentError do - Developer.paginate :page => 1, :count => {}, :total_entries => 1 - end - assert_match /exclusive/, e.to_s - end - - def test_readonly - assert_nothing_raised { Developer.paginate :readonly => true, :page => 1 } - end - - # this functionality is temporarily removed - def xtest_pagination_defines_method - pager = "paginate_by_created_at" - assert !User.methods.include?(pager), "User methods should not include `#{pager}` method" - # paginate! - assert 0, User.send(pager, nil, :page => 1).total_entries - # the paging finder should now be defined - assert User.methods.include?(pager), "`#{pager}` method should be defined on User" - end - - # Is this Rails 2.0? Find out by testing find_all which was removed in [6998] - unless ActiveRecord::Base.respond_to? :find_all - def test_paginate_array_of_ids - # AR finders also accept arrays of IDs - # (this was broken in Rails before [6912]) - assert_queries(1) do - entries = Developer.paginate((1..8).to_a, :per_page => 3, :page => 2, :order => 'id') - assert_equal (4..6).to_a, entries.map(&:id) - assert_equal 8, entries.total_entries - end - end - end - - uses_mocha 'internals' do - def test_implicit_all_with_dynamic_finders - Topic.expects(:find_all_by_foo).returns([]) - Topic.expects(:count).returns(0) - Topic.paginate_by_foo :page => 2 - end - - def test_guessing_the_total_count - Topic.expects(:find).returns(Array.new(2)) - Topic.expects(:count).never - - entries = Topic.paginate :page => 2, :per_page => 4 - assert_equal 6, entries.total_entries - end - - def test_guessing_that_there_are_no_records - Topic.expects(:find).returns([]) - Topic.expects(:count).never - - entries = Topic.paginate :page => 1, :per_page => 4 - assert_equal 0, entries.total_entries - end - - def test_extra_parameters_stay_untouched - Topic.expects(:find).with(:all, {:foo => 'bar', :limit => 4, :offset => 0 }).returns(Array.new(5)) - Topic.expects(:count).with({:foo => 'bar'}).returns(1) - - Topic.paginate :foo => 'bar', :page => 1, :per_page => 4 - end - - def test_count_skips_select - Developer.stubs(:find).returns([]) - Developer.expects(:count).with({}).returns(0) - Developer.paginate :select => 'salary', :page => 2 - end - - def test_count_select_when_distinct - Developer.stubs(:find).returns([]) - Developer.expects(:count).with(:select => 'DISTINCT salary').returns(0) - Developer.paginate :select => 'DISTINCT salary', :page => 2 - end - - def test_should_use_scoped_finders_if_present - # scope-out compatibility - Topic.expects(:find_best).returns(Array.new(5)) - Topic.expects(:with_best).returns(1) - - Topic.paginate_best :page => 1, :per_page => 4 - end - - def test_paginate_by_sql - assert_respond_to Developer, :paginate_by_sql - Developer.expects(:find_by_sql).with(regexp_matches(/sql LIMIT 3(,| OFFSET) 3/)).returns([]) - Developer.expects(:count_by_sql).with('SELECT COUNT(*) FROM (sql) AS count_table').returns(0) - - entries = Developer.paginate_by_sql 'sql', :page => 2, :per_page => 3 - end - - def test_paginate_by_sql_respects_total_entries_setting - Developer.expects(:find_by_sql).returns([]) - Developer.expects(:count_by_sql).never - - entries = Developer.paginate_by_sql 'sql', :page => 1, :total_entries => 999 - assert_equal 999, entries.total_entries - end - - def test_paginate_by_sql_strips_order_by_when_counting - Developer.expects(:find_by_sql).returns([]) - Developer.expects(:count_by_sql).with("SELECT COUNT(*) FROM (sql\n ) AS count_table").returns(0) - - Developer.paginate_by_sql "sql\n ORDER\nby foo, bar, `baz` ASC", :page => 2 - end - - # TODO: counts are still wrong - def test_ability_to_use_with_custom_finders - # acts_as_taggable defines find_tagged_with(tag, options) - Topic.expects(:find_tagged_with).with('will_paginate', :offset => 5, :limit => 5).returns([]) - Topic.expects(:count).with({}).returns(0) - - Topic.paginate_tagged_with 'will_paginate', :page => 2, :per_page => 5 - end - - def test_array_argument_doesnt_eliminate_count - ids = (1..8).to_a - Developer.expects(:find_all_by_id).returns([]) - Developer.expects(:count).returns(0) - - Developer.paginate_by_id(ids, :per_page => 3, :page => 2, :order => 'id') - end - - def test_paginating_finder_doesnt_mangle_options - Developer.expects(:find).returns([]) - options = { :page => 1 } - options.expects(:delete).never - options_before = options.dup - - Developer.paginate(options) - assert_equal options, options_before - end - - def test_paginated_each - collection = stub('collection', :size => 5, :empty? => false, :per_page => 5) - collection.expects(:each).times(2).returns(collection) - last_collection = stub('collection', :size => 4, :empty? => false, :per_page => 5) - last_collection.expects(:each).returns(last_collection) - - params = { :order => 'id', :total_entries => 0 } - - Developer.expects(:paginate).with(params.merge(:page => 2)).returns(collection) - Developer.expects(:paginate).with(params.merge(:page => 3)).returns(collection) - Developer.expects(:paginate).with(params.merge(:page => 4)).returns(last_collection) - - assert_equal 14, Developer.paginated_each(:page => '2') { } - end - - # detect ActiveRecord 2.1 - if ActiveRecord::Base.private_methods.include?('references_eager_loaded_tables?') - def test_removes_irrelevant_includes_in_count - Developer.expects(:find).returns([1]) - Developer.expects(:count).with({}).returns(0) - - Developer.paginate :page => 1, :per_page => 1, :include => :projects - end - - def test_doesnt_remove_referenced_includes_in_count - Developer.expects(:find).returns([1]) - Developer.expects(:count).with({ :include => :projects, :conditions => 'projects.id > 2' }).returns(0) - - Developer.paginate :page => 1, :per_page => 1, - :include => :projects, :conditions => 'projects.id > 2' - end - end - end -end diff --git a/vendor/plugins/will_paginate/test/fixtures/admin.rb b/vendor/plugins/will_paginate/test/fixtures/admin.rb deleted file mode 100644 index 1d5e7f36..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/admin.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Admin < User - has_many :companies, :finder_sql => 'SELECT * FROM companies' -end diff --git a/vendor/plugins/will_paginate/test/fixtures/developer.rb b/vendor/plugins/will_paginate/test/fixtures/developer.rb deleted file mode 100644 index 7105355d..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/developer.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Developer < User - has_and_belongs_to_many :projects, :include => :topics, :order => 'projects.name' - - def self.with_poor_ones(&block) - with_scope :find => { :conditions => ['salary <= ?', 80000], :order => 'salary' } do - yield - end - end - - named_scope :poor, :conditions => ['salary <= ?', 80000], :order => 'salary' - - def self.per_page() 10 end -end diff --git a/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml b/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml deleted file mode 100644 index cee359c7..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +++ /dev/null @@ -1,13 +0,0 @@ -david_action_controller: - developer_id: 1 - project_id: 2 - joined_on: 2004-10-10 - -david_active_record: - developer_id: 1 - project_id: 1 - joined_on: 2004-10-10 - -jamis_active_record: - developer_id: 2 - project_id: 1 \ No newline at end of file diff --git a/vendor/plugins/will_paginate/test/fixtures/project.rb b/vendor/plugins/will_paginate/test/fixtures/project.rb deleted file mode 100644 index 0f85ef5e..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/project.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Project < ActiveRecord::Base - has_and_belongs_to_many :developers, :uniq => true - - has_many :topics - # :finder_sql => 'SELECT * FROM topics WHERE (topics.project_id = #{id})', - # :counter_sql => 'SELECT COUNT(*) FROM topics WHERE (topics.project_id = #{id})' - - has_many :replies, :through => :topics do - def find_recent(params = {}) - with_scope :find => { :conditions => ['replies.created_at > ?', 15.minutes.ago] } do - find :all, params - end - end - end -end diff --git a/vendor/plugins/will_paginate/test/fixtures/projects.yml b/vendor/plugins/will_paginate/test/fixtures/projects.yml deleted file mode 100644 index 74f3c32f..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/projects.yml +++ /dev/null @@ -1,6 +0,0 @@ -active_record: - id: 1 - name: Active Record -action_controller: - id: 2 - name: Active Controller diff --git a/vendor/plugins/will_paginate/test/fixtures/replies.yml b/vendor/plugins/will_paginate/test/fixtures/replies.yml deleted file mode 100644 index 9a83c004..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/replies.yml +++ /dev/null @@ -1,29 +0,0 @@ -witty_retort: - id: 1 - topic_id: 1 - content: Birdman is better! - created_at: <%= 6.hours.ago.to_s(:db) %> - -another: - id: 2 - topic_id: 2 - content: Nuh uh! - created_at: <%= 1.hour.ago.to_s(:db) %> - -spam: - id: 3 - topic_id: 1 - content: Nice site! - created_at: <%= 1.hour.ago.to_s(:db) %> - -decisive: - id: 4 - topic_id: 4 - content: "I'm getting to the bottom of this" - created_at: <%= 30.minutes.ago.to_s(:db) %> - -brave: - id: 5 - topic_id: 4 - content: "AR doesn't scare me a bit" - created_at: <%= 10.minutes.ago.to_s(:db) %> diff --git a/vendor/plugins/will_paginate/test/fixtures/reply.rb b/vendor/plugins/will_paginate/test/fixtures/reply.rb deleted file mode 100644 index ecaf3c1f..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/reply.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Reply < ActiveRecord::Base - belongs_to :topic, :include => [:replies] - - named_scope :recent, :conditions => ['replies.created_at > ?', 15.minutes.ago] - - validates_presence_of :content -end diff --git a/vendor/plugins/will_paginate/test/fixtures/schema.rb b/vendor/plugins/will_paginate/test/fixtures/schema.rb deleted file mode 100644 index 8831aad2..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/schema.rb +++ /dev/null @@ -1,38 +0,0 @@ -ActiveRecord::Schema.define do - - create_table "users", :force => true do |t| - t.column "name", :text - t.column "salary", :integer, :default => 70000 - t.column "created_at", :datetime - t.column "updated_at", :datetime - t.column "type", :text - end - - create_table "projects", :force => true do |t| - t.column "name", :text - end - - create_table "developers_projects", :id => false, :force => true do |t| - t.column "developer_id", :integer, :null => false - t.column "project_id", :integer, :null => false - t.column "joined_on", :date - t.column "access_level", :integer, :default => 1 - end - - create_table "topics", :force => true do |t| - t.column "project_id", :integer - t.column "title", :string - t.column "subtitle", :string - t.column "content", :text - t.column "created_at", :datetime - t.column "updated_at", :datetime - end - - create_table "replies", :force => true do |t| - t.column "content", :text - t.column "created_at", :datetime - t.column "updated_at", :datetime - t.column "topic_id", :integer - end - -end diff --git a/vendor/plugins/will_paginate/test/fixtures/topic.rb b/vendor/plugins/will_paginate/test/fixtures/topic.rb deleted file mode 100644 index 77be0dda..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/topic.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Topic < ActiveRecord::Base - has_many :replies, :dependent => :destroy, :order => 'replies.created_at DESC' - belongs_to :project - - named_scope :mentions_activerecord, :conditions => ['topics.title LIKE ?', '%ActiveRecord%'] -end diff --git a/vendor/plugins/will_paginate/test/fixtures/topics.yml b/vendor/plugins/will_paginate/test/fixtures/topics.yml deleted file mode 100644 index 0a269047..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/topics.yml +++ /dev/null @@ -1,30 +0,0 @@ -futurama: - id: 1 - title: Isnt futurama awesome? - subtitle: It really is, isnt it. - content: I like futurama - created_at: <%= 1.day.ago.to_s(:db) %> - updated_at: - -harvey_birdman: - id: 2 - title: Harvey Birdman is the king of all men - subtitle: yup - content: He really is - created_at: <%= 2.hours.ago.to_s(:db) %> - updated_at: - -rails: - id: 3 - project_id: 1 - title: Rails is nice - subtitle: It makes me happy - content: except when I have to hack internals to fix pagination. even then really. - created_at: <%= 20.minutes.ago.to_s(:db) %> - -ar: - id: 4 - project_id: 1 - title: ActiveRecord sometimes freaks me out - content: "I mean, what's the deal with eager loading?" - created_at: <%= 15.minutes.ago.to_s(:db) %> diff --git a/vendor/plugins/will_paginate/test/fixtures/user.rb b/vendor/plugins/will_paginate/test/fixtures/user.rb deleted file mode 100644 index 4a57cf07..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/user.rb +++ /dev/null @@ -1,2 +0,0 @@ -class User < ActiveRecord::Base -end diff --git a/vendor/plugins/will_paginate/test/fixtures/users.yml b/vendor/plugins/will_paginate/test/fixtures/users.yml deleted file mode 100644 index ed2c03ae..00000000 --- a/vendor/plugins/will_paginate/test/fixtures/users.yml +++ /dev/null @@ -1,35 +0,0 @@ -david: - id: 1 - name: David - salary: 80000 - type: Developer - -jamis: - id: 2 - name: Jamis - salary: 150000 - type: Developer - -<% for digit in 3..10 %> -dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - salary: 100000 - type: Developer -<% end %> - -poor_jamis: - id: 11 - name: Jamis - salary: 9000 - type: Developer - -admin: - id: 12 - name: admin - type: Admin - -goofy: - id: 13 - name: Goofy - type: Admin diff --git a/vendor/plugins/will_paginate/test/helper.rb b/vendor/plugins/will_paginate/test/helper.rb deleted file mode 100644 index ad52b1b6..00000000 --- a/vendor/plugins/will_paginate/test/helper.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'test/unit' -require 'rubygems' - -# gem install redgreen for colored test output -begin require 'redgreen'; rescue LoadError; end - -require 'boot' unless defined?(ActiveRecord) - -class Test::Unit::TestCase - protected - def assert_respond_to_all object, methods - methods.each do |method| - [method.to_s, method.to_sym].each { |m| assert_respond_to object, m } - end - end - - def collect_deprecations - old_behavior = WillPaginate::Deprecation.behavior - deprecations = [] - WillPaginate::Deprecation.behavior = Proc.new do |message, callstack| - deprecations << message - end - result = yield - [result, deprecations] - ensure - WillPaginate::Deprecation.behavior = old_behavior - end -end - -# Wrap tests that use Mocha and skip if unavailable. -def uses_mocha(test_name) - require 'mocha' unless Object.const_defined?(:Mocha) -rescue LoadError => load_error - $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again." -else - yield -end diff --git a/vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb b/vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb deleted file mode 100644 index 8f66ebee..00000000 --- a/vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'lib/activerecord_test_connector' - -class ActiveRecordTestCase < Test::Unit::TestCase - # Set our fixture path - if ActiveRecordTestConnector.able_to_connect - self.fixture_path = File.join(File.dirname(__FILE__), '..', 'fixtures') - self.use_transactional_fixtures = true - end - - def self.fixtures(*args) - super if ActiveRecordTestConnector.connected - end - - def run(*args) - super if ActiveRecordTestConnector.connected - end - - # Default so Test::Unit::TestCase doesn't complain - def test_truth - end - - protected - - def assert_queries(num = 1) - $query_count = 0 - yield - ensure - assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed." - end - - def assert_no_queries(&block) - assert_queries(0, &block) - end -end - -ActiveRecordTestConnector.setup diff --git a/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb b/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb deleted file mode 100644 index 0decd8a2..00000000 --- a/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'active_record' -require 'active_record/version' -require 'active_record/fixtures' - -class ActiveRecordTestConnector - cattr_accessor :able_to_connect - cattr_accessor :connected - - FIXTURES_PATH = File.join(File.dirname(__FILE__), '..', 'fixtures') - - # Set our defaults - self.connected = false - self.able_to_connect = true - - def self.setup - unless self.connected || !self.able_to_connect - setup_connection - load_schema - Dependencies.load_paths.unshift FIXTURES_PATH - self.connected = true - end - rescue Exception => e # errors from ActiveRecord setup - $stderr.puts "\nSkipping ActiveRecord tests: #{e}" - $stderr.puts "Install SQLite3 to run the full test suite for will_paginate.\n\n" - self.able_to_connect = false - end - - private - - def self.setup_connection - db = ENV['DB'].blank?? 'sqlite3' : ENV['DB'] - - configurations = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'database.yml')) - raise "no configuration for '#{db}'" unless configurations.key? db - configuration = configurations[db] - - ActiveRecord::Base.logger = Logger.new(STDOUT) if $0 == 'irb' - puts "using #{configuration['adapter']} adapter" unless ENV['DB'].blank? - - ActiveRecord::Base.establish_connection(configuration) - ActiveRecord::Base.configurations = { db => configuration } - prepare ActiveRecord::Base.connection - - unless Object.const_defined?(:QUOTED_TYPE) - Object.send :const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type') - end - end - - def self.load_schema - ActiveRecord::Base.silence do - ActiveRecord::Migration.verbose = false - load File.join(FIXTURES_PATH, 'schema.rb') - end - end - - def self.prepare(conn) - class << conn - IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SHOW FIELDS /] - - def execute_with_counting(sql, name = nil, &block) - $query_count ||= 0 - $query_count += 1 unless IGNORED_SQL.any? { |r| sql =~ r } - execute_without_counting(sql, name, &block) - end - - alias_method_chain :execute, :counting - end - end -end diff --git a/vendor/plugins/will_paginate/test/lib/load_fixtures.rb b/vendor/plugins/will_paginate/test/lib/load_fixtures.rb deleted file mode 100644 index 10d6f420..00000000 --- a/vendor/plugins/will_paginate/test/lib/load_fixtures.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'boot' -require 'lib/activerecord_test_connector' - -# setup the connection -ActiveRecordTestConnector.setup - -# load all fixtures -Fixtures.create_fixtures(ActiveRecordTestConnector::FIXTURES_PATH, ActiveRecord::Base.connection.tables) - -require 'will_paginate' -WillPaginate.enable_activerecord diff --git a/vendor/plugins/will_paginate/test/lib/view_test_process.rb b/vendor/plugins/will_paginate/test/lib/view_test_process.rb deleted file mode 100644 index e4e79d57..00000000 --- a/vendor/plugins/will_paginate/test/lib/view_test_process.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'action_controller' -require 'action_controller/test_process' - -require 'will_paginate' -WillPaginate.enable_actionpack - -ActionController::Routing::Routes.draw do |map| - map.connect 'dummy/page/:page', :controller => 'dummy' - map.connect 'dummy/dots/page.:page', :controller => 'dummy', :action => 'dots' - map.connect 'ibocorp/:page', :controller => 'ibocorp', - :requirements => { :page => /\d+/ }, - :defaults => { :page => 1 } - - map.connect ':controller/:action/:id' -end - -ActionController::Base.perform_caching = false - -class WillPaginate::ViewTestCase < Test::Unit::TestCase - def setup - super - @controller = DummyController.new - @request = @controller.request - @html_result = nil - @template = '<%= will_paginate collection, options %>' - - @view = ActionView::Base.new - @view.assigns['controller'] = @controller - @view.assigns['_request'] = @request - @view.assigns['_params'] = @request.params - end - - def test_no_complain; end - - protected - - def paginate(collection = {}, options = {}, &block) - if collection.instance_of? Hash - page_options = { :page => 1, :total_entries => 11, :per_page => 4 }.merge(collection) - collection = [1].paginate(page_options) - end - - locals = { :collection => collection, :options => options } - - if defined? ActionView::InlineTemplate - # Rails 2.1 - args = [ ActionView::InlineTemplate.new(@view, @template, locals) ] - else - # older Rails versions - args = [nil, @template, nil, locals] - end - - @html_result = @view.render_template(*args) - @html_document = HTML::Document.new(@html_result, true, false) - - if block_given? - classname = options[:class] || WillPaginate::ViewHelpers.pagination_options[:class] - assert_select("div.#{classname}", 1, 'no main DIV', &block) - end - end - - def response_from_page_or_rjs - @html_document.root - end - - def validate_page_numbers expected, links, param_name = :page - param_pattern = /\W#{CGI.escape(param_name.to_s)}=([^&]*)/ - - assert_equal(expected, links.map { |e| - e['href'] =~ param_pattern - $1 ? $1.to_i : $1 - }) - end - - def assert_links_match pattern, links = nil, numbers = nil - links ||= assert_select 'div.pagination a[href]' do |elements| - elements - end - - pages = [] if numbers - - links.each do |el| - assert_match pattern, el['href'] - if numbers - el['href'] =~ pattern - pages << ($1.nil?? nil : $1.to_i) - end - end - - assert_equal numbers, pages, "page numbers don't match" if numbers - end - - def assert_no_links_match pattern - assert_select 'div.pagination a[href]' do |elements| - elements.each do |el| - assert_no_match pattern, el['href'] - end - end - end -end - -class DummyRequest - attr_accessor :symbolized_path_parameters - - def initialize - @get = true - @params = {} - @symbolized_path_parameters = { :controller => 'foo', :action => 'bar' } - end - - def get? - @get - end - - def post - @get = false - end - - def relative_url_root - '' - end - - def params(more = nil) - @params.update(more) if more - @params - end -end - -class DummyController - attr_reader :request - attr_accessor :controller_name - - def initialize - @request = DummyRequest.new - @url = ActionController::UrlRewriter.new(@request, @request.params) - end - - def params - @request.params - end - - def url_for(params) - @url.rewrite(params) - end -end - -module HTML - Node.class_eval do - def inner_text - children.map(&:inner_text).join('') - end - end - - Text.class_eval do - def inner_text - self.to_s - end - end - - Tag.class_eval do - def inner_text - childless?? '' : super - end - end -end diff --git a/vendor/plugins/will_paginate/test/tasks.rake b/vendor/plugins/will_paginate/test/tasks.rake deleted file mode 100644 index 4b2de3b8..00000000 --- a/vendor/plugins/will_paginate/test/tasks.rake +++ /dev/null @@ -1,56 +0,0 @@ -require 'rake/testtask' - -desc 'Test the will_paginate plugin.' -Rake::TestTask.new(:test) do |t| - t.pattern = 'test/**/*_test.rb' - t.verbose = true - t.libs << 'test' -end - -# I want to specify environment variables at call time -class EnvTestTask < Rake::TestTask - attr_accessor :env - - def ruby(*args) - env.each { |key, value| ENV[key] = value } if env - super - env.keys.each { |key| ENV.delete key } if env - end -end - -for configuration in %w( sqlite3 mysql postgres ) - EnvTestTask.new("test_#{configuration}") do |t| - t.pattern = 'test/finder_test.rb' - t.verbose = true - t.env = { 'DB' => configuration } - t.libs << 'test' - end -end - -task :test_databases => %w(test_mysql test_sqlite3 test_postgres) - -desc %{Test everything on SQLite3, MySQL and PostgreSQL} -task :test_full => %w(test test_mysql test_postgres) - -desc %{Test everything with Rails 1.2.x and 2.0.x gems} -task :test_all do - all = Rake::Task['test_full'] - ENV['RAILS_VERSION'] = '~>1.2.6' - all.invoke - # reset the invoked flag - %w( test_full test test_mysql test_postgres ).each do |name| - Rake::Task[name].instance_variable_set '@already_invoked', false - end - # do it again - ENV['RAILS_VERSION'] = '~>2.0.2' - all.invoke -end - -task :rcov do - excludes = %w( lib/will_paginate/named_scope* - lib/will_paginate/core_ext.rb - lib/will_paginate.rb - rails* ) - - system %[rcov -Itest:lib test/*.rb -x #{excludes.join(',')}] -end diff --git a/vendor/plugins/will_paginate/test/view_test.rb b/vendor/plugins/will_paginate/test/view_test.rb deleted file mode 100644 index b6d1a207..00000000 --- a/vendor/plugins/will_paginate/test/view_test.rb +++ /dev/null @@ -1,355 +0,0 @@ -require 'helper' -require 'lib/view_test_process' - -class AdditionalLinkAttributesRenderer < WillPaginate::LinkRenderer - def initialize(link_attributes = nil) - super() - @additional_link_attributes = link_attributes || { :default => 'true' } - end - - def page_link(page, text, attributes = {}) - @template.link_to text, url_for(page), attributes.merge(@additional_link_attributes) - end -end - -class ViewTest < WillPaginate::ViewTestCase - - ## basic pagination ## - - def test_will_paginate - paginate do |pagination| - assert_select 'a[href]', 3 do |elements| - validate_page_numbers [2,3,2], elements - assert_select elements.last, ':last-child', "Next »" - end - assert_select 'span', 2 - assert_select 'span.disabled:first-child', '« Previous' - assert_select 'span.current', '1' - assert_equal '« Previous 1 2 3 Next »', pagination.first.inner_text - end - end - - def test_no_pagination_when_page_count_is_one - paginate :per_page => 30 - assert_equal '', @html_result - end - - def test_will_paginate_with_options - paginate({ :page => 2 }, - :class => 'will_paginate', :prev_label => 'Prev', :next_label => 'Next') do - assert_select 'a[href]', 4 do |elements| - validate_page_numbers [1,1,3,3], elements - # test rel attribute values: - assert_select elements[1], 'a', '1' do |link| - assert_equal 'prev start', link.first['rel'] - end - assert_select elements.first, 'a', "Prev" do |link| - assert_equal 'prev start', link.first['rel'] - end - assert_select elements.last, 'a', "Next" do |link| - assert_equal 'next', link.first['rel'] - end - end - assert_select 'span.current', '2' - end - end - - def test_will_paginate_using_renderer_class - paginate({}, :renderer => AdditionalLinkAttributesRenderer) do - assert_select 'a[default=true]', 3 - end - end - - def test_will_paginate_using_renderer_instance - renderer = WillPaginate::LinkRenderer.new - renderer.gap_marker = '~~' - - paginate({ :per_page => 2 }, :inner_window => 0, :outer_window => 0, :renderer => renderer) do - assert_select 'span.my-gap', '~~' - end - - renderer = AdditionalLinkAttributesRenderer.new(:title => 'rendered') - paginate({}, :renderer => renderer) do - assert_select 'a[title=rendered]', 3 - end - end - - def test_prev_next_links_have_classnames - paginate do |pagination| - assert_select 'span.disabled.prev_page:first-child' - assert_select 'a.next_page[href]:last-child' - end - end - - def test_full_output - paginate - expected = <<-HTML - - HTML - expected.strip!.gsub!(/\s{2,}/, ' ') - - assert_dom_equal expected, @html_result - end - - def test_escaping_of_urls - paginate({:page => 1, :per_page => 1, :total_entries => 2}, - :page_links => false, :params => { :tag => '
' }) - - assert_select 'a[href]', 1 do |links| - query = links.first['href'].split('?', 2)[1] - assert_equal %w(page=2 tag=%3Cbr%3E), query.split('&').sort - end - end - - ## advanced options for pagination ## - - def test_will_paginate_without_container - paginate({}, :container => false) - assert_select 'div.pagination', 0, 'main DIV present when it shouldn\'t' - assert_select 'a[href]', 3 - end - - def test_will_paginate_without_page_links - paginate({ :page => 2 }, :page_links => false) do - assert_select 'a[href]', 2 do |elements| - validate_page_numbers [1,3], elements - end - end - end - - def test_will_paginate_windows - paginate({ :page => 6, :per_page => 1 }, :inner_window => 1) do |pagination| - assert_select 'a[href]', 8 do |elements| - validate_page_numbers [5,1,2,5,7,10,11,7], elements - assert_select elements.first, 'a', '« Previous' - assert_select elements.last, 'a', 'Next »' - end - assert_select 'span.current', '6' - assert_equal '« Previous 1 2 … 5 6 7 … 10 11 Next »', pagination.first.inner_text - end - end - - def test_will_paginate_eliminates_small_gaps - paginate({ :page => 6, :per_page => 1 }, :inner_window => 2) do - assert_select 'a[href]', 12 do |elements| - validate_page_numbers [5,1,2,3,4,5,7,8,9,10,11,7], elements - end - end - end - - def test_container_id - paginate do |div| - assert_nil div.first['id'] - end - - # magic ID - paginate({}, :id => true) do |div| - assert_equal 'fixnums_pagination', div.first['id'] - end - - # explicit ID - paginate({}, :id => 'custom_id') do |div| - assert_equal 'custom_id', div.first['id'] - end - end - - ## other helpers ## - - def test_paginated_section - @template = <<-ERB - <% paginated_section collection, options do %> - <%= content_tag :div, '', :id => "developers" %> - <% end %> - ERB - - paginate - assert_select 'div.pagination', 2 - assert_select 'div.pagination + div#developers', 1 - end - - def test_page_entries_info - @template = '<%= page_entries_info collection %>' - array = ('a'..'z').to_a - - paginate array.paginate(:page => 2, :per_page => 5) - assert_equal %{Displaying strings 6 - 10 of 26 in total}, - @html_result - - paginate array.paginate(:page => 7, :per_page => 4) - assert_equal %{Displaying strings 25 - 26 of 26 in total}, - @html_result - end - - def test_page_entries_info_with_longer_class_name - @template = '<%= page_entries_info collection %>' - collection = ('a'..'z').to_a.paginate - collection.first.stubs(:class).returns(mock('class', :name => 'ProjectType')) - - paginate collection - assert @html_result.index('project types'), "expected <#{@html_result.inspect}> to mention 'project types'" - end - - def test_page_entries_info_with_single_page_collection - @template = '<%= page_entries_info collection %>' - - paginate(('a'..'d').to_a.paginate(:page => 1, :per_page => 5)) - assert_equal %{Displaying all 4 strings}, @html_result - - paginate(['a'].paginate(:page => 1, :per_page => 5)) - assert_equal %{Displaying 1 string}, @html_result - - paginate([].paginate(:page => 1, :per_page => 5)) - assert_equal %{No entries found}, @html_result - end - - def test_page_entries_info_with_custom_entry_name - @template = '<%= page_entries_info collection, :entry_name => "author" %>' - - entries = (1..20).to_a - - paginate(entries.paginate(:page => 1, :per_page => 5)) - assert_equal %{Displaying authors 1 - 5 of 20 in total}, @html_result - - paginate(entries.paginate(:page => 1, :per_page => 20)) - assert_equal %{Displaying all 20 authors}, @html_result - - paginate(['a'].paginate(:page => 1, :per_page => 5)) - assert_equal %{Displaying 1 author}, @html_result - - paginate([].paginate(:page => 1, :per_page => 5)) - assert_equal %{No authors found}, @html_result - end - - ## parameter handling in page links ## - - def test_will_paginate_preserves_parameters_on_get - @request.params :foo => { :bar => 'baz' } - paginate - assert_links_match /foo%5Bbar%5D=baz/ - end - - def test_will_paginate_doesnt_preserve_parameters_on_post - @request.post - @request.params :foo => 'bar' - paginate - assert_no_links_match /foo=bar/ - end - - def test_adding_additional_parameters - paginate({}, :params => { :foo => 'bar' }) - assert_links_match /foo=bar/ - end - - def test_adding_anchor_parameter - paginate({}, :params => { :anchor => 'anchor' }) - assert_links_match /#anchor$/ - end - - def test_removing_arbitrary_parameters - @request.params :foo => 'bar' - paginate({}, :params => { :foo => nil }) - assert_no_links_match /foo=bar/ - end - - def test_adding_additional_route_parameters - paginate({}, :params => { :controller => 'baz', :action => 'list' }) - assert_links_match %r{\Wbaz/list\W} - end - - def test_will_paginate_with_custom_page_param - paginate({ :page => 2 }, :param_name => :developers_page) do - assert_select 'a[href]', 4 do |elements| - validate_page_numbers [1,1,3,3], elements, :developers_page - end - end - end - - def test_complex_custom_page_param - @request.params :developers => { :page => 2 } - - paginate({ :page => 2 }, :param_name => 'developers[page]') do - assert_select 'a[href]', 4 do |links| - assert_links_match /\?developers%5Bpage%5D=\d+$/, links - validate_page_numbers [1,1,3,3], links, 'developers[page]' - end - end - end - - def test_custom_routing_page_param - @request.symbolized_path_parameters.update :controller => 'dummy', :action => nil - paginate :per_page => 2 do - assert_select 'a[href]', 6 do |links| - assert_links_match %r{/page/(\d+)$}, links, [2, 3, 4, 5, 6, 2] - end - end - end - - def test_custom_routing_page_param_with_dot_separator - @request.symbolized_path_parameters.update :controller => 'dummy', :action => 'dots' - paginate :per_page => 2 do - assert_select 'a[href]', 6 do |links| - assert_links_match %r{/page\.(\d+)$}, links, [2, 3, 4, 5, 6, 2] - end - end - end - - def test_custom_routing_with_first_page_hidden - @request.symbolized_path_parameters.update :controller => 'ibocorp', :action => nil - paginate :page => 2, :per_page => 2 do - assert_select 'a[href]', 7 do |links| - assert_links_match %r{/ibocorp(?:/(\d+))?$}, links, [nil, nil, 3, 4, 5, 6, 3] - end - end - end - - ## internal hardcore stuff ## - - class LegacyCollection < WillPaginate::Collection - alias :page_count :total_pages - undef :total_pages - end - - def test_deprecation_notices_with_page_count - collection = LegacyCollection.new(1, 1, 2) - - assert_deprecated collection.class.name do - paginate collection - end - end - - uses_mocha 'view internals' do - def test_collection_name_can_be_guessed - collection = mock - collection.expects(:total_pages).returns(1) - - @template = '<%= will_paginate options %>' - @controller.controller_name = 'developers' - @view.assigns['developers'] = collection - - paginate(nil) - end - end - - def test_inferred_collection_name_raises_error_when_nil - @template = '<%= will_paginate options %>' - @controller.controller_name = 'developers' - - e = assert_raise ArgumentError do - paginate(nil) - end - assert e.message.include?('@developers') - end - - if ActionController::Base.respond_to? :rescue_responses - # only on Rails 2 - def test_rescue_response_hook_presence - assert_equal :not_found, - ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] - end - end - -end diff --git a/vendor/plugins/will_paginate/will_paginate.gemspec b/vendor/plugins/will_paginate/will_paginate.gemspec deleted file mode 100644 index 92e00978..00000000 --- a/vendor/plugins/will_paginate/will_paginate.gemspec +++ /dev/null @@ -1,21 +0,0 @@ -Gem::Specification.new do |s| - s.name = 'will_paginate' - s.version = '2.3.2' - s.date = '2008-05-16' - - s.summary = "Most awesome pagination solution for Rails" - s.description = "The will_paginate library provides a simple, yet powerful and extensible API for ActiveRecord pagination and rendering of pagination links in ActionView templates." - - s.authors = ['Mislav Marohnić', 'PJ Hyett'] - s.email = 'mislav.marohnic@gmail.com' - s.homepage = 'http://github.com/mislav/will_paginate/wikis' - - s.has_rdoc = true - s.rdoc_options = ['--main', 'README.rdoc'] - s.rdoc_options << '--inline-source' << '--charset=UTF-8' - s.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'CHANGELOG'] - s.add_dependency 'activesupport', ['>= 1.4.4'] - - s.files = %w(CHANGELOG LICENSE README.rdoc Rakefile examples examples/apple-circle.gif examples/index.haml examples/index.html examples/pagination.css examples/pagination.sass init.rb lib lib/will_paginate lib/will_paginate.rb lib/will_paginate/array.rb lib/will_paginate/collection.rb lib/will_paginate/core_ext.rb lib/will_paginate/finder.rb lib/will_paginate/named_scope.rb lib/will_paginate/named_scope_patch.rb lib/will_paginate/version.rb lib/will_paginate/view_helpers.rb test test/boot.rb test/collection_test.rb test/console test/database.yml test/finder_test.rb test/fixtures test/fixtures/admin.rb test/fixtures/developer.rb test/fixtures/developers_projects.yml test/fixtures/project.rb test/fixtures/projects.yml test/fixtures/replies.yml test/fixtures/reply.rb test/fixtures/schema.rb test/fixtures/topic.rb test/fixtures/topics.yml test/fixtures/user.rb test/fixtures/users.yml test/helper.rb test/lib test/lib/activerecord_test_case.rb test/lib/activerecord_test_connector.rb test/lib/load_fixtures.rb test/lib/view_test_process.rb test/tasks.rake test/view_test.rb) - s.test_files = %w(test/boot.rb test/collection_test.rb test/console test/database.yml test/finder_test.rb test/fixtures test/fixtures/admin.rb test/fixtures/developer.rb test/fixtures/developers_projects.yml test/fixtures/project.rb test/fixtures/projects.yml test/fixtures/replies.yml test/fixtures/reply.rb test/fixtures/schema.rb test/fixtures/topic.rb test/fixtures/topics.yml test/fixtures/user.rb test/fixtures/users.yml test/helper.rb test/lib test/lib/activerecord_test_case.rb test/lib/activerecord_test_connector.rb test/lib/load_fixtures.rb test/lib/view_test_process.rb test/tasks.rake test/view_test.rb) -end