akamai_bookmarklet 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/nokogiri +3 -0
- data/bin/rackup +3 -0
- data/config.ru +6 -0
- data/lib/akamai_bookmarklet.rb +2 -0
- data/lib/application/application.rb +34 -0
- data/lib/application/views/bookmarklet.html.erb +22 -0
- data/lib/application/views/purge.js.erb +32 -0
- data/test/helper.rb +10 -0
- data/test/test_akamai_bookmarklet.rb +7 -0
- data/vendor/gems/environment.rb +4 -0
- data/vendor/gems/ruby/1.8/cache/akamai-0.0.1.gem +0 -0
- data/vendor/gems/ruby/1.8/cache/casrack_the_authenticator-1.6.0.gem +0 -0
- data/vendor/gems/ruby/1.8/cache/nokogiri-1.3.3.gem +0 -0
- data/vendor/gems/ruby/1.8/cache/rack-1.1.0.gem +0 -0
- data/vendor/gems/ruby/1.8/cache/sinatra-0.9.4.gem +0 -0
- data/vendor/gems/ruby/1.8/environment.rb +112 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/.document +5 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/.gitignore +21 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/LICENSE +20 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/README.rdoc +17 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/Rakefile +53 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/VERSION +1 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/lib/akamai.rb +54 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/test/helper.rb +10 -0
- data/vendor/gems/ruby/1.8/gems/akamai-0.0.1/test/test_akamai.rb +7 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/.gitignore +3 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/README.rdoc +87 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/Rakefile +7 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/VERSION +1 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/casrack_the_authenticator.gemspec +83 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/developer_tasks/doc.rake +22 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/developer_tasks/gem.rake +20 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/developer_tasks/test.rake +24 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/features/fake.feature +34 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/features/require_cas.feature +19 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/features/simple.feature +32 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/features/step_definitions/fake_cas_steps.rb +14 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/features/step_definitions/rack_steps.rb +69 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/features/support/assertions.rb +3 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/features/support/rack_support.rb +89 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/lib/casrack_the_authenticator/configuration.rb +88 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/lib/casrack_the_authenticator/fake.rb +49 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/lib/casrack_the_authenticator/require_cas.rb +36 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/lib/casrack_the_authenticator/service_ticket_validator.rb +55 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/lib/casrack_the_authenticator/simple.rb +82 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/lib/casrack_the_authenticator.rb +11 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/test/configuration_test.rb +83 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/test/fake_test.rb +94 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/test/service_ticket_validator_test.rb +85 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/test/simple_test.rb +131 -0
- data/vendor/gems/ruby/1.8/gems/casrack_the_authenticator-1.6.0/test/test_helper.rb +16 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/.autotest +27 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/.require_paths +3 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/CHANGELOG.ja.rdoc +285 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/CHANGELOG.rdoc +272 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/Manifest.txt +254 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/README.ja.rdoc +107 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/README.rdoc +121 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/Rakefile +208 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/bin/nokogiri +47 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/Makefile +150 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/conftest.dSYM/Contents/Info.plist +25 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/conftest.dSYM/Contents/Resources/DWARF/conftest +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/extconf.rb +161 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_document.c +181 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_document.h +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_document.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_element_description.c +272 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_element_description.h +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_element_description.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_entity_lookup.c +30 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_entity_lookup.h +8 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_entity_lookup.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_sax_parser.c +57 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_sax_parser.h +11 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_sax_parser.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/mkmf.log +248 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/nokogiri.bundle +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/nokogiri.c +83 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/nokogiri.h +149 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/nokogiri.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_attr.c +92 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_attr.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_attr.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_cdata.c +53 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_cdata.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_cdata.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_comment.c +51 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_comment.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_comment.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_document.c +318 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_document.h +24 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_document.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_document_fragment.c +48 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_document_fragment.h +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_document_fragment.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_dtd.c +135 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_dtd.h +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_dtd.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_entity_reference.c +50 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_entity_reference.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_entity_reference.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_io.c +24 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_io.h +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_io.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_namespace.c +74 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_namespace.h +12 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_namespace.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_node.c +955 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_node.h +14 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_node.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_node_set.c +390 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_node_set.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_node_set.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_processing_instruction.c +54 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_processing_instruction.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_reader.c +565 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_reader.h +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_reader.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_relax_ng.c +159 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_relax_ng.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_relax_ng.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_sax_parser.c +345 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_sax_parser.h +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_sax_parser.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_sax_push_parser.c +86 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_sax_push_parser.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_schema.c +156 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_schema.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_schema.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_syntax_error.c +210 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_syntax_error.h +13 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_syntax_error.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_text.c +47 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_text.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_text.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_xpath.c +53 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_xpath.h +11 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_xpath.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_xpath_context.c +252 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_xpath_context.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xml_xpath_context.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xslt_stylesheet.c +131 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xslt_stylesheet.h +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/xslt_stylesheet.o +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/action-nokogiri.rb +38 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/generated_parser.rb +646 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/generated_tokenizer.rb +142 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/node.rb +107 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/parser.rb +82 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/parser.y +227 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/syntax_error.rb +7 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/tokenizer.rb +7 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/tokenizer.rex +54 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css/xpath_visitor.rb +172 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/css.rb +25 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators/hpricot/node.rb +56 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators/hpricot/node_set.rb +54 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +30 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators/hpricot.rb +3 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators/slop.rb +33 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators.rb +2 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/html/document.rb +37 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/html/element_description.rb +85 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/html/entity_lookup.rb +16 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/html/sax/parser.rb +21 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/io_callbacks.rb +40 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/libxml.rb +322 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/common_node.rb +26 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/html_elem_desc.rb +24 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/html_entity_desc.rb +13 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_alloc.rb +16 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_attr.rb +19 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_buffer.rb +16 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_document.rb +108 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_dtd.rb +26 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_node.rb +28 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_node_set.rb +53 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_notation.rb +11 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_ns.rb +15 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_relax_ng.rb +14 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_sax_handler.rb +51 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +14 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_schema.rb +13 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_syntax_error.rb +31 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_text_reader.rb +12 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_xpath_context.rb +37 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_xpath_object.rb +35 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +20 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +13 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/attr.rb +41 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/cdata.rb +19 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/comment.rb +18 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/document.rb +118 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/document_fragment.rb +26 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/dtd.rb +58 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/entity_reference.rb +19 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/namespace.rb +44 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/node.rb +404 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/node_set.rb +133 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/processing_instruction.rb +20 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/reader.rb +206 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/relax_ng.rb +85 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/sax/parser.rb +149 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/sax/push_parser.rb +38 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/schema.rb +92 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/syntax_error.rb +76 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/text.rb +18 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/xpath.rb +19 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xml/xpath_context.rb +135 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/ffi/xslt/stylesheet.rb +47 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/hpricot.rb +92 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/html/builder.rb +35 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/html/document.rb +73 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/html/document_fragment.rb +15 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/html/element_description.rb +23 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/html/entity_lookup.rb +13 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/html/sax/parser.rb +48 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/html.rb +34 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/nokogiri.bundle +0 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/syntax_error.rb +4 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/version.rb +33 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/version_warning.rb +11 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/attr.rb +9 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/builder.rb +297 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/cdata.rb +11 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/document.rb +117 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/document_fragment.rb +49 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/dtd.rb +11 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/entity_declaration.rb +11 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/fragment_handler.rb +60 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/namespace.rb +7 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/node/save_options.rb +42 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/node.rb +647 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/node_set.rb +285 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/notation.rb +6 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/parse_options.rb +85 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/processing_instruction.rb +8 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/reader.rb +66 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/relax_ng.rb +32 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/sax/document.rb +143 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/sax/legacy_handlers.rb +65 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/sax/parser.rb +108 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/sax/push_parser.rb +63 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/sax.rb +4 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/schema.rb +61 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/syntax_error.rb +34 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/xpath/syntax_error.rb +8 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/xpath.rb +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml/xpath_context.rb +16 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xml.rb +62 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xslt/stylesheet.rb +25 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/xslt.rb +48 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri.rb +116 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/xsd/xmlparser/nokogiri.rb +71 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/tasks/test.rb +100 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/css/test_nthiness.rb +159 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/css/test_parser.rb +277 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/css/test_tokenizer.rb +183 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/css/test_xpath_visitor.rb +76 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/ffi/test_document.rb +35 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/2ch.html +108 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/address_book.rlx +12 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/address_book.xml +10 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/bar/bar.xsd +4 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/dont_hurt_em_why.xml +422 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/exslt.xml +8 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/exslt.xslt +35 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/foo/foo.xsd +4 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/po.xml +32 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/po.xsd +66 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/shift_jis.xml +5 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/snuggles.xml +3 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/staff.xml +59 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/staff.xslt +32 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/tlm.html +850 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/files/valid_bar.xml +2 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/helper.rb +127 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/basic.xhtml +17 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/boingboing.html +2266 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/cy0.html +3653 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/immob.html +400 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/pace_application.html +1320 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/tenderlove.html +16 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/uswebgen.html +220 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/utf8.html +1054 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/week9.html +1723 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/files/why.xml +19 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/load_files.rb +11 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/test_alter.rb +68 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/test_builder.rb +20 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/test_parser.rb +350 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/test_paths.rb +15 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/test_preserved.rb +77 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/hpricot/test_xml.rb +30 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/html/sax/test_parser.rb +64 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/html/test_builder.rb +158 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/html/test_document.rb +368 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/html/test_document_encoding.rb +63 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/html/test_document_fragment.rb +123 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/html/test_element_description.rb +95 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/html/test_named_characters.rb +14 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/html/test_node.rb +168 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/test_convert_xpath.rb +137 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/test_css_cache.rb +45 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/test_gc.rb +15 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/test_memory_leak.rb +77 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/test_nokogiri.rb +134 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/test_reader.rb +330 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/test_xslt_transforms.rb +131 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/node/test_save_options.rb +20 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/node/test_subclass.rb +44 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/sax/test_parser.rb +246 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/sax/test_push_parser.rb +96 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_attr.rb +38 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_builder.rb +73 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_cdata.rb +38 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_comment.rb +23 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_document.rb +466 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_document_encoding.rb +26 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_document_fragment.rb +88 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_dtd.rb +47 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_dtd_encoding.rb +31 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_entity_reference.rb +21 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_namespace.rb +48 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_node.rb +823 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_node_attributes.rb +34 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_node_encoding.rb +107 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_node_set.rb +397 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_parse_options.rb +52 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_processing_instruction.rb +30 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_reader_encoding.rb +126 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_relax_ng.rb +60 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_schema.rb +89 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_text.rb +18 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_unparented_node.rb +381 -0
- data/vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/test/xml/test_xpath.rb +106 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/COPYING +18 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/KNOWN-ISSUES +21 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/RDOX +0 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/README +399 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/SPEC +171 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/bin/rackup +4 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/contrib/rack_logo.svg +111 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/example/lobster.ru +4 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/example/protectedlobster.rb +14 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/example/protectedlobster.ru +8 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/adapter/camping.rb +22 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/auth/abstract/handler.rb +37 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/auth/abstract/request.rb +37 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/auth/basic.rb +58 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/auth/digest/md5.rb +124 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/auth/digest/nonce.rb +51 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/auth/digest/params.rb +55 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/auth/digest/request.rb +40 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/builder.rb +80 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/cascade.rb +41 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/chunked.rb +49 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/commonlogger.rb +49 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/conditionalget.rb +47 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/config.rb +15 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/content_length.rb +29 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/content_type.rb +23 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/deflater.rb +96 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/directory.rb +157 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/etag.rb +23 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/file.rb +90 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/cgi.rb +61 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/evented_mongrel.rb +8 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/fastcgi.rb +89 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/lsws.rb +63 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb +90 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/scgi.rb +62 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/swiftiplied_mongrel.rb +8 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/thin.rb +18 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb +69 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/handler.rb +88 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/head.rb +19 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/lint.rb +575 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/lobster.rb +65 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/lock.rb +16 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/logger.rb +20 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb +27 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/mime.rb +206 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/mock.rb +189 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/nulllogger.rb +18 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/recursive.rb +57 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/reloader.rb +109 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/request.rb +271 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/response.rb +149 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/rewindable_input.rb +100 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/runtime.rb +27 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/sendfile.rb +142 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/server.rb +212 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/session/abstract/id.rb +140 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/session/cookie.rb +90 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/session/memcache.rb +119 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/session/pool.rb +100 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/showexceptions.rb +349 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/showstatus.rb +106 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/static.rb +38 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb +56 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/utils.rb +620 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack.rb +92 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/rack.gemspec +38 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_auth_basic.rb +73 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_auth_digest.rb +226 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_builder.rb +84 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_camping.rb +51 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_cascade.rb +48 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_cgi.rb +89 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_chunked.rb +62 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_commonlogger.rb +61 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_conditionalget.rb +41 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_config.rb +24 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_content_length.rb +43 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_content_type.rb +30 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_deflater.rb +127 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_directory.rb +61 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_etag.rb +17 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_fastcgi.rb +89 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_file.rb +75 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_handler.rb +43 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_head.rb +30 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_lint.rb +528 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_lobster.rb +45 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_lock.rb +38 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_logger.rb +21 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_methodoverride.rb +60 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_mock.rb +243 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_mongrel.rb +189 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_nulllogger.rb +13 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_recursive.rb +77 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_request.rb +545 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_response.rb +221 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_rewindable_input.rb +118 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_runtime.rb +35 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_sendfile.rb +86 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_session_cookie.rb +73 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_session_memcache.rb +273 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_session_pool.rb +172 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_showexceptions.rb +21 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_showstatus.rb +72 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_static.rb +37 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_thin.rb +91 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_urlmap.rb +215 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_utils.rb +552 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_webrick.rb +130 -0
- data/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rackup.rb +154 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/AUTHORS +41 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/CHANGES +385 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/LICENSE +22 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/README.rdoc +573 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/Rakefile +138 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/app_test.rb +282 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/application_test.rb +262 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/builder_test.rb +101 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/compat_test.rb +12 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/custom_error_test.rb +62 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/erb_test.rb +136 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/events_test.rb +78 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/filter_test.rb +30 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/haml_test.rb +236 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/helper.rb +33 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/mapped_error_test.rb +72 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/pipeline_test.rb +45 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/public/foo.xml +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/sass_test.rb +67 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/sessions_test.rb +42 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/streaming_test.rb +133 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/sym_params_test.rb +19 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/template_test.rb +30 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/use_in_file_templates_test.rb +47 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/foo.builder +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/foo.erb +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/foo.haml +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/foo.sass +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/foo_layout.erb +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/foo_layout.haml +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/layout_test/foo.builder +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/layout_test/foo.erb +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/layout_test/foo.haml +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/layout_test/foo.sass +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/layout_test/layout.builder +3 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/layout_test/layout.erb +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/layout_test/layout.haml +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/layout_test/layout.sass +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/no_layout/no_layout.builder +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/views/no_layout/no_layout.haml +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/base.rb +1119 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/compat.rb +266 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/images/404.png +0 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/images/500.png +0 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/main.rb +35 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/showexceptions.rb +303 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/test/bacon.rb +19 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/test/rspec.rb +13 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/test/spec.rb +11 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/test/unit.rb +13 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra/test.rb +128 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/lib/sinatra.rb +8 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/sinatra.gemspec +125 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/base_test.rb +160 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/builder_test.rb +65 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/contest.rb +64 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/data/reload_app_file.rb +3 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/erb_test.rb +81 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/extensions_test.rb +100 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/filter_test.rb +99 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/haml_test.rb +90 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/helper.rb +76 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/helpers_test.rb +503 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/mapped_error_test.rb +155 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/middleware_test.rb +68 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/options_test.rb +372 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/render_backtrace_test.rb +145 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/request_test.rb +18 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/response_test.rb +42 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/result_test.rb +98 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/route_added_hook_test.rb +59 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/routing_test.rb +784 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/sass_test.rb +79 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/server_test.rb +47 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/sinatra_test.rb +13 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/static_test.rb +80 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/templates_test.rb +122 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/test_test.rb +152 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/error.builder +3 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/error.erb +3 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/error.haml +3 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/error.sass +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/foo/hello.test +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/hello.builder +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/hello.erb +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/hello.haml +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/hello.sass +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/hello.test +1 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/layout2.builder +3 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/layout2.erb +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/layout2.haml +2 -0
- data/vendor/gems/ruby/1.8/gems/sinatra-0.9.4/test/views/layout2.test +1 -0
- data/vendor/gems/ruby/1.8/specifications/akamai-0.0.1.gemspec +33 -0
- data/vendor/gems/ruby/1.8/specifications/casrack_the_authenticator-1.6.0.gemspec +45 -0
- data/vendor/gems/ruby/1.8/specifications/nokogiri-1.3.3.gemspec +50 -0
- data/vendor/gems/ruby/1.8/specifications/rack-1.1.0.gemspec +57 -0
- data/vendor/gems/ruby/1.8/specifications/sinatra-0.9.4.gemspec +40 -0
- metadata +621 -0
@@ -0,0 +1,1119 @@
|
|
1
|
+
require 'thread'
|
2
|
+
require 'time'
|
3
|
+
require 'uri'
|
4
|
+
require 'rack'
|
5
|
+
require 'rack/builder'
|
6
|
+
require 'sinatra/showexceptions'
|
7
|
+
|
8
|
+
module Sinatra
|
9
|
+
VERSION = '0.9.4'
|
10
|
+
|
11
|
+
# The request object. See Rack::Request for more info:
|
12
|
+
# http://rack.rubyforge.org/doc/classes/Rack/Request.html
|
13
|
+
class Request < Rack::Request
|
14
|
+
def user_agent
|
15
|
+
@env['HTTP_USER_AGENT']
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns an array of acceptable media types for the response
|
19
|
+
def accept
|
20
|
+
@env['HTTP_ACCEPT'].to_s.split(',').map { |a| a.strip }
|
21
|
+
end
|
22
|
+
|
23
|
+
# Override Rack 0.9.x's #params implementation (see #72 in lighthouse)
|
24
|
+
def params
|
25
|
+
self.GET.update(self.POST)
|
26
|
+
rescue EOFError, Errno::ESPIPE
|
27
|
+
self.GET
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# The response object. See Rack::Response and Rack::ResponseHelpers for
|
32
|
+
# more info:
|
33
|
+
# http://rack.rubyforge.org/doc/classes/Rack/Response.html
|
34
|
+
# http://rack.rubyforge.org/doc/classes/Rack/Response/Helpers.html
|
35
|
+
class Response < Rack::Response
|
36
|
+
def finish
|
37
|
+
@body = block if block_given?
|
38
|
+
if [204, 304].include?(status.to_i)
|
39
|
+
header.delete "Content-Type"
|
40
|
+
[status.to_i, header.to_hash, []]
|
41
|
+
else
|
42
|
+
body = @body || []
|
43
|
+
body = [body] if body.respond_to? :to_str
|
44
|
+
if body.respond_to?(:to_ary)
|
45
|
+
header["Content-Length"] = body.to_ary.
|
46
|
+
inject(0) { |len, part| len + part.bytesize }.to_s
|
47
|
+
end
|
48
|
+
[status.to_i, header.to_hash, body]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class NotFound < NameError #:nodoc:
|
54
|
+
def code ; 404 ; end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Methods available to routes, before filters, and views.
|
58
|
+
module Helpers
|
59
|
+
# Set or retrieve the response status code.
|
60
|
+
def status(value=nil)
|
61
|
+
response.status = value if value
|
62
|
+
response.status
|
63
|
+
end
|
64
|
+
|
65
|
+
# Set or retrieve the response body. When a block is given,
|
66
|
+
# evaluation is deferred until the body is read with #each.
|
67
|
+
def body(value=nil, &block)
|
68
|
+
if block_given?
|
69
|
+
def block.each ; yield call ; end
|
70
|
+
response.body = block
|
71
|
+
else
|
72
|
+
response.body = value
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Halt processing and redirect to the URI provided.
|
77
|
+
def redirect(uri, *args)
|
78
|
+
status 302
|
79
|
+
response['Location'] = uri
|
80
|
+
halt(*args)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Halt processing and return the error status provided.
|
84
|
+
def error(code, body=nil)
|
85
|
+
code, body = 500, code.to_str if code.respond_to? :to_str
|
86
|
+
response.body = body unless body.nil?
|
87
|
+
halt code
|
88
|
+
end
|
89
|
+
|
90
|
+
# Halt processing and return a 404 Not Found.
|
91
|
+
def not_found(body=nil)
|
92
|
+
error 404, body
|
93
|
+
end
|
94
|
+
|
95
|
+
# Set multiple response headers with Hash.
|
96
|
+
def headers(hash=nil)
|
97
|
+
response.headers.merge! hash if hash
|
98
|
+
response.headers
|
99
|
+
end
|
100
|
+
|
101
|
+
# Access the underlying Rack session.
|
102
|
+
def session
|
103
|
+
env['rack.session'] ||= {}
|
104
|
+
end
|
105
|
+
|
106
|
+
# Look up a media type by file extension in Rack's mime registry.
|
107
|
+
def media_type(type)
|
108
|
+
Base.media_type(type)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Set the Content-Type of the response body given a media type or file
|
112
|
+
# extension.
|
113
|
+
def content_type(type, params={})
|
114
|
+
media_type = self.media_type(type)
|
115
|
+
fail "Unknown media type: %p" % type if media_type.nil?
|
116
|
+
if params.any?
|
117
|
+
params = params.collect { |kv| "%s=%s" % kv }.join(', ')
|
118
|
+
response['Content-Type'] = [media_type, params].join(";")
|
119
|
+
else
|
120
|
+
response['Content-Type'] = media_type
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Set the Content-Disposition to "attachment" with the specified filename,
|
125
|
+
# instructing the user agents to prompt to save.
|
126
|
+
def attachment(filename=nil)
|
127
|
+
response['Content-Disposition'] = 'attachment'
|
128
|
+
if filename
|
129
|
+
params = '; filename="%s"' % File.basename(filename)
|
130
|
+
response['Content-Disposition'] << params
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Use the contents of the file at +path+ as the response body.
|
135
|
+
def send_file(path, opts={})
|
136
|
+
stat = File.stat(path)
|
137
|
+
last_modified stat.mtime
|
138
|
+
|
139
|
+
content_type media_type(opts[:type]) ||
|
140
|
+
media_type(File.extname(path)) ||
|
141
|
+
response['Content-Type'] ||
|
142
|
+
'application/octet-stream'
|
143
|
+
|
144
|
+
response['Content-Length'] ||= (opts[:length] || stat.size).to_s
|
145
|
+
|
146
|
+
if opts[:disposition] == 'attachment' || opts[:filename]
|
147
|
+
attachment opts[:filename] || path
|
148
|
+
elsif opts[:disposition] == 'inline'
|
149
|
+
response['Content-Disposition'] = 'inline'
|
150
|
+
end
|
151
|
+
|
152
|
+
halt StaticFile.open(path, 'rb')
|
153
|
+
rescue Errno::ENOENT
|
154
|
+
not_found
|
155
|
+
end
|
156
|
+
|
157
|
+
# Rack response body used to deliver static files. The file contents are
|
158
|
+
# generated iteratively in 8K chunks.
|
159
|
+
class StaticFile < ::File #:nodoc:
|
160
|
+
alias_method :to_path, :path
|
161
|
+
def each
|
162
|
+
rewind
|
163
|
+
while buf = read(8192)
|
164
|
+
yield buf
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Set the last modified time of the resource (HTTP 'Last-Modified' header)
|
170
|
+
# and halt if conditional GET matches. The +time+ argument is a Time,
|
171
|
+
# DateTime, or other object that responds to +to_time+.
|
172
|
+
#
|
173
|
+
# When the current request includes an 'If-Modified-Since' header that
|
174
|
+
# matches the time specified, execution is immediately halted with a
|
175
|
+
# '304 Not Modified' response.
|
176
|
+
def last_modified(time)
|
177
|
+
time = time.to_time if time.respond_to?(:to_time)
|
178
|
+
time = time.httpdate if time.respond_to?(:httpdate)
|
179
|
+
response['Last-Modified'] = time
|
180
|
+
halt 304 if time == request.env['HTTP_IF_MODIFIED_SINCE']
|
181
|
+
time
|
182
|
+
end
|
183
|
+
|
184
|
+
# Set the response entity tag (HTTP 'ETag' header) and halt if conditional
|
185
|
+
# GET matches. The +value+ argument is an identifier that uniquely
|
186
|
+
# identifies the current version of the resource. The +strength+ argument
|
187
|
+
# indicates whether the etag should be used as a :strong (default) or :weak
|
188
|
+
# cache validator.
|
189
|
+
#
|
190
|
+
# When the current request includes an 'If-None-Match' header with a
|
191
|
+
# matching etag, execution is immediately halted. If the request method is
|
192
|
+
# GET or HEAD, a '304 Not Modified' response is sent.
|
193
|
+
def etag(value, kind=:strong)
|
194
|
+
raise TypeError, ":strong or :weak expected" if ![:strong,:weak].include?(kind)
|
195
|
+
value = '"%s"' % value
|
196
|
+
value = 'W/' + value if kind == :weak
|
197
|
+
response['ETag'] = value
|
198
|
+
|
199
|
+
# Conditional GET check
|
200
|
+
if etags = env['HTTP_IF_NONE_MATCH']
|
201
|
+
etags = etags.split(/\s*,\s*/)
|
202
|
+
halt 304 if etags.include?(value) || etags.include?('*')
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
## Sugar for redirect (example: redirect back)
|
207
|
+
def back ; request.referer ; end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
# Template rendering methods. Each method takes a the name of a template
|
212
|
+
# to render as a Symbol and returns a String with the rendered output,
|
213
|
+
# as well as an optional hash with additional options.
|
214
|
+
#
|
215
|
+
# `template` is either the name or path of the template as symbol
|
216
|
+
# (Use `:'subdir/myview'` for views in subdirectories), or a string
|
217
|
+
# that will be rendered.
|
218
|
+
#
|
219
|
+
# Possible options are:
|
220
|
+
# :layout If set to false, no layout is rendered, otherwise
|
221
|
+
# the specified layout is used (Ignored for `sass`)
|
222
|
+
# :locals A hash with local variables that should be available
|
223
|
+
# in the template
|
224
|
+
module Templates
|
225
|
+
def erb(template, options={}, locals={})
|
226
|
+
require_warn('ERB') unless defined?(::ERB)
|
227
|
+
|
228
|
+
render :erb, template, options, locals
|
229
|
+
end
|
230
|
+
|
231
|
+
def haml(template, options={}, locals={})
|
232
|
+
require_warn('Haml') unless defined?(::Haml::Engine)
|
233
|
+
|
234
|
+
render :haml, template, options, locals
|
235
|
+
end
|
236
|
+
|
237
|
+
def sass(template, options={}, locals={})
|
238
|
+
require_warn('Sass') unless defined?(::Sass::Engine)
|
239
|
+
|
240
|
+
options[:layout] = false
|
241
|
+
render :sass, template, options, locals
|
242
|
+
end
|
243
|
+
|
244
|
+
def builder(template=nil, options={}, locals={}, &block)
|
245
|
+
require_warn('Builder') unless defined?(::Builder)
|
246
|
+
|
247
|
+
options, template = template, nil if template.is_a?(Hash)
|
248
|
+
template = lambda { block } if template.nil?
|
249
|
+
render :builder, template, options, locals
|
250
|
+
end
|
251
|
+
|
252
|
+
private
|
253
|
+
def render(engine, template, options={}, locals={})
|
254
|
+
# merge app-level options
|
255
|
+
options = self.class.send(engine).merge(options) if self.class.respond_to?(engine)
|
256
|
+
|
257
|
+
# extract generic options
|
258
|
+
layout = options.delete(:layout)
|
259
|
+
layout = :layout if layout.nil? || layout == true
|
260
|
+
views = options.delete(:views) || self.class.views || "./views"
|
261
|
+
locals = options.delete(:locals) || locals || {}
|
262
|
+
|
263
|
+
# render template
|
264
|
+
data, options[:filename], options[:line] = lookup_template(engine, template, views)
|
265
|
+
output = __send__("render_#{engine}", template, data, options, locals)
|
266
|
+
|
267
|
+
# render layout
|
268
|
+
if layout
|
269
|
+
data, options[:filename], options[:line] = lookup_layout(engine, layout, views)
|
270
|
+
if data
|
271
|
+
output = __send__("render_#{engine}", layout, data, options, locals) { output }
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
output
|
276
|
+
end
|
277
|
+
|
278
|
+
def lookup_template(engine, template, views_dir, filename = nil, line = nil)
|
279
|
+
case template
|
280
|
+
when Symbol
|
281
|
+
if cached = self.class.templates[template]
|
282
|
+
lookup_template(engine, cached[:template], views_dir, cached[:filename], cached[:line])
|
283
|
+
else
|
284
|
+
path = ::File.join(views_dir, "#{template}.#{engine}")
|
285
|
+
[ ::File.read(path), path, 1 ]
|
286
|
+
end
|
287
|
+
when Proc
|
288
|
+
filename, line = self.class.caller_locations.first if filename.nil?
|
289
|
+
[ template.call, filename, line.to_i ]
|
290
|
+
when String
|
291
|
+
filename, line = self.class.caller_locations.first if filename.nil?
|
292
|
+
[ template, filename, line.to_i ]
|
293
|
+
else
|
294
|
+
raise ArgumentError
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
def lookup_layout(engine, template, views_dir)
|
299
|
+
lookup_template(engine, template, views_dir)
|
300
|
+
rescue Errno::ENOENT
|
301
|
+
nil
|
302
|
+
end
|
303
|
+
|
304
|
+
def render_erb(template, data, options, locals, &block)
|
305
|
+
original_out_buf = defined?(@_out_buf) && @_out_buf
|
306
|
+
data = data.call if data.kind_of? Proc
|
307
|
+
|
308
|
+
instance = ::ERB.new(data, nil, nil, '@_out_buf')
|
309
|
+
locals_assigns = locals.to_a.collect { |k,v| "#{k} = locals[:#{k}]" }
|
310
|
+
|
311
|
+
filename = options.delete(:filename) || '(__ERB__)'
|
312
|
+
line = options.delete(:line) || 1
|
313
|
+
line -= 1 if instance.src =~ /^#coding:/
|
314
|
+
|
315
|
+
render_binding = binding
|
316
|
+
eval locals_assigns.join("\n"), render_binding
|
317
|
+
eval instance.src, render_binding, filename, line
|
318
|
+
@_out_buf, result = original_out_buf, @_out_buf
|
319
|
+
result
|
320
|
+
end
|
321
|
+
|
322
|
+
def render_haml(template, data, options, locals, &block)
|
323
|
+
::Haml::Engine.new(data, options).render(self, locals, &block)
|
324
|
+
end
|
325
|
+
|
326
|
+
def render_sass(template, data, options, locals, &block)
|
327
|
+
::Sass::Engine.new(data, options).render
|
328
|
+
end
|
329
|
+
|
330
|
+
def render_builder(template, data, options, locals, &block)
|
331
|
+
options = { :indent => 2 }.merge(options)
|
332
|
+
filename = options.delete(:filename) || '<BUILDER>'
|
333
|
+
line = options.delete(:line) || 1
|
334
|
+
xml = ::Builder::XmlMarkup.new(options)
|
335
|
+
if data.respond_to?(:to_str)
|
336
|
+
eval data.to_str, binding, filename, line
|
337
|
+
elsif data.kind_of?(Proc)
|
338
|
+
data.call(xml)
|
339
|
+
end
|
340
|
+
xml.target!
|
341
|
+
end
|
342
|
+
|
343
|
+
def require_warn(engine)
|
344
|
+
warn "Auto-require of #{engine} is deprecated; add require '#{engine}' to your app."
|
345
|
+
require engine.downcase
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
# Base class for all Sinatra applications and middleware.
|
350
|
+
class Base
|
351
|
+
include Rack::Utils
|
352
|
+
include Helpers
|
353
|
+
include Templates
|
354
|
+
|
355
|
+
attr_accessor :app
|
356
|
+
|
357
|
+
def initialize(app=nil)
|
358
|
+
@app = app
|
359
|
+
yield self if block_given?
|
360
|
+
end
|
361
|
+
|
362
|
+
# Rack call interface.
|
363
|
+
def call(env)
|
364
|
+
dup.call!(env)
|
365
|
+
end
|
366
|
+
|
367
|
+
attr_accessor :env, :request, :response, :params
|
368
|
+
|
369
|
+
def call!(env)
|
370
|
+
@env = env
|
371
|
+
@request = Request.new(env)
|
372
|
+
@response = Response.new
|
373
|
+
@params = nil
|
374
|
+
|
375
|
+
invoke { dispatch! }
|
376
|
+
invoke { error_block!(response.status) }
|
377
|
+
|
378
|
+
status, header, body = @response.finish
|
379
|
+
|
380
|
+
# Never produce a body on HEAD requests. Do retain the Content-Length
|
381
|
+
# unless it's "0", in which case we assume it was calculated erroneously
|
382
|
+
# for a manual HEAD response and remove it entirely.
|
383
|
+
if @env['REQUEST_METHOD'] == 'HEAD'
|
384
|
+
body = []
|
385
|
+
header.delete('Content-Length') if header['Content-Length'] == '0'
|
386
|
+
end
|
387
|
+
|
388
|
+
[status, header, body]
|
389
|
+
end
|
390
|
+
|
391
|
+
# Access options defined with Base.set.
|
392
|
+
def options
|
393
|
+
self.class
|
394
|
+
end
|
395
|
+
|
396
|
+
# Exit the current block, halts any further processing
|
397
|
+
# of the request, and returns the specified response.
|
398
|
+
def halt(*response)
|
399
|
+
response = response.first if response.length == 1
|
400
|
+
throw :halt, response
|
401
|
+
end
|
402
|
+
|
403
|
+
# Pass control to the next matching route.
|
404
|
+
# If there are no more matching routes, Sinatra will
|
405
|
+
# return a 404 response.
|
406
|
+
def pass
|
407
|
+
throw :pass
|
408
|
+
end
|
409
|
+
|
410
|
+
# Forward the request to the downstream app -- middleware only.
|
411
|
+
def forward
|
412
|
+
fail "downstream app not set" unless @app.respond_to? :call
|
413
|
+
status, headers, body = @app.call(@request.env)
|
414
|
+
@response.status = status
|
415
|
+
@response.body = body
|
416
|
+
@response.headers.merge! headers
|
417
|
+
nil
|
418
|
+
end
|
419
|
+
|
420
|
+
private
|
421
|
+
# Run before filters and then locate and run a matching route.
|
422
|
+
def route!
|
423
|
+
# enable nested params in Rack < 1.0; allow indifferent access
|
424
|
+
@params =
|
425
|
+
if Rack::Utils.respond_to?(:parse_nested_query)
|
426
|
+
indifferent_params(@request.params)
|
427
|
+
else
|
428
|
+
nested_params(@request.params)
|
429
|
+
end
|
430
|
+
|
431
|
+
# before filters
|
432
|
+
self.class.filters.each { |block| instance_eval(&block) }
|
433
|
+
|
434
|
+
# routes
|
435
|
+
if routes = self.class.routes[@request.request_method]
|
436
|
+
original_params = @params
|
437
|
+
path = unescape(@request.path_info)
|
438
|
+
|
439
|
+
routes.each do |pattern, keys, conditions, block|
|
440
|
+
if match = pattern.match(path)
|
441
|
+
values = match.captures.to_a
|
442
|
+
params =
|
443
|
+
if keys.any?
|
444
|
+
keys.zip(values).inject({}) do |hash,(k,v)|
|
445
|
+
if k == 'splat'
|
446
|
+
(hash[k] ||= []) << v
|
447
|
+
else
|
448
|
+
hash[k] = v
|
449
|
+
end
|
450
|
+
hash
|
451
|
+
end
|
452
|
+
elsif values.any?
|
453
|
+
{'captures' => values}
|
454
|
+
else
|
455
|
+
{}
|
456
|
+
end
|
457
|
+
@params = original_params.merge(params)
|
458
|
+
@block_params = values
|
459
|
+
|
460
|
+
catch(:pass) do
|
461
|
+
conditions.each { |cond|
|
462
|
+
throw :pass if instance_eval(&cond) == false }
|
463
|
+
route_eval(&block)
|
464
|
+
end
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
route_missing
|
470
|
+
end
|
471
|
+
|
472
|
+
# Run a route block and throw :halt with the result.
|
473
|
+
def route_eval(&block)
|
474
|
+
throw :halt, instance_eval(&block)
|
475
|
+
end
|
476
|
+
|
477
|
+
# No matching route was found or all routes passed. The default
|
478
|
+
# implementation is to forward the request downstream when running
|
479
|
+
# as middleware (@app is non-nil); when no downstream app is set, raise
|
480
|
+
# a NotFound exception. Subclasses can override this method to perform
|
481
|
+
# custom route miss logic.
|
482
|
+
def route_missing
|
483
|
+
if @app
|
484
|
+
forward
|
485
|
+
else
|
486
|
+
raise NotFound
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
# Enable string or symbol key access to the nested params hash.
|
491
|
+
def indifferent_params(params)
|
492
|
+
params = indifferent_hash.merge(params)
|
493
|
+
params.each do |key, value|
|
494
|
+
next unless value.is_a?(Hash)
|
495
|
+
params[key] = indifferent_params(value)
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
# Recursively replace the params hash with a nested indifferent
|
500
|
+
# hash. Rack 1.0 has a built in implementation of this method - remove
|
501
|
+
# this once Rack 1.0 is required.
|
502
|
+
def nested_params(params)
|
503
|
+
return indifferent_hash.merge(params) if !params.keys.join.include?('[')
|
504
|
+
params.inject indifferent_hash do |res, (key,val)|
|
505
|
+
if key.include?('[')
|
506
|
+
head = key.split(/[\]\[]+/)
|
507
|
+
last = head.pop
|
508
|
+
head.inject(res){ |hash,k| hash[k] ||= indifferent_hash }[last] = val
|
509
|
+
else
|
510
|
+
res[key] = val
|
511
|
+
end
|
512
|
+
res
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
def indifferent_hash
|
517
|
+
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
|
518
|
+
end
|
519
|
+
|
520
|
+
# Run the block with 'throw :halt' support and apply result to the response.
|
521
|
+
def invoke(&block)
|
522
|
+
res = catch(:halt) { instance_eval(&block) }
|
523
|
+
return if res.nil?
|
524
|
+
|
525
|
+
case
|
526
|
+
when res.respond_to?(:to_str)
|
527
|
+
@response.body = [res]
|
528
|
+
when res.respond_to?(:to_ary)
|
529
|
+
res = res.to_ary
|
530
|
+
if Fixnum === res.first
|
531
|
+
if res.length == 3
|
532
|
+
@response.status, headers, body = res
|
533
|
+
@response.body = body if body
|
534
|
+
headers.each { |k, v| @response.headers[k] = v } if headers
|
535
|
+
elsif res.length == 2
|
536
|
+
@response.status = res.first
|
537
|
+
@response.body = res.last
|
538
|
+
else
|
539
|
+
raise TypeError, "#{res.inspect} not supported"
|
540
|
+
end
|
541
|
+
else
|
542
|
+
@response.body = res
|
543
|
+
end
|
544
|
+
when res.respond_to?(:each)
|
545
|
+
@response.body = res
|
546
|
+
when (100...599) === res
|
547
|
+
@response.status = res
|
548
|
+
end
|
549
|
+
|
550
|
+
res
|
551
|
+
end
|
552
|
+
|
553
|
+
# Dispatch a request with error handling.
|
554
|
+
def dispatch!
|
555
|
+
route!
|
556
|
+
rescue NotFound => boom
|
557
|
+
handle_not_found!(boom)
|
558
|
+
rescue ::Exception => boom
|
559
|
+
handle_exception!(boom)
|
560
|
+
end
|
561
|
+
|
562
|
+
def handle_not_found!(boom)
|
563
|
+
@env['sinatra.error'] = boom
|
564
|
+
@response.status = 404
|
565
|
+
@response.body = ['<h1>Not Found</h1>']
|
566
|
+
error_block! boom.class, NotFound
|
567
|
+
end
|
568
|
+
|
569
|
+
def handle_exception!(boom)
|
570
|
+
@env['sinatra.error'] = boom
|
571
|
+
|
572
|
+
dump_errors!(boom) if options.dump_errors?
|
573
|
+
raise boom if options.raise_errors? || options.show_exceptions?
|
574
|
+
|
575
|
+
@response.status = 500
|
576
|
+
error_block! boom.class, Exception
|
577
|
+
end
|
578
|
+
|
579
|
+
# Find an custom error block for the key(s) specified.
|
580
|
+
def error_block!(*keys)
|
581
|
+
errmap = self.class.errors
|
582
|
+
keys.each do |key|
|
583
|
+
if block = errmap[key]
|
584
|
+
res = instance_eval(&block)
|
585
|
+
return res
|
586
|
+
end
|
587
|
+
end
|
588
|
+
nil
|
589
|
+
end
|
590
|
+
|
591
|
+
def dump_errors!(boom)
|
592
|
+
backtrace = clean_backtrace(boom.backtrace)
|
593
|
+
msg = ["#{boom.class} - #{boom.message}:",
|
594
|
+
*backtrace].join("\n ")
|
595
|
+
@env['rack.errors'].write(msg)
|
596
|
+
end
|
597
|
+
|
598
|
+
def clean_backtrace(trace)
|
599
|
+
return trace unless options.clean_trace?
|
600
|
+
|
601
|
+
trace.reject { |line|
|
602
|
+
line =~ /lib\/sinatra.*\.rb/ ||
|
603
|
+
(defined?(Gem) && line.include?(Gem.dir))
|
604
|
+
}.map! { |line| line.gsub(/^\.\//, '') }
|
605
|
+
end
|
606
|
+
|
607
|
+
@routes = {}
|
608
|
+
@filters = []
|
609
|
+
@conditions = []
|
610
|
+
@templates = {}
|
611
|
+
@middleware = []
|
612
|
+
@errors = {}
|
613
|
+
@prototype = nil
|
614
|
+
@extensions = []
|
615
|
+
|
616
|
+
class << self
|
617
|
+
attr_accessor :routes, :filters, :conditions, :templates,
|
618
|
+
:middleware, :errors
|
619
|
+
|
620
|
+
# Sets an option to the given value. If the value is a proc,
|
621
|
+
# the proc will be called every time the option is accessed.
|
622
|
+
def set(option, value=self)
|
623
|
+
if value.kind_of?(Proc)
|
624
|
+
metadef(option, &value)
|
625
|
+
metadef("#{option}?") { !!__send__(option) }
|
626
|
+
metadef("#{option}=") { |val| set(option, Proc.new{val}) }
|
627
|
+
elsif value == self && option.respond_to?(:to_hash)
|
628
|
+
option.to_hash.each { |k,v| set(k, v) }
|
629
|
+
elsif respond_to?("#{option}=")
|
630
|
+
__send__ "#{option}=", value
|
631
|
+
else
|
632
|
+
set option, Proc.new{value}
|
633
|
+
end
|
634
|
+
self
|
635
|
+
end
|
636
|
+
|
637
|
+
# Same as calling `set :option, true` for each of the given options.
|
638
|
+
def enable(*opts)
|
639
|
+
opts.each { |key| set(key, true) }
|
640
|
+
end
|
641
|
+
|
642
|
+
# Same as calling `set :option, false` for each of the given options.
|
643
|
+
def disable(*opts)
|
644
|
+
opts.each { |key| set(key, false) }
|
645
|
+
end
|
646
|
+
|
647
|
+
# Define a custom error handler. Optionally takes either an Exception
|
648
|
+
# class, or an HTTP status code to specify which errors should be
|
649
|
+
# handled.
|
650
|
+
def error(codes=Exception, &block)
|
651
|
+
if codes.respond_to? :each
|
652
|
+
codes.each { |err| error(err, &block) }
|
653
|
+
else
|
654
|
+
@errors[codes] = block
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
# Sugar for `error(404) { ... }`
|
659
|
+
def not_found(&block)
|
660
|
+
error 404, &block
|
661
|
+
end
|
662
|
+
|
663
|
+
# Define a named template. The block must return the template source.
|
664
|
+
def template(name, &block)
|
665
|
+
filename, line = caller_locations.first
|
666
|
+
templates[name] = { :filename => filename, :line => line, :template => block }
|
667
|
+
end
|
668
|
+
|
669
|
+
# Define the layout template. The block must return the template source.
|
670
|
+
def layout(name=:layout, &block)
|
671
|
+
template name, &block
|
672
|
+
end
|
673
|
+
|
674
|
+
# Load embeded templates from the file; uses the caller's __FILE__
|
675
|
+
# when no file is specified.
|
676
|
+
def use_in_file_templates!(file=nil)
|
677
|
+
file ||= caller_files.first
|
678
|
+
app, data =
|
679
|
+
::IO.read(file).split(/^__END__$/, 2) rescue nil
|
680
|
+
|
681
|
+
if data
|
682
|
+
data.gsub!(/\r\n/, "\n")
|
683
|
+
lines = app.count("\n") + 1
|
684
|
+
template = nil
|
685
|
+
data.each_line do |line|
|
686
|
+
lines += 1
|
687
|
+
if line =~ /^@@\s*(.*)/
|
688
|
+
template = ''
|
689
|
+
templates[$1.to_sym] = { :filename => file, :line => lines, :template => template }
|
690
|
+
elsif template
|
691
|
+
template << line
|
692
|
+
end
|
693
|
+
end
|
694
|
+
end
|
695
|
+
end
|
696
|
+
|
697
|
+
# Look up a media type by file extension in Rack's mime registry.
|
698
|
+
def media_type(type)
|
699
|
+
return type if type.nil? || type.to_s.include?('/')
|
700
|
+
type = ".#{type}" unless type.to_s[0] == ?.
|
701
|
+
Rack::Mime.mime_type(type, nil)
|
702
|
+
end
|
703
|
+
|
704
|
+
# Define a before filter. Filters are run before all requests
|
705
|
+
# within the same context as route handlers and may access/modify the
|
706
|
+
# request and response.
|
707
|
+
def before(&block)
|
708
|
+
@filters << block
|
709
|
+
end
|
710
|
+
|
711
|
+
# Add a route condition. The route is considered non-matching when the
|
712
|
+
# block returns false.
|
713
|
+
def condition(&block)
|
714
|
+
@conditions << block
|
715
|
+
end
|
716
|
+
|
717
|
+
private
|
718
|
+
def host_name(pattern)
|
719
|
+
condition { pattern === request.host }
|
720
|
+
end
|
721
|
+
|
722
|
+
def user_agent(pattern)
|
723
|
+
condition {
|
724
|
+
if request.user_agent =~ pattern
|
725
|
+
@params[:agent] = $~[1..-1]
|
726
|
+
true
|
727
|
+
else
|
728
|
+
false
|
729
|
+
end
|
730
|
+
}
|
731
|
+
end
|
732
|
+
alias_method :agent, :user_agent
|
733
|
+
|
734
|
+
def provides(*types)
|
735
|
+
types = [types] unless types.kind_of? Array
|
736
|
+
types.map!{|t| media_type(t)}
|
737
|
+
|
738
|
+
condition {
|
739
|
+
matching_types = (request.accept & types)
|
740
|
+
unless matching_types.empty?
|
741
|
+
response.headers['Content-Type'] = matching_types.first
|
742
|
+
true
|
743
|
+
else
|
744
|
+
false
|
745
|
+
end
|
746
|
+
}
|
747
|
+
end
|
748
|
+
|
749
|
+
public
|
750
|
+
# Defining a `GET` handler also automatically defines
|
751
|
+
# a `HEAD` handler.
|
752
|
+
def get(path, opts={}, &block)
|
753
|
+
conditions = @conditions.dup
|
754
|
+
route('GET', path, opts, &block)
|
755
|
+
|
756
|
+
@conditions = conditions
|
757
|
+
route('HEAD', path, opts, &block)
|
758
|
+
end
|
759
|
+
|
760
|
+
def put(path, opts={}, &bk); route 'PUT', path, opts, &bk end
|
761
|
+
def post(path, opts={}, &bk); route 'POST', path, opts, &bk end
|
762
|
+
def delete(path, opts={}, &bk); route 'DELETE', path, opts, &bk end
|
763
|
+
def head(path, opts={}, &bk); route 'HEAD', path, opts, &bk end
|
764
|
+
|
765
|
+
private
|
766
|
+
def route(verb, path, options={}, &block)
|
767
|
+
# Because of self.options.host
|
768
|
+
host_name(options.delete(:host)) if options.key?(:host)
|
769
|
+
|
770
|
+
options.each {|option, args| send(option, *args)}
|
771
|
+
|
772
|
+
pattern, keys = compile(path)
|
773
|
+
conditions, @conditions = @conditions, []
|
774
|
+
|
775
|
+
define_method "#{verb} #{path}", &block
|
776
|
+
unbound_method = instance_method("#{verb} #{path}")
|
777
|
+
block =
|
778
|
+
if block.arity != 0
|
779
|
+
lambda { unbound_method.bind(self).call(*@block_params) }
|
780
|
+
else
|
781
|
+
lambda { unbound_method.bind(self).call }
|
782
|
+
end
|
783
|
+
|
784
|
+
invoke_hook(:route_added, verb, path, block)
|
785
|
+
|
786
|
+
(routes[verb] ||= []).
|
787
|
+
push([pattern, keys, conditions, block]).last
|
788
|
+
end
|
789
|
+
|
790
|
+
def invoke_hook(name, *args)
|
791
|
+
extensions.each { |e| e.send(name, *args) if e.respond_to?(name) }
|
792
|
+
end
|
793
|
+
|
794
|
+
def compile(path)
|
795
|
+
keys = []
|
796
|
+
if path.respond_to? :to_str
|
797
|
+
special_chars = %w{. + ( )}
|
798
|
+
pattern =
|
799
|
+
path.to_str.gsub(/((:\w+)|[\*#{special_chars.join}])/) do |match|
|
800
|
+
case match
|
801
|
+
when "*"
|
802
|
+
keys << 'splat'
|
803
|
+
"(.*?)"
|
804
|
+
when *special_chars
|
805
|
+
Regexp.escape(match)
|
806
|
+
else
|
807
|
+
keys << $2[1..-1]
|
808
|
+
"([^/?&#]+)"
|
809
|
+
end
|
810
|
+
end
|
811
|
+
[/^#{pattern}$/, keys]
|
812
|
+
elsif path.respond_to?(:keys) && path.respond_to?(:match)
|
813
|
+
[path, path.keys]
|
814
|
+
elsif path.respond_to? :match
|
815
|
+
[path, keys]
|
816
|
+
else
|
817
|
+
raise TypeError, path
|
818
|
+
end
|
819
|
+
end
|
820
|
+
|
821
|
+
public
|
822
|
+
# Makes the methods defined in the block and in the Modules given
|
823
|
+
# in `extensions` available to the handlers and templates
|
824
|
+
def helpers(*extensions, &block)
|
825
|
+
class_eval(&block) if block_given?
|
826
|
+
include(*extensions) if extensions.any?
|
827
|
+
end
|
828
|
+
|
829
|
+
def extensions
|
830
|
+
(@extensions + (superclass.extensions rescue [])).uniq
|
831
|
+
end
|
832
|
+
|
833
|
+
def register(*extensions, &block)
|
834
|
+
extensions << Module.new(&block) if block_given?
|
835
|
+
@extensions += extensions
|
836
|
+
extensions.each do |extension|
|
837
|
+
extend extension
|
838
|
+
extension.registered(self) if extension.respond_to?(:registered)
|
839
|
+
end
|
840
|
+
end
|
841
|
+
|
842
|
+
def development?; environment == :development end
|
843
|
+
def production?; environment == :production end
|
844
|
+
def test?; environment == :test end
|
845
|
+
|
846
|
+
# Set configuration options for Sinatra and/or the app.
|
847
|
+
# Allows scoping of settings for certain environments.
|
848
|
+
def configure(*envs, &block)
|
849
|
+
yield self if envs.empty? || envs.include?(environment.to_sym)
|
850
|
+
end
|
851
|
+
|
852
|
+
# Use the specified Rack middleware
|
853
|
+
def use(middleware, *args, &block)
|
854
|
+
@prototype = nil
|
855
|
+
@middleware << [middleware, args, block]
|
856
|
+
end
|
857
|
+
|
858
|
+
# Run the Sinatra app as a self-hosted server using
|
859
|
+
# Thin, Mongrel or WEBrick (in that order)
|
860
|
+
def run!(options={})
|
861
|
+
set options
|
862
|
+
handler = detect_rack_handler
|
863
|
+
handler_name = handler.name.gsub(/.*::/, '')
|
864
|
+
puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " +
|
865
|
+
"on #{port} for #{environment} with backup from #{handler_name}" unless handler_name =~/cgi/i
|
866
|
+
handler.run self, :Host => host, :Port => port do |server|
|
867
|
+
trap(:INT) do
|
868
|
+
## Use thins' hard #stop! if available, otherwise just #stop
|
869
|
+
server.respond_to?(:stop!) ? server.stop! : server.stop
|
870
|
+
puts "\n== Sinatra has ended his set (crowd applauds)" unless handler_name =~/cgi/i
|
871
|
+
end
|
872
|
+
end
|
873
|
+
rescue Errno::EADDRINUSE => e
|
874
|
+
puts "== Someone is already performing on port #{port}!"
|
875
|
+
end
|
876
|
+
|
877
|
+
# The prototype instance used to process requests.
|
878
|
+
def prototype
|
879
|
+
@prototype ||= new
|
880
|
+
end
|
881
|
+
|
882
|
+
# Create a new instance of the class fronted by its middleware
|
883
|
+
# pipeline. The object is guaranteed to respond to #call but may not be
|
884
|
+
# an instance of the class new was called on.
|
885
|
+
def new(*args, &bk)
|
886
|
+
builder = Rack::Builder.new
|
887
|
+
builder.use Rack::Session::Cookie if sessions? && !test?
|
888
|
+
builder.use Rack::CommonLogger if logging?
|
889
|
+
builder.use Rack::MethodOverride if methodoverride?
|
890
|
+
builder.use ShowExceptions if show_exceptions?
|
891
|
+
|
892
|
+
@middleware.each { |c,a,b| builder.use(c, *a, &b) }
|
893
|
+
builder.run super
|
894
|
+
builder.to_app
|
895
|
+
end
|
896
|
+
|
897
|
+
def call(env)
|
898
|
+
synchronize { prototype.call(env) }
|
899
|
+
end
|
900
|
+
|
901
|
+
def reset!(base=superclass)
|
902
|
+
@routes = base.dupe_routes
|
903
|
+
@templates = base.templates.dup
|
904
|
+
@conditions = []
|
905
|
+
@filters = base.filters.dup
|
906
|
+
@errors = base.errors.dup
|
907
|
+
@middleware = base.middleware.dup
|
908
|
+
@prototype = nil
|
909
|
+
@extensions = []
|
910
|
+
end
|
911
|
+
|
912
|
+
protected
|
913
|
+
def dupe_routes
|
914
|
+
routes.inject({}) do |hash,(request_method,routes)|
|
915
|
+
hash[request_method] = routes.dup
|
916
|
+
hash
|
917
|
+
end
|
918
|
+
end
|
919
|
+
|
920
|
+
private
|
921
|
+
def detect_rack_handler
|
922
|
+
servers = Array(self.server)
|
923
|
+
servers.each do |server_name|
|
924
|
+
begin
|
925
|
+
return Rack::Handler.get(server_name.downcase)
|
926
|
+
rescue LoadError
|
927
|
+
rescue NameError
|
928
|
+
end
|
929
|
+
end
|
930
|
+
fail "Server handler (#{servers.join(',')}) not found."
|
931
|
+
end
|
932
|
+
|
933
|
+
def inherited(subclass)
|
934
|
+
subclass.reset! self
|
935
|
+
super
|
936
|
+
end
|
937
|
+
|
938
|
+
@@mutex = Mutex.new
|
939
|
+
def synchronize(&block)
|
940
|
+
if lock?
|
941
|
+
@@mutex.synchronize(&block)
|
942
|
+
else
|
943
|
+
yield
|
944
|
+
end
|
945
|
+
end
|
946
|
+
|
947
|
+
def metadef(message, &block)
|
948
|
+
(class << self; self; end).
|
949
|
+
send :define_method, message, &block
|
950
|
+
end
|
951
|
+
|
952
|
+
public
|
953
|
+
CALLERS_TO_IGNORE = [
|
954
|
+
/\/sinatra(\/(base|main|showexceptions|compat))?\.rb$/, # all sinatra code
|
955
|
+
/\(.*\)/, # generated code
|
956
|
+
/custom_require\.rb$/, # rubygems require hacks
|
957
|
+
/active_support/, # active_support require hacks
|
958
|
+
] unless self.const_defined?('CALLERS_TO_IGNORE')
|
959
|
+
|
960
|
+
# add rubinius (and hopefully other VM impls) ignore patterns ...
|
961
|
+
CALLERS_TO_IGNORE.concat(RUBY_IGNORE_CALLERS) if defined?(RUBY_IGNORE_CALLERS)
|
962
|
+
|
963
|
+
# Like Kernel#caller but excluding certain magic entries and without
|
964
|
+
# line / method information; the resulting array contains filenames only.
|
965
|
+
def caller_files
|
966
|
+
caller_locations.
|
967
|
+
map { |file,line| file }
|
968
|
+
end
|
969
|
+
|
970
|
+
def caller_locations
|
971
|
+
caller(1).
|
972
|
+
map { |line| line.split(/:(?=\d|in )/)[0,2] }.
|
973
|
+
reject { |file,line| CALLERS_TO_IGNORE.any? { |pattern| file =~ pattern } }
|
974
|
+
end
|
975
|
+
end
|
976
|
+
|
977
|
+
set :raise_errors, true
|
978
|
+
set :dump_errors, false
|
979
|
+
set :clean_trace, true
|
980
|
+
set :show_exceptions, false
|
981
|
+
set :sessions, false
|
982
|
+
set :logging, false
|
983
|
+
set :methodoverride, false
|
984
|
+
set :static, false
|
985
|
+
set :environment, (ENV['RACK_ENV'] || :development).to_sym
|
986
|
+
|
987
|
+
set :run, false
|
988
|
+
set :server, %w[thin mongrel webrick]
|
989
|
+
set :host, '0.0.0.0'
|
990
|
+
set :port, 4567
|
991
|
+
|
992
|
+
set :app_file, nil
|
993
|
+
set :root, Proc.new { app_file && File.expand_path(File.dirname(app_file)) }
|
994
|
+
set :views, Proc.new { root && File.join(root, 'views') }
|
995
|
+
set :public, Proc.new { root && File.join(root, 'public') }
|
996
|
+
set :lock, false
|
997
|
+
|
998
|
+
# static files route
|
999
|
+
get(/.*[^\/]$/) do
|
1000
|
+
pass unless options.static? && options.public?
|
1001
|
+
public_dir = File.expand_path(options.public)
|
1002
|
+
path = File.expand_path(public_dir + unescape(request.path_info))
|
1003
|
+
pass if path[0, public_dir.length] != public_dir
|
1004
|
+
pass unless File.file?(path)
|
1005
|
+
send_file path, :disposition => nil
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
error ::Exception do
|
1009
|
+
response.status = 500
|
1010
|
+
content_type 'text/html'
|
1011
|
+
'<h1>Internal Server Error</h1>'
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
configure :development do
|
1015
|
+
get '/__sinatra__/:image.png' do
|
1016
|
+
filename = File.dirname(__FILE__) + "/images/#{params[:image]}.png"
|
1017
|
+
content_type :png
|
1018
|
+
send_file filename
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
error NotFound do
|
1022
|
+
content_type 'text/html'
|
1023
|
+
|
1024
|
+
(<<-HTML).gsub(/^ {8}/, '')
|
1025
|
+
<!DOCTYPE html>
|
1026
|
+
<html>
|
1027
|
+
<head>
|
1028
|
+
<style type="text/css">
|
1029
|
+
body { text-align:center;font-family:helvetica,arial;font-size:22px;
|
1030
|
+
color:#888;margin:20px}
|
1031
|
+
#c {margin:0 auto;width:500px;text-align:left}
|
1032
|
+
</style>
|
1033
|
+
</head>
|
1034
|
+
<body>
|
1035
|
+
<h2>Sinatra doesn't know this ditty.</h2>
|
1036
|
+
<img src='/__sinatra__/404.png'>
|
1037
|
+
<div id="c">
|
1038
|
+
Try this:
|
1039
|
+
<pre>#{request.request_method.downcase} '#{request.path_info}' do\n "Hello World"\nend</pre>
|
1040
|
+
</div>
|
1041
|
+
</body>
|
1042
|
+
</html>
|
1043
|
+
HTML
|
1044
|
+
end
|
1045
|
+
end
|
1046
|
+
end
|
1047
|
+
|
1048
|
+
# Base class for classic style (top-level) applications.
|
1049
|
+
class Default < Base
|
1050
|
+
set :raise_errors, Proc.new { test? }
|
1051
|
+
set :show_exceptions, Proc.new { development? }
|
1052
|
+
set :dump_errors, true
|
1053
|
+
set :sessions, false
|
1054
|
+
set :logging, Proc.new { ! test? }
|
1055
|
+
set :methodoverride, true
|
1056
|
+
set :static, true
|
1057
|
+
set :run, Proc.new { ! test? }
|
1058
|
+
|
1059
|
+
def self.register(*extensions, &block) #:nodoc:
|
1060
|
+
added_methods = extensions.map {|m| m.public_instance_methods }.flatten
|
1061
|
+
Delegator.delegate(*added_methods)
|
1062
|
+
super(*extensions, &block)
|
1063
|
+
end
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
# The top-level Application. All DSL methods executed on main are delegated
|
1067
|
+
# to this class.
|
1068
|
+
class Application < Default
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
# Sinatra delegation mixin. Mixing this module into an object causes all
|
1072
|
+
# methods to be delegated to the Sinatra::Application class. Used primarily
|
1073
|
+
# at the top-level.
|
1074
|
+
module Delegator #:nodoc:
|
1075
|
+
def self.delegate(*methods)
|
1076
|
+
methods.each do |method_name|
|
1077
|
+
eval <<-RUBY, binding, '(__DELEGATE__)', 1
|
1078
|
+
def #{method_name}(*args, &b)
|
1079
|
+
::Sinatra::Application.send(#{method_name.inspect}, *args, &b)
|
1080
|
+
end
|
1081
|
+
private #{method_name.inspect}
|
1082
|
+
RUBY
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
delegate :get, :put, :post, :delete, :head, :template, :layout, :before,
|
1087
|
+
:error, :not_found, :configures, :configure, :set, :set_option,
|
1088
|
+
:set_options, :enable, :disable, :use, :development?, :test?,
|
1089
|
+
:production?, :use_in_file_templates!, :helpers
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
# Create a new Sinatra application. The block is evaluated in the new app's
|
1093
|
+
# class scope.
|
1094
|
+
def self.new(base=Base, options={}, &block)
|
1095
|
+
base = Class.new(base)
|
1096
|
+
base.send :class_eval, &block if block_given?
|
1097
|
+
base
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
# Extend the top-level DSL with the modules provided.
|
1101
|
+
def self.register(*extensions, &block)
|
1102
|
+
Default.register(*extensions, &block)
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
# Include the helper modules provided in Sinatra's request context.
|
1106
|
+
def self.helpers(*extensions, &block)
|
1107
|
+
Default.helpers(*extensions, &block)
|
1108
|
+
end
|
1109
|
+
end
|
1110
|
+
|
1111
|
+
class String #:nodoc:
|
1112
|
+
# Define String#each under 1.9 for Rack compatibility. This should be
|
1113
|
+
# removed once Rack is fully 1.9 compatible.
|
1114
|
+
alias_method :each, :each_line unless ''.respond_to? :each
|
1115
|
+
|
1116
|
+
# Define String#bytesize as an alias to String#length for Ruby 1.8.6 and
|
1117
|
+
# earlier.
|
1118
|
+
alias_method :bytesize, :length unless ''.respond_to? :bytesize
|
1119
|
+
end
|