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
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Lexical analyzer for JSON
|
|
3
|
+
# Copyright (C) 2003,2005 Rafael R. Sevilla <dido@imperium.ph>
|
|
4
|
+
# This file is part of JSON for Ruby
|
|
5
|
+
#
|
|
6
|
+
# JSON for Ruby is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU Lesser General Public License
|
|
8
|
+
# as published by the Free Software Foundation; either version 2.1 of
|
|
9
|
+
# the License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# JSON for Ruby is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# Lesser General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
# License along with JSON for Ruby; if not, write to the Free
|
|
18
|
+
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
19
|
+
# 02111-1307 USA.
|
|
20
|
+
#
|
|
21
|
+
# Author:: Rafael R. Sevilla (mailto:dido@imperium.ph)
|
|
22
|
+
# Some bugs fixed by Adam Kramer (mailto:adam@the-kramers.net)
|
|
23
|
+
# Copyright:: Copyright (c) 2003,2005 Rafael R. Sevilla
|
|
24
|
+
# License:: GNU Lesser General Public License
|
|
25
|
+
# $Id: lexer.rb,v 1.7 2005/01/28 02:42:10 didosevilla Exp $
|
|
26
|
+
#
|
|
27
|
+
require 'iowa/JSON-objects'
|
|
28
|
+
|
|
29
|
+
module JSON
|
|
30
|
+
class Lexer
|
|
31
|
+
# This method will initialize the lexer to contain a string.
|
|
32
|
+
# =====Parameters
|
|
33
|
+
# +s+:: the string to initialize the lexer object with
|
|
34
|
+
def initialize(s)
|
|
35
|
+
@index = 0
|
|
36
|
+
@source = s
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Backs up the lexer status one character.
|
|
40
|
+
def back
|
|
41
|
+
@index -= 1 if @index > 0
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def more?
|
|
45
|
+
return(@index < @source.length)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Consumes the next character.
|
|
49
|
+
def nextchar
|
|
50
|
+
c = self.more?() ? @source[@index,1] : "\0"
|
|
51
|
+
@index += 1
|
|
52
|
+
return(c)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Consumes the next character and check that it matches a specified
|
|
56
|
+
# character.
|
|
57
|
+
def nextmatch(char)
|
|
58
|
+
n = self.nextchar
|
|
59
|
+
raise "Expected '#{char}' and instead saw '#{n}'." if (n != char)
|
|
60
|
+
return(n)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Read the next n characters from the string in the lexer.
|
|
64
|
+
# =====Parameters
|
|
65
|
+
# +n+:: the number of characters to read from the lexer
|
|
66
|
+
def nextchars(n)
|
|
67
|
+
raise "substring bounds error" if (@index + n > @source.length)
|
|
68
|
+
i = @index
|
|
69
|
+
@index += n
|
|
70
|
+
return(@source[i,n])
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Read the next n characters from the string with escape sequence
|
|
74
|
+
# processing.
|
|
75
|
+
def nextclean
|
|
76
|
+
while true
|
|
77
|
+
c = self.nextchar()
|
|
78
|
+
if (c == '/')
|
|
79
|
+
case self.nextchar()
|
|
80
|
+
when '/'
|
|
81
|
+
c = self.nextchar()
|
|
82
|
+
while c != "\n" && c != "\r" && c != "\0"
|
|
83
|
+
c = self.nextchar()
|
|
84
|
+
end
|
|
85
|
+
when '*'
|
|
86
|
+
while true
|
|
87
|
+
c = self.nextchar()
|
|
88
|
+
raise "unclosed comment" if (c == "\0")
|
|
89
|
+
if (c == '*')
|
|
90
|
+
break if (self.nextchar() == '/')
|
|
91
|
+
self.back()
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
else
|
|
95
|
+
self.back()
|
|
96
|
+
return '/';
|
|
97
|
+
end
|
|
98
|
+
elsif c == "\0" || c[0] > " "[0]
|
|
99
|
+
return(c)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Given a Unicode code point, return a string giving its UTF-8
|
|
105
|
+
# representation based on RFC 2279.
|
|
106
|
+
def utf8str(code)
|
|
107
|
+
if (code & ~(0x7f)) == 0
|
|
108
|
+
# UCS-4 range 0x00000000 - 0x0000007F
|
|
109
|
+
return(code.chr)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
buf = ""
|
|
113
|
+
if (code & ~(0x7ff)) == 0
|
|
114
|
+
# UCS-4 range 0x00000080 - 0x000007FF
|
|
115
|
+
buf << (0b11000000 | (code >> 6)).chr
|
|
116
|
+
buf << (0b10000000 | (code & 0b00111111)).chr
|
|
117
|
+
return(buf)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
if (code & ~(0x000ffff)) == 0
|
|
121
|
+
# UCS-4 range 0x00000800 - 0x0000FFFF
|
|
122
|
+
buf << (0b11100000 | (code >> 12)).chr
|
|
123
|
+
buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr
|
|
124
|
+
buf << (0b10000000 | (code & 0b0011111)).chr
|
|
125
|
+
return(buf)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Not used -- JSON only has UCS-2, but for the sake
|
|
129
|
+
# of completeness
|
|
130
|
+
if (code & ~(0x1FFFFF)) == 0
|
|
131
|
+
# UCS-4 range 0x00010000 - 0x001FFFFF
|
|
132
|
+
buf << (0b11110000 | (code >> 18)).chr
|
|
133
|
+
buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr
|
|
134
|
+
buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr
|
|
135
|
+
buf << (0b10000000 | (code & 0b0011111)).chr
|
|
136
|
+
return(buf)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
if (code & ~(0x03FFFFFF)) == 0
|
|
140
|
+
# UCS-4 range 0x00200000 - 0x03FFFFFF
|
|
141
|
+
buf << (0b11110000 | (code >> 24)).chr
|
|
142
|
+
buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr
|
|
143
|
+
buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr
|
|
144
|
+
buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr
|
|
145
|
+
buf << (0b10000000 | (code & 0b0011111)).chr
|
|
146
|
+
return(buf)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# UCS-4 range 0x04000000 - 0x7FFFFFFF
|
|
150
|
+
buf << (0b11111000 | (code >> 30)).chr
|
|
151
|
+
buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr
|
|
152
|
+
buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr
|
|
153
|
+
buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr
|
|
154
|
+
buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr
|
|
155
|
+
buf << (0b10000000 | (code & 0b0011111)).chr
|
|
156
|
+
return(buf)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Reads the next string, given a quote character (usually ' or ")
|
|
160
|
+
# =====Parameters
|
|
161
|
+
# +quot+: the next matching quote character to use
|
|
162
|
+
def nextstring(quot)
|
|
163
|
+
c = buf = ""
|
|
164
|
+
while true
|
|
165
|
+
c = self.nextchar()
|
|
166
|
+
case c
|
|
167
|
+
when /\0|\n\r/
|
|
168
|
+
raise "Unterminated string"
|
|
169
|
+
when "\\"
|
|
170
|
+
chr = self.nextchar()
|
|
171
|
+
case chr
|
|
172
|
+
when 'b'
|
|
173
|
+
buf << "\b"
|
|
174
|
+
when 't'
|
|
175
|
+
buf << "\t"
|
|
176
|
+
when 'n'
|
|
177
|
+
buf << "\n"
|
|
178
|
+
when 'f'
|
|
179
|
+
buf << "\f"
|
|
180
|
+
when 'r'
|
|
181
|
+
buf << "\r"
|
|
182
|
+
when 'u'
|
|
183
|
+
buf << utf8str(Integer("0x" + self.nextchars(4)))
|
|
184
|
+
else
|
|
185
|
+
buf << chr
|
|
186
|
+
end
|
|
187
|
+
else
|
|
188
|
+
return(buf) if (c == quot)
|
|
189
|
+
buf << c
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Reads the next group of characters that match a regular
|
|
195
|
+
# expresion.
|
|
196
|
+
#
|
|
197
|
+
def nextto(regex)
|
|
198
|
+
buf = ""
|
|
199
|
+
while (true)
|
|
200
|
+
c = self.nextchar()
|
|
201
|
+
if !(regex =~ c).nil? || c == '\0' || c == '\n' || c == '\r'
|
|
202
|
+
self.back() if (c != '\0')
|
|
203
|
+
return(buf.chomp())
|
|
204
|
+
end
|
|
205
|
+
buf += c
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Reads the next value from the string. This can return either a
|
|
210
|
+
# string, a FixNum, a floating point value, a JSON array, or a
|
|
211
|
+
# JSON object.
|
|
212
|
+
def nextvalue
|
|
213
|
+
c = self.nextclean
|
|
214
|
+
s = ""
|
|
215
|
+
|
|
216
|
+
case c
|
|
217
|
+
when /\"|\'/
|
|
218
|
+
return(self.nextstring(c))
|
|
219
|
+
when '{'
|
|
220
|
+
self.back()
|
|
221
|
+
return(Hash.new.from_json(self))
|
|
222
|
+
when '['
|
|
223
|
+
self.back()
|
|
224
|
+
return(Array.new.from_json(self))
|
|
225
|
+
else
|
|
226
|
+
buf = ""
|
|
227
|
+
while ((c =~ /"| |:|,|\]|\}|\/|\0/).nil?)
|
|
228
|
+
buf += c
|
|
229
|
+
c = self.nextchar()
|
|
230
|
+
end
|
|
231
|
+
self.back()
|
|
232
|
+
s = buf.chomp
|
|
233
|
+
case s
|
|
234
|
+
when "true"
|
|
235
|
+
return(true)
|
|
236
|
+
when "false"
|
|
237
|
+
return(false)
|
|
238
|
+
when "null"
|
|
239
|
+
return(nil)
|
|
240
|
+
when /^[0-9]|\.|-|\+/
|
|
241
|
+
begin
|
|
242
|
+
return(Integer(s))
|
|
243
|
+
rescue ArgumentError
|
|
244
|
+
# do nothing on an error, the next case should do the trick
|
|
245
|
+
end
|
|
246
|
+
begin
|
|
247
|
+
return(Float(s))
|
|
248
|
+
rescue ArgumentError
|
|
249
|
+
# do nothing
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
if (s == "")
|
|
253
|
+
s = nil
|
|
254
|
+
end
|
|
255
|
+
return(s)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Skip to the next instance of the character specified
|
|
260
|
+
# =====Parameters
|
|
261
|
+
# +to+:: Character to skip to
|
|
262
|
+
def skipto(to)
|
|
263
|
+
index = @index
|
|
264
|
+
loop {
|
|
265
|
+
c = self.nextchar()
|
|
266
|
+
if (c == '\0')
|
|
267
|
+
@index = index
|
|
268
|
+
return(c)
|
|
269
|
+
end
|
|
270
|
+
if (c == to)
|
|
271
|
+
self.back
|
|
272
|
+
return(c)
|
|
273
|
+
end
|
|
274
|
+
}
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def unescape
|
|
278
|
+
@source.unescape
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# Skip past the next instance of the character specified
|
|
282
|
+
# =====Parameters
|
|
283
|
+
# +to+:: the character to skip past
|
|
284
|
+
def skippast(to)
|
|
285
|
+
@index = @source.index(to, @index)
|
|
286
|
+
@index = (@index.nil?) ? @source.length : @index + to.length
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def each
|
|
290
|
+
while (n = nextvalue)
|
|
291
|
+
yield(n)
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#
|
|
2
|
+
# JSON Objects
|
|
3
|
+
# Copyright (C) 2003,2005 Rafael R. Sevilla <dido@imperium.ph>
|
|
4
|
+
# This file is part of JSON for Ruby
|
|
5
|
+
#
|
|
6
|
+
# JSON for Ruby is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU Lesser General Public License
|
|
8
|
+
# as published by the Free Software Foundation; either version 2.1 of
|
|
9
|
+
# the License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# JSON for Ruby is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# Lesser General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
# License along with JSON for Ruby; if not, write to the Free
|
|
18
|
+
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
19
|
+
# 02111-1307 USA.
|
|
20
|
+
#
|
|
21
|
+
# Author:: Rafael R. Sevilla (mailto:dido@imperium.ph)
|
|
22
|
+
# Heavily modified by Adam Kramer (mailto:adam@the-kramers.net)
|
|
23
|
+
# Copyright:: Copyright (c) 2003,2005 Rafael R. Sevilla
|
|
24
|
+
# License:: GNU Lesser General Public License
|
|
25
|
+
# $Id: objects.rb,v 1.1 2005/01/28 02:08:45 didosevilla Exp $
|
|
26
|
+
#
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Object
|
|
30
|
+
def to_json #all strings in json need to have double quotes around them, treat random objects as strings
|
|
31
|
+
String.to_json(to_s)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class NilClass
|
|
37
|
+
def to_json
|
|
38
|
+
"null"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
class TrueClass
|
|
42
|
+
def to_json
|
|
43
|
+
"true"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class FalseClass
|
|
48
|
+
def to_json
|
|
49
|
+
"false"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class Numeric
|
|
54
|
+
def to_json
|
|
55
|
+
to_s
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class String
|
|
60
|
+
# produce a string in double quotes with all the necessary quoting
|
|
61
|
+
# done
|
|
62
|
+
def to_json
|
|
63
|
+
return String.to_json(self)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.to_json(str)
|
|
67
|
+
return "\"\"" if (str.length == 0)
|
|
68
|
+
newstr = "\""
|
|
69
|
+
str.each_byte {
|
|
70
|
+
|b|
|
|
71
|
+
c = b.chr
|
|
72
|
+
case c
|
|
73
|
+
when /\\|\">/
|
|
74
|
+
newstr << "\\" + c
|
|
75
|
+
when "\b"
|
|
76
|
+
newstr << "\\b"
|
|
77
|
+
when "\t"
|
|
78
|
+
newstr << "\\t"
|
|
79
|
+
when "\n"
|
|
80
|
+
newstr << "\\n"
|
|
81
|
+
when "\f"
|
|
82
|
+
newstr << "\\f"
|
|
83
|
+
when "\r"
|
|
84
|
+
newstr << "\\r"
|
|
85
|
+
else
|
|
86
|
+
if (c < ' ')
|
|
87
|
+
t = "000" + sprintf("%0x", b)
|
|
88
|
+
newstr << ("\\u" + t[0,t.length - 4])
|
|
89
|
+
else
|
|
90
|
+
newstr << c
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
}
|
|
94
|
+
newstr += '"'
|
|
95
|
+
return(newstr)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
class Array
|
|
100
|
+
|
|
101
|
+
# This method will return a string giving the contents of the JSON
|
|
102
|
+
# array in standard JSON format.
|
|
103
|
+
def to_json
|
|
104
|
+
retval = '['
|
|
105
|
+
|
|
106
|
+
first=true
|
|
107
|
+
self.each { |obj|
|
|
108
|
+
retval << ',' unless first
|
|
109
|
+
retval << obj.to_json
|
|
110
|
+
first=false
|
|
111
|
+
}
|
|
112
|
+
retval << "]"
|
|
113
|
+
return(retval)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# This method will parse a JSON array from the passed lexer
|
|
117
|
+
# object. It takes a lexer object which is about to read a JSON
|
|
118
|
+
# array. It raises a runtime error otherwise. It returns the
|
|
119
|
+
# original JSON array. This method is not intended to be used
|
|
120
|
+
# directly.
|
|
121
|
+
# =====Parameters
|
|
122
|
+
# +lexer+:: Lexer object to use
|
|
123
|
+
def from_json(lexer)
|
|
124
|
+
raise "A JSON Array must begin with '['" if (lexer.nextclean != "[")
|
|
125
|
+
return if lexer.nextclean == ']'
|
|
126
|
+
lexer.back
|
|
127
|
+
loop {
|
|
128
|
+
self << lexer.nextvalue
|
|
129
|
+
case lexer.nextclean
|
|
130
|
+
when ','
|
|
131
|
+
return if (lexer.nextclean == ']')
|
|
132
|
+
lexer.back
|
|
133
|
+
when ']'
|
|
134
|
+
return(self)
|
|
135
|
+
else
|
|
136
|
+
raise "Expected a ',' or ']'"
|
|
137
|
+
end
|
|
138
|
+
}
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class Hash
|
|
146
|
+
|
|
147
|
+
# This method will serialize the hash into regular JSON format.
|
|
148
|
+
def to_json
|
|
149
|
+
retval = "{"
|
|
150
|
+
|
|
151
|
+
first = true
|
|
152
|
+
self.each {|key, val|
|
|
153
|
+
retval << "," unless first
|
|
154
|
+
key = key.to_s #keys in json hashes need to be strings, nothing else.
|
|
155
|
+
retval << key.to_json + ":"
|
|
156
|
+
retval << val.to_json
|
|
157
|
+
first = false
|
|
158
|
+
}
|
|
159
|
+
retval << "}"
|
|
160
|
+
return(retval)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# This method will parse a JSON object from the passed lexer
|
|
164
|
+
# object. It takes a lexer object which is about to read a JSON
|
|
165
|
+
# object. It raises a runtime error otherwise. It returns the
|
|
166
|
+
# original JSON object. This method probably shouldn't be used
|
|
167
|
+
# directly.
|
|
168
|
+
# =====Parameters
|
|
169
|
+
def from_json(lexer)
|
|
170
|
+
lexer.unescape if (lexer.nextclean == '%')
|
|
171
|
+
lexer.back
|
|
172
|
+
raise "A JSON Object must begin with '{'" if (lexer.nextclean != "{")
|
|
173
|
+
loop {
|
|
174
|
+
c = lexer.nextclean
|
|
175
|
+
key = nil
|
|
176
|
+
case c
|
|
177
|
+
when '\0'
|
|
178
|
+
raise "A JSON Object must end with '}'"
|
|
179
|
+
when '}'
|
|
180
|
+
return;
|
|
181
|
+
else
|
|
182
|
+
lexer.back
|
|
183
|
+
key = lexer.nextvalue().to_s()
|
|
184
|
+
end
|
|
185
|
+
raise "Expected a ':' after a key" if (lexer.nextclean() != ':')
|
|
186
|
+
self[key] = lexer.nextvalue()
|
|
187
|
+
case lexer.nextclean()
|
|
188
|
+
when ','
|
|
189
|
+
return if (lexer.nextclean() == '}')
|
|
190
|
+
lexer.back
|
|
191
|
+
when '}'
|
|
192
|
+
return(self)
|
|
193
|
+
else
|
|
194
|
+
raise "Expected a ',' or '}'"
|
|
195
|
+
end
|
|
196
|
+
}
|
|
197
|
+
return(self)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
end
|
|
201
|
+
|