IOWA 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/src/iowa/Hash.rb
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module Iowa
|
|
2
|
+
|
|
3
|
+
# This is a subclass of Ruby's Hash that implements a few convenient
|
|
4
|
+
# methods used by IOWA.
|
|
5
|
+
|
|
6
|
+
class Hash < Hash
|
|
7
|
+
|
|
8
|
+
# A simple little routine to downcase any String used as a key
|
|
9
|
+
# in a hash or any hash nested as value somewhere within the hash.
|
|
10
|
+
# Thanks to Daniel Berger for this implementation.
|
|
11
|
+
|
|
12
|
+
def downcase_keys!
|
|
13
|
+
upper = /A-Z/
|
|
14
|
+
self.each do |k,v|
|
|
15
|
+
next unless k.kind_of? String
|
|
16
|
+
self[k.dup.downcase] = v
|
|
17
|
+
self.delete(k) if upper.match(k)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Convert any symbolic keys to strings.
|
|
22
|
+
|
|
23
|
+
def stringify_keys!
|
|
24
|
+
current_keys = self.keys
|
|
25
|
+
current_keys.each do |k|
|
|
26
|
+
v = self[k]
|
|
27
|
+
self.delete k
|
|
28
|
+
self[k.to_s] = v
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Convert any string keys to symbols.
|
|
33
|
+
|
|
34
|
+
def symbolify_keys!
|
|
35
|
+
current_keys = self.keys
|
|
36
|
+
current_keys.each do |k|
|
|
37
|
+
v = self[k]
|
|
38
|
+
self.delete k
|
|
39
|
+
self[k.to_s.intern] = v
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def symbolify_all_keys!
|
|
44
|
+
current_keys = self.keys
|
|
45
|
+
current_keys.each do |k|
|
|
46
|
+
v = self[k]
|
|
47
|
+
v.symbolify_all_keys! if v.respond_to?(:has_key?)
|
|
48
|
+
self.delete k
|
|
49
|
+
self[k.to_s.intern] = v
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def step_merge!(h)
|
|
54
|
+
h.each do |k,v|
|
|
55
|
+
if v.kind_of?(::Hash)
|
|
56
|
+
if self[k].kind_of?(::Hash)
|
|
57
|
+
unless self[k].respond_to?(:step_merge!)
|
|
58
|
+
if dp = self[k].default_proc
|
|
59
|
+
self[k] = Iowa::Hash.new {|h,k| dp.call(h,k)}.step_merge!(self[k])
|
|
60
|
+
else
|
|
61
|
+
osk = self[k]
|
|
62
|
+
self[k] = Iowa::Hash.new
|
|
63
|
+
self[k].step_merge!(osk)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
self[k].step_merge!(v)
|
|
67
|
+
else
|
|
68
|
+
if self.default_proc
|
|
69
|
+
self.delete k
|
|
70
|
+
self[k]
|
|
71
|
+
end
|
|
72
|
+
unless self[k].kind_of?(::Hash)
|
|
73
|
+
self.delete k
|
|
74
|
+
self[k] = Iowa::Hash.new
|
|
75
|
+
end
|
|
76
|
+
self[k].step_merge!(v)
|
|
77
|
+
end
|
|
78
|
+
else
|
|
79
|
+
self[k] = v
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
end
|
data/src/iowa/ISAAC.rb
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
module Crypt
|
|
2
|
+
|
|
3
|
+
# This is included in IOWA for convenience. This PRNG is packaged
|
|
4
|
+
# separately for use independly from IOWA, and can be found on
|
|
5
|
+
# Rubyforge at http://rubyforge.org/projects/crypt-isaac
|
|
6
|
+
#
|
|
7
|
+
# ISAAC is a fast, strong random number generator. Details on the
|
|
8
|
+
# algorithm can be found here: http://burtleburtle.net/bob/rand/isaac.html
|
|
9
|
+
# This provides a consistent and capable algorithm for producing
|
|
10
|
+
# independent streams of quality random numbers.
|
|
11
|
+
|
|
12
|
+
class ISAAC
|
|
13
|
+
|
|
14
|
+
attr_accessor :randrsl, :randcnt
|
|
15
|
+
attr_accessor :mm, :aa, :bb, :cc
|
|
16
|
+
|
|
17
|
+
# When a Crypt::ISAAC object is created, it needs to be seeded for
|
|
18
|
+
# random number generation. If the system has a /dev/urandom file,
|
|
19
|
+
# that will be used to do the seeding by default. If false is explictly
|
|
20
|
+
# passed when creating the object, it will instead use /dev/random to
|
|
21
|
+
# generate its seeds. Be warned that this may make for SLOW
|
|
22
|
+
# initialization.
|
|
23
|
+
# If the requested source (/dev/urandom or /dev/random) do not exist,
|
|
24
|
+
# the system will fall back to a simplistic initialization mechanism
|
|
25
|
+
# using the builtin Mersenne Twister PRNG.
|
|
26
|
+
|
|
27
|
+
def initialize(noblock = true)
|
|
28
|
+
@mm = []
|
|
29
|
+
@randrsl = []
|
|
30
|
+
# Best initialization of the generator would be by pulling
|
|
31
|
+
# numbers from /dev/random.
|
|
32
|
+
rnd_source = noblock ? '/dev/urandom' : '/dev/random'
|
|
33
|
+
if (FileTest.exist? rnd_source)
|
|
34
|
+
File.open(rnd_source,'r') do |r|
|
|
35
|
+
256.times do |t|
|
|
36
|
+
z = r.sysread(4)
|
|
37
|
+
x = z.unpack('V')[0]
|
|
38
|
+
@randrsl[t] = x
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
else
|
|
42
|
+
# If urandom isn't available, the standard Ruby PRNG makes an
|
|
43
|
+
# adequate fallback.
|
|
44
|
+
256.times do |t|
|
|
45
|
+
@randrsl[t] = Kernel.rand(4294967295)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
randinit(true)
|
|
49
|
+
nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Works just like the standard rand() function. If called with an
|
|
53
|
+
# integer argument, rand() will return positive random number in
|
|
54
|
+
# the range of 0 to (argument - 1). If called without an integer
|
|
55
|
+
# argument, rand() returns a positive floating point number less than 1.
|
|
56
|
+
|
|
57
|
+
def rand(*num)
|
|
58
|
+
if (@randcnt == 1)
|
|
59
|
+
isaac
|
|
60
|
+
@randcnt = 256
|
|
61
|
+
end
|
|
62
|
+
@randcnt -= 1
|
|
63
|
+
if num[0].to_i > 0
|
|
64
|
+
@randrsl[@randcnt].modulo(num[0])
|
|
65
|
+
else
|
|
66
|
+
@randrsl[@randcnt]/4294967296.0
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def isaac
|
|
71
|
+
i = 0
|
|
72
|
+
x = 0
|
|
73
|
+
y = 0
|
|
74
|
+
|
|
75
|
+
@cc += 1
|
|
76
|
+
@bb += @cc
|
|
77
|
+
@bb &= 0xffffffff
|
|
78
|
+
|
|
79
|
+
while (i < 256) do
|
|
80
|
+
x = @mm[i]
|
|
81
|
+
@aa = (@mm[(i + 128) & 255] + (@aa^(@aa << 13)) ) & 0xffffffff
|
|
82
|
+
@mm[i] = y = (@mm[(x>>2)&255] + @aa + @bb ) & 0xffffffff
|
|
83
|
+
@randrsl[i] = @bb = (@mm[(y>>10)&255] + x ) & 0xffffffff
|
|
84
|
+
i += 1
|
|
85
|
+
|
|
86
|
+
x = @mm[i]
|
|
87
|
+
@aa = (@mm[(i+128)&255] + (@aa^(0x03ffffff & (@aa >> 6))) ) & 0xffffffff
|
|
88
|
+
@mm[i] = y = (@mm[(x>>2)&255] + @aa + @bb ) & 0xffffffff
|
|
89
|
+
@randrsl[i] = @bb = (@mm[(y>>10)&255] + x ) & 0xffffffff
|
|
90
|
+
i += 1
|
|
91
|
+
|
|
92
|
+
x = @mm[i]
|
|
93
|
+
@aa = (@mm[(i + 128)&255] + (@aa^(@aa << 2)) ) & 0xffffffff
|
|
94
|
+
@mm[i] = y = (@mm[(x>>2)&255] + @aa + @bb ) & 0xffffffff
|
|
95
|
+
@randrsl[i] = @bb = (@mm[(y>>10)&255] + x ) & 0xffffffff
|
|
96
|
+
i += 1
|
|
97
|
+
|
|
98
|
+
x = @mm[i]
|
|
99
|
+
@aa = (@mm[(i+128)&255] + (@aa^(0x0000ffff & (@aa >> 16))) ) & 0xffffffff
|
|
100
|
+
@mm[i] = y = (@mm[(x>>2)&255] + @aa + @bb ) & 0xffffffff
|
|
101
|
+
@randrsl[i] = @bb = (@mm[(y>>10)&255] + x ) & 0xffffffff
|
|
102
|
+
i += 1
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def randinit(flag)
|
|
107
|
+
i = 0
|
|
108
|
+
a = 0
|
|
109
|
+
b = 0
|
|
110
|
+
c = 0
|
|
111
|
+
d = 0
|
|
112
|
+
e = 0
|
|
113
|
+
f = 0
|
|
114
|
+
g = 0
|
|
115
|
+
@aa = @bb = @cc = 0
|
|
116
|
+
a = b = c = d = e = f = g = h = 0x9e3779b9
|
|
117
|
+
|
|
118
|
+
while (i < 4) do
|
|
119
|
+
a ^= b<<1; d += a; b += c
|
|
120
|
+
b ^= 0x3fffffff & (c>>2); e += b; c += d
|
|
121
|
+
c ^= d << 8; f += c; d += e
|
|
122
|
+
d ^= 0x0000ffff & (e >> 16); g += d; e += f
|
|
123
|
+
e ^= f << 10; h += e; f += g
|
|
124
|
+
f ^= 0x0fffffff & (g >> 4); a += f; g += h
|
|
125
|
+
g ^= h << 8; b += g; h += a
|
|
126
|
+
h ^= 0x007fffff & (a >> 9); c += h; a += b
|
|
127
|
+
i += 1
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
i = 0
|
|
131
|
+
while (i < 256) do
|
|
132
|
+
if (flag)
|
|
133
|
+
a+=@randrsl[i ].to_i; b+=@randrsl[i+1].to_i;
|
|
134
|
+
c+=@randrsl[i+2]; d+=@randrsl[i+3];
|
|
135
|
+
e+=@randrsl[i+4]; f+=@randrsl[i+5];
|
|
136
|
+
g+=@randrsl[i+6]; h+=@randrsl[i+7];
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
a^=b<<11; d+=a; b+=c;
|
|
140
|
+
b^=0x3fffffff & (c>>2); e+=b; c+=d;
|
|
141
|
+
c^=d<<8; f+=c; d+=e;
|
|
142
|
+
d^=0x0000ffff & (e>>16); g+=d; e+=f;
|
|
143
|
+
e^=f<<10; h+=e; f+=g;
|
|
144
|
+
f^=0x0fffffff & (g>>4); a+=f; g+=h;
|
|
145
|
+
g^=h<<8; b+=g; h+=a;
|
|
146
|
+
h^=0x007fffff & (a>>9); c+=h; a+=b;
|
|
147
|
+
@mm[i]=a;@mm[i+1]=b; @mm[i+2]=c; @mm[i+3]=d;
|
|
148
|
+
@mm[i+4]=e; @mm[i+5]=f; @mm[i+6]=g; @mm[i+7]=h;
|
|
149
|
+
i += 8
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
if flag
|
|
153
|
+
i = 0
|
|
154
|
+
while (i < 256)
|
|
155
|
+
a+=@mm[i ]; b+=@mm[i+1]; c+=@mm[i+2]; d+=@mm[i+3];
|
|
156
|
+
e+=@mm[i+4]; f+=@mm[i+5]; g+=@mm[i+6]; h+=@mm[i+7];
|
|
157
|
+
a^=b<<11; d+=a; b+=c;
|
|
158
|
+
b^=0x3fffffff & (c>>2); e+=b; c+=d;
|
|
159
|
+
c^=d<<8; f+=c; d+=e;
|
|
160
|
+
d^=0x0000ffff & (e>>16); g+=d; e+=f;
|
|
161
|
+
e^=f<<10; h+=e; f+=g;
|
|
162
|
+
f^=0x0fffffff & (g>>4); a+=f; g+=h;
|
|
163
|
+
g^=h<<8; b+=g; h+=a;
|
|
164
|
+
h^=0x007fffff & (a>>9); c+=h; a+=b;
|
|
165
|
+
@mm[i ]=a; @mm[i+1]=b; @mm[i+2]=c; @mm[i+3]=d;
|
|
166
|
+
@mm[i+4]=e; @mm[i+5]=f; @mm[i+6]=g; @mm[i+7]=h;
|
|
167
|
+
i += 8
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
isaac()
|
|
172
|
+
@randcnt=256; # /* prepare to use the first set of results */
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# This is based on the image size library found at http://www.rubycgi.org/archive
|
|
2
|
+
|
|
3
|
+
module Iowa
|
|
4
|
+
class ImageSize
|
|
5
|
+
# Image Type Constants
|
|
6
|
+
module Type
|
|
7
|
+
OTHER = "OTHER"
|
|
8
|
+
GIF = "GIF"
|
|
9
|
+
PNG = "PNG"
|
|
10
|
+
JPEG = "JPEG"
|
|
11
|
+
BMP = "BMP"
|
|
12
|
+
PPM = "PPM" # PPM is like PBM, PGM, & XV
|
|
13
|
+
PBM = "PBM"
|
|
14
|
+
PGM = "PGM"
|
|
15
|
+
# XV = "XV"
|
|
16
|
+
XBM = "XBM"
|
|
17
|
+
TIFF = "TIFF"
|
|
18
|
+
XPM = "XPM"
|
|
19
|
+
PSD = "PSD"
|
|
20
|
+
PCX = "PCX"
|
|
21
|
+
SWF = "SWF"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
JpegCodeCheck = [
|
|
25
|
+
"\xc0", "\xc1", "\xc2", "\xc3",
|
|
26
|
+
"\xc5", "\xc6", "\xc7",
|
|
27
|
+
"\xc9", "\xca", "\xcb",
|
|
28
|
+
"\xcd", "\xce", "\xcf",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
# image type list
|
|
32
|
+
def ImageSize.type_list
|
|
33
|
+
Type.constants
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# receive image & make size
|
|
37
|
+
# argument is image String or IO
|
|
38
|
+
def initialize(img_data, img_type = nil)
|
|
39
|
+
@img_data = img_data.dup
|
|
40
|
+
@img_wedth = nil
|
|
41
|
+
@img_height = nil
|
|
42
|
+
|
|
43
|
+
if @img_data.is_a?(IO)
|
|
44
|
+
@img_top = @img_data.read(128)
|
|
45
|
+
@img_data.seek(0, 0)
|
|
46
|
+
# define Singleton-method definition to IO (byte, offset)
|
|
47
|
+
def @img_data.read_o(length = 1, offset = nil)
|
|
48
|
+
self.seek(offset, 0) if offset
|
|
49
|
+
ret = self.read(length)
|
|
50
|
+
raise "cannot read!!" unless ret
|
|
51
|
+
ret
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
@img_data = @img_data.to_s
|
|
55
|
+
@img_top = @img_data[0, 128]
|
|
56
|
+
# define Singleton-method definition to String (byte, offset)
|
|
57
|
+
def @img_data.read_o(length = 1, offset = nil)
|
|
58
|
+
@img_offset = 0 if !(defined?(@img_offset))
|
|
59
|
+
@img_offset = offset if offset
|
|
60
|
+
ret = self[@img_offset, length]
|
|
61
|
+
@img_offset += length
|
|
62
|
+
ret
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if img_type.nil?
|
|
67
|
+
@img_type = check_type()
|
|
68
|
+
else
|
|
69
|
+
match = false
|
|
70
|
+
Type.constants.each do |t|
|
|
71
|
+
match = true if img_type == t
|
|
72
|
+
end
|
|
73
|
+
raise("img_type is failed. #{img_type}\n") if match == false
|
|
74
|
+
@img_type = img_type
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
@img_width, @img_height = __send__("measure_#{@img_type}") if @img_type != Type::OTHER
|
|
78
|
+
# eval("@img_width, @img_height = measure_" + @img_type + "()") if @img_type != Type::OTHER
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# get parameter
|
|
82
|
+
def type; @img_type; end
|
|
83
|
+
def height
|
|
84
|
+
if @img_type == Type::OTHER then nil else @img_height end
|
|
85
|
+
end
|
|
86
|
+
def width
|
|
87
|
+
if @img_type == Type::OTHER then nil else @img_width end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def check_type()
|
|
91
|
+
if @img_top =~ /^GIF8[7,9]a/ then Type::GIF
|
|
92
|
+
elsif @img_top[0, 8] == "\x89PNG\x0d\x0a\x1a\x0a" then Type::PNG
|
|
93
|
+
elsif @img_top[0, 2] == "\xFF\xD8" then Type::JPEG
|
|
94
|
+
elsif @img_top[0, 2] == 'BM' then Type::BMP
|
|
95
|
+
elsif @img_top =~ /^P[1-7]/ then Type::PPM
|
|
96
|
+
elsif @img_top =~ /\#define\s+\S+\s+\d+/ then Type::XBM
|
|
97
|
+
elsif @img_top[0, 4] == "MM\x00\x2a" then Type::TIFF
|
|
98
|
+
elsif @img_top[0, 4] == "II\x2a\x00" then Type::TIFF
|
|
99
|
+
elsif @img_top =~ /\/\* XPM \*\// then Type::XPM
|
|
100
|
+
elsif @img_top[0, 4] == "8BPS" then Type::PSD
|
|
101
|
+
elsif @img_top[0, 3] == "FWS" then Type::SWF
|
|
102
|
+
elsif @img_top[0] == 10 then Type::PCX
|
|
103
|
+
else Type::OTHER
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
private(:check_type)
|
|
107
|
+
|
|
108
|
+
def measure_GIF()
|
|
109
|
+
@img_data.read_o(6)
|
|
110
|
+
@img_data.read_o(4).unpack('vv')
|
|
111
|
+
end
|
|
112
|
+
private(:measure_GIF)
|
|
113
|
+
|
|
114
|
+
def measure_PNG()
|
|
115
|
+
@img_data.read_o(12)
|
|
116
|
+
raise "This file is not PNG." unless @img_data.read_o(4) == "IHDR"
|
|
117
|
+
@img_data.read_o(8).unpack('NN')
|
|
118
|
+
end
|
|
119
|
+
private(:measure_PNG)
|
|
120
|
+
|
|
121
|
+
def measure_JPEG()
|
|
122
|
+
c_marker = "\xFF" # Section marker.
|
|
123
|
+
@img_data.read_o(2)
|
|
124
|
+
while(true)
|
|
125
|
+
marker, code, length = @img_data.read_o(4).unpack('aan')
|
|
126
|
+
raise "JPEG marker not found!" if marker != c_marker
|
|
127
|
+
|
|
128
|
+
if JpegCodeCheck.include?(code)
|
|
129
|
+
height, width = @img_data.read_o(5).unpack('xnn')
|
|
130
|
+
return([width, height])
|
|
131
|
+
end
|
|
132
|
+
@img_data.read_o(length - 2)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
private(:measure_JPEG)
|
|
136
|
+
|
|
137
|
+
def measure_BMP()
|
|
138
|
+
@img_data.read_o(26).unpack("x18VV");
|
|
139
|
+
end
|
|
140
|
+
private(:measure_BMP)
|
|
141
|
+
|
|
142
|
+
def measure_PPM()
|
|
143
|
+
header = @img_data.read_o(1024)
|
|
144
|
+
header.gsub!(/^\#[^\n\r]*/m, "")
|
|
145
|
+
header =~ /^(P[1-6])\s+?(\d+)\s+?(\d+)/m
|
|
146
|
+
width = $2.to_i; height = $3.to_i
|
|
147
|
+
case $1
|
|
148
|
+
when "P1", "P4" then @img_type = "PBM"
|
|
149
|
+
when "P2", "P5" then @img_type = "PGM"
|
|
150
|
+
when "P3", "P6" then @img_type = "PPM"
|
|
151
|
+
# when "P7"
|
|
152
|
+
# @img_type = "XV"
|
|
153
|
+
# header =~ /IMGINFO:(\d+)x(\d+)/m
|
|
154
|
+
# width = $1.to_i; height = $2.to_i
|
|
155
|
+
end
|
|
156
|
+
[width, height]
|
|
157
|
+
end
|
|
158
|
+
private(:measure_PPM)
|
|
159
|
+
|
|
160
|
+
alias :measure_PGM :measure_PPM
|
|
161
|
+
private(:measure_PGM)
|
|
162
|
+
alias :measure_PBM :measure_PPM
|
|
163
|
+
private(:measure_PBM)
|
|
164
|
+
|
|
165
|
+
def measure_XBM()
|
|
166
|
+
@img_data.read_o(1024) =~ /^\#define\s*\S*\s*(\d+)\s*\n\#define\s*\S*\s*(\d+)/mi
|
|
167
|
+
[$1.to_i, $2.to_i]
|
|
168
|
+
end
|
|
169
|
+
private(:measure_XBM)
|
|
170
|
+
|
|
171
|
+
def measure_XPM()
|
|
172
|
+
width = height = nil
|
|
173
|
+
while(line = @img_data.read_o(1024))
|
|
174
|
+
if line =~ /"\s*(\d+)\s+(\d+)(\s+\d+\s+\d+){1,2}\s*"/m
|
|
175
|
+
width = $1.to_i; height = $2.to_i
|
|
176
|
+
break
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
[width, height]
|
|
180
|
+
end
|
|
181
|
+
private(:measure_XPM)
|
|
182
|
+
|
|
183
|
+
def measure_PSD()
|
|
184
|
+
y,x = @img_data.read_o(26).unpack("x14NN")
|
|
185
|
+
[x,y]
|
|
186
|
+
end
|
|
187
|
+
private(:measure_PSD)
|
|
188
|
+
|
|
189
|
+
def measure_TIFF()
|
|
190
|
+
endian = if (@img_data.read_o(4) =~ /II\x2a\x00/o) then 'v' else 'n' end
|
|
191
|
+
# 'v' little-endian 'n' default to big-endian
|
|
192
|
+
|
|
193
|
+
packspec = [
|
|
194
|
+
nil, # nothing (shouldn't happen)
|
|
195
|
+
'C', # BYTE (8-bit unsigned integer)
|
|
196
|
+
nil, # ASCII
|
|
197
|
+
endian, # SHORT (16-bit unsigned integer)
|
|
198
|
+
endian.upcase, # LONG (32-bit unsigned integer)
|
|
199
|
+
nil, # RATIONAL
|
|
200
|
+
'c', # SBYTE (8-bit signed integer)
|
|
201
|
+
nil, # UNDEFINED
|
|
202
|
+
endian, # SSHORT (16-bit unsigned integer)
|
|
203
|
+
endian.upcase, # SLONG (32-bit unsigned integer)
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
offset = @img_data.read_o(4).unpack(endian.upcase)[0] # Get offset to IFD
|
|
207
|
+
|
|
208
|
+
ifd = @img_data.read_o(2, offset)
|
|
209
|
+
num_dirent = ifd.unpack(endian)[0] # Make it useful
|
|
210
|
+
offset += 2
|
|
211
|
+
num_dirent = offset + (num_dirent * 12); # Calc. maximum offset of IFD
|
|
212
|
+
|
|
213
|
+
ifd = width = height = nil
|
|
214
|
+
while(width.nil? || height.nil?)
|
|
215
|
+
ifd = @img_data.read_o(12, offset) # Get first directory entry
|
|
216
|
+
break if (ifd.nil? || (offset > num_dirent))
|
|
217
|
+
offset += 12
|
|
218
|
+
tag = ifd.unpack(endian)[0] # ...and decode its tag
|
|
219
|
+
type = ifd[2, 2].unpack(endian)[0] # ...and the data type
|
|
220
|
+
|
|
221
|
+
# Check the type for sanity.
|
|
222
|
+
next if (type > packspec.size + 0) || (packspec[type].nil?)
|
|
223
|
+
if tag == 0x0100 # Decode the value
|
|
224
|
+
width = ifd[8, 4].unpack(packspec[type])[0]
|
|
225
|
+
elsif tag == 0x0101 # Decode the value
|
|
226
|
+
height = ifd[8, 4].unpack(packspec[type])[0]
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
raise "#{if width.nil? then 'width not defined.' end} #{if height.nil? then 'height not defined.' end}" if width.nil? || height.nil?
|
|
231
|
+
[width, height]
|
|
232
|
+
end
|
|
233
|
+
private(:measure_TIFF)
|
|
234
|
+
|
|
235
|
+
def measure_PCX()
|
|
236
|
+
header = @img_data.read_o(128)
|
|
237
|
+
head_part = header.unpack('C4S4')
|
|
238
|
+
width = head_part[6] - head_part[4] + 1
|
|
239
|
+
height = head_part[7] - head_part[5] + 1
|
|
240
|
+
[width, height]
|
|
241
|
+
end
|
|
242
|
+
private(:measure_PCX)
|
|
243
|
+
|
|
244
|
+
def measure_SWF()
|
|
245
|
+
header = @img_data.read_o(9)
|
|
246
|
+
raise("This file is not SWF.") unless header.unpack('a3')[0] == 'FWS'
|
|
247
|
+
|
|
248
|
+
bit_length = Integer("0b#{header.unpack('@8B5')}")
|
|
249
|
+
header << @img_data.read_o(bit_length*4/8+1)
|
|
250
|
+
str = header.unpack("@8B#{5+bit_length*4}")[0]
|
|
251
|
+
last = 5
|
|
252
|
+
x_min = Integer("0b#{str[last,bit_length]}")
|
|
253
|
+
x_max = Integer("0b#{str[(last += bit_length),bit_length]}")
|
|
254
|
+
y_min = Integer("0b#{str[(last += bit_length),bit_length]}")
|
|
255
|
+
y_max = Integer("0b#{str[(last += bit_length),bit_length]}")
|
|
256
|
+
width = (x_max - x_min)/20
|
|
257
|
+
height = (y_max - y_min)/20
|
|
258
|
+
[width, height]
|
|
259
|
+
end
|
|
260
|
+
private(:measure_PCX)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
if __FILE__ == $0
|
|
266
|
+
print "TypeList: #{ImageSize.type.inspect}\n"
|
|
267
|
+
|
|
268
|
+
Dir.glob("*").each do |file|
|
|
269
|
+
print "#{file} (string)\n"
|
|
270
|
+
open(file, "rb") do |fh|
|
|
271
|
+
img = ImageSize.new(fh.read)
|
|
272
|
+
print <<-EOF
|
|
273
|
+
type: #{img.type.inspect}
|
|
274
|
+
width: #{img.width.inspect}
|
|
275
|
+
height: #{img.height.inspect}
|
|
276
|
+
EOF
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
end
|