qwik2md 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,273 @@
|
|
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
|
+
require 'socket'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
14
|
+
require 'qwik/mail'
|
15
|
+
require 'qwik/util-charset'
|
16
|
+
|
17
|
+
module Qwik
|
18
|
+
class Sendmail
|
19
|
+
def initialize(host, port, test=false)
|
20
|
+
@host, @port = host, port
|
21
|
+
@test = test
|
22
|
+
end
|
23
|
+
|
24
|
+
def send(mail)
|
25
|
+
Sendmail.send(@host, @port, mail[:from], mail[:to], mail[:subject],
|
26
|
+
mail[:content], @test)
|
27
|
+
end
|
28
|
+
|
29
|
+
# FIXME: This method is too ad hoc.
|
30
|
+
def self.send(host, port, from, to, subject, body, test)
|
31
|
+
efrom = QuickML::Mail.encode_field(from.to_s)
|
32
|
+
eto = QuickML::Mail.encode_field(to.to_s)
|
33
|
+
esubject = QuickML::Mail.encode_field(subject)
|
34
|
+
body = body.set_sourcecode_charset.to_mail_charset
|
35
|
+
message =
|
36
|
+
"From: #{efrom}
|
37
|
+
To: #{eto}
|
38
|
+
Subject: #{esubject}
|
39
|
+
Content-Type: text/plain; charset=\"ISO-2022-JP\"
|
40
|
+
|
41
|
+
#{body}
|
42
|
+
"
|
43
|
+
if test
|
44
|
+
$smtp_sendmail = [host, port, efrom, eto, message]
|
45
|
+
return message # for debug
|
46
|
+
end
|
47
|
+
|
48
|
+
require 'net/smtp'
|
49
|
+
Net::SMTP.start(host, port) {|smtp|
|
50
|
+
smtp.send_mail(message, from, to)
|
51
|
+
}
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Sendmail
|
58
|
+
def self.send_mail (smtp_host, smtp_port, logger, mail)
|
59
|
+
validate_mail(mail)
|
60
|
+
|
61
|
+
msg = build_message(mail)
|
62
|
+
|
63
|
+
result = nil
|
64
|
+
begin
|
65
|
+
config = Sendmail.prepare_config(smtp_host, smtp_port, true)
|
66
|
+
s = Sendmail.open_socket(config)
|
67
|
+
|
68
|
+
myhostname = config[:test] ? 'sender' : Socket.gethostname
|
69
|
+
|
70
|
+
Sendmail.send_to_socket(config, s, myhostname, msg,
|
71
|
+
mail[:mail_from], mail[:recipient])
|
72
|
+
result = s
|
73
|
+
rescue => e
|
74
|
+
logger.log "Error: Unable to send mail: #{e.class}: #{e.message}"
|
75
|
+
end
|
76
|
+
|
77
|
+
if $test
|
78
|
+
$quickml_sendmail = [smtp_host, smtp_port,
|
79
|
+
mail[:mail_from], mail[:recipient], msg]
|
80
|
+
end
|
81
|
+
|
82
|
+
return result # Only for test
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def self.validate_mail(mail)
|
88
|
+
if mail[:mail_from].nil? ||
|
89
|
+
mail[:recipient].nil? ||
|
90
|
+
mail[:header].nil? ||
|
91
|
+
mail[:body].nil?
|
92
|
+
raise "Missing mail header."
|
93
|
+
end
|
94
|
+
|
95
|
+
mail[:recipient] = [mail[:recipient]] if mail[:recipient].kind_of?(String)
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.build_message(mail)
|
99
|
+
return mail[:header].map {|field|
|
100
|
+
key, value = field
|
101
|
+
"#{key}: #{value}\n"
|
102
|
+
}.join+"\n"+mail[:body]
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.prepare_config(smtp_host, smtp_port,
|
106
|
+
use_xverp = false, test = false)
|
107
|
+
test = true if defined?($test) && $test
|
108
|
+
config = {
|
109
|
+
:smtp_port => smtp_port,
|
110
|
+
:smtp_host => smtp_host,
|
111
|
+
:use_xverp => use_xverp,
|
112
|
+
:xverp_available => false,
|
113
|
+
:test => test,
|
114
|
+
}
|
115
|
+
return config
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.open_socket(c)
|
119
|
+
klass = c[:test] ? MockSmtpServer : TCPSocket
|
120
|
+
s = $ml_sm = klass.open(c[:smtp_host], c[:smtp_port]) # $ml_sm is for test
|
121
|
+
return s
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.send_to_socket(c, s, myhostname, message, mail_from, recipients)
|
125
|
+
recipients = [recipients] if recipients.kind_of?(String)
|
126
|
+
|
127
|
+
send_command(c, s, nil, 220)
|
128
|
+
|
129
|
+
send_command(c, s, "EHLO #{myhostname}", 250)
|
130
|
+
|
131
|
+
if c[:use_xverp] and c[:xverp_available] and (not mail_from.empty?)
|
132
|
+
send_command(c, s, "MAIL FROM: <#{mail_from}> XVERP===", 250)
|
133
|
+
else
|
134
|
+
send_command(c, s, "MAIL FROM: <#{mail_from}>", 250)
|
135
|
+
end
|
136
|
+
|
137
|
+
recipients.each {|recipient|
|
138
|
+
send_command(c, s, "RCPT TO: <#{recipient}>", 250)
|
139
|
+
}
|
140
|
+
|
141
|
+
send_command(c, s, 'DATA', 354)
|
142
|
+
|
143
|
+
message.each_line {|line|
|
144
|
+
line.sub!(/\r?\n/, "")
|
145
|
+
line.sub!(/^\./, '..')
|
146
|
+
line << "\r\n"
|
147
|
+
s.print(line)
|
148
|
+
}
|
149
|
+
|
150
|
+
send_command(c, s, '.', 250)
|
151
|
+
send_command(c, s, 'QUIT', 221)
|
152
|
+
|
153
|
+
s.close
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.send_command (c, s, command, code)
|
157
|
+
s.print(command + "\r\n") if command
|
158
|
+
begin
|
159
|
+
line = s.gets
|
160
|
+
c[:xverp_available] = true if /^250-XVERP/.match(line)
|
161
|
+
end while line[3] == ?-
|
162
|
+
|
163
|
+
return_code = line[0, 3].to_i
|
164
|
+
if return_code == code
|
165
|
+
line
|
166
|
+
else
|
167
|
+
raise "smtp-error: #{command} => #{line}"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def Sendmail(*args)
|
173
|
+
Sendmail.send_mail(*args)
|
174
|
+
end
|
175
|
+
|
176
|
+
if $0 == __FILE__
|
177
|
+
require 'test/unit'
|
178
|
+
require 'qwik/testunit'
|
179
|
+
require 'qwik/mock-sendmail'
|
180
|
+
require 'pp'
|
181
|
+
$test = true
|
182
|
+
end
|
183
|
+
|
184
|
+
if defined?($test) && $test
|
185
|
+
class TestSendmail < Test::Unit::TestCase
|
186
|
+
def test_all
|
187
|
+
sm = Qwik::Sendmail.new('127.0.0.1', '25', true)
|
188
|
+
mail = {
|
189
|
+
:from => 'from@example.com',
|
190
|
+
:to => 'to@example.com',
|
191
|
+
:subject => 'subject',
|
192
|
+
:content => 'content',
|
193
|
+
}
|
194
|
+
assert_equal "From: from@example.com
|
195
|
+
To: to@example.com
|
196
|
+
Subject: subject
|
197
|
+
Content-Type: text/plain; charset=\"ISO-2022-JP\"
|
198
|
+
|
199
|
+
content
|
200
|
+
",
|
201
|
+
sm.send(mail)
|
202
|
+
|
203
|
+
mail = {
|
204
|
+
:from => 'from@example.com',
|
205
|
+
:to => 'to@example.com',
|
206
|
+
:subject => '題名',
|
207
|
+
:content => '本文',
|
208
|
+
}
|
209
|
+
assert_equal "From: from@example.com
|
210
|
+
To: to@example.com
|
211
|
+
Subject: =?ISO-2022-JP?B?GyRCQmpMPhsoQg==?=
|
212
|
+
Content-Type: text/plain; charset=\"ISO-2022-JP\"
|
213
|
+
|
214
|
+
\e$BK\\J8\e(B
|
215
|
+
",
|
216
|
+
sm.send(mail)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
if defined?($test) && $test
|
222
|
+
class TestSendmail < Test::Unit::TestCase
|
223
|
+
def test_all
|
224
|
+
c = Sendmail
|
225
|
+
|
226
|
+
# test_build_message
|
227
|
+
is "\n", c.build_message(:header=>[], :body=>'')
|
228
|
+
is "a: b\n\nc", c.build_message(:header=>[['a', 'b']], :body=>'c')
|
229
|
+
is "a: b\n\nc", c.build_message(:header=>[[:a, 'b']], :body=>'c')
|
230
|
+
|
231
|
+
# test_send
|
232
|
+
mail = {
|
233
|
+
:mail_from => '',
|
234
|
+
:recipient => '',
|
235
|
+
:header => [],
|
236
|
+
:body => '',
|
237
|
+
}
|
238
|
+
so = Sendmail('localhost', 25, nil, mail)
|
239
|
+
is "EHLO sender
|
240
|
+
MAIL FROM: <>
|
241
|
+
RCPT TO: <>
|
242
|
+
DATA
|
243
|
+
|
244
|
+
.
|
245
|
+
QUIT",
|
246
|
+
so.buffer.join("\n")
|
247
|
+
|
248
|
+
mail = {
|
249
|
+
:mail_from => 'alice@example.com',
|
250
|
+
:recipient => 'bob@example.com',
|
251
|
+
:header => [
|
252
|
+
['To', 'bob@example.com'],
|
253
|
+
['From', 'alice@example.com'],
|
254
|
+
['Subject', 'test'],
|
255
|
+
],
|
256
|
+
:body => 'This is a test.',
|
257
|
+
}
|
258
|
+
so = Sendmail('localhost', 25, false, mail)
|
259
|
+
is "EHLO sender
|
260
|
+
MAIL FROM: <alice@example.com>
|
261
|
+
RCPT TO: <bob@example.com>
|
262
|
+
DATA
|
263
|
+
To: bob@example.com
|
264
|
+
From: alice@example.com
|
265
|
+
Subject: test
|
266
|
+
|
267
|
+
This is a test.
|
268
|
+
.
|
269
|
+
QUIT",
|
270
|
+
so.buffer.join("\n")
|
271
|
+
end
|
272
|
+
end
|
273
|
+
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 'digest/md5'
|
6
|
+
|
7
|
+
$LOAD_PATH << 'compat' unless $LOAD_PATH.include? 'compat'
|
8
|
+
require 'base64'
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
11
|
+
require 'qwik/util-charset'
|
12
|
+
|
13
|
+
class String
|
14
|
+
def xchomp
|
15
|
+
return self.chomp("\n").chomp("\r")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Used from parser.rb
|
19
|
+
def chompp
|
20
|
+
return self.sub(/[\n\r]+\z/, '')
|
21
|
+
end
|
22
|
+
|
23
|
+
def normalize_eol
|
24
|
+
return self.xchomp+"\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
def normalize_newline
|
28
|
+
return self.gsub("\r\n", "\n").gsub("\r", "\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
def sub_str(pattern, replace)
|
32
|
+
return sub(Regexp.new(Regexp.escape(pattern)), replace)
|
33
|
+
end
|
34
|
+
|
35
|
+
def md5
|
36
|
+
return Digest::MD5.digest(self)
|
37
|
+
end
|
38
|
+
|
39
|
+
def md5hex
|
40
|
+
return Digest::MD5.hexdigest(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def base64
|
44
|
+
return Base64.encode64(self).chomp
|
45
|
+
end
|
46
|
+
|
47
|
+
# ============================== escape
|
48
|
+
# Copied from cgi.rb
|
49
|
+
def escape
|
50
|
+
return self.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
|
51
|
+
'%' + $1.unpack('H2' * $1.size).join('%').upcase
|
52
|
+
}.tr(' ', "+")
|
53
|
+
end
|
54
|
+
|
55
|
+
def unescape
|
56
|
+
return self.tr("+", ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) {
|
57
|
+
[$1.delete('%')].pack('H*')
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def unescapeHTML
|
62
|
+
return self.gsub(/&(.*?);/n) {
|
63
|
+
match = $1.dup
|
64
|
+
case match
|
65
|
+
when /\Aamp\z/ni then "&"
|
66
|
+
when /\Aquot\z/ni then "'"
|
67
|
+
when /\Agt\z/ni then ">"
|
68
|
+
when /\Alt\z/ni then "<"
|
69
|
+
else
|
70
|
+
"&#{match};"
|
71
|
+
end
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def mb_length
|
76
|
+
case self.charset || self.guess_charset
|
77
|
+
when 'UTF-8'; return self.split(//u).length
|
78
|
+
when 'Shift_JIS'; return self.split(//s).length
|
79
|
+
when 'EUC-JP'; return self.split(//e).length
|
80
|
+
end
|
81
|
+
return self.length
|
82
|
+
end
|
83
|
+
|
84
|
+
def mb_substring(s,e)
|
85
|
+
case self.charset || self.guess_charset
|
86
|
+
when 'UTF-8'; return self.split(//u)[s...e].to_s
|
87
|
+
when 'Shift_JIS'; return self.split(//s)[s...e].to_s
|
88
|
+
when 'EUC-JP'; return self.split(//e)[s...e].to_s
|
89
|
+
end
|
90
|
+
return self[s...e]
|
91
|
+
end
|
92
|
+
|
93
|
+
# Copied from gonzui-0.1
|
94
|
+
# Use this method instead of WEBrick::HTMLUtils.escape for performance reason.
|
95
|
+
EscapeTable = {
|
96
|
+
"&" => "&",
|
97
|
+
'"' => """,
|
98
|
+
'<' => "<",
|
99
|
+
'>' => ">",
|
100
|
+
}
|
101
|
+
def escapeHTML
|
102
|
+
string = self
|
103
|
+
return string.gsub(/[&"<>]/) {|x| EscapeTable[x] }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if $0 == __FILE__
|
108
|
+
require 'test/unit'
|
109
|
+
$test = true
|
110
|
+
end
|
111
|
+
|
112
|
+
if defined?($test) && $test
|
113
|
+
class TestString < Test::Unit::TestCase
|
114
|
+
def test_string
|
115
|
+
# test_xchomp
|
116
|
+
assert_equal '', ''.xchomp
|
117
|
+
assert_equal '', "\n".xchomp
|
118
|
+
assert_equal '', "\r".xchomp
|
119
|
+
assert_equal '', "\r\n".xchomp
|
120
|
+
assert_equal "\n", "\n\r".xchomp
|
121
|
+
assert_equal 't', 't'.xchomp
|
122
|
+
assert_equal 't', "t\r".xchomp
|
123
|
+
assert_equal 't', "t\n".xchomp
|
124
|
+
|
125
|
+
# test_chompp
|
126
|
+
assert_equal '', "\n\r".chompp
|
127
|
+
assert_equal '', "\n\r\n\r".chompp
|
128
|
+
|
129
|
+
# test_normalize_eol
|
130
|
+
assert_equal "\n", ''.normalize_eol
|
131
|
+
assert_equal "\n", "\n".normalize_eol
|
132
|
+
assert_equal "t\n", 't'.normalize_eol
|
133
|
+
assert_equal "t\n", "t\n".normalize_eol
|
134
|
+
|
135
|
+
# test_normalize_newline
|
136
|
+
assert_equal "\n", "\n".normalize_newline
|
137
|
+
assert_equal "\n", "\r".normalize_newline
|
138
|
+
assert_equal "\n", "\r\n".normalize_newline
|
139
|
+
assert_equal "\n\n", "\n\r".normalize_newline
|
140
|
+
assert_equal "\na\n", "\ra\r".normalize_newline
|
141
|
+
assert_equal "\na\n", "\r\na\r\n".normalize_newline
|
142
|
+
assert_equal "\n\na\n\n", "\n\ra\n\r".normalize_newline
|
143
|
+
|
144
|
+
# test_sub_str
|
145
|
+
assert_equal 'a:b', 'a*b'.sub_str('*', ':')
|
146
|
+
|
147
|
+
# test_md5
|
148
|
+
assert_instance_of String, 't'.md5
|
149
|
+
assert_equal 16, 't'.md5.length
|
150
|
+
assert_equal "\343X\357\244\211\365\200b\361\r\3271ked\236", 't'.md5
|
151
|
+
assert_instance_of String, 't'.md5hex
|
152
|
+
assert_equal 32, 't'.md5hex.length
|
153
|
+
assert_equal 'e358efa489f58062f10dd7316b65649e', 't'.md5hex
|
154
|
+
assert_equal 'dA==', 't'.base64
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_escape
|
158
|
+
# test_escape
|
159
|
+
assert_equal('A', 'A'.escape)
|
160
|
+
assert_equal("+", ' '.escape)
|
161
|
+
assert_equal('%2B', "+".escape)
|
162
|
+
assert_equal('%21', "!".escape)
|
163
|
+
assert_equal("ABC%82%A0%82%A2%82%A4+%2B%23", "ABCあいう +#".escape)
|
164
|
+
|
165
|
+
# test_unescape
|
166
|
+
assert_equal('A', '%41'.unescape)
|
167
|
+
assert_equal(' ', "+".unescape)
|
168
|
+
assert_equal("!", '%21'.unescape)
|
169
|
+
assert_equal("ABCあいう +#", "ABC%82%A0%82%A2%82%A4+%2B%23".unescape)
|
170
|
+
|
171
|
+
# test_escapeHTML
|
172
|
+
assert_equal("<", "<".escapeHTML)
|
173
|
+
assert_equal(">", ">".escapeHTML)
|
174
|
+
assert_equal("&", "&".escapeHTML)
|
175
|
+
assert_equal("<a href="http://e.com/">e.com</a>",
|
176
|
+
'<a href="http://e.com/">e.com</a>'.escapeHTML)
|
177
|
+
|
178
|
+
# test_unescapeHTML
|
179
|
+
assert_equal("<", "<".unescapeHTML)
|
180
|
+
assert_equal(">", ">".unescapeHTML)
|
181
|
+
assert_equal("&", "&".unescapeHTML)
|
182
|
+
assert_equal("<a href='http://e.com/'>e.com</a>",
|
183
|
+
"<a href="http://e.com/">e.com</a>".unescapeHTML)
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_mb_length
|
187
|
+
str = "日本語文字列"
|
188
|
+
assert_equal(6,str.mb_length)
|
189
|
+
|
190
|
+
str = "English"
|
191
|
+
assert_equal(7,str.mb_length)
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_mb_substring
|
195
|
+
str = "日本語文字列"
|
196
|
+
assert_equal("本語文",str.mb_substring(1,4))
|
197
|
+
|
198
|
+
str = "English"
|
199
|
+
assert_equal("ngl",str.mb_substring(1,4))
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,125 @@
|
|
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 'parsedate'
|
6
|
+
|
7
|
+
class Time
|
8
|
+
def md
|
9
|
+
return strftime('%m-%d') # 01-01
|
10
|
+
end
|
11
|
+
|
12
|
+
def ymd_s
|
13
|
+
return strftime('%Y%m%d') # 20000101
|
14
|
+
end
|
15
|
+
|
16
|
+
def ymd
|
17
|
+
return strftime('%Y-%m-%d') # 2000-01-01
|
18
|
+
end
|
19
|
+
|
20
|
+
def ymdx
|
21
|
+
return strftime('%Y-%m-%d %X') # 2000-01-01 12:34:56
|
22
|
+
end
|
23
|
+
|
24
|
+
def ymdax
|
25
|
+
return strftime("%Y-%m-%d(%a) %X") # 2000-01-01(Sat) 12:34:56
|
26
|
+
end
|
27
|
+
|
28
|
+
def format_date
|
29
|
+
day = %w(日 月 火 水 木 金 土) # 2000-01-01 (土) 12:34:56
|
30
|
+
return strftime("%Y-%m-%d #DAY# %H:%M:%S").sub(/#DAY#/, "(#{day[wday]})")
|
31
|
+
end
|
32
|
+
|
33
|
+
def rfc1123_date
|
34
|
+
return strftime('%a, %d %b %Y %H:%M:%S GMT') # Sat, 01 Jan 2000 12:34:56 GMT
|
35
|
+
end
|
36
|
+
|
37
|
+
def rfc_date
|
38
|
+
return strftime('%Y-%m-%dT%H:%M:%S') # 2000-01-01T12:34:56
|
39
|
+
end
|
40
|
+
|
41
|
+
# ============================== date
|
42
|
+
def self.date_parse(tag)
|
43
|
+
if /\A(\d\d\d\d)-(\d\d)-(\d\d)\z/ =~ tag
|
44
|
+
return Time.local($1.to_i, $2.to_i, $3.to_i)
|
45
|
+
end
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.date_abbr(now, date)
|
50
|
+
year = date.year
|
51
|
+
month = date.month
|
52
|
+
mday = date.mday
|
53
|
+
return date.ymd if now.year != date.year
|
54
|
+
return date.md
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.date_emphasis(now, date, title)
|
58
|
+
diff = date - now
|
59
|
+
day = 60*60*24
|
60
|
+
if diff < -day # past
|
61
|
+
return [:span, {:class=>'past'}, title]
|
62
|
+
elsif diff < day*7 # This week.
|
63
|
+
return [:strong, title]
|
64
|
+
elsif diff < day*30 # This month.
|
65
|
+
return [:em, title]
|
66
|
+
else
|
67
|
+
return [:span, {:class=>'future'}, title]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
if $0 == __FILE__
|
73
|
+
require 'test/unit'
|
74
|
+
$test = true
|
75
|
+
end
|
76
|
+
|
77
|
+
if defined?($test) && $test
|
78
|
+
class TestUtilTime < Test::Unit::TestCase
|
79
|
+
def test_time
|
80
|
+
t = Time.gm(2000, 1, 1, 12, 34, 56)
|
81
|
+
assert_equal '01-01', t.md
|
82
|
+
assert_equal '20000101', t.ymd_s
|
83
|
+
assert_equal '2000-01-01', t.ymd
|
84
|
+
assert_equal '2000-01-01 12:34:56', t.ymdx
|
85
|
+
assert_equal "2000-01-01(Sat) 12:34:56", t.ymdax
|
86
|
+
assert_equal "2000-01-01 (土) 12:34:56", t.format_date
|
87
|
+
assert_equal 'Sat, 01 Jan 2000 12:34:56 GMT', t.rfc1123_date
|
88
|
+
assert_equal '2000-01-01T12:34:56', t.rfc_date
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_date
|
93
|
+
# test_date_parse
|
94
|
+
time = Time.date_parse('1970-01-01')
|
95
|
+
assert_equal(-32400, time.to_i)
|
96
|
+
|
97
|
+
# test_date_abbr
|
98
|
+
now = Time.local(1970, 1, 1)
|
99
|
+
t2 = Time.local(1970, 1, 2)
|
100
|
+
abbr = Time.date_abbr(now, t2)
|
101
|
+
assert_equal '01-02', abbr
|
102
|
+
|
103
|
+
t2 = Time.local(1971, 1, 1)
|
104
|
+
abbr = Time.date_abbr(now, t2)
|
105
|
+
assert_equal '1971-01-01', abbr
|
106
|
+
|
107
|
+
# test_date_emphasis
|
108
|
+
now = Time.local(1970, 2, 1)
|
109
|
+
past = Time.local(1970, 1, 30)
|
110
|
+
span = Time.date_emphasis(now, past, 't')
|
111
|
+
assert_equal [:span, {:class=>'past'}, 't'], span
|
112
|
+
|
113
|
+
tomorrow = Time.local(1970, 2, 2)
|
114
|
+
span = Time.date_emphasis(now, tomorrow, 't')
|
115
|
+
assert_equal [:strong, 't'], span
|
116
|
+
|
117
|
+
nextweek = Time.local(1970, 2, 9)
|
118
|
+
span = Time.date_emphasis(now, nextweek, 't')
|
119
|
+
assert_equal [:em, 't'], span
|
120
|
+
|
121
|
+
nextmonth = Time.local(1970, 3, 3)
|
122
|
+
span = Time.date_emphasis(now, nextmonth, 't')
|
123
|
+
assert_equal [:span, {:class=>'future'}, 't'], span
|
124
|
+
end
|
125
|
+
end
|