qwik2md 0.1.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/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/qwik2md +17 -0
- data/lib/qwik2md/version.rb +3 -0
- data/lib/qwik2md.rb +39 -0
- data/qwik2md.gemspec +30 -0
- data/vendor/qwik/AUTHORS +10 -0
- data/vendor/qwik/COPYING +340 -0
- data/vendor/qwik/COPYRIGHT +346 -0
- data/vendor/qwik/lib/qwik/Makefile +63 -0
- data/vendor/qwik/lib/qwik/Rakefile +17 -0
- data/vendor/qwik/lib/qwik/act-aa.rb +83 -0
- data/vendor/qwik/lib/qwik/act-archive.rb +386 -0
- data/vendor/qwik/lib/qwik/act-attach.rb +304 -0
- data/vendor/qwik/lib/qwik/act-backup.rb +236 -0
- data/vendor/qwik/lib/qwik/act-basic.rb +325 -0
- data/vendor/qwik/lib/qwik/act-book.rb +161 -0
- data/vendor/qwik/lib/qwik/act-calc.rb +371 -0
- data/vendor/qwik/lib/qwik/act-charset.rb +251 -0
- data/vendor/qwik/lib/qwik/act-christel.rb +112 -0
- data/vendor/qwik/lib/qwik/act-chronology.rb +149 -0
- data/vendor/qwik/lib/qwik/act-code.rb +155 -0
- data/vendor/qwik/lib/qwik/act-comment.rb +554 -0
- data/vendor/qwik/lib/qwik/act-config.rb +49 -0
- data/vendor/qwik/lib/qwik/act-counter.rb +125 -0
- data/vendor/qwik/lib/qwik/act-day.rb +96 -0
- data/vendor/qwik/lib/qwik/act-describe.rb +135 -0
- data/vendor/qwik/lib/qwik/act-diary.rb +109 -0
- data/vendor/qwik/lib/qwik/act-edit.rb +317 -0
- data/vendor/qwik/lib/qwik/act-embed-html.rb +296 -0
- data/vendor/qwik/lib/qwik/act-emode.rb +150 -0
- data/vendor/qwik/lib/qwik/act-event.rb +187 -0
- data/vendor/qwik/lib/qwik/act-file.rb +303 -0
- data/vendor/qwik/lib/qwik/act-files.rb +771 -0
- data/vendor/qwik/lib/qwik/act-getpass.rb +295 -0
- data/vendor/qwik/lib/qwik/act-history.rb +136 -0
- data/vendor/qwik/lib/qwik/act-html.rb +204 -0
- data/vendor/qwik/lib/qwik/act-httpauth.rb +147 -0
- data/vendor/qwik/lib/qwik/act-include.rb +142 -0
- data/vendor/qwik/lib/qwik/act-interwiki.rb +189 -0
- data/vendor/qwik/lib/qwik/act-isearch.rb +109 -0
- data/vendor/qwik/lib/qwik/act-keywords.rb +137 -0
- data/vendor/qwik/lib/qwik/act-lang.rb +81 -0
- data/vendor/qwik/lib/qwik/act-license.rb +63 -0
- data/vendor/qwik/lib/qwik/act-list.rb +287 -0
- data/vendor/qwik/lib/qwik/act-login.rb +410 -0
- data/vendor/qwik/lib/qwik/act-logout.rb +60 -0
- data/vendor/qwik/lib/qwik/act-mail.rb +159 -0
- data/vendor/qwik/lib/qwik/act-map.rb +292 -0
- data/vendor/qwik/lib/qwik/act-md5.rb +42 -0
- data/vendor/qwik/lib/qwik/act-mdlb.rb +741 -0
- data/vendor/qwik/lib/qwik/act-media.rb +416 -0
- data/vendor/qwik/lib/qwik/act-member.rb +157 -0
- data/vendor/qwik/lib/qwik/act-menu.rb +142 -0
- data/vendor/qwik/lib/qwik/act-metadata.rb +323 -0
- data/vendor/qwik/lib/qwik/act-mlsubmitform.rb +49 -0
- data/vendor/qwik/lib/qwik/act-monitor.rb +167 -0
- data/vendor/qwik/lib/qwik/act-new.rb +418 -0
- data/vendor/qwik/lib/qwik/act-pagelist.rb +248 -0
- data/vendor/qwik/lib/qwik/act-password.rb +145 -0
- data/vendor/qwik/lib/qwik/act-plan.rb +210 -0
- data/vendor/qwik/lib/qwik/act-povray.rb +230 -0
- data/vendor/qwik/lib/qwik/act-presen.rb +380 -0
- data/vendor/qwik/lib/qwik/act-redirect.rb +133 -0
- data/vendor/qwik/lib/qwik/act-ring.rb +1071 -0
- data/vendor/qwik/lib/qwik/act-rrefs.rb +255 -0
- data/vendor/qwik/lib/qwik/act-ruby.rb +116 -0
- data/vendor/qwik/lib/qwik/act-sample.rb +170 -0
- data/vendor/qwik/lib/qwik/act-save.rb +295 -0
- data/vendor/qwik/lib/qwik/act-schedule.rb +374 -0
- data/vendor/qwik/lib/qwik/act-search.rb +180 -0
- data/vendor/qwik/lib/qwik/act-searchwords.rb +51 -0
- data/vendor/qwik/lib/qwik/act-sendpass.rb +83 -0
- data/vendor/qwik/lib/qwik/act-site.rb +89 -0
- data/vendor/qwik/lib/qwik/act-sitebackup.rb +419 -0
- data/vendor/qwik/lib/qwik/act-sitelog.rb +118 -0
- data/vendor/qwik/lib/qwik/act-smil.rb +299 -0
- data/vendor/qwik/lib/qwik/act-status.rb +220 -0
- data/vendor/qwik/lib/qwik/act-style.rb +608 -0
- data/vendor/qwik/lib/qwik/act-table.rb +263 -0
- data/vendor/qwik/lib/qwik/act-tableform.rb +241 -0
- data/vendor/qwik/lib/qwik/act-tag.rb +103 -0
- data/vendor/qwik/lib/qwik/act-text.rb +70 -0
- data/vendor/qwik/lib/qwik/act-textarea.rb +164 -0
- data/vendor/qwik/lib/qwik/act-theme.rb +346 -0
- data/vendor/qwik/lib/qwik/act-toc.rb +112 -0
- data/vendor/qwik/lib/qwik/act-typekey.rb +198 -0
- data/vendor/qwik/lib/qwik/act-under-const.rb +94 -0
- data/vendor/qwik/lib/qwik/act-webservice.rb +321 -0
- data/vendor/qwik/lib/qwik/act-wema.rb +558 -0
- data/vendor/qwik/lib/qwik/act-wysiwyg.rb +238 -0
- data/vendor/qwik/lib/qwik/action.rb +325 -0
- data/vendor/qwik/lib/qwik/autoreload.rb +98 -0
- data/vendor/qwik/lib/qwik/bench-bench.rb +28 -0
- data/vendor/qwik/lib/qwik/bench-emode.rb +47 -0
- data/vendor/qwik/lib/qwik/bench-format-xml.rb +70 -0
- data/vendor/qwik/lib/qwik/bench-large-table.rb +62 -0
- data/vendor/qwik/lib/qwik/bench-md5.rb +14 -0
- data/vendor/qwik/lib/qwik/bench-module-session.rb +19 -0
- data/vendor/qwik/lib/qwik/bench-page.rb +50 -0
- data/vendor/qwik/lib/qwik/bench-s-md5.rb +28 -0
- data/vendor/qwik/lib/qwik/bench-session.rb +25 -0
- data/vendor/qwik/lib/qwik/bench-textformat.rb +31 -0
- data/vendor/qwik/lib/qwik/catalog-factory.rb +91 -0
- data/vendor/qwik/lib/qwik/catalog-ja.rb +479 -0
- data/vendor/qwik/lib/qwik/catalog-ml-ja.rb +145 -0
- data/vendor/qwik/lib/qwik/check-act-monitor.rb +112 -0
- data/vendor/qwik/lib/qwik/check-act-monitor2.rb +46 -0
- data/vendor/qwik/lib/qwik/check-act-theme.rb +27 -0
- data/vendor/qwik/lib/qwik/check-event.rb +112 -0
- data/vendor/qwik/lib/qwik/check-event2.rb +55 -0
- data/vendor/qwik/lib/qwik/check-htree-rexml.rb +77 -0
- data/vendor/qwik/lib/qwik/check-htree.rb +51 -0
- data/vendor/qwik/lib/qwik/check-libxml.rb +135 -0
- data/vendor/qwik/lib/qwik/check-many-pages.rb +47 -0
- data/vendor/qwik/lib/qwik/check-monitor.rb +33 -0
- data/vendor/qwik/lib/qwik/check-observer.rb +67 -0
- data/vendor/qwik/lib/qwik/check-server.rb +61 -0
- data/vendor/qwik/lib/qwik/check-uuencode.rb +33 -0
- data/vendor/qwik/lib/qwik/check-webdav.rb +65 -0
- data/vendor/qwik/lib/qwik/check-xml-xpath.rb +27 -0
- data/vendor/qwik/lib/qwik/common-backtrace.rb +94 -0
- data/vendor/qwik/lib/qwik/common-basic.rb +111 -0
- data/vendor/qwik/lib/qwik/common-condition.rb +142 -0
- data/vendor/qwik/lib/qwik/common-error.rb +48 -0
- data/vendor/qwik/lib/qwik/common-gettext.rb +50 -0
- data/vendor/qwik/lib/qwik/common-javascript.rb +45 -0
- data/vendor/qwik/lib/qwik/common-notice.rb +132 -0
- data/vendor/qwik/lib/qwik/common-plain.rb +105 -0
- data/vendor/qwik/lib/qwik/common-plugin.rb +111 -0
- data/vendor/qwik/lib/qwik/common-res.rb +76 -0
- data/vendor/qwik/lib/qwik/common-resolve.rb +92 -0
- data/vendor/qwik/lib/qwik/common-send.rb +171 -0
- data/vendor/qwik/lib/qwik/common-session.rb +139 -0
- data/vendor/qwik/lib/qwik/common-surface.rb +261 -0
- data/vendor/qwik/lib/qwik/common-url.rb +90 -0
- data/vendor/qwik/lib/qwik/compat/Makefile +12 -0
- data/vendor/qwik/lib/qwik/compat/add_load_path.rb +1 -0
- data/vendor/qwik/lib/qwik/config.rb +299 -0
- data/vendor/qwik/lib/qwik/db-b-backup.rb +142 -0
- data/vendor/qwik/lib/qwik/db-backup.rb +184 -0
- data/vendor/qwik/lib/qwik/db-berkeley.rb +306 -0
- data/vendor/qwik/lib/qwik/db-filesystem.rb +305 -0
- data/vendor/qwik/lib/qwik/db-indexer.rb +154 -0
- data/vendor/qwik/lib/qwik/db-searchwords.rb +238 -0
- data/vendor/qwik/lib/qwik/description-ja.rb +267 -0
- data/vendor/qwik/lib/qwik/description.rb +256 -0
- data/vendor/qwik/lib/qwik/dev-add-copyright.rb +23 -0
- data/vendor/qwik/lib/qwik/dev-backup.rb +24 -0
- data/vendor/qwik/lib/qwik/dev-bench.rb +175 -0
- data/vendor/qwik/lib/qwik/dev-calctime.rb +52 -0
- data/vendor/qwik/lib/qwik/dev-css-compressor.rb +60 -0
- data/vendor/qwik/lib/qwik/dev-extract-catalog.rb +102 -0
- data/vendor/qwik/lib/qwik/dev-js-compressor.rb +73 -0
- data/vendor/qwik/lib/qwik/dev-release.rb +235 -0
- data/vendor/qwik/lib/qwik/dev-replace.rb +353 -0
- data/vendor/qwik/lib/qwik/dev-sendmail.rb +25 -0
- data/vendor/qwik/lib/qwik/farm.rb +283 -0
- data/vendor/qwik/lib/qwik/gettext.rb +56 -0
- data/vendor/qwik/lib/qwik/group-cond.rb +157 -0
- data/vendor/qwik/lib/qwik/group-config.rb +247 -0
- data/vendor/qwik/lib/qwik/group-confirm.rb +147 -0
- data/vendor/qwik/lib/qwik/group-db.rb +326 -0
- data/vendor/qwik/lib/qwik/group-mail.rb +195 -0
- data/vendor/qwik/lib/qwik/group-member.rb +307 -0
- data/vendor/qwik/lib/qwik/group-sendmail.rb +231 -0
- data/vendor/qwik/lib/qwik/group-site.rb +374 -0
- data/vendor/qwik/lib/qwik/group-sweep.rb +63 -0
- data/vendor/qwik/lib/qwik/group.rb +157 -0
- data/vendor/qwik/lib/qwik/helper.rb +6 -0
- data/vendor/qwik/lib/qwik/html-generator.rb +104 -0
- data/vendor/qwik/lib/qwik/html-to-wabisabi.rb +148 -0
- data/vendor/qwik/lib/qwik/htree-diff.rb +87 -0
- data/vendor/qwik/lib/qwik/htree-format-xml.rb +57 -0
- data/vendor/qwik/lib/qwik/htree-generator.rb +144 -0
- data/vendor/qwik/lib/qwik/htree-get.rb +251 -0
- data/vendor/qwik/lib/qwik/htree-html-generator.rb +179 -0
- data/vendor/qwik/lib/qwik/htree-template.rb +263 -0
- data/vendor/qwik/lib/qwik/htree-to-wabisabi.rb +171 -0
- data/vendor/qwik/lib/qwik/loadlib.rb +79 -0
- data/vendor/qwik/lib/qwik/logger.rb +115 -0
- data/vendor/qwik/lib/qwik/mail-body.rb +171 -0
- data/vendor/qwik/lib/qwik/mail-header.rb +474 -0
- data/vendor/qwik/lib/qwik/mail-multipart.rb +193 -0
- data/vendor/qwik/lib/qwik/mail-parse.rb +147 -0
- data/vendor/qwik/lib/qwik/mail.rb +341 -0
- data/vendor/qwik/lib/qwik/mailaddress.rb +83 -0
- data/vendor/qwik/lib/qwik/mdlb-model.rb +81 -0
- data/vendor/qwik/lib/qwik/mdlb-sample.rb +324 -0
- data/vendor/qwik/lib/qwik/ml-catalog-factory.rb +27 -0
- data/vendor/qwik/lib/qwik/ml-exception.rb +15 -0
- data/vendor/qwik/lib/qwik/ml-generator.rb +28 -0
- data/vendor/qwik/lib/qwik/ml-gettext.rb +137 -0
- data/vendor/qwik/lib/qwik/ml-logger.rb +82 -0
- data/vendor/qwik/lib/qwik/ml-memory.rb +65 -0
- data/vendor/qwik/lib/qwik/ml-msg-validator.rb +86 -0
- data/vendor/qwik/lib/qwik/ml-processor.rb +609 -0
- data/vendor/qwik/lib/qwik/ml-quickml-server.rb +122 -0
- data/vendor/qwik/lib/qwik/ml-sendmail.rb +0 -0
- data/vendor/qwik/lib/qwik/ml-server.rb +107 -0
- data/vendor/qwik/lib/qwik/ml-session.rb +348 -0
- data/vendor/qwik/lib/qwik/ml-sweeper.rb +101 -0
- data/vendor/qwik/lib/qwik/mock-logger.rb +65 -0
- data/vendor/qwik/lib/qwik/mock-sendmail.rb +78 -0
- data/vendor/qwik/lib/qwik/mock-socket.rb +82 -0
- data/vendor/qwik/lib/qwik/modulobe.rb +406 -0
- data/vendor/qwik/lib/qwik/mongrel-server.rb +72 -0
- data/vendor/qwik/lib/qwik/page-files.rb +249 -0
- data/vendor/qwik/lib/qwik/page-generate.rb +82 -0
- data/vendor/qwik/lib/qwik/page-get.rb +262 -0
- data/vendor/qwik/lib/qwik/page-images.rb +168 -0
- data/vendor/qwik/lib/qwik/page-put.rb +128 -0
- data/vendor/qwik/lib/qwik/page-rrefs.rb +154 -0
- data/vendor/qwik/lib/qwik/page-title.rb +0 -0
- data/vendor/qwik/lib/qwik/page-wikidb.rb +234 -0
- data/vendor/qwik/lib/qwik/page.rb +67 -0
- data/vendor/qwik/lib/qwik/pages.rb +444 -0
- data/vendor/qwik/lib/qwik/parse-plugin.rb +249 -0
- data/vendor/qwik/lib/qwik/parser-emode.rb +116 -0
- data/vendor/qwik/lib/qwik/parser-inline.rb +272 -0
- data/vendor/qwik/lib/qwik/parser.rb +349 -0
- data/vendor/qwik/lib/qwik/password.rb +183 -0
- data/vendor/qwik/lib/qwik/periodic.rb +79 -0
- data/vendor/qwik/lib/qwik/qp.rb +56 -0
- data/vendor/qwik/lib/qwik/qwik-service.rb +341 -0
- data/vendor/qwik/lib/qwik/qwik.rb +5 -0
- data/vendor/qwik/lib/qwik/qwikweb-adduser.rb +34 -0
- data/vendor/qwik/lib/qwik/qwikweb-catalog-validator.rb +110 -0
- data/vendor/qwik/lib/qwik/qwikweb-incgen.rb +28 -0
- data/vendor/qwik/lib/qwik/qwikweb-makesite.rb +41 -0
- data/vendor/qwik/lib/qwik/qwikweb-server.rb +44 -0
- data/vendor/qwik/lib/qwik/qwikweb-showpassword.rb +26 -0
- data/vendor/qwik/lib/qwik/qwikweb-watchlog.rb +67 -0
- data/vendor/qwik/lib/qwik/request-path.rb +304 -0
- data/vendor/qwik/lib/qwik/request-ua.rb +76 -0
- data/vendor/qwik/lib/qwik/request-webrick.rb +81 -0
- data/vendor/qwik/lib/qwik/request.rb +91 -0
- data/vendor/qwik/lib/qwik/resolve-tdiary.rb +292 -0
- data/vendor/qwik/lib/qwik/resolve.rb +121 -0
- data/vendor/qwik/lib/qwik/response.rb +228 -0
- data/vendor/qwik/lib/qwik/server-memory.rb +57 -0
- data/vendor/qwik/lib/qwik/server-webrick.rb +102 -0
- data/vendor/qwik/lib/qwik/server.rb +252 -0
- data/vendor/qwik/lib/qwik/site-config.rb +149 -0
- data/vendor/qwik/lib/qwik/site-db.rb +136 -0
- data/vendor/qwik/lib/qwik/site-event.rb +162 -0
- data/vendor/qwik/lib/qwik/site-files.rb +86 -0
- data/vendor/qwik/lib/qwik/site-group.rb +103 -0
- data/vendor/qwik/lib/qwik/site-index.rb +47 -0
- data/vendor/qwik/lib/qwik/site-log.rb +64 -0
- data/vendor/qwik/lib/qwik/site-member.rb +230 -0
- data/vendor/qwik/lib/qwik/site-monitor.rb +97 -0
- data/vendor/qwik/lib/qwik/site-pages.rb +62 -0
- data/vendor/qwik/lib/qwik/site-plan.rb +139 -0
- data/vendor/qwik/lib/qwik/site-report.rb +282 -0
- data/vendor/qwik/lib/qwik/site-resolve.rb +230 -0
- data/vendor/qwik/lib/qwik/site-rrefs.rb +18 -0
- data/vendor/qwik/lib/qwik/site-search.rb +180 -0
- data/vendor/qwik/lib/qwik/site-timeline.rb +153 -0
- data/vendor/qwik/lib/qwik/site-url.rb +189 -0
- data/vendor/qwik/lib/qwik/site.rb +76 -0
- data/vendor/qwik/lib/qwik/smil-time.rb +105 -0
- data/vendor/qwik/lib/qwik/smtp-session.rb +331 -0
- data/vendor/qwik/lib/qwik/template-generator.rb +149 -0
- data/vendor/qwik/lib/qwik/template.rb +85 -0
- data/vendor/qwik/lib/qwik/test-common.rb +10 -0
- data/vendor/qwik/lib/qwik/test-ml-info.rb +225 -0
- data/vendor/qwik/lib/qwik/test-module-ml.rb +142 -0
- data/vendor/qwik/lib/qwik/test-module-path.rb +110 -0
- data/vendor/qwik/lib/qwik/test-module-public.rb +70 -0
- data/vendor/qwik/lib/qwik/test-module-server.rb +98 -0
- data/vendor/qwik/lib/qwik/test-module-session.rb +264 -0
- data/vendor/qwik/lib/qwik/test-module-suite.rb +91 -0
- data/vendor/qwik/lib/qwik/test-ms-applemail.rb +59 -0
- data/vendor/qwik/lib/qwik/test-ms-attach.rb +174 -0
- data/vendor/qwik/lib/qwik/test-ms-basic.rb +40 -0
- data/vendor/qwik/lib/qwik/test-ms-close.rb +35 -0
- data/vendor/qwik/lib/qwik/test-ms-confirm.rb +75 -0
- data/vendor/qwik/lib/qwik/test-ms-ignore-spam.rb +57 -0
- data/vendor/qwik/lib/qwik/test-ms-japanese.rb +97 -0
- data/vendor/qwik/lib/qwik/test-ms-jfilename.rb +82 -0
- data/vendor/qwik/lib/qwik/test-ms-large.rb +58 -0
- data/vendor/qwik/lib/qwik/test-ms-member.rb +103 -0
- data/vendor/qwik/lib/qwik/test-ms-multipart.rb +84 -0
- data/vendor/qwik/lib/qwik/test-ms-org.rb +129 -0
- data/vendor/qwik/lib/qwik/test-ms-plan.rb +130 -0
- data/vendor/qwik/lib/qwik/test-ms-post.rb +53 -0
- data/vendor/qwik/lib/qwik/test-ms-quopri.rb +76 -0
- data/vendor/qwik/lib/qwik/test-sub-quopri.rb +45 -0
- data/vendor/qwik/lib/qwik/test-submit-base64.rb +59 -0
- data/vendor/qwik/lib/qwik/test-submit-forward.rb +61 -0
- data/vendor/qwik/lib/qwik/test-submit-html-mail.rb +52 -0
- data/vendor/qwik/lib/qwik/test-submit-japanese.rb +135 -0
- data/vendor/qwik/lib/qwik/test-submit-jfilename.rb +144 -0
- data/vendor/qwik/lib/qwik/test-submit-uuencode.rb +71 -0
- data/vendor/qwik/lib/qwik/test-suite-all.rb +8 -0
- data/vendor/qwik/lib/qwik/test-suite-basic.rb +9 -0
- data/vendor/qwik/lib/qwik/test-suite-ml.rb +9 -0
- data/vendor/qwik/lib/qwik/test-typekey.rb +64 -0
- data/vendor/qwik/lib/qwik/testunit.rb +45 -0
- data/vendor/qwik/lib/qwik/tokenizer-inline.rb +288 -0
- data/vendor/qwik/lib/qwik/tokenizer.rb +331 -0
- data/vendor/qwik/lib/qwik/typekey.rb +160 -0
- data/vendor/qwik/lib/qwik/util-basic.rb +135 -0
- data/vendor/qwik/lib/qwik/util-charset.rb +331 -0
- data/vendor/qwik/lib/qwik/util-css.rb +56 -0
- data/vendor/qwik/lib/qwik/util-csv-tokenizer.rb +113 -0
- data/vendor/qwik/lib/qwik/util-filename.rb +112 -0
- data/vendor/qwik/lib/qwik/util-pathname.rb +202 -0
- data/vendor/qwik/lib/qwik/util-pid.rb +58 -0
- data/vendor/qwik/lib/qwik/util-safe.rb +67 -0
- data/vendor/qwik/lib/qwik/util-sendmail.rb +273 -0
- data/vendor/qwik/lib/qwik/util-string.rb +202 -0
- data/vendor/qwik/lib/qwik/util-time.rb +125 -0
- data/vendor/qwik/lib/qwik/util-webrick.rb +176 -0
- data/vendor/qwik/lib/qwik/version.rb +11 -0
- data/vendor/qwik/lib/qwik/wabisabi-basic.rb +163 -0
- data/vendor/qwik/lib/qwik/wabisabi-diff.rb +130 -0
- data/vendor/qwik/lib/qwik/wabisabi-format-xml.rb +310 -0
- data/vendor/qwik/lib/qwik/wabisabi-generator.rb +262 -0
- data/vendor/qwik/lib/qwik/wabisabi-index.rb +174 -0
- data/vendor/qwik/lib/qwik/wabisabi-table.rb +212 -0
- data/vendor/qwik/lib/qwik/wabisabi-template.rb +295 -0
- data/vendor/qwik/lib/qwik/wabisabi-to-htree.rb +111 -0
- data/vendor/qwik/lib/qwik/wabisabi-to-wiki.rb +690 -0
- data/vendor/qwik/lib/qwik/wabisabi-traverse.rb +207 -0
- data/vendor/qwik/lib/qwik/wabisabi-validator.rb +116 -0
- data/vendor/qwik/lib/qwik/wabisabi.rb +5 -0
- metadata +492 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
class CSVTokenizer
|
|
6
|
+
def self.csv_split(source)
|
|
7
|
+
status = :IN_FIELD
|
|
8
|
+
csv = []
|
|
9
|
+
last = ''
|
|
10
|
+
csv << last
|
|
11
|
+
|
|
12
|
+
while !source.empty?
|
|
13
|
+
case status
|
|
14
|
+
|
|
15
|
+
when :IN_FIELD
|
|
16
|
+
case source
|
|
17
|
+
when /\A'/
|
|
18
|
+
source = $'
|
|
19
|
+
last << "'"
|
|
20
|
+
status = :IN_QFIELD
|
|
21
|
+
when /\A,/
|
|
22
|
+
source = $'
|
|
23
|
+
last = ''
|
|
24
|
+
csv << last
|
|
25
|
+
when /\A(\\)/
|
|
26
|
+
source = $'
|
|
27
|
+
when /\A([^,'\\]*)/ # anything else
|
|
28
|
+
source = $'
|
|
29
|
+
last << $1
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
when :IN_QFIELD
|
|
33
|
+
case source
|
|
34
|
+
when /\A'/
|
|
35
|
+
source = $'
|
|
36
|
+
last << "'"
|
|
37
|
+
status = :IN_FIELD
|
|
38
|
+
when /\A(\\)/
|
|
39
|
+
source = $'
|
|
40
|
+
last << $1
|
|
41
|
+
status = :IN_ESCAPE
|
|
42
|
+
when /\A([^'\\]*)/ # anything else
|
|
43
|
+
source = $'
|
|
44
|
+
last << $1
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
when :IN_ESCAPE
|
|
48
|
+
if /\A(.)/ =~ source
|
|
49
|
+
source = $'
|
|
50
|
+
last << $1
|
|
51
|
+
end
|
|
52
|
+
status = :IN_QFIELD
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
csv = csv.map {|a|
|
|
58
|
+
a.strip
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
csv
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if $0 == __FILE__
|
|
66
|
+
require 'test/unit'
|
|
67
|
+
$test = true
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if defined?($test) && $test
|
|
71
|
+
class TestCSVTokenizer < Test::Unit::TestCase
|
|
72
|
+
def ok(e, s)
|
|
73
|
+
assert_equal e, CSVTokenizer.csv_split(s)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_csv
|
|
77
|
+
# test basic
|
|
78
|
+
ok(['1'], '1')
|
|
79
|
+
ok(['1', ''], '1,')
|
|
80
|
+
ok(['1', '2'], '1,2')
|
|
81
|
+
ok(['1', '', '3'], '1,,3')
|
|
82
|
+
|
|
83
|
+
# test from plugin
|
|
84
|
+
ok(['a', 'b'], 'a,b')
|
|
85
|
+
ok(["'a'", 'b'], "'a',b")
|
|
86
|
+
ok(['a', 'b'], 'a, b')
|
|
87
|
+
ok(['a', '', 'b'], 'a,,b')
|
|
88
|
+
|
|
89
|
+
# test space
|
|
90
|
+
ok(['1'], ' 1')
|
|
91
|
+
ok(['1'], '1 ')
|
|
92
|
+
ok(['1', '2'], '1, 2')
|
|
93
|
+
ok(['1', '2'], "1,\n2")
|
|
94
|
+
ok(['1', '2'], "1,\t2")
|
|
95
|
+
ok(['1', '2'], "1,\\2")
|
|
96
|
+
|
|
97
|
+
# test escape
|
|
98
|
+
ok(["\"1\"\""], '"1""')
|
|
99
|
+
|
|
100
|
+
# test IN_QFIELD
|
|
101
|
+
ok(["'1'"], "'1'")
|
|
102
|
+
ok(["'1 '"], "'1 '")
|
|
103
|
+
ok(["'1,2'"], "'1,2'")
|
|
104
|
+
ok(["\"1\""], "\"1\"")
|
|
105
|
+
ok(["\"1\"", "\"2\""], "\"1\",\"2\"")
|
|
106
|
+
ok(["\"1", "2\""], '"1,2"')
|
|
107
|
+
|
|
108
|
+
# test with space
|
|
109
|
+
ok(["'a b'"], "'a b'")
|
|
110
|
+
ok(['a b'], 'a b')
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
# Thanks to Mr. Shuhei Yamamoto
|
|
6
|
+
|
|
7
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
8
|
+
require 'qwik/util-string'
|
|
9
|
+
require 'qwik/util-charset'
|
|
10
|
+
|
|
11
|
+
module Qwik
|
|
12
|
+
class Filename
|
|
13
|
+
def self.encode(str)
|
|
14
|
+
str = str.to_filename_charset
|
|
15
|
+
str = str.gsub(/\342\200\276/n) {
|
|
16
|
+
'~'
|
|
17
|
+
}
|
|
18
|
+
str = str.gsub(/([^ 0-9A-Za-z_.\/-]+)/n) {
|
|
19
|
+
'=' + $1.unpack('H2' * $1.size).join('=').upcase
|
|
20
|
+
}
|
|
21
|
+
return str
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.decode(str)
|
|
25
|
+
str = str.gsub(/((?:=[0-9a-fA-F]{2})+)/n) {
|
|
26
|
+
[$1.delete('=')].pack('H*')
|
|
27
|
+
}
|
|
28
|
+
str = str.to_filename_charset
|
|
29
|
+
return str
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.contain_multibyte?(filename)
|
|
33
|
+
filename.each_byte {|byte|
|
|
34
|
+
if 0x7f < byte || byte == ?\e
|
|
35
|
+
return true
|
|
36
|
+
end
|
|
37
|
+
}
|
|
38
|
+
return false
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.extname(filename)
|
|
42
|
+
return File.extname(filename).sub(/\A\./, '')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
ALLOWABLE_CHARACTERS_FOR_PATH_RE = /\A[\/ 0-9A-Za-z_.-]+\z/
|
|
46
|
+
|
|
47
|
+
def self.allowable_characters_for_path?(f)
|
|
48
|
+
return true if ALLOWABLE_CHARACTERS_FOR_PATH_RE =~ f
|
|
49
|
+
return false
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
ALLOWABLE_CHARACTERS_RE = /\A[ 0-9A-Za-z_.-]+\z/
|
|
55
|
+
|
|
56
|
+
def self.allowable_characters?(f)
|
|
57
|
+
return true if ALLOWABLE_CHARACTERS_RE =~ f
|
|
58
|
+
return false
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if $0 == __FILE__
|
|
64
|
+
require 'qwik/test-common'
|
|
65
|
+
$test = true
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if defined?($test) && $test
|
|
69
|
+
class TestFilename < Test::Unit::TestCase
|
|
70
|
+
include TestSession
|
|
71
|
+
|
|
72
|
+
def test_all
|
|
73
|
+
c = Qwik::Filename
|
|
74
|
+
|
|
75
|
+
# test_encode
|
|
76
|
+
ok_eq('t', c.encode('t'))
|
|
77
|
+
ok_eq(' ', c.encode(' '))
|
|
78
|
+
ok_eq('=E3=81=82', c.encode("あ"))
|
|
79
|
+
ok_eq('=E3=81=82', c.encode("\202\240"))
|
|
80
|
+
ok_eq('=E3=81=82.txt', c.encode("\202\240.txt"))
|
|
81
|
+
|
|
82
|
+
# test_bug
|
|
83
|
+
ok_eq('=7E', c.encode('~'))
|
|
84
|
+
ok_eq('=7E', c.encode('~'.set_sjis))
|
|
85
|
+
|
|
86
|
+
# test_decode
|
|
87
|
+
ok_eq('t', c.decode('t'))
|
|
88
|
+
ok_eq(' ', c.decode(' '))
|
|
89
|
+
ok_eq("\343\201\202", c.decode('=E3=81=82'))
|
|
90
|
+
ok_eq("\343\201\202.txt", c.decode('=E3=81=82.txt'))
|
|
91
|
+
|
|
92
|
+
# test_contain_multibyte?
|
|
93
|
+
ok_eq(false, c.contain_multibyte?('t'))
|
|
94
|
+
ok_eq(false, c.contain_multibyte?('t t'))
|
|
95
|
+
ok_eq(true, c.contain_multibyte?("\202\240"))
|
|
96
|
+
|
|
97
|
+
# test_allowable_characters?
|
|
98
|
+
ok_eq(true, c.allowable_characters?('t'))
|
|
99
|
+
ok_eq(true, c.allowable_characters?('t t'))
|
|
100
|
+
ok_eq(true, c.allowable_characters?('t.-_t'))
|
|
101
|
+
ok_eq(true, c.allowable_characters?('t..t'))
|
|
102
|
+
ok_eq(false, c.allowable_characters?("\202\240"))
|
|
103
|
+
ok_eq(false, c.allowable_characters?('t/t'))
|
|
104
|
+
|
|
105
|
+
# test_allowable_characters_for_path?
|
|
106
|
+
ok_eq(true, c.allowable_characters_for_path?('t/t'))
|
|
107
|
+
|
|
108
|
+
# test_extname
|
|
109
|
+
ok_eq('txt', c.extname('t.txt'))
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
require 'pathname'
|
|
6
|
+
|
|
7
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
8
|
+
|
|
9
|
+
class String
|
|
10
|
+
def path
|
|
11
|
+
return Pathname.new(self)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Pathname
|
|
16
|
+
def path
|
|
17
|
+
return self
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# /cygdrive/c -> c:
|
|
21
|
+
def to_win_dir
|
|
22
|
+
return self.to_s.sub(%r!\A/cygdrive/(\w)!) {|a| $1+':' }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def ext
|
|
26
|
+
return (self.extname.to_s).sub(/\A\./, '')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def write(str)
|
|
30
|
+
return self.open('wb') {|f| f.print str }
|
|
31
|
+
end
|
|
32
|
+
alias put write
|
|
33
|
+
|
|
34
|
+
def append(str)
|
|
35
|
+
return self.open('ab') {|f| f.print str }
|
|
36
|
+
end
|
|
37
|
+
alias add append
|
|
38
|
+
|
|
39
|
+
def get_first
|
|
40
|
+
return self.open('rb') {|f| f.gets }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def check_directory
|
|
44
|
+
if self.exist?
|
|
45
|
+
if ! self.directory?
|
|
46
|
+
raise "#{self} is not directory. failed."
|
|
47
|
+
end
|
|
48
|
+
return # The directory is already exist.
|
|
49
|
+
end
|
|
50
|
+
self.mkpath
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def erase_all
|
|
54
|
+
self.each_entry {|file|
|
|
55
|
+
base = file.to_s
|
|
56
|
+
next if base == '.' || base == '..'
|
|
57
|
+
f = self + file
|
|
58
|
+
if f.directory?
|
|
59
|
+
f.erase_all
|
|
60
|
+
next
|
|
61
|
+
end
|
|
62
|
+
if f.exist?
|
|
63
|
+
f.unlink
|
|
64
|
+
end
|
|
65
|
+
}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def remove_directory
|
|
69
|
+
if self.exist?
|
|
70
|
+
if self.directory?
|
|
71
|
+
self.rmtree
|
|
72
|
+
self.rmdir if self.directory?
|
|
73
|
+
else
|
|
74
|
+
raise "#{self} is not directory. failed."
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if $0 == __FILE__
|
|
81
|
+
require 'qwik/testunit'
|
|
82
|
+
require 'qwik/test-module-path'
|
|
83
|
+
$test = true
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if defined?($test) && $test
|
|
87
|
+
class TestUtilPathname < Test::Unit::TestCase
|
|
88
|
+
def test_all
|
|
89
|
+
# test_string_path
|
|
90
|
+
assert_instance_of Pathname, 't'.path
|
|
91
|
+
assert_equal 't', 't'.path.to_s
|
|
92
|
+
|
|
93
|
+
# test_path_path
|
|
94
|
+
assert_instance_of Pathname, 't'.path.path
|
|
95
|
+
|
|
96
|
+
# test_to_win_dir
|
|
97
|
+
assert_equal 'c:/t', '/cygdrive/c/t'.path.to_win_dir
|
|
98
|
+
|
|
99
|
+
# test_extname
|
|
100
|
+
assert_equal '', 't'.path.extname
|
|
101
|
+
assert_equal '.txt', 't.txt'.path.extname
|
|
102
|
+
assert_equal '.gz', 't.tar.gz'.path.extname
|
|
103
|
+
|
|
104
|
+
# test_ext
|
|
105
|
+
assert_equal 'txt', 't.txt'.path.ext
|
|
106
|
+
assert_equal 'gz', 't.tar.gz'.path.ext
|
|
107
|
+
|
|
108
|
+
# test_write
|
|
109
|
+
'test.txt'.path.write('t')
|
|
110
|
+
|
|
111
|
+
# test_read
|
|
112
|
+
assert_equal 't', 'test.txt'.path.read
|
|
113
|
+
|
|
114
|
+
# test_append
|
|
115
|
+
'test.txt'.path.append('t')
|
|
116
|
+
assert_equal 'tt', 'test.txt'.path.read
|
|
117
|
+
|
|
118
|
+
# test_get_first
|
|
119
|
+
'test.txt'.path.write("s\nt\n")
|
|
120
|
+
assert_equal "s\nt\n", 'test.txt'.path.read
|
|
121
|
+
assert_equal "s\n", 'test.txt'.path.get_first
|
|
122
|
+
|
|
123
|
+
# teardown
|
|
124
|
+
assert_equal true, 'test.txt'.path.exist?
|
|
125
|
+
'test.txt'.path.unlink
|
|
126
|
+
assert_equal false, 'test.txt'.path.exist?
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_check_directory
|
|
130
|
+
return if $0 != __FILE__ # Only for unit test.
|
|
131
|
+
|
|
132
|
+
dir = 'testdir'.path
|
|
133
|
+
dir.erase_all if dir.exist?
|
|
134
|
+
dir.rmtree if dir.exist?
|
|
135
|
+
dir.rmdir if dir.exist?
|
|
136
|
+
assert_equal false, dir.exist?
|
|
137
|
+
|
|
138
|
+
dir.check_directory
|
|
139
|
+
assert_equal true, dir.exist?
|
|
140
|
+
|
|
141
|
+
dir.check_directory # Check again cause no error.
|
|
142
|
+
assert_equal true, dir.exist?
|
|
143
|
+
|
|
144
|
+
dir.erase_all
|
|
145
|
+
dir.rmdir
|
|
146
|
+
assert_equal false, dir.exist?
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_check_directory_raise
|
|
150
|
+
return if $0 != __FILE__ # Only for unit test.
|
|
151
|
+
|
|
152
|
+
# Make a plain text file.
|
|
153
|
+
file = 't.txt'.path
|
|
154
|
+
file.write('t')
|
|
155
|
+
|
|
156
|
+
# Try to create a directory with the same name cause exception.
|
|
157
|
+
assert_raise(RuntimeError) {
|
|
158
|
+
file.check_directory
|
|
159
|
+
}
|
|
160
|
+
file.unlink
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_erase_all
|
|
164
|
+
dir = 'testdir'.path
|
|
165
|
+
dir.check_directory # mkdir
|
|
166
|
+
|
|
167
|
+
file = 'testdir/t.txt'.path # Create a dummy file.
|
|
168
|
+
file.write('t')
|
|
169
|
+
assert_equal true, file.exist?
|
|
170
|
+
|
|
171
|
+
dir.erase_all
|
|
172
|
+
assert_equal false, file.exist? # The file is deleted.
|
|
173
|
+
assert_equal true, dir.exist? # But the directory is remained here.
|
|
174
|
+
|
|
175
|
+
dir.rmdir
|
|
176
|
+
assert_equal false, dir.exist?
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def test_check_pathname
|
|
180
|
+
dir = 'testdir'.path
|
|
181
|
+
dir.rmtree if dir.exist?
|
|
182
|
+
dir.rmdir if dir.exist?
|
|
183
|
+
|
|
184
|
+
dir.mkdir
|
|
185
|
+
assert_equal true, dir.exist?
|
|
186
|
+
|
|
187
|
+
file = dir+'t'
|
|
188
|
+
file.write('test string')
|
|
189
|
+
assert_equal true, file.exist?
|
|
190
|
+
dir.rmtree
|
|
191
|
+
assert_equal false, dir.exist?
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def test_chdir
|
|
195
|
+
pwd = Dir.pwd
|
|
196
|
+
Dir.chdir('/') {
|
|
197
|
+
assert_not_equal(pwd, Dir.pwd)
|
|
198
|
+
}
|
|
199
|
+
assert_equal pwd, Dir.pwd
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
6
|
+
require 'qwik/util-pathname'
|
|
7
|
+
|
|
8
|
+
module PidModule
|
|
9
|
+
def write_pid_file(pidfile)
|
|
10
|
+
pidfile.path.put("#{Process.pid}\n")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def read_pid_file(pidfile)
|
|
14
|
+
pid = nil
|
|
15
|
+
pid = pidfile.path.get_first.chomp.to_i
|
|
16
|
+
return pid
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def remove_pid_file(pidfile)
|
|
20
|
+
if Process.pid == read_pid_file(pidfile)
|
|
21
|
+
pidfile.path.unlink
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# for test
|
|
26
|
+
def exist_pid_file?(pidfile)
|
|
27
|
+
return pidfile.path.exist?
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
if $0 == __FILE__
|
|
32
|
+
require 'test/unit'
|
|
33
|
+
$test = true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
if defined?($test) && $test
|
|
37
|
+
class TestUtilPid < Test::Unit::TestCase
|
|
38
|
+
include PidModule
|
|
39
|
+
|
|
40
|
+
def test_all
|
|
41
|
+
f = 'test-pid.txt'
|
|
42
|
+
|
|
43
|
+
# test_exist_pid_file?
|
|
44
|
+
assert_equal false, exist_pid_file?(f)
|
|
45
|
+
|
|
46
|
+
# test_write_pid_file
|
|
47
|
+
write_pid_file(f)
|
|
48
|
+
assert_equal true, exist_pid_file?(f)
|
|
49
|
+
|
|
50
|
+
# test_read_pid_file
|
|
51
|
+
assert_equal Process.pid, read_pid_file(f)
|
|
52
|
+
|
|
53
|
+
# test_remove_pid_file
|
|
54
|
+
remove_pid_file(f)
|
|
55
|
+
assert_equal false, exist_pid_file?(f)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2002-2004 Satoru Takabayashi <satoru@namazu.org>
|
|
3
|
+
# Copyright (C) 2003-2006 Kouichirou Eto
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
6
|
+
#
|
|
7
|
+
# You can redistribute it and/or modify it under the terms of
|
|
8
|
+
# the GNU General Public License version 2.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
12
|
+
|
|
13
|
+
#class TooLongLine < StandardError; end
|
|
14
|
+
class TooLongLine < Exception; end # FIXME: should be StandardError.
|
|
15
|
+
|
|
16
|
+
module SafeGetsModule
|
|
17
|
+
def safe_gets (max_length = 1024)
|
|
18
|
+
s = ''
|
|
19
|
+
while ! self.eof?
|
|
20
|
+
c = self.read(1) # FIXME: This code may be slow.
|
|
21
|
+
s << c
|
|
22
|
+
|
|
23
|
+
if max_length < s.length
|
|
24
|
+
raise TooLongLine
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
if c == "\n"
|
|
28
|
+
return s
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
res = if s.empty? then nil else s end
|
|
33
|
+
return res
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class IO
|
|
38
|
+
include SafeGetsModule
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
if $0 == __FILE__
|
|
42
|
+
require 'test/unit'
|
|
43
|
+
require 'stringio'
|
|
44
|
+
$test = true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
if defined?($test) && $test
|
|
48
|
+
class StringIO
|
|
49
|
+
include SafeGetsModule
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class TestUtilSafe < Test::Unit::TestCase
|
|
53
|
+
def test_safe_gets
|
|
54
|
+
# under max
|
|
55
|
+
line = 'a' * 1024
|
|
56
|
+
assert_equal line, StringIO.new(line).gets
|
|
57
|
+
assert_equal line, StringIO.new(line).safe_gets
|
|
58
|
+
|
|
59
|
+
# over max
|
|
60
|
+
line = 'a' * 1025
|
|
61
|
+
assert_equal line, StringIO.new(line).gets
|
|
62
|
+
assert_raise(TooLongLine) {
|
|
63
|
+
assert_equal line, StringIO.new(line).safe_gets
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|