IOWA 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTORS +14 -0
- data/README.md +23 -0
- data/RELEASE_NOTES +77 -0
- data/ToDo +21 -0
- data/components/CRUDList/CRUDList.html +13 -0
- data/components/CRUDList/CRUDList.iwa +136 -0
- data/components/Content/Content.html +0 -0
- data/components/Content/Content.iwa +143 -0
- data/components/Content/example/README +9 -0
- data/components/Content/example/cgi/iowa.cgi +10 -0
- data/components/Content/example/demo.rb +30 -0
- data/components/Content/example/doc/index.html +7 -0
- data/components/Content/example/iowa/Content.html +1 -0
- data/components/Content/example/iowa/Content.iwa +1 -0
- data/components/Content/example/iowa/Main.html +6 -0
- data/components/Content/example/iowa/Main.iwa +3 -0
- data/components/Content/example/iowa/_content/body +7 -0
- data/components/Content/example/iowa/_content/body2 +3 -0
- data/components/Content/example/iowa/_content/title +2 -0
- data/components/Content/example/iowa/app.cnf +8 -0
- data/components/Content/example/iowa/app.rb +8 -0
- data/components/Content/example/webrick.rb +38 -0
- data/components/Include/Include.html +1 -0
- data/components/Include/Include.iwa +30 -0
- data/components/Include/readme +5 -0
- data/components/JumpTo/JumpTo.html +8 -0
- data/components/JumpTo/JumpTo.iwa +8 -0
- data/components/JumpTo/readme +6 -0
- data/doc/Architecture.txt +6 -0
- data/doc/History.txt +33 -0
- data/doc/StandardDispatcher.txt +19 -0
- data/examples/blog/README +1 -0
- data/examples/hello_world/README +17 -0
- data/examples/hello_world/htdocs/hello_world_html.html +24 -0
- data/examples/hello_world/htdocs/hello_world_ruby.html +41 -0
- data/examples/hello_world/iowa/HelloWorld.html +14 -0
- data/examples/hello_world/iowa/HelloWorld.iwa +31 -0
- data/examples/hello_world/iowa/Index.html +16 -0
- data/examples/hello_world/iowa/Index.iwa +5 -0
- data/examples/hello_world/iowa/iowa_hello_world.cnf +19 -0
- data/examples/hello_world/iowa/iowa_hello_world.rb +5 -0
- data/examples/hello_world/iowa/mapfile.cnf +6 -0
- data/examples/hw1/iowa/Main.html +1 -0
- data/examples/hw1/iowa/README +9 -0
- data/examples/hw1/iowa/hw.rb +4 -0
- data/examples/hw2/iowa/Main.html +10 -0
- data/examples/hw2/iowa/Main.iwa +7 -0
- data/examples/hw2/iowa/README +16 -0
- data/examples/hw2/iowa/hw.rb +4 -0
- data/examples/hw3/iowa/Main.html +11 -0
- data/examples/hw3/iowa/Main.iwa +7 -0
- data/examples/hw3/iowa/README +22 -0
- data/examples/hw3/iowa/hw.rb +4 -0
- data/examples/hw4/iowa/Greetings.html +10 -0
- data/examples/hw4/iowa/Greetings.iwa +9 -0
- data/examples/hw4/iowa/Main.html +12 -0
- data/examples/hw4/iowa/Main.iwa +10 -0
- data/examples/hw4/iowa/README +28 -0
- data/examples/hw4/iowa/hw.rb +4 -0
- data/examples/hw5/iowa/Footer.html +2 -0
- data/examples/hw5/iowa/Greetings.html +4 -0
- data/examples/hw5/iowa/Greetings.iwa +12 -0
- data/examples/hw5/iowa/Header.html +6 -0
- data/examples/hw5/iowa/Main.html +12 -0
- data/examples/hw5/iowa/Main.iwa +13 -0
- data/examples/hw5/iowa/README +16 -0
- data/examples/hw5/iowa/hw.rb +4 -0
- data/examples/template_server/iowa/Content.iwa +121 -0
- data/examples/template_server/iowa/Content.view +0 -0
- data/examples/template_server/iowa/DBContentDispatcher.rb +112 -0
- data/examples/template_server/iowa/DBContentPage.html +3 -0
- data/examples/template_server/iowa/DBContentPage.iwa +85 -0
- data/examples/template_server/iowa/app.cnf +13 -0
- data/examples/template_server/iowa/app.rb +5 -0
- data/ext/Classifier/classifier.c +256 -0
- data/ext/Classifier/ext_help.h +14 -0
- data/ext/Classifier/extconf.rb +5 -0
- data/ext/Classifier/tst.h +40 -0
- data/ext/Classifier/tst_cleanup.c +24 -0
- data/ext/Classifier/tst_delete.c +146 -0
- data/ext/Classifier/tst_grow_node_free_list.c +38 -0
- data/ext/Classifier/tst_init.c +41 -0
- data/ext/Classifier/tst_insert.c +192 -0
- data/ext/Classifier/tst_search.c +68 -0
- data/ext/http11/README +11 -0
- data/ext/http11/ext_help.h +15 -0
- data/ext/http11/extconf.rb +5 -0
- data/ext/http11/http11.c +534 -0
- data/ext/http11/http11.c.dif +422 -0
- data/ext/http11/http11_parser.c +1243 -0
- data/ext/http11/http11_parser.c.dif +193 -0
- data/ext/http11/http11_parser.h +49 -0
- data/ext/http11/http11_parser.h.dif +20 -0
- data/ext/http11/http11_parser.rl +192 -0
- data/ext/httpmachine/Makefile +149 -0
- data/ext/httpmachine/extconf.rb +33 -0
- data/ext/httpmachine/http.cpp +430 -0
- data/ext/httpmachine/http.h +156 -0
- data/ext/httpmachine/rubyhttp.cpp +165 -0
- data/external/mime-types/LICENCE +18 -0
- data/external/mime-types/README +46 -0
- data/external/mime-types/doc/classes/MIME.html +120 -0
- data/external/mime-types/doc/classes/MIME/InvalidContentType.html +119 -0
- data/external/mime-types/doc/classes/MIME/Type.html +866 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000010.html +22 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000011.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000012.html +19 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000013.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000014.html +26 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000015.html +33 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000016.html +27 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000017.html +35 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000018.html +34 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000019.html +24 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000020.html +38 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000021.html +22 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000022.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000023.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000024.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000025.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000026.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000027.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000028.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000029.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000030.html +19 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000031.html +26 -0
- data/external/mime-types/doc/classes/MIME/Types.html +459 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000001.html +19 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000002.html +32 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000003.html +21 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000004.html +18 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000005.html +26 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000006.html +18 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000007.html +18 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000008.html +18 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000009.html +18 -0
- data/external/mime-types/doc/created.rid +1 -0
- data/external/mime-types/doc/files/ChangeLog.html +320 -0
- data/external/mime-types/doc/files/README.html +145 -0
- data/external/mime-types/doc/files/lib/mime/types_rb.html +101 -0
- data/external/mime-types/doc/fr_class_index.html +30 -0
- data/external/mime-types/doc/fr_file_index.html +29 -0
- data/external/mime-types/doc/fr_method_index.html +57 -0
- data/external/mime-types/doc/index.html +24 -0
- data/external/mime-types/doc/rdoc-style.css +208 -0
- data/external/mime-types/lib/mime/types.rb +1558 -0
- data/external/package.rb +672 -0
- data/external/test_support.rb +95 -0
- data/external/tmail/README +7 -0
- data/external/tmail/tmail.rb +4 -0
- data/external/tmail/tmail/address.rb +222 -0
- data/external/tmail/tmail/base64.rb +52 -0
- data/external/tmail/tmail/compat.rb +39 -0
- data/external/tmail/tmail/config.rb +50 -0
- data/external/tmail/tmail/encode.rb +447 -0
- data/external/tmail/tmail/header.rb +895 -0
- data/external/tmail/tmail/info.rb +14 -0
- data/external/tmail/tmail/loader.rb +1 -0
- data/external/tmail/tmail/mail.rb +869 -0
- data/external/tmail/tmail/mailbox.rb +386 -0
- data/external/tmail/tmail/mbox.rb +1 -0
- data/external/tmail/tmail/net.rb +260 -0
- data/external/tmail/tmail/obsolete.rb +123 -0
- data/external/tmail/tmail/parser.rb +1475 -0
- data/external/tmail/tmail/parser.y +372 -0
- data/external/tmail/tmail/port.rb +356 -0
- data/external/tmail/tmail/scanner.rb +17 -0
- data/external/tmail/tmail/scanner_r.rb +243 -0
- data/external/tmail/tmail/stringio.rb +256 -0
- data/external/tmail/tmail/textutils.rb +197 -0
- data/external/tmail/tmail/tmail.rb +1 -0
- data/external/tmail/tmail/utils.rb +23 -0
- data/external/win32-process/README +133 -0
- data/external/win32-process/lib/win32/process.rb +561 -0
- data/external/windows-pr/README +145 -0
- data/external/windows-pr/doc/conversion_guide.txt +25 -0
- data/external/windows-pr/lib/windows/clipboard.rb +72 -0
- data/external/windows-pr/lib/windows/console.rb +323 -0
- data/external/windows-pr/lib/windows/device_io.rb +88 -0
- data/external/windows-pr/lib/windows/directory.rb +80 -0
- data/external/windows-pr/lib/windows/error.rb +313 -0
- data/external/windows-pr/lib/windows/eventlog.rb +120 -0
- data/external/windows-pr/lib/windows/file.rb +349 -0
- data/external/windows-pr/lib/windows/filesystem.rb +16 -0
- data/external/windows-pr/lib/windows/handle.rb +31 -0
- data/external/windows-pr/lib/windows/library.rb +76 -0
- data/external/windows-pr/lib/windows/limits.rb +13 -0
- data/external/windows-pr/lib/windows/memory.rb +117 -0
- data/external/windows-pr/lib/windows/msvcrt/buffer.rb +48 -0
- data/external/windows-pr/lib/windows/msvcrt/file.rb +18 -0
- data/external/windows-pr/lib/windows/msvcrt/string.rb +46 -0
- data/external/windows-pr/lib/windows/national.rb +557 -0
- data/external/windows-pr/lib/windows/path.rb +296 -0
- data/external/windows-pr/lib/windows/pipe.rb +77 -0
- data/external/windows-pr/lib/windows/process.rb +171 -0
- data/external/windows-pr/lib/windows/registry.rb +238 -0
- data/external/windows-pr/lib/windows/security.rb +89 -0
- data/external/windows-pr/lib/windows/service.rb +183 -0
- data/external/windows-pr/lib/windows/shell.rb +88 -0
- data/external/windows-pr/lib/windows/sound.rb +52 -0
- data/external/windows-pr/lib/windows/synchronize.rb +161 -0
- data/external/windows-pr/lib/windows/system_info.rb +70 -0
- data/external/windows-pr/lib/windows/unicode.rb +138 -0
- data/external/windows-pr/lib/windows/window.rb +22 -0
- data/iowa.gemspec +45 -0
- data/microprojects/DiskCache/LICENSE +28 -0
- data/microprojects/DiskCache/README +17 -0
- data/microprojects/DiskCache/external/package.rb +608 -0
- data/microprojects/DiskCache/external/test_support.rb +8 -0
- data/microprojects/DiskCache/setup.rb +22 -0
- data/microprojects/DiskCache/src/iowa/Association.rb +67 -0
- data/microprojects/DiskCache/src/iowa/Constants.rb +159 -0
- data/microprojects/DiskCache/src/iowa/DiskStore.rb +377 -0
- data/microprojects/DiskCache/src/iowa/Hash.rb +63 -0
- data/microprojects/DiskCache/src/iowa/Lockfile.rb +575 -0
- data/microprojects/DiskCache/src/iowa/Mutex.rb +142 -0
- data/microprojects/DiskCache/src/iowa/caches/DiskCache.rb +605 -0
- data/microprojects/DiskCache/src/iowa/caches/LRUCache.rb +287 -0
- data/microprojects/DiskCache/test/TC_DiskCache.rb +218 -0
- data/microprojects/LRUCache/LICENSE +28 -0
- data/microprojects/LRUCache/README +13 -0
- data/microprojects/LRUCache/external/package.rb +608 -0
- data/microprojects/LRUCache/external/test_support.rb +8 -0
- data/microprojects/LRUCache/setup.rb +22 -0
- data/microprojects/LRUCache/src/iowa/Association.rb +57 -0
- data/microprojects/LRUCache/src/iowa/Constants.rb +159 -0
- data/microprojects/LRUCache/src/iowa/Hash.rb +63 -0
- data/microprojects/LRUCache/src/iowa/Mutex.rb +129 -0
- data/microprojects/LRUCache/src/iowa/caches/LRUCache.rb +287 -0
- data/microprojects/LRUCache/test/TC_LRUCache.rb +65 -0
- data/microprojects/LinkedList/LICENSE +28 -0
- data/microprojects/LinkedList/README +13 -0
- data/microprojects/LinkedList/external/package.rb +608 -0
- data/microprojects/LinkedList/external/test_support.rb +8 -0
- data/microprojects/LinkedList/setup.rb +22 -0
- data/microprojects/LinkedList/src/iowa/LinkedList.rb +165 -0
- data/microprojects/LinkedList/test/TC_LinkedList.rb +42 -0
- data/microprojects/README +8 -0
- data/setup.rb +116 -0
- data/share/iowa/app_skeleton/Main.html +8 -0
- data/share/iowa/app_skeleton/Main.iwa +15 -0
- data/share/iowa/app_skeleton/app.cnf +48 -0
- data/share/iowa/app_skeleton/app.rb +58 -0
- data/share/iowa/app_skeleton/models/model.rb +49 -0
- data/src/ihc.rb +223 -0
- data/src/iowa.cgi +29 -0
- data/src/iowa.rb +637 -0
- data/src/iowa/AbstractCache.rb +96 -0
- data/src/iowa/AcceptLanguage.rb +76 -0
- data/src/iowa/Application.rb +928 -0
- data/src/iowa/ApplicationStats.rb +72 -0
- data/src/iowa/Association.rb +67 -0
- data/src/iowa/BindingsParser.rb +62 -0
- data/src/iowa/Breakpoint.rb +273 -0
- data/src/iowa/CSS.rb +564 -0
- data/src/iowa/Client.rb +192 -0
- data/src/iowa/Component.rb +405 -0
- data/src/iowa/ComponentProxy.rb +26 -0
- data/src/iowa/Config.rb +21 -0
- data/src/iowa/Constants.rb +226 -0
- data/src/iowa/Context.rb +218 -0
- data/src/iowa/ContextLogger.rb +16 -0
- data/src/iowa/DbPool.rb +222 -0
- data/src/iowa/DetachedComponent.rb +18 -0
- data/src/iowa/Dispatcher.rb +27 -0
- data/src/iowa/DynamicElements.rb +471 -0
- data/src/iowa/Element.rb +100 -0
- data/src/iowa/Email.rb +287 -0
- data/src/iowa/Extensions/AllExtensions.rb +4 -0
- data/src/iowa/Extensions/Class.rb +94 -0
- data/src/iowa/Extensions/Date.rb +88 -0
- data/src/iowa/Extensions/DateTime.rb +88 -0
- data/src/iowa/Extensions/Hash.rb +22 -0
- data/src/iowa/Extensions/Kernel.rb +6 -0
- data/src/iowa/Extensions/Numeric.rb +47 -0
- data/src/iowa/Extensions/Object.rb +11 -0
- data/src/iowa/Extensions/String.rb +60 -0
- data/src/iowa/Extensions/Time.rb +89 -0
- data/src/iowa/Extensions/TimeExtensions.rb +6 -0
- data/src/iowa/Form.rb +368 -0
- data/src/iowa/Hash.rb +85 -0
- data/src/iowa/ISAAC.rb +175 -0
- data/src/iowa/ImageSize.rb +279 -0
- data/src/iowa/IowaComponentMixins.rb +7 -0
- data/src/iowa/JSON-lexer.rb +296 -0
- data/src/iowa/JSON-objects.rb +201 -0
- data/src/iowa/KeyValueCoding.rb +91 -0
- data/src/iowa/LinkedList.rb +175 -0
- data/src/iowa/Loader.rb +22 -0
- data/src/iowa/Lockfile.rb +575 -0
- data/src/iowa/Logger.rb +74 -0
- data/src/iowa/Monkey.rb +20 -0
- data/src/iowa/Mutex.rb +142 -0
- data/src/iowa/Policy.rb +70 -0
- data/src/iowa/Pool.rb +243 -0
- data/src/iowa/PrettyException.rb +1091 -0
- data/src/iowa/Request.rb +244 -0
- data/src/iowa/Response.rb +133 -0
- data/src/iowa/Session.rb +354 -0
- data/src/iowa/SessionStats.rb +78 -0
- data/src/iowa/String.rb +65 -0
- data/src/iowa/Tag.rb +101 -0
- data/src/iowa/TemplateParser.rb +236 -0
- data/src/iowa/Util.rb +314 -0
- data/src/iowa/Webcache.rb +122 -0
- data/src/iowa/caches/BiLevelCache.rb +65 -0
- data/src/iowa/caches/ClassLimitedCache.rb +67 -0
- data/src/iowa/caches/DiskCache.rb +609 -0
- data/src/iowa/caches/DiskStore.rb +380 -0
- data/src/iowa/caches/LRUCache-alternative.rb +155 -0
- data/src/iowa/caches/LRUCache.rb +290 -0
- data/src/iowa/caches/SimpleLRUCache.rb +112 -0
- data/src/iowa/dispatchers/StandardDispatcher.rb +396 -0
- data/src/iowa/dispatchers/StandardDispatcherWithClassifier.rb +93 -0
- data/src/iowa/js/iowa_jsonrpc.js +381 -0
- data/src/iowa/js/jsonrpc.js +187 -0
- data/src/iowa/js/jsonrpc_async.js +261 -0
- data/src/iowa/loaders/DiskLoader.rb +50 -0
- data/src/iowa/loggers/Analogger.rb +54 -0
- data/src/iowa/loggers/AsyncLogger.rb +54 -0
- data/src/iowa/loggers/BitBucket.rb +38 -0
- data/src/iowa/loggers/Log4R.rb +13 -0
- data/src/iowa/loggers/Log4rLogger.rb +48 -0
- data/src/iowa/loggers/Logger.rb +29 -0
- data/src/iowa/loggers/RubyLogger.rb +9 -0
- data/src/iowa/pools/DBConnectionPool.rb +53 -0
- data/src/iowa/request/Apache.rb +90 -0
- data/src/iowa/request/EMHybrid.rb +59 -0
- data/src/iowa/request/ENV.rb +80 -0
- data/src/iowa/request/FCGI.rb +68 -0
- data/src/iowa/request/HTTPMachine.rb +75 -0
- data/src/iowa/request/Mongrel.rb +68 -0
- data/src/iowa/request/WEBrick.rb +48 -0
- data/src/iowa/version.rb +3 -0
- data/src/iowa/webrick/HTTPServer.rb +43 -0
- data/src/iowa/webrick/WEBrickServlet.rb +28 -0
- data/src/iowa_fcgi_handler.rb +101 -0
- data/src/iowa_httpmachine.rb +141 -0
- data/src/iowa_hybrid.rb +193 -0
- data/src/iowa_hybrid_cluster.rb +231 -0
- data/src/iowa_mongrel.rb +136 -0
- data/src/iowa_webrick.rb +194 -0
- data/src/iowa_webrick_legacy.rb +104 -0
- data/src/mod_iowa.rb +104 -0
- data/tcss.rb +61 -0
- data/test/README.windows +12 -0
- data/test/TC_AcceptLanguage.rb +61 -0
- data/test/TC_AppConfig.rb +43 -0
- data/test/TC_AppConfig/cgi/iowa.cgi +7 -0
- data/test/TC_AppConfig/doc/index.html +1 -0
- data/test/TC_AppConfig/iowa/Main.html +4 -0
- data/test/TC_AppConfig/iowa/Main.iwa +17 -0
- data/test/TC_AppConfig/iowa/README +1 -0
- data/test/TC_AppConfig/iowa/app.cnf +19 -0
- data/test/TC_AppConfig/iowa/app.rb +8 -0
- data/test/TC_AppConfig/webrick.rb +38 -0
- data/test/TC_Association.rb +29 -0
- data/test/TC_BiLevelCache.rb +71 -0
- data/test/TC_CGI_Adaptor.rb +55 -0
- data/test/TC_CGI_Adaptor/cgi/iowa.cgi +7 -0
- data/test/TC_CGI_Adaptor/doc/index.html +1 -0
- data/test/TC_CGI_Adaptor/iowa/Main.html +8 -0
- data/test/TC_CGI_Adaptor/iowa/Main.iwa +14 -0
- data/test/TC_CGI_Adaptor/iowa/README +1 -0
- data/test/TC_CGI_Adaptor/iowa/app.cnf +8 -0
- data/test/TC_CGI_Adaptor/iowa/app.rb +8 -0
- data/test/TC_CGI_Adaptor/webrick.rb +38 -0
- data/test/TC_CSS.rb +660 -0
- data/test/TC_ClassLimitedCache.rb +89 -0
- data/test/TC_Classifier.rb +80 -0
- data/test/TC_DbPool.rb +127 -0
- data/test/TC_DiskCache.rb +218 -0
- data/test/TC_Hybrid.rb +58 -0
- data/test/TC_Hybrid/doc/thing.txt +1 -0
- data/test/TC_Hybrid/iowa/Main.html +3 -0
- data/test/TC_Hybrid/iowa/Main.iwa +7 -0
- data/test/TC_Hybrid/iowa/NewPage.html +1 -0
- data/test/TC_Hybrid/iowa/NewPage.iwa +5 -0
- data/test/TC_Hybrid/iowa/app.cnf +10 -0
- data/test/TC_Hybrid/iowa/app.rb +5 -0
- data/test/TC_IOWAFunctions/doc/Ajax1.html +1 -0
- data/test/TC_IOWAFunctions/doc/Ajax1.iwa +1 -0
- data/test/TC_IOWAFunctions/doc/index.html +1 -0
- data/test/TC_IOWAFunctions/doc/js/dojo.js +9686 -0
- data/test/TC_IOWAFunctions/iowa/Ajax1.html +40 -0
- data/test/TC_IOWAFunctions/iowa/Ajax1.iwa +23 -0
- data/test/TC_IOWAFunctions/iowa/AjaxWidget.iwa +19 -0
- data/test/TC_IOWAFunctions/iowa/AjaxWidget.view +22 -0
- data/test/TC_IOWAFunctions/iowa/DanielTest.html +9 -0
- data/test/TC_IOWAFunctions/iowa/DanielTest.iwa +10 -0
- data/test/TC_IOWAFunctions/iowa/IntervalWidget.html +1 -0
- data/test/TC_IOWAFunctions/iowa/IntervalWidget.iwa +14 -0
- data/test/TC_IOWAFunctions/iowa/Main.html +1 -0
- data/test/TC_IOWAFunctions/iowa/NestedRepeat1.html +12 -0
- data/test/TC_IOWAFunctions/iowa/NestedRepeat1.iwa +24 -0
- data/test/TC_IOWAFunctions/iowa/RPCResponse.iwa +7 -0
- data/test/TC_IOWAFunctions/iowa/RPCResponse.view +1 -0
- data/test/TC_IOWAFunctions/iowa/Repeat1.iwa +31 -0
- data/test/TC_IOWAFunctions/iowa/Repeat1.view +9 -0
- data/test/TC_IOWAFunctions/iowa/Repeat2.iwa +32 -0
- data/test/TC_IOWAFunctions/iowa/Repeat2.view +11 -0
- data/test/TC_IOWAFunctions/iowa/Repeat3.iwa +44 -0
- data/test/TC_IOWAFunctions/iowa/Repeat3.view +18 -0
- data/test/TC_IOWAFunctions/iowa/TesCon.html +1 -0
- data/test/TC_IOWAFunctions/iowa/TesCon.iwa +5 -0
- data/test/TC_IOWAFunctions/iowa/app.cnf +19 -0
- data/test/TC_IOWAFunctions/iowa/app.rb +9 -0
- data/test/TC_IOWAFunctions/iowa/mapfile.cnf +8 -0
- data/test/TC_ISAAC.rb +52 -0
- data/test/TC_ImageSize.rb +84 -0
- data/test/TC_ImageSize/img.bmp +0 -0
- data/test/TC_ImageSize/img.gif +0 -0
- data/test/TC_ImageSize/img.jpg +0 -0
- data/test/TC_ImageSize/img.pcx +0 -0
- data/test/TC_ImageSize/img.pgm +7144 -0
- data/test/TC_ImageSize/img.png +0 -0
- data/test/TC_ImageSize/img.ppm +0 -0
- data/test/TC_ImageSize/img.psd +0 -0
- data/test/TC_ImageSize/img.tiff +0 -0
- data/test/TC_ImageSize/img.xbm +22 -0
- data/test/TC_KeyValueCoding.rb +35 -0
- data/test/TC_LRUCache.rb +296 -0
- data/test/TC_LinkedList.rb +46 -0
- data/test/TC_Lockfile.rb +106 -0
- data/test/TC_Minimal.rb +45 -0
- data/test/TC_Minimal/app.cnf +8 -0
- data/test/TC_Minimal/cgi-bin/iowa.cgi +11 -0
- data/test/TC_Minimal/doc/index.html +1 -0
- data/test/TC_Minimal/iowa/Main.html +1 -0
- data/test/TC_Minimal/iowa/README +1 -0
- data/test/TC_Minimal/iowa/app.rb +3 -0
- data/test/TC_Minimal/webrick.rb +38 -0
- data/test/TC_Mongrel.rb +58 -0
- data/test/TC_Mongrel/doc/thing.txt +1 -0
- data/test/TC_Mongrel/iowa/Main.html +3 -0
- data/test/TC_Mongrel/iowa/Main.iwa +7 -0
- data/test/TC_Mongrel/iowa/NewPage.html +1 -0
- data/test/TC_Mongrel/iowa/NewPage.iwa +5 -0
- data/test/TC_Mongrel/iowa/app.cnf +10 -0
- data/test/TC_Mongrel/iowa/app.rb +5 -0
- data/test/TC_NoSubclass.rb +56 -0
- data/test/TC_NoSubclass/cgi/iowa.cgi +7 -0
- data/test/TC_NoSubclass/doc/index.html +1 -0
- data/test/TC_NoSubclass/iowa/Main.html +8 -0
- data/test/TC_NoSubclass/iowa/Main.iwa +14 -0
- data/test/TC_NoSubclass/iowa/README +1 -0
- data/test/TC_NoSubclass/iowa/app.cnf +8 -0
- data/test/TC_NoSubclass/iowa/app.rb +5 -0
- data/test/TC_NoSubclass/webrick.rb +38 -0
- data/test/TC_Pool.rb +139 -0
- data/test/TC_RenderedCache/doc/thing.txt +1 -0
- data/test/TC_RenderedCache/iowa/BigPage.html +1 -0
- data/test/TC_RenderedCache/iowa/BigPage.iwa +12 -0
- data/test/TC_RenderedCache/iowa/Main.html +3 -0
- data/test/TC_RenderedCache/iowa/Main.iwa +7 -0
- data/test/TC_RenderedCache/iowa/NewPage.html +1 -0
- data/test/TC_RenderedCache/iowa/NewPage.iwa +11 -0
- data/test/TC_RenderedCache/iowa/app.cnf +13 -0
- data/test/TC_RenderedCache/iowa/app.rb +5 -0
- data/test/TC_RenderedCache/iowa/mapfile.map +4 -0
- data/test/TC_ResourceURL.rb +73 -0
- data/test/TC_ResourceURL/iowa/Main.html +2 -0
- data/test/TC_ResourceURL/iowa/Main.iwa +10 -0
- data/test/TC_ResourceURL/iowa/app.cnf +10 -0
- data/test/TC_ResourceURL/iowa/app.rb +5 -0
- data/test/TC_SimpleDetached.rb +41 -0
- data/test/TC_StandardDispatcher.rb +362 -0
- data/test/TC_StandardDispatcherWithClassifier.rb +358 -0
- data/test/TC_String.rb +24 -0
- data/test/TC_Tag.rb +41 -0
- data/test/TC_Webrick.rb +56 -0
- data/test/TC_Webrick/doc/thing.txt +1 -0
- data/test/TC_Webrick/iowa/Main.html +3 -0
- data/test/TC_Webrick/iowa/Main.iwa +7 -0
- data/test/TC_Webrick/iowa/NewPage.html +1 -0
- data/test/TC_Webrick/iowa/NewPage.iwa +5 -0
- data/test/TC_Webrick/iowa/app.cnf +10 -0
- data/test/TC_Webrick/iowa/app.rb +5 -0
- data/test/tc_template.rb +15 -0
- data/test/tests.conf +19 -0
- data/utils/CVS/Entries +3 -0
- data/utils/CVS/Repository +1 -0
- data/utils/CVS/Root +1 -0
- data/utils/QuickCert-1.0.2.tar.gz +0 -0
- data/utils/QuickCert-1.0.2/InstalledFiles +7 -0
- data/utils/QuickCert-1.0.2/MANIFEST +10 -0
- data/utils/QuickCert-1.0.2/Makefile +15 -0
- data/utils/QuickCert-1.0.2/README +56 -0
- data/utils/QuickCert-1.0.2/bin/QuickCert +355 -0
- data/utils/QuickCert-1.0.2/config.save +12 -0
- data/utils/QuickCert-1.0.2/data/examples/ruby/QuickCert/README +60 -0
- data/utils/QuickCert-1.0.2/data/examples/ruby/QuickCert/drbssl_c.rb +26 -0
- data/utils/QuickCert-1.0.2/data/examples/ruby/QuickCert/drbssl_s.rb +35 -0
- data/utils/QuickCert-1.0.2/data/examples/ruby/QuickCert/qc_config +21 -0
- data/utils/QuickCert-1.0.2/lib/QuickCert/defaults.rb +28 -0
- data/utils/QuickCert-1.0.2/setup.rb +1312 -0
- data/utils/iowa_apps +422 -0
- data/utils/smtp_sink.rb +9 -0
- data/utils/startup_template.cnf +27 -0
- data/utils/startup_template.rb +73 -0
- metadata +551 -0
@@ -0,0 +1,290 @@
|
|
1
|
+
require 'enumerator'
|
2
|
+
require 'thread'
|
3
|
+
require 'iowa/Constants'
|
4
|
+
require 'iowa/Hash'
|
5
|
+
|
6
|
+
module Iowa
|
7
|
+
module Caches
|
8
|
+
|
9
|
+
#++
|
10
|
+
# Iowa::Caches::LRUCache is an LRU cache based on a linked list.
|
11
|
+
# It provides efficient random access to elements, like a hash,
|
12
|
+
# along with efficient stack or queue-like behaviors -- elements can
|
13
|
+
# be pushed, poped, shifted, and unshifted from the cache.
|
14
|
+
|
15
|
+
class LRUCache
|
16
|
+
include Enumerable
|
17
|
+
|
18
|
+
# * Iowa::Caches::LRUCache.new
|
19
|
+
# * Iowa::Caches::LRUCache.new(:maxsize => 20)
|
20
|
+
# * Iowa::Caches::LRUCache.new(20)
|
21
|
+
# * Iowa::Caches::LRUCache.new(:maxsize => 20, :ttl => 3600)
|
22
|
+
# * Iowa::Caches::LRUCache.new(20,3600)
|
23
|
+
#
|
24
|
+
# If called with no arguments, the cache will default to a max size
|
25
|
+
# of 20 elements, with no max time to live (ttl) on the elements.
|
26
|
+
#
|
27
|
+
# If called using a hash with keyword arguments, the :maxsize is the
|
28
|
+
# maximum number of elements to keep in the hash, and :ttl is the
|
29
|
+
# maximum age allowed for elements in the hash.
|
30
|
+
#
|
31
|
+
# If called with list arguments, the first is the max size, and the
|
32
|
+
# second is the TTL.
|
33
|
+
|
34
|
+
def initialize(args = {Cmaxsize => 20, Cttl => nil}, ttlarg = nil)
|
35
|
+
if args.kind_of? ::Hash
|
36
|
+
oargs = args
|
37
|
+
args = Iowa::Hash.new
|
38
|
+
args.step_merge!(oargs)
|
39
|
+
end
|
40
|
+
args.stringify_keys! if args.respond_to? :stringify_keys!
|
41
|
+
begin
|
42
|
+
@max = args[Cmaxsize] || 20
|
43
|
+
@maxttl = args[Cttl]
|
44
|
+
@mutex = Mutex.new
|
45
|
+
rescue Exception
|
46
|
+
args = {Cmaxsize => args || 20, Cttl => ttlarg}
|
47
|
+
retry
|
48
|
+
end
|
49
|
+
@finalizers = []
|
50
|
+
@head = Node.new
|
51
|
+
@tail = Node.new
|
52
|
+
@lookup = Hash.new
|
53
|
+
node_join(@head,@tail)
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# Check to see if the given key is in the cache.
|
58
|
+
|
59
|
+
def include?(v)
|
60
|
+
@lookup.has_key?(v)
|
61
|
+
end
|
62
|
+
alias :has_key? :include?
|
63
|
+
|
64
|
+
def [](v)
|
65
|
+
@mutex.lock
|
66
|
+
if @lookup.has_key?(v)
|
67
|
+
n = @lookup[v]
|
68
|
+
n.age = Time.now
|
69
|
+
node_delete(n)
|
70
|
+
node_join(n,@head.next_node)
|
71
|
+
node_join(@head,n)
|
72
|
+
node_prune
|
73
|
+
@mutex.unlock
|
74
|
+
n.value
|
75
|
+
else
|
76
|
+
node_prune
|
77
|
+
@mutex.unlock
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def []=(k,v)
|
83
|
+
@mutex.lock
|
84
|
+
if @lookup.has_key?(k)
|
85
|
+
n = @lookup[k]
|
86
|
+
n.value = v
|
87
|
+
n.age = Time.now
|
88
|
+
node_delete(n)
|
89
|
+
node_join(n,@head.next_node)
|
90
|
+
node_join(@head,n)
|
91
|
+
else
|
92
|
+
n = Node.new(k,v,Time.now,@head,@head.next_node)
|
93
|
+
node_join(n,@head.next_node)
|
94
|
+
node_join(@head,n)
|
95
|
+
@lookup[k] = n
|
96
|
+
end
|
97
|
+
node_prune
|
98
|
+
@mutex.unlock
|
99
|
+
v
|
100
|
+
end
|
101
|
+
|
102
|
+
def empty?
|
103
|
+
@lookup.empty?
|
104
|
+
end
|
105
|
+
|
106
|
+
def delete(k)
|
107
|
+
@mutex.lock
|
108
|
+
n = @lookup.delete(k)
|
109
|
+
node_purge(n) if n
|
110
|
+
node_prune
|
111
|
+
@mutex.unlock
|
112
|
+
n.value
|
113
|
+
end
|
114
|
+
|
115
|
+
def first
|
116
|
+
@head.next_node.value
|
117
|
+
end
|
118
|
+
|
119
|
+
def last
|
120
|
+
@tail.prev_node.value
|
121
|
+
end
|
122
|
+
|
123
|
+
def shift
|
124
|
+
@mutex.lock
|
125
|
+
k = @head.next_node.key
|
126
|
+
n = @lookup.delete(k)
|
127
|
+
node_delete(n) if n
|
128
|
+
node_prune
|
129
|
+
@mutex.unlock
|
130
|
+
n.value
|
131
|
+
end
|
132
|
+
|
133
|
+
def unshift(v)
|
134
|
+
@mutex.lock
|
135
|
+
if @lookup.has_key?(v)
|
136
|
+
n = @lookup[v]
|
137
|
+
node_delete(n)
|
138
|
+
node_join(n,@head.next_node)
|
139
|
+
node_join(@head,n)
|
140
|
+
else
|
141
|
+
n = Node.new(v,v,Time.now,@head,@head.next_node)
|
142
|
+
node_join(n,@head.next_node)
|
143
|
+
node_join(@head,n)
|
144
|
+
@lookup[v] = n
|
145
|
+
end
|
146
|
+
node_prune
|
147
|
+
@mutex.unlock
|
148
|
+
v
|
149
|
+
end
|
150
|
+
|
151
|
+
def pop
|
152
|
+
@mutex.lock
|
153
|
+
k = @tail.prev_node.key
|
154
|
+
n = @lookup.delete(k)
|
155
|
+
node_delete(n) if n
|
156
|
+
node_prune
|
157
|
+
@mutex.unlock
|
158
|
+
n.value
|
159
|
+
end
|
160
|
+
|
161
|
+
def push(v)
|
162
|
+
@mutex.lock
|
163
|
+
if @lookup.has_key?(v)
|
164
|
+
n = @lookup[v]
|
165
|
+
node_delete(n)
|
166
|
+
node_join(@tail.prev_node,n)
|
167
|
+
node_join(n,@tail)
|
168
|
+
else
|
169
|
+
n = Node.new(v,v,Time.now,@tail.prev_node,@tail)
|
170
|
+
node_join(@tail.prev_node,n)
|
171
|
+
node_join(n,@tail)
|
172
|
+
@lookup[v] = n
|
173
|
+
end
|
174
|
+
node_prune
|
175
|
+
@mutex.unlock
|
176
|
+
v
|
177
|
+
end
|
178
|
+
|
179
|
+
def queue
|
180
|
+
r = []
|
181
|
+
n = @head
|
182
|
+
while (n = n.next_node) and n != @tail
|
183
|
+
r << n.key
|
184
|
+
end
|
185
|
+
r
|
186
|
+
end
|
187
|
+
|
188
|
+
def to_a
|
189
|
+
r = []
|
190
|
+
n = @head
|
191
|
+
while (n = n.next_node) and n != @tail
|
192
|
+
r << n.value
|
193
|
+
end
|
194
|
+
r
|
195
|
+
end
|
196
|
+
|
197
|
+
def length
|
198
|
+
@lookup.length
|
199
|
+
end
|
200
|
+
alias :size :length
|
201
|
+
|
202
|
+
def each
|
203
|
+
n = @head
|
204
|
+
while (n = n.next_node) and n != @tail
|
205
|
+
yield(n.key,n.value)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def maxsize
|
210
|
+
@max
|
211
|
+
end
|
212
|
+
|
213
|
+
def maxsize=(v)
|
214
|
+
@max = v
|
215
|
+
node_prune
|
216
|
+
end
|
217
|
+
alias :size= :maxsize=
|
218
|
+
|
219
|
+
def ttl
|
220
|
+
@maxttl
|
221
|
+
end
|
222
|
+
|
223
|
+
def ttl=(v)
|
224
|
+
@maxttl = v
|
225
|
+
node_prune
|
226
|
+
end
|
227
|
+
|
228
|
+
# Adds a finalization method to the cache that will be called before
|
229
|
+
# the object in the cache is expired.
|
230
|
+
|
231
|
+
def add_finalizer(*args,&block)
|
232
|
+
@finalizers.push [block,args]
|
233
|
+
end
|
234
|
+
|
235
|
+
private
|
236
|
+
|
237
|
+
def node_delete(n)
|
238
|
+
node_join(n.prev_node,n.next_node)
|
239
|
+
end
|
240
|
+
|
241
|
+
def node_purge(n)
|
242
|
+
node_join(n.prev_node,n.next_node)
|
243
|
+
v = n.value
|
244
|
+
k = n.key
|
245
|
+
n.value = nil
|
246
|
+
n.key = nil
|
247
|
+
n.next_node = nil
|
248
|
+
n.prev_node = nil
|
249
|
+
do_finalization(k,v) if @finalizers
|
250
|
+
v
|
251
|
+
end
|
252
|
+
|
253
|
+
def node_join(a,b)
|
254
|
+
a.next_node = b
|
255
|
+
b.prev_node = a
|
256
|
+
end
|
257
|
+
|
258
|
+
def node_prune
|
259
|
+
node_purge(@lookup.delete(@tail.prev_node.key)) while @lookup.size > @max
|
260
|
+
if @maxttl
|
261
|
+
expiration_date = Time.now - @maxttl
|
262
|
+
while (n = @tail.prev_node) and n != @head and n.age < expiration_date
|
263
|
+
node_purge(@lookup.delete(n.key))
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
# Is called when an object in the cache is expired. Iterates through
|
269
|
+
# the defined finalization methods, if any.
|
270
|
+
def do_finalization(key,obj)
|
271
|
+
@finalizers.each do |f|
|
272
|
+
f[0].call(key,obj,*f[1])
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
class Node
|
277
|
+
attr_accessor :key, :value, :age, :prev_node, :next_node
|
278
|
+
|
279
|
+
def initialize(key=nil,value=nil,age=Time.now,prev_node=nil,next_node=nil)
|
280
|
+
@key = key
|
281
|
+
@value = value
|
282
|
+
@age = age
|
283
|
+
@prev_node = prev_node
|
284
|
+
@next_node = next_node
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# This cache is based off of the LRUCache found in Facets
|
2
|
+
# (http://facets.rubyforg.org) version 1.7.30, which was
|
3
|
+
# contributed by George Moscovitis.
|
4
|
+
|
5
|
+
module Iowa
|
6
|
+
module Caches
|
7
|
+
class SimpleLRUCache < Hash
|
8
|
+
|
9
|
+
# Mix this in your class to make LRU-managable.
|
10
|
+
|
11
|
+
module Item
|
12
|
+
attr_accessor :lru_key, :lru_prev, :lru_next
|
13
|
+
end
|
14
|
+
|
15
|
+
class Sentinel; include Item; end
|
16
|
+
|
17
|
+
attr_accessor :max_items
|
18
|
+
attr_reader :head, :tail
|
19
|
+
|
20
|
+
def initialize(args = {Cmaxsize => 20, Cttl => nil})
|
21
|
+
@finalizers = []
|
22
|
+
lru_clear()
|
23
|
+
if args.kind_of? ::Hash
|
24
|
+
oargs = args
|
25
|
+
args = ::Iowa::Hash.new
|
26
|
+
args.step_merge!(oargs)
|
27
|
+
end
|
28
|
+
args.stringify_keys! if args.respond_to? :stringify_keys!
|
29
|
+
begin
|
30
|
+
@max_items = args[Cmaxsize] || 20
|
31
|
+
@ttl = args[Cttl]
|
32
|
+
@timer = nil
|
33
|
+
lru_clear()
|
34
|
+
rescue Exception
|
35
|
+
args = {Cmaxsize => args || 20, Cttl => nil}
|
36
|
+
retry
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def [](key)
|
41
|
+
if item = super
|
42
|
+
lru_touch(item)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def []=(key, item)
|
47
|
+
item = super
|
48
|
+
item.lru_key = key
|
49
|
+
lru_insert(item)
|
50
|
+
end
|
51
|
+
|
52
|
+
def delete(key)
|
53
|
+
lru_delete(item) if item = super
|
54
|
+
end
|
55
|
+
|
56
|
+
def clear
|
57
|
+
super
|
58
|
+
lru_clear()
|
59
|
+
end
|
60
|
+
|
61
|
+
def first
|
62
|
+
@head.lru_next
|
63
|
+
end
|
64
|
+
|
65
|
+
def last
|
66
|
+
@tail.lru_prev
|
67
|
+
end
|
68
|
+
alias_method :lru, :last
|
69
|
+
|
70
|
+
def add_finalizer(*args,&block)
|
71
|
+
@finalizers.push [block,args]
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def lru_delete(item)
|
77
|
+
lru_join(item.lru_prev, item.lru_next)
|
78
|
+
item
|
79
|
+
end
|
80
|
+
|
81
|
+
def lru_join(x, y)
|
82
|
+
x.lru_next = y
|
83
|
+
y.lru_prev = x
|
84
|
+
y
|
85
|
+
end
|
86
|
+
|
87
|
+
def lru_append(parent, child)
|
88
|
+
lru_join(child, parent.lru_next)
|
89
|
+
lru_join(parent, child)
|
90
|
+
end
|
91
|
+
|
92
|
+
def lru_insert(item)
|
93
|
+
lru_append(@head, item)
|
94
|
+
delete(last.lru_key) if size() > @max_items
|
95
|
+
end
|
96
|
+
|
97
|
+
def lru_touch(item)
|
98
|
+
lru_append(@head, lru_delete(item))
|
99
|
+
end
|
100
|
+
|
101
|
+
def lru_clear
|
102
|
+
@head = Sentinel.new
|
103
|
+
@tail = Sentinel.new
|
104
|
+
lru_join(@head, @tail)
|
105
|
+
end
|
106
|
+
|
107
|
+
def do_finalization(key,obj)
|
108
|
+
@finalizers.each {|f| f[0].call(key,obj,*f[1])}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,396 @@
|
|
1
|
+
require 'thread'
|
2
|
+
require 'iowa/Hash'
|
3
|
+
require 'iowa/Request'
|
4
|
+
require 'iowa/KeyValueCoding'
|
5
|
+
require 'iowa/caches/LRUCache'
|
6
|
+
|
7
|
+
module Iowa
|
8
|
+
module Dispatchers
|
9
|
+
class StandardDispatcher
|
10
|
+
attr_accessor :mapfile
|
11
|
+
|
12
|
+
class NoMapFile < Exception; end
|
13
|
+
|
14
|
+
# {:mapfile => 'FILENAME', :poll_interval => 30, :map => {'/foo/bar.html' => 'Bar'}, :rewrites => [], :secondary_rewrites => []}
|
15
|
+
def initialize(*args)
|
16
|
+
@mutex = Mutex.new
|
17
|
+
@mapfileMTime = Time.at(1)
|
18
|
+
@next_check = Time.at(1)
|
19
|
+
if args[0].respond_to?(:[])
|
20
|
+
if args[0].kind_of?(::Hash)
|
21
|
+
oargs = args[0]
|
22
|
+
args = Iowa::Hash.new
|
23
|
+
args.step_merge!(oargs)
|
24
|
+
end
|
25
|
+
args.stringify_keys! if args.respond_to? :stringify_keys!
|
26
|
+
@mapfile = args[Cmapfile]
|
27
|
+
@poll_interval = args['poll_interval'] ? args['poll_interval'].to_i : 30
|
28
|
+
@path_map = args['map'] || {}
|
29
|
+
@rewrites = RuleSet.new(args['rewrites'] || [])
|
30
|
+
@secondary_rewrites = RuleSet.new(args['secondary_rewrites'] || [])
|
31
|
+
else
|
32
|
+
@mapfile = args[0]
|
33
|
+
@poll_interval = args[1] ? args[1].to_i : 30
|
34
|
+
@path_map = args[2] || {}
|
35
|
+
@rewrites = RuleSet.new(args[3] || [])
|
36
|
+
@secondary_rewrites = RuleSet.new(args[4] || [])
|
37
|
+
end
|
38
|
+
|
39
|
+
raise(NoMapFile, "The mapfile (#{@mapfile}) does not appear to exist.") if !FileTest.exist?(@mapfile.to_s) if @mapfile
|
40
|
+
@mapfile ||= 'mapfile.map' if FileTest.exist?('mapfile.map')
|
41
|
+
check_mapfile
|
42
|
+
@mapfile
|
43
|
+
end
|
44
|
+
|
45
|
+
# Checks to see if the mapfile needs to be reloaded. To avoid
|
46
|
+
# a deluge of stat() calls, it will only check once every
|
47
|
+
# @poll_interval seconds (set during initialization; defaults to
|
48
|
+
# 30 seconds).
|
49
|
+
|
50
|
+
def check_mapfile
|
51
|
+
if @mapfile and @next_check < Time.now
|
52
|
+
@mutex.synchronize do
|
53
|
+
@next_check = Time.at(Time.now + @poll_interval)
|
54
|
+
if File.stat(@mapfile).mtime != @mapfileMTime
|
55
|
+
load_mapfile
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Loads @mapfile.
|
62
|
+
|
63
|
+
def load_mapfile
|
64
|
+
raw_data = {}
|
65
|
+
File.open(@mapfile) do |mf|
|
66
|
+
rd = YAML::load(mf)
|
67
|
+
break unless rd.respond_to?(:has_key?)
|
68
|
+
raw_data = Iowa::Hash.new
|
69
|
+
raw_data.step_merge!(rd)
|
70
|
+
raw_data.symbolify_keys!
|
71
|
+
rs = raw_data.has_key?(:rewrites) ? raw_data[:rewrites] : []
|
72
|
+
@rewrites = RuleSet.new(rs)
|
73
|
+
rs = (raw_data.respond_to?(:[]) and raw_data.has_key?(:secondary_rewrites)) ? raw_data[:secondary_rewrites] : []
|
74
|
+
@secondary_rewrites = RuleSet.new(rs)
|
75
|
+
@path_map = (raw_data.respond_to?(:[]) and raw_data.has_key?(:map)) ? raw_data[:map] : {}
|
76
|
+
if raw_data.respond_to?(:delete)
|
77
|
+
raw_data.delete(:rewrites)
|
78
|
+
raw_data.delete(:secondary_rewrites)
|
79
|
+
raw_data.delete(:map)
|
80
|
+
end
|
81
|
+
raw_data.each {|k,v| @path_map[k] = v if (k.class.is_a?(String) and v.class.is_a?(String))}
|
82
|
+
@mapfileMTime = mf.mtime
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns true if the dispatcher is willing to handle this request.
|
87
|
+
|
88
|
+
def handleRequest?(request)
|
89
|
+
check_mapfile
|
90
|
+
if !Iowa.app.policy.getIDs(request.uri)[1].nil?
|
91
|
+
true
|
92
|
+
else
|
93
|
+
process(request)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Dispatches the request.
|
98
|
+
|
99
|
+
def dispatch(session,context,dispatch_destination = nil)
|
100
|
+
unless dispatch_destination or context.actionID
|
101
|
+
request = context.request
|
102
|
+
check_mapfile
|
103
|
+
dispatch_destination = process(request)
|
104
|
+
end
|
105
|
+
session.handleRequest(context,dispatch_destination)
|
106
|
+
end
|
107
|
+
|
108
|
+
def process(request)
|
109
|
+
dd = @rewrites.process(request)
|
110
|
+
return dd if dd.is_a?(Iowa::DispatchDestination)
|
111
|
+
if c = @path_map[request.uri]
|
112
|
+
return Iowa::DispatchDestination.new(c)
|
113
|
+
else
|
114
|
+
dd = @secondary_rewrites.process(request)
|
115
|
+
return dd if dd.is_a?(Iowa::DispatchDestination)
|
116
|
+
|
117
|
+
# At this point, the easy checks are done. If we are still here, there was no
|
118
|
+
# match in the mapfile, and no rule provided a specific dispatch destination.
|
119
|
+
# So, use a set of heuristics, assuming a RESTfully structured URI, to figure
|
120
|
+
# out what should be done.
|
121
|
+
#
|
122
|
+
# The basic pattern that is expected is /component/method/arg1/arg2/argn
|
123
|
+
#
|
124
|
+
# On top of this basic pattern, there are some specific exceptions, based on
|
125
|
+
# the HTTP verb the request is using (GET, PUT, POST, DELETE), that
|
126
|
+
# deviate from that basic pattern. These provide shortcuts for RESTful URLs,
|
127
|
+
# and are based in part on the RESTful Rails work.
|
128
|
+
#
|
129
|
+
# Method dispatch also supports the notion of dispatching to verb specific
|
130
|
+
# methods. This is ultimately carried out in the Context object when an
|
131
|
+
# action is being invoked, however, as the target object must be interrogated
|
132
|
+
# to determine whether it has a method specific to the verb.
|
133
|
+
#
|
134
|
+
|
135
|
+
dd = nil
|
136
|
+
request_uri = request.uri.sub(/\.\w+$/,C_empty)
|
137
|
+
#/component/method/arg1/arg2/argn
|
138
|
+
if request_uri =~ /^\/(\w+)\/(?:(\w+)((?:\/\w+)+)|([a-zA-Z]\w*)((?:\/\w+)*))$/
|
139
|
+
c = $1
|
140
|
+
m = $2 || $4
|
141
|
+
args = $3 || $5
|
142
|
+
args = args ? args[1..-1].to_s.split(C_slash) : []
|
143
|
+
dd = Iowa::DispatchDestination.new(c,m,args)
|
144
|
+
#/component/arg1/arg2/argn;method
|
145
|
+
#elsif request_uri =~ /^\/(\w+)((?:\/[\d\-a-f]+)+);(\w+)$/
|
146
|
+
elsif request_uri =~ /^\/(\w+)((?:\/[\w%]+)+);(\w+)$/
|
147
|
+
c = $1
|
148
|
+
m = $3
|
149
|
+
args = $2[1..-1].to_s.split(C_slash)
|
150
|
+
dd = Iowa::DispatchDestination.new(c,m,args)
|
151
|
+
else
|
152
|
+
request.request_method = request.params[C_method] if request.params[C_method]
|
153
|
+
rmeth = request.params[C_method] ? request.params[C_method].upcase : request.request_method.upcase
|
154
|
+
if rmeth == CGET or rmeth == CHEAD
|
155
|
+
if request_uri =~ /^\/(\w+)$/
|
156
|
+
dd = Iowa::DispatchDestination.new($1)
|
157
|
+
#elsif request_uri =~ /^\/(\w+)((?:\/[\d\-a-f]+)+)$/
|
158
|
+
elsif request_uri =~ /^\/(\w+)((?:\/[\w%]+)+)$/
|
159
|
+
c = $1
|
160
|
+
args = $2[1..-1].to_s.split(C_slash)
|
161
|
+
dd = Iowa::DispatchDestination.new(c,Cshow,args)
|
162
|
+
end
|
163
|
+
elsif rmeth == CPOST
|
164
|
+
if request_uri =~ /^\/(\w+)$/
|
165
|
+
dd = Iowa::DispatchDestination.new($1,Ccreate)
|
166
|
+
end
|
167
|
+
elsif rmeth == CPUT
|
168
|
+
#if request_uri =~ /^\/(\w+)((?:\/[\d\-a-f]+)+)$/
|
169
|
+
if request_uri =~ /^\/(\w+)((?:\/[\w%]+)+)$/
|
170
|
+
c = $1
|
171
|
+
args = $2[1..-1].to_s.split(C_slash)
|
172
|
+
dd = Iowa::DispatchDestination.new(c,Cupdate,args)
|
173
|
+
end
|
174
|
+
elsif rmeth == CDELETE
|
175
|
+
#if request_uri =~ /^\/(\w+)((?:\/[\d\-a-f]+)+)$/
|
176
|
+
if request_uri =~ /^\/(\w+)((?:\/[\w%]+)+)$/
|
177
|
+
c = $1
|
178
|
+
args = $2[1..-1].to_s.split(C_slash)
|
179
|
+
dd = Iowa::DispatchDestination.new(c,Cdestroy,args)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
dd
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# --------------------
|
188
|
+
|
189
|
+
class RuleSet
|
190
|
+
def initialize(rule_struct)
|
191
|
+
@rules = []
|
192
|
+
if rule_struct.respond_to?(:[])
|
193
|
+
if rule_struct.respond_to?(:has_key?)
|
194
|
+
@rules << RewriteRule.new(rule_struct)
|
195
|
+
else
|
196
|
+
rule_struct.each {|rule| @rules << RewriteRule.new(rule)}
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def process(request)
|
202
|
+
catch(:final) do
|
203
|
+
@rules.each {|rule| rule.process(request)}
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
class RewriteRule
|
210
|
+
def initialize(prearg = {:match => '',
|
211
|
+
:sub => nil,
|
212
|
+
:target => nil,
|
213
|
+
:gsub => nil,
|
214
|
+
:call => nil,
|
215
|
+
:eval => nil,
|
216
|
+
:branch => nil,
|
217
|
+
:dispatch => nil,
|
218
|
+
:final => false,
|
219
|
+
:cache => nil})
|
220
|
+
arg = Iowa::Hash.new
|
221
|
+
arg.step_merge!(prearg)
|
222
|
+
arg.symbolify_keys!
|
223
|
+
|
224
|
+
if arg[:cache]
|
225
|
+
@cache_size = arg[:cache].to_i > 0 ? arg[:cache].to_i : 100
|
226
|
+
self.cacheable = true
|
227
|
+
else
|
228
|
+
@cache_size = 100
|
229
|
+
self.cacheable = false
|
230
|
+
end
|
231
|
+
|
232
|
+
@final = arg[:final] ? true : false
|
233
|
+
if !arg[:match].is_a?(Regexp) and arg[:match] =~ /^\s*(\{|do).*(\}|end)\s*/m
|
234
|
+
instance_eval("@match = Proc.new #{arg[:match]}")
|
235
|
+
else
|
236
|
+
@match = arg[:match].is_a?(Regexp) ? arg[:match] : Regexp.new(arg[:match])
|
237
|
+
end
|
238
|
+
|
239
|
+
if arg[:target] =~ /^\s*(\{|do).*(\}|end)\s*/m
|
240
|
+
instance_eval("@target = Proc.new #{arg[:target]}")
|
241
|
+
else
|
242
|
+
@target = arg[:target]
|
243
|
+
end
|
244
|
+
|
245
|
+
@subtype = (arg[:gsub] && :gsub) || (arg[:sub] && :sub) || nil
|
246
|
+
rawsub = arg[:gsub] || arg[:sub]
|
247
|
+
if rawsub =~ /^\s*(\{|do).*(\}|end)\s*/m
|
248
|
+
instance_eval("@subproc = Proc.new #{rawsub}")
|
249
|
+
@subsub = nil
|
250
|
+
else
|
251
|
+
@subsub = rawsub
|
252
|
+
@subproc = nil
|
253
|
+
end
|
254
|
+
|
255
|
+
if arg[:eval]
|
256
|
+
ep = arg[:eval]
|
257
|
+
if ep !~ /^\s*(\{|do).*(\}|end)\s*/m
|
258
|
+
ep = "{|request| #{ep}}"
|
259
|
+
end
|
260
|
+
instance_eval("@evalproc = Proc.new #{ep}")
|
261
|
+
else
|
262
|
+
@evalproc = nil
|
263
|
+
end
|
264
|
+
|
265
|
+
@call = arg[:call]
|
266
|
+
@branch = arg[:branch] ? RuleSet.new(arg[:branch]) : nil
|
267
|
+
if arg[:dispatch] =~ /^\s*(\{|do).*(\}|end)\s*/m
|
268
|
+
instance_eval("@dispatch = Proc.new #{arg[:dispatch]}")
|
269
|
+
@final = true
|
270
|
+
elsif arg[:dispatch]
|
271
|
+
@dispatch = Iowa::DispatchDestination.new(arg[:dispatch])
|
272
|
+
@final = true
|
273
|
+
else
|
274
|
+
@dispatch = nil
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def cacheable?
|
279
|
+
@cacheable
|
280
|
+
end
|
281
|
+
|
282
|
+
def cacheable=(val)
|
283
|
+
if val
|
284
|
+
@cache = Iowa::Caches::LRUCache(@cache_size)
|
285
|
+
@cacheable = true
|
286
|
+
else
|
287
|
+
@cache = nil
|
288
|
+
@cacheable = false
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def component=(c)
|
293
|
+
if @destination
|
294
|
+
@destination.component = c
|
295
|
+
else
|
296
|
+
@destination = Iowa::DispatchDestination.new(c)
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def component
|
301
|
+
@destination ? @destination.component : nil
|
302
|
+
end
|
303
|
+
|
304
|
+
def method=(m)
|
305
|
+
if @destination
|
306
|
+
@destination.method = m
|
307
|
+
else
|
308
|
+
@destination = Iowa::DispatchDestination.new(m)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def method
|
313
|
+
@destination ? @destination.method : nil
|
314
|
+
end
|
315
|
+
|
316
|
+
def args=(a)
|
317
|
+
if @destination
|
318
|
+
@destination.args = a
|
319
|
+
else
|
320
|
+
@destination = Iowa::DispatchDestination.new(a)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
def args
|
325
|
+
@destination ? @destination.args : nil
|
326
|
+
end
|
327
|
+
|
328
|
+
def process(request)
|
329
|
+
do_branch = @branch
|
330
|
+
original_uri = request.uri
|
331
|
+
request.uri = ::String.new(request.uri) if request.uri.frozen?
|
332
|
+
@destination = nil
|
333
|
+
if @cacheable and @cache.include?(request.uri)
|
334
|
+
request.uri = @cache[request.uri]
|
335
|
+
do_branch = false
|
336
|
+
elsif (@match.is_a?(::Proc) ? @match.call(request) : @match.match(request.uri))
|
337
|
+
if @subtype
|
338
|
+
if @subsub
|
339
|
+
if @subtype == :sub
|
340
|
+
request.uri.sub!(@match,@subsub)
|
341
|
+
elsif @subtype == :gsub
|
342
|
+
request.uri.gsub!(@match,@subsub)
|
343
|
+
end
|
344
|
+
elsif @subproc
|
345
|
+
if @subtype == :sub
|
346
|
+
request.uri.sub!(@match) {|*args| @subproc.call(request,*args)}
|
347
|
+
elsif @subtype == :gsub
|
348
|
+
request.uri.gsub!(@match) {|*args| @subproc.call(request,*args)}
|
349
|
+
end
|
350
|
+
end
|
351
|
+
elsif @call
|
352
|
+
call_completed = false
|
353
|
+
if @call =~ /(?:::|^[A-Z][\w\d]*\.)/
|
354
|
+
@call.sub!(/^::/,'')
|
355
|
+
if @call =~ /::/
|
356
|
+
parts = @call.split(/::/).reject {|p| p == ''}
|
357
|
+
else
|
358
|
+
parts = @call.split('.',2)
|
359
|
+
end
|
360
|
+
meth = parts.pop
|
361
|
+
catch(:bad_const) do
|
362
|
+
klass = parts.inject(Object) do |o,n|
|
363
|
+
if o.const_defined? n
|
364
|
+
o.const_get n
|
365
|
+
else
|
366
|
+
throw :bad_const
|
367
|
+
end
|
368
|
+
end
|
369
|
+
throw :bad_const unless klass.existsKeyPath?(meth)
|
370
|
+
klass.valueForKeyPathWithArgs(meth,request)
|
371
|
+
call_completed = true
|
372
|
+
end
|
373
|
+
end
|
374
|
+
unless call_completed
|
375
|
+
::TOPLEVEL_BINDING.send(:valueForKeyPathWithArgs,@call,request)
|
376
|
+
end
|
377
|
+
elsif @evalproc
|
378
|
+
@evalproc.call(request)
|
379
|
+
end
|
380
|
+
|
381
|
+
if do_branch and !@final
|
382
|
+
@branch.process(request)
|
383
|
+
end
|
384
|
+
|
385
|
+
@destination = @dispatch
|
386
|
+
@cache[original_uri] = request.uri if @cacheable
|
387
|
+
|
388
|
+
throw(:final,@destination) if @final
|
389
|
+
end
|
390
|
+
|
391
|
+
@destination
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|