qwik2md 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +4 -0
  5. data/README.md +36 -0
  6. data/Rakefile +10 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/exe/qwik2md +17 -0
  10. data/lib/qwik2md/version.rb +3 -0
  11. data/lib/qwik2md.rb +39 -0
  12. data/qwik2md.gemspec +30 -0
  13. data/vendor/qwik/AUTHORS +10 -0
  14. data/vendor/qwik/COPYING +340 -0
  15. data/vendor/qwik/COPYRIGHT +346 -0
  16. data/vendor/qwik/lib/qwik/Makefile +63 -0
  17. data/vendor/qwik/lib/qwik/Rakefile +17 -0
  18. data/vendor/qwik/lib/qwik/act-aa.rb +83 -0
  19. data/vendor/qwik/lib/qwik/act-archive.rb +386 -0
  20. data/vendor/qwik/lib/qwik/act-attach.rb +304 -0
  21. data/vendor/qwik/lib/qwik/act-backup.rb +236 -0
  22. data/vendor/qwik/lib/qwik/act-basic.rb +325 -0
  23. data/vendor/qwik/lib/qwik/act-book.rb +161 -0
  24. data/vendor/qwik/lib/qwik/act-calc.rb +371 -0
  25. data/vendor/qwik/lib/qwik/act-charset.rb +251 -0
  26. data/vendor/qwik/lib/qwik/act-christel.rb +112 -0
  27. data/vendor/qwik/lib/qwik/act-chronology.rb +149 -0
  28. data/vendor/qwik/lib/qwik/act-code.rb +155 -0
  29. data/vendor/qwik/lib/qwik/act-comment.rb +554 -0
  30. data/vendor/qwik/lib/qwik/act-config.rb +49 -0
  31. data/vendor/qwik/lib/qwik/act-counter.rb +125 -0
  32. data/vendor/qwik/lib/qwik/act-day.rb +96 -0
  33. data/vendor/qwik/lib/qwik/act-describe.rb +135 -0
  34. data/vendor/qwik/lib/qwik/act-diary.rb +109 -0
  35. data/vendor/qwik/lib/qwik/act-edit.rb +317 -0
  36. data/vendor/qwik/lib/qwik/act-embed-html.rb +296 -0
  37. data/vendor/qwik/lib/qwik/act-emode.rb +150 -0
  38. data/vendor/qwik/lib/qwik/act-event.rb +187 -0
  39. data/vendor/qwik/lib/qwik/act-file.rb +303 -0
  40. data/vendor/qwik/lib/qwik/act-files.rb +771 -0
  41. data/vendor/qwik/lib/qwik/act-getpass.rb +295 -0
  42. data/vendor/qwik/lib/qwik/act-history.rb +136 -0
  43. data/vendor/qwik/lib/qwik/act-html.rb +204 -0
  44. data/vendor/qwik/lib/qwik/act-httpauth.rb +147 -0
  45. data/vendor/qwik/lib/qwik/act-include.rb +142 -0
  46. data/vendor/qwik/lib/qwik/act-interwiki.rb +189 -0
  47. data/vendor/qwik/lib/qwik/act-isearch.rb +109 -0
  48. data/vendor/qwik/lib/qwik/act-keywords.rb +137 -0
  49. data/vendor/qwik/lib/qwik/act-lang.rb +81 -0
  50. data/vendor/qwik/lib/qwik/act-license.rb +63 -0
  51. data/vendor/qwik/lib/qwik/act-list.rb +287 -0
  52. data/vendor/qwik/lib/qwik/act-login.rb +410 -0
  53. data/vendor/qwik/lib/qwik/act-logout.rb +60 -0
  54. data/vendor/qwik/lib/qwik/act-mail.rb +159 -0
  55. data/vendor/qwik/lib/qwik/act-map.rb +292 -0
  56. data/vendor/qwik/lib/qwik/act-md5.rb +42 -0
  57. data/vendor/qwik/lib/qwik/act-mdlb.rb +741 -0
  58. data/vendor/qwik/lib/qwik/act-media.rb +416 -0
  59. data/vendor/qwik/lib/qwik/act-member.rb +157 -0
  60. data/vendor/qwik/lib/qwik/act-menu.rb +142 -0
  61. data/vendor/qwik/lib/qwik/act-metadata.rb +323 -0
  62. data/vendor/qwik/lib/qwik/act-mlsubmitform.rb +49 -0
  63. data/vendor/qwik/lib/qwik/act-monitor.rb +167 -0
  64. data/vendor/qwik/lib/qwik/act-new.rb +418 -0
  65. data/vendor/qwik/lib/qwik/act-pagelist.rb +248 -0
  66. data/vendor/qwik/lib/qwik/act-password.rb +145 -0
  67. data/vendor/qwik/lib/qwik/act-plan.rb +210 -0
  68. data/vendor/qwik/lib/qwik/act-povray.rb +230 -0
  69. data/vendor/qwik/lib/qwik/act-presen.rb +380 -0
  70. data/vendor/qwik/lib/qwik/act-redirect.rb +133 -0
  71. data/vendor/qwik/lib/qwik/act-ring.rb +1071 -0
  72. data/vendor/qwik/lib/qwik/act-rrefs.rb +255 -0
  73. data/vendor/qwik/lib/qwik/act-ruby.rb +116 -0
  74. data/vendor/qwik/lib/qwik/act-sample.rb +170 -0
  75. data/vendor/qwik/lib/qwik/act-save.rb +295 -0
  76. data/vendor/qwik/lib/qwik/act-schedule.rb +374 -0
  77. data/vendor/qwik/lib/qwik/act-search.rb +180 -0
  78. data/vendor/qwik/lib/qwik/act-searchwords.rb +51 -0
  79. data/vendor/qwik/lib/qwik/act-sendpass.rb +83 -0
  80. data/vendor/qwik/lib/qwik/act-site.rb +89 -0
  81. data/vendor/qwik/lib/qwik/act-sitebackup.rb +419 -0
  82. data/vendor/qwik/lib/qwik/act-sitelog.rb +118 -0
  83. data/vendor/qwik/lib/qwik/act-smil.rb +299 -0
  84. data/vendor/qwik/lib/qwik/act-status.rb +220 -0
  85. data/vendor/qwik/lib/qwik/act-style.rb +608 -0
  86. data/vendor/qwik/lib/qwik/act-table.rb +263 -0
  87. data/vendor/qwik/lib/qwik/act-tableform.rb +241 -0
  88. data/vendor/qwik/lib/qwik/act-tag.rb +103 -0
  89. data/vendor/qwik/lib/qwik/act-text.rb +70 -0
  90. data/vendor/qwik/lib/qwik/act-textarea.rb +164 -0
  91. data/vendor/qwik/lib/qwik/act-theme.rb +346 -0
  92. data/vendor/qwik/lib/qwik/act-toc.rb +112 -0
  93. data/vendor/qwik/lib/qwik/act-typekey.rb +198 -0
  94. data/vendor/qwik/lib/qwik/act-under-const.rb +94 -0
  95. data/vendor/qwik/lib/qwik/act-webservice.rb +321 -0
  96. data/vendor/qwik/lib/qwik/act-wema.rb +558 -0
  97. data/vendor/qwik/lib/qwik/act-wysiwyg.rb +238 -0
  98. data/vendor/qwik/lib/qwik/action.rb +325 -0
  99. data/vendor/qwik/lib/qwik/autoreload.rb +98 -0
  100. data/vendor/qwik/lib/qwik/bench-bench.rb +28 -0
  101. data/vendor/qwik/lib/qwik/bench-emode.rb +47 -0
  102. data/vendor/qwik/lib/qwik/bench-format-xml.rb +70 -0
  103. data/vendor/qwik/lib/qwik/bench-large-table.rb +62 -0
  104. data/vendor/qwik/lib/qwik/bench-md5.rb +14 -0
  105. data/vendor/qwik/lib/qwik/bench-module-session.rb +19 -0
  106. data/vendor/qwik/lib/qwik/bench-page.rb +50 -0
  107. data/vendor/qwik/lib/qwik/bench-s-md5.rb +28 -0
  108. data/vendor/qwik/lib/qwik/bench-session.rb +25 -0
  109. data/vendor/qwik/lib/qwik/bench-textformat.rb +31 -0
  110. data/vendor/qwik/lib/qwik/catalog-factory.rb +91 -0
  111. data/vendor/qwik/lib/qwik/catalog-ja.rb +479 -0
  112. data/vendor/qwik/lib/qwik/catalog-ml-ja.rb +145 -0
  113. data/vendor/qwik/lib/qwik/check-act-monitor.rb +112 -0
  114. data/vendor/qwik/lib/qwik/check-act-monitor2.rb +46 -0
  115. data/vendor/qwik/lib/qwik/check-act-theme.rb +27 -0
  116. data/vendor/qwik/lib/qwik/check-event.rb +112 -0
  117. data/vendor/qwik/lib/qwik/check-event2.rb +55 -0
  118. data/vendor/qwik/lib/qwik/check-htree-rexml.rb +77 -0
  119. data/vendor/qwik/lib/qwik/check-htree.rb +51 -0
  120. data/vendor/qwik/lib/qwik/check-libxml.rb +135 -0
  121. data/vendor/qwik/lib/qwik/check-many-pages.rb +47 -0
  122. data/vendor/qwik/lib/qwik/check-monitor.rb +33 -0
  123. data/vendor/qwik/lib/qwik/check-observer.rb +67 -0
  124. data/vendor/qwik/lib/qwik/check-server.rb +61 -0
  125. data/vendor/qwik/lib/qwik/check-uuencode.rb +33 -0
  126. data/vendor/qwik/lib/qwik/check-webdav.rb +65 -0
  127. data/vendor/qwik/lib/qwik/check-xml-xpath.rb +27 -0
  128. data/vendor/qwik/lib/qwik/common-backtrace.rb +94 -0
  129. data/vendor/qwik/lib/qwik/common-basic.rb +111 -0
  130. data/vendor/qwik/lib/qwik/common-condition.rb +142 -0
  131. data/vendor/qwik/lib/qwik/common-error.rb +48 -0
  132. data/vendor/qwik/lib/qwik/common-gettext.rb +50 -0
  133. data/vendor/qwik/lib/qwik/common-javascript.rb +45 -0
  134. data/vendor/qwik/lib/qwik/common-notice.rb +132 -0
  135. data/vendor/qwik/lib/qwik/common-plain.rb +105 -0
  136. data/vendor/qwik/lib/qwik/common-plugin.rb +111 -0
  137. data/vendor/qwik/lib/qwik/common-res.rb +76 -0
  138. data/vendor/qwik/lib/qwik/common-resolve.rb +92 -0
  139. data/vendor/qwik/lib/qwik/common-send.rb +171 -0
  140. data/vendor/qwik/lib/qwik/common-session.rb +139 -0
  141. data/vendor/qwik/lib/qwik/common-surface.rb +261 -0
  142. data/vendor/qwik/lib/qwik/common-url.rb +90 -0
  143. data/vendor/qwik/lib/qwik/compat/Makefile +12 -0
  144. data/vendor/qwik/lib/qwik/compat/add_load_path.rb +1 -0
  145. data/vendor/qwik/lib/qwik/config.rb +299 -0
  146. data/vendor/qwik/lib/qwik/db-b-backup.rb +142 -0
  147. data/vendor/qwik/lib/qwik/db-backup.rb +184 -0
  148. data/vendor/qwik/lib/qwik/db-berkeley.rb +306 -0
  149. data/vendor/qwik/lib/qwik/db-filesystem.rb +305 -0
  150. data/vendor/qwik/lib/qwik/db-indexer.rb +154 -0
  151. data/vendor/qwik/lib/qwik/db-searchwords.rb +238 -0
  152. data/vendor/qwik/lib/qwik/description-ja.rb +267 -0
  153. data/vendor/qwik/lib/qwik/description.rb +256 -0
  154. data/vendor/qwik/lib/qwik/dev-add-copyright.rb +23 -0
  155. data/vendor/qwik/lib/qwik/dev-backup.rb +24 -0
  156. data/vendor/qwik/lib/qwik/dev-bench.rb +175 -0
  157. data/vendor/qwik/lib/qwik/dev-calctime.rb +52 -0
  158. data/vendor/qwik/lib/qwik/dev-css-compressor.rb +60 -0
  159. data/vendor/qwik/lib/qwik/dev-extract-catalog.rb +102 -0
  160. data/vendor/qwik/lib/qwik/dev-js-compressor.rb +73 -0
  161. data/vendor/qwik/lib/qwik/dev-release.rb +235 -0
  162. data/vendor/qwik/lib/qwik/dev-replace.rb +353 -0
  163. data/vendor/qwik/lib/qwik/dev-sendmail.rb +25 -0
  164. data/vendor/qwik/lib/qwik/farm.rb +283 -0
  165. data/vendor/qwik/lib/qwik/gettext.rb +56 -0
  166. data/vendor/qwik/lib/qwik/group-cond.rb +157 -0
  167. data/vendor/qwik/lib/qwik/group-config.rb +247 -0
  168. data/vendor/qwik/lib/qwik/group-confirm.rb +147 -0
  169. data/vendor/qwik/lib/qwik/group-db.rb +326 -0
  170. data/vendor/qwik/lib/qwik/group-mail.rb +195 -0
  171. data/vendor/qwik/lib/qwik/group-member.rb +307 -0
  172. data/vendor/qwik/lib/qwik/group-sendmail.rb +231 -0
  173. data/vendor/qwik/lib/qwik/group-site.rb +374 -0
  174. data/vendor/qwik/lib/qwik/group-sweep.rb +63 -0
  175. data/vendor/qwik/lib/qwik/group.rb +157 -0
  176. data/vendor/qwik/lib/qwik/helper.rb +6 -0
  177. data/vendor/qwik/lib/qwik/html-generator.rb +104 -0
  178. data/vendor/qwik/lib/qwik/html-to-wabisabi.rb +148 -0
  179. data/vendor/qwik/lib/qwik/htree-diff.rb +87 -0
  180. data/vendor/qwik/lib/qwik/htree-format-xml.rb +57 -0
  181. data/vendor/qwik/lib/qwik/htree-generator.rb +144 -0
  182. data/vendor/qwik/lib/qwik/htree-get.rb +251 -0
  183. data/vendor/qwik/lib/qwik/htree-html-generator.rb +179 -0
  184. data/vendor/qwik/lib/qwik/htree-template.rb +263 -0
  185. data/vendor/qwik/lib/qwik/htree-to-wabisabi.rb +171 -0
  186. data/vendor/qwik/lib/qwik/loadlib.rb +79 -0
  187. data/vendor/qwik/lib/qwik/logger.rb +115 -0
  188. data/vendor/qwik/lib/qwik/mail-body.rb +171 -0
  189. data/vendor/qwik/lib/qwik/mail-header.rb +474 -0
  190. data/vendor/qwik/lib/qwik/mail-multipart.rb +193 -0
  191. data/vendor/qwik/lib/qwik/mail-parse.rb +147 -0
  192. data/vendor/qwik/lib/qwik/mail.rb +341 -0
  193. data/vendor/qwik/lib/qwik/mailaddress.rb +83 -0
  194. data/vendor/qwik/lib/qwik/mdlb-model.rb +81 -0
  195. data/vendor/qwik/lib/qwik/mdlb-sample.rb +324 -0
  196. data/vendor/qwik/lib/qwik/ml-catalog-factory.rb +27 -0
  197. data/vendor/qwik/lib/qwik/ml-exception.rb +15 -0
  198. data/vendor/qwik/lib/qwik/ml-generator.rb +28 -0
  199. data/vendor/qwik/lib/qwik/ml-gettext.rb +137 -0
  200. data/vendor/qwik/lib/qwik/ml-logger.rb +82 -0
  201. data/vendor/qwik/lib/qwik/ml-memory.rb +65 -0
  202. data/vendor/qwik/lib/qwik/ml-msg-validator.rb +86 -0
  203. data/vendor/qwik/lib/qwik/ml-processor.rb +609 -0
  204. data/vendor/qwik/lib/qwik/ml-quickml-server.rb +122 -0
  205. data/vendor/qwik/lib/qwik/ml-sendmail.rb +0 -0
  206. data/vendor/qwik/lib/qwik/ml-server.rb +107 -0
  207. data/vendor/qwik/lib/qwik/ml-session.rb +348 -0
  208. data/vendor/qwik/lib/qwik/ml-sweeper.rb +101 -0
  209. data/vendor/qwik/lib/qwik/mock-logger.rb +65 -0
  210. data/vendor/qwik/lib/qwik/mock-sendmail.rb +78 -0
  211. data/vendor/qwik/lib/qwik/mock-socket.rb +82 -0
  212. data/vendor/qwik/lib/qwik/modulobe.rb +406 -0
  213. data/vendor/qwik/lib/qwik/mongrel-server.rb +72 -0
  214. data/vendor/qwik/lib/qwik/page-files.rb +249 -0
  215. data/vendor/qwik/lib/qwik/page-generate.rb +82 -0
  216. data/vendor/qwik/lib/qwik/page-get.rb +262 -0
  217. data/vendor/qwik/lib/qwik/page-images.rb +168 -0
  218. data/vendor/qwik/lib/qwik/page-put.rb +128 -0
  219. data/vendor/qwik/lib/qwik/page-rrefs.rb +154 -0
  220. data/vendor/qwik/lib/qwik/page-title.rb +0 -0
  221. data/vendor/qwik/lib/qwik/page-wikidb.rb +234 -0
  222. data/vendor/qwik/lib/qwik/page.rb +67 -0
  223. data/vendor/qwik/lib/qwik/pages.rb +444 -0
  224. data/vendor/qwik/lib/qwik/parse-plugin.rb +249 -0
  225. data/vendor/qwik/lib/qwik/parser-emode.rb +116 -0
  226. data/vendor/qwik/lib/qwik/parser-inline.rb +272 -0
  227. data/vendor/qwik/lib/qwik/parser.rb +349 -0
  228. data/vendor/qwik/lib/qwik/password.rb +183 -0
  229. data/vendor/qwik/lib/qwik/periodic.rb +79 -0
  230. data/vendor/qwik/lib/qwik/qp.rb +56 -0
  231. data/vendor/qwik/lib/qwik/qwik-service.rb +341 -0
  232. data/vendor/qwik/lib/qwik/qwik.rb +5 -0
  233. data/vendor/qwik/lib/qwik/qwikweb-adduser.rb +34 -0
  234. data/vendor/qwik/lib/qwik/qwikweb-catalog-validator.rb +110 -0
  235. data/vendor/qwik/lib/qwik/qwikweb-incgen.rb +28 -0
  236. data/vendor/qwik/lib/qwik/qwikweb-makesite.rb +41 -0
  237. data/vendor/qwik/lib/qwik/qwikweb-server.rb +44 -0
  238. data/vendor/qwik/lib/qwik/qwikweb-showpassword.rb +26 -0
  239. data/vendor/qwik/lib/qwik/qwikweb-watchlog.rb +67 -0
  240. data/vendor/qwik/lib/qwik/request-path.rb +304 -0
  241. data/vendor/qwik/lib/qwik/request-ua.rb +76 -0
  242. data/vendor/qwik/lib/qwik/request-webrick.rb +81 -0
  243. data/vendor/qwik/lib/qwik/request.rb +91 -0
  244. data/vendor/qwik/lib/qwik/resolve-tdiary.rb +292 -0
  245. data/vendor/qwik/lib/qwik/resolve.rb +121 -0
  246. data/vendor/qwik/lib/qwik/response.rb +228 -0
  247. data/vendor/qwik/lib/qwik/server-memory.rb +57 -0
  248. data/vendor/qwik/lib/qwik/server-webrick.rb +102 -0
  249. data/vendor/qwik/lib/qwik/server.rb +252 -0
  250. data/vendor/qwik/lib/qwik/site-config.rb +149 -0
  251. data/vendor/qwik/lib/qwik/site-db.rb +136 -0
  252. data/vendor/qwik/lib/qwik/site-event.rb +162 -0
  253. data/vendor/qwik/lib/qwik/site-files.rb +86 -0
  254. data/vendor/qwik/lib/qwik/site-group.rb +103 -0
  255. data/vendor/qwik/lib/qwik/site-index.rb +47 -0
  256. data/vendor/qwik/lib/qwik/site-log.rb +64 -0
  257. data/vendor/qwik/lib/qwik/site-member.rb +230 -0
  258. data/vendor/qwik/lib/qwik/site-monitor.rb +97 -0
  259. data/vendor/qwik/lib/qwik/site-pages.rb +62 -0
  260. data/vendor/qwik/lib/qwik/site-plan.rb +139 -0
  261. data/vendor/qwik/lib/qwik/site-report.rb +282 -0
  262. data/vendor/qwik/lib/qwik/site-resolve.rb +230 -0
  263. data/vendor/qwik/lib/qwik/site-rrefs.rb +18 -0
  264. data/vendor/qwik/lib/qwik/site-search.rb +180 -0
  265. data/vendor/qwik/lib/qwik/site-timeline.rb +153 -0
  266. data/vendor/qwik/lib/qwik/site-url.rb +189 -0
  267. data/vendor/qwik/lib/qwik/site.rb +76 -0
  268. data/vendor/qwik/lib/qwik/smil-time.rb +105 -0
  269. data/vendor/qwik/lib/qwik/smtp-session.rb +331 -0
  270. data/vendor/qwik/lib/qwik/template-generator.rb +149 -0
  271. data/vendor/qwik/lib/qwik/template.rb +85 -0
  272. data/vendor/qwik/lib/qwik/test-common.rb +10 -0
  273. data/vendor/qwik/lib/qwik/test-ml-info.rb +225 -0
  274. data/vendor/qwik/lib/qwik/test-module-ml.rb +142 -0
  275. data/vendor/qwik/lib/qwik/test-module-path.rb +110 -0
  276. data/vendor/qwik/lib/qwik/test-module-public.rb +70 -0
  277. data/vendor/qwik/lib/qwik/test-module-server.rb +98 -0
  278. data/vendor/qwik/lib/qwik/test-module-session.rb +264 -0
  279. data/vendor/qwik/lib/qwik/test-module-suite.rb +91 -0
  280. data/vendor/qwik/lib/qwik/test-ms-applemail.rb +59 -0
  281. data/vendor/qwik/lib/qwik/test-ms-attach.rb +174 -0
  282. data/vendor/qwik/lib/qwik/test-ms-basic.rb +40 -0
  283. data/vendor/qwik/lib/qwik/test-ms-close.rb +35 -0
  284. data/vendor/qwik/lib/qwik/test-ms-confirm.rb +75 -0
  285. data/vendor/qwik/lib/qwik/test-ms-ignore-spam.rb +57 -0
  286. data/vendor/qwik/lib/qwik/test-ms-japanese.rb +97 -0
  287. data/vendor/qwik/lib/qwik/test-ms-jfilename.rb +82 -0
  288. data/vendor/qwik/lib/qwik/test-ms-large.rb +58 -0
  289. data/vendor/qwik/lib/qwik/test-ms-member.rb +103 -0
  290. data/vendor/qwik/lib/qwik/test-ms-multipart.rb +84 -0
  291. data/vendor/qwik/lib/qwik/test-ms-org.rb +129 -0
  292. data/vendor/qwik/lib/qwik/test-ms-plan.rb +130 -0
  293. data/vendor/qwik/lib/qwik/test-ms-post.rb +53 -0
  294. data/vendor/qwik/lib/qwik/test-ms-quopri.rb +76 -0
  295. data/vendor/qwik/lib/qwik/test-sub-quopri.rb +45 -0
  296. data/vendor/qwik/lib/qwik/test-submit-base64.rb +59 -0
  297. data/vendor/qwik/lib/qwik/test-submit-forward.rb +61 -0
  298. data/vendor/qwik/lib/qwik/test-submit-html-mail.rb +52 -0
  299. data/vendor/qwik/lib/qwik/test-submit-japanese.rb +135 -0
  300. data/vendor/qwik/lib/qwik/test-submit-jfilename.rb +144 -0
  301. data/vendor/qwik/lib/qwik/test-submit-uuencode.rb +71 -0
  302. data/vendor/qwik/lib/qwik/test-suite-all.rb +8 -0
  303. data/vendor/qwik/lib/qwik/test-suite-basic.rb +9 -0
  304. data/vendor/qwik/lib/qwik/test-suite-ml.rb +9 -0
  305. data/vendor/qwik/lib/qwik/test-typekey.rb +64 -0
  306. data/vendor/qwik/lib/qwik/testunit.rb +45 -0
  307. data/vendor/qwik/lib/qwik/tokenizer-inline.rb +288 -0
  308. data/vendor/qwik/lib/qwik/tokenizer.rb +331 -0
  309. data/vendor/qwik/lib/qwik/typekey.rb +160 -0
  310. data/vendor/qwik/lib/qwik/util-basic.rb +135 -0
  311. data/vendor/qwik/lib/qwik/util-charset.rb +331 -0
  312. data/vendor/qwik/lib/qwik/util-css.rb +56 -0
  313. data/vendor/qwik/lib/qwik/util-csv-tokenizer.rb +113 -0
  314. data/vendor/qwik/lib/qwik/util-filename.rb +112 -0
  315. data/vendor/qwik/lib/qwik/util-pathname.rb +202 -0
  316. data/vendor/qwik/lib/qwik/util-pid.rb +58 -0
  317. data/vendor/qwik/lib/qwik/util-safe.rb +67 -0
  318. data/vendor/qwik/lib/qwik/util-sendmail.rb +273 -0
  319. data/vendor/qwik/lib/qwik/util-string.rb +202 -0
  320. data/vendor/qwik/lib/qwik/util-time.rb +125 -0
  321. data/vendor/qwik/lib/qwik/util-webrick.rb +176 -0
  322. data/vendor/qwik/lib/qwik/version.rb +11 -0
  323. data/vendor/qwik/lib/qwik/wabisabi-basic.rb +163 -0
  324. data/vendor/qwik/lib/qwik/wabisabi-diff.rb +130 -0
  325. data/vendor/qwik/lib/qwik/wabisabi-format-xml.rb +310 -0
  326. data/vendor/qwik/lib/qwik/wabisabi-generator.rb +262 -0
  327. data/vendor/qwik/lib/qwik/wabisabi-index.rb +174 -0
  328. data/vendor/qwik/lib/qwik/wabisabi-table.rb +212 -0
  329. data/vendor/qwik/lib/qwik/wabisabi-template.rb +295 -0
  330. data/vendor/qwik/lib/qwik/wabisabi-to-htree.rb +111 -0
  331. data/vendor/qwik/lib/qwik/wabisabi-to-wiki.rb +690 -0
  332. data/vendor/qwik/lib/qwik/wabisabi-traverse.rb +207 -0
  333. data/vendor/qwik/lib/qwik/wabisabi-validator.rb +116 -0
  334. data/vendor/qwik/lib/qwik/wabisabi.rb +5 -0
  335. metadata +492 -0
@@ -0,0 +1,349 @@
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-string'
7
+ require 'qwik/tokenizer'
8
+ require 'qwik/parser-inline'
9
+ require 'qwik/tokenizer-inline'
10
+ require 'qwik/html-to-wabisabi'
11
+ require 'qwik/wabisabi-validator'
12
+
13
+ module Qwik
14
+ class TextParser
15
+ # Make a tree from tokens.
16
+ def self.make_tree(tokens)
17
+ ar = []
18
+
19
+ tokens.each {|token|
20
+ tag = token.first
21
+ case tag
22
+
23
+ when :h2, :h3, :h4, :h5, :h6
24
+ ar << [tag, *inline(token[1])]
25
+
26
+ when :ul, :ol
27
+ lu = ar
28
+ token[1].times {
29
+ if lu.last && lu.last.is_a?(Array) && lu.last.first == tag
30
+ lu = lu.last
31
+ else
32
+ a = [tag]
33
+ lu << a
34
+ lu = a
35
+ end
36
+ }
37
+ lu << [:li, *inline(token[2])]
38
+
39
+ when :pre, :blockquote
40
+ if ar.last && ar.last.first == tag
41
+ ar.last[1] << "\n"+token[1]
42
+ else
43
+ ar << [tag, token[1]]
44
+ end
45
+
46
+ when :dl
47
+ a = []
48
+ a << [:dt, *inline(token[1])] if token[1]
49
+ a << [:dd, *inline(token[2])] if token[2]
50
+ if ar.last && ar.last.first == tag
51
+ ar.last << a[0]
52
+ ar.last << a[1] if a[1]
53
+ else
54
+ ar << [tag, *a]
55
+ end
56
+
57
+ when :table
58
+ token.shift
59
+ table_ar = token.map {|td|
60
+ inline_ar = inline(td)
61
+ inline_ar << '' if inline_ar.empty?
62
+ [:td] + inline_ar
63
+ }
64
+ tr = [:tr] + table_ar
65
+ if ar.last && ar.last.first == tag
66
+ ar.last << tr
67
+ else
68
+ ar << [tag, tr]
69
+ end
70
+
71
+ when :text
72
+ line_ar = inline(token[1])
73
+ if ar.last && ar.last.is_a?(Array) && ar.last.first == :p
74
+ ar[-1] << "\n" if ar.last.last != [:br]
75
+ ar[-1] += line_ar
76
+ else
77
+ ar << [:p, *line_ar]
78
+ end
79
+
80
+ when :empty
81
+ ar << ["\n"]
82
+
83
+ when :plugin
84
+ ar << parse_plugin(token)
85
+
86
+ when :html
87
+ ar << parse_html(token)
88
+
89
+ else
90
+ ar << token
91
+ end
92
+ }
93
+
94
+ nar = []
95
+ ar.each {|block|
96
+ tag = block.first
97
+ case tag
98
+ when :blockquote
99
+ str = block[1]
100
+
101
+ tokens = TextTokenizer.tokenize(str)
102
+ tree = make_tree(tokens) # Recursive.
103
+ nar << [tag, *tree]
104
+
105
+ when :p
106
+ while block[1] == [:br]
107
+ block.delete_at(1)
108
+ end
109
+ while block.last == [:br]
110
+ block.pop
111
+ end
112
+ nar << block
113
+ else
114
+ nar << block
115
+ end
116
+ }
117
+
118
+ return nar
119
+ end
120
+
121
+ def self.inline(str)
122
+ return str if str.is_a? Array
123
+
124
+ tokens = InlineTokenizer.tokenize(str)
125
+ tree = InlineParser.make_tree(tokens)
126
+ return tree
127
+ end
128
+
129
+ def self.parse_plugin(token)
130
+ method = token[1].to_s
131
+ param = token[2].to_s
132
+ plugin = [:plugin, {:method=>method, :param=>param}]
133
+ plugin << token[3].to_s if token[3]
134
+ return plugin
135
+ end
136
+
137
+ def self.parse_html(token)
138
+ str = token[1]
139
+ wabisabi = HtmlToWabisabi.parse(str)
140
+
141
+ v = WabisabiValidator.valid?(wabisabi)
142
+ if v == true
143
+ return [:html, *wabisabi]
144
+ else
145
+ return [:div, {:class=>'error'}, "can not use [#{v}]"]
146
+ end
147
+ end
148
+
149
+ end
150
+ end
151
+
152
+ if $0 == __FILE__
153
+ if ARGV[0] == '-b'
154
+ $bench = true
155
+ else
156
+ require 'qwik/testunit'
157
+ $test = true
158
+ end
159
+ end
160
+
161
+ if defined?($test) && $test
162
+ class TestParser < Test::Unit::TestCase
163
+ def ok(e, str)
164
+ tokens = Qwik::TextTokenizer.tokenize(str)
165
+ ok_eq(e, Qwik::TextParser.make_tree(tokens))
166
+ end
167
+
168
+ def test_all
169
+ # test none
170
+ ok([], '')
171
+ ok([["\n"]], "#t")
172
+
173
+ # test p
174
+ ok([[:p, 't']], 't')
175
+ ok([[:p, 's', "\n", 't']], "s\nt")
176
+ ok([[:p, 's'], ["\n"], [:p, 't']], "s\n\nt")
177
+ ok([[:p, 's', [:br], 't']], "s~\nt~")
178
+
179
+ ok([[:dl, [:dt, 'dt1'], [:dd, 'dd1']], [:p, 'p1'],
180
+ [:dl, [:dd, 'dd2']]], ":dt1:dd1\np1\n::dd2")
181
+
182
+ # test header
183
+ ok([[:h2, 't']], '*t')
184
+ ok([[:h2, 't'], [:p, 't']], "*t\nt")
185
+ ok([[:h3, 't']], '**t')
186
+ ok([[:h4, 't']], '***t')
187
+ ok([[:h5, 't']], '****t')
188
+ ok([[:h6, 't']], '*****t')
189
+ ok([[:h6, '*t']], '******t')
190
+ ok([[:h6, '**t']], '*******t')
191
+
192
+ # test_ignore_space
193
+ ok([[:h2, 't']], '* t')
194
+ ok([[:h2, 't']], '*t ')
195
+ ok([[:h2, 't']], '* t ')
196
+ ok([[:h3, 't']], '** t')
197
+ ok([[:h3, 't']], '**t ')
198
+ ok([[:h3, 't']], '** t ')
199
+
200
+ # test listing
201
+ ok([[:ul, [:li, 't']]], '-t')
202
+ ok([[:ul, [:ul, [:li, 't']]]], '--t')
203
+ ok([[:ul, [:ul, [:ul, [:li, 't']]]]], '---t')
204
+ ok([[:ul, [:li, 't']], [:p, 't']], "-t\nt")
205
+ ok([[:ul, [:li, 't'], [:li, 't']]], "-t\n-t")
206
+ ok([[:ul, [:li, 't'], [:ul, [:li, 't']]]], "-t\n--t")
207
+ ok([[:ul, [:ul, [:li, 't']], [:li, 't']]], "--t\n-t")
208
+ ok([[:ul, [:ul, [:li, 't']], [:li, 't'], [:ul, [:li, 't']]]],
209
+ "--t\n-t\n--t")
210
+ ok([[:ol, [:li, 't']]], "+t")
211
+ ok([[:ul, [:li, 't']], [:ol, [:li, 't']]], "-t\n+t")
212
+ ok([[:ul, [:li, 't1']], ["\n"], [:ul, [:li, 't2']]], "-t1\n\n-t2")
213
+ ok([["\n"], [:ul, [:li, 't1'], [:li, 't2']]], "\n-t1\n-t2")
214
+
215
+ # test blockquote
216
+ ok([[:blockquote, [:p, 't']]], ">t")
217
+ ok([[:blockquote, [:p, 's', "\n", 't']]], ">s\n>t")
218
+ ok([[:blockquote, [:ul, [:li, 's'], [:li, 't']]]], ">-s\n>-t")
219
+
220
+ # test dl
221
+ ok([[:dl, [:dt, 'dt'],[:dd, 'dd']]], ':dt:dd')
222
+ ok([[:dl, [:dt, 'dt']]], ':dt')
223
+ ok([[:dl]], ':')
224
+ ok([[:dl]], '::')
225
+ ok([[:dl, [:dd, 'dd']]], '::dd')
226
+ ok([[:dl, [:dt, 'dt'], [:dd, 'dd'], [:dt, 'dt2'], [:dd, 'dd2']]],
227
+ ":dt:dd\n:dt2:dd2")
228
+ ok([[:dl, [:dt, 'dt'], [:dd, 'dd'], [:dd, 'dd2']]], ":dt:dd\n::dd2")
229
+
230
+ # test pre
231
+ ok([[:pre, 't']], ' t')
232
+ ok([[:pre, "s\nt"]], " s\n t")
233
+
234
+ ok([[:pre, "s\n"]], "{{{\ns\n}}}")
235
+ ok([[:pre, "s\nt\n"]], "{{{\ns\nt\n}}}")
236
+ ok([[:pre, "#s\n"]], "{{{\n#s\n}}}")
237
+
238
+ ok([[:pre, 't1'], ["\n"], [:pre, 't2']], " t1\n\n t2")
239
+
240
+ # test_table
241
+ ok([[:table, [:tr, [:td, 't']]]], ',t')
242
+ ok([[:table, [:tr, [:td, 't1'], [:td, 't2']]]], ',t1,t2')
243
+ ok([[:table, [:tr, [:td, ''], [:td, 't2']]]], ',,t2')
244
+ ok([[:table, [:tr, [:td, 's']], [:tr, [:td, 't']]]], ",s\n,t")
245
+ ok([[:table, [:tr, [:td, 's1'], [:td, 's2']],
246
+ [:tr, [:td, 't1'], [:td, 't2']]]], ",s1,s2\n,t1,t2")
247
+
248
+ # test plugin
249
+ ok([[:plugin, {:method=>'t', :param=>''}]], "{{t}}")
250
+ ok([[:plugin, {:method=>'t', :param=>'a'}]], "{{t(a)}}")
251
+ ok([[:plugin, {:method=>'t', :param=>""}, "s\n"]], "{{t\ns\n}}")
252
+ ok([[:plugin, {:method=>'t', :param=>""}, "s1\ns2\n"]],
253
+ "{{t\ns1\ns2\n}}")
254
+
255
+ # test_multiline
256
+ ok([[:p, 's', "\n", 't']], "s\nt")
257
+ ok([[:p, 's', [:br], 't']], "s~\nt~")
258
+ ok([[:p, 's'], ["\n"], [:p, 't']], "s\n\nt")
259
+ ok([[:p, 's', [:br], [:br], 't']], "s~\n~\nt~")
260
+
261
+ str = <<'EOT'
262
+ p1~
263
+ ~
264
+ > b1~
265
+ > b2~
266
+ > ~
267
+ > > bb1~
268
+ > > bb2~
269
+ > ~
270
+ > b3~
271
+ > b4~
272
+ ~
273
+ p2~
274
+ EOT
275
+ ok([[:p, 'p1'],
276
+ [:blockquote, [:p, 'b1', [:br], 'b2'],
277
+ [:blockquote, [:p, 'bb1', [:br], 'bb2']],
278
+ [:p, 'b3', [:br], 'b4']],
279
+ [:p, 'p2']],
280
+ str)
281
+
282
+ # test_html
283
+ ok([[:html, "t\n"]], "<html>\nt\n</html>")
284
+ ok([[:div, {:class=>'error'}, "can not use [script]"]],
285
+ "<html>\n<script>t</script>\n</html>")
286
+
287
+ # test_ref
288
+ ok([[:ul, [:li, [:a, {:href=>'http://e.com/'}, 't']]]],
289
+ "- [http://e.com/ t]")
290
+
291
+ # test_hr
292
+ ok([[:hr]], "====")
293
+
294
+ # test_bug
295
+ ok_eq("\226]", '望')
296
+ ok([[:p, [:a, {:href=>"\226].html"}, "\226]"]]], '[[望]]')
297
+ end
298
+
299
+ def test_from_resolve
300
+ # test_lines
301
+ ok([[:ul, [:li, 't1'], [:li, 't2']]], "- t1\n- t2")
302
+ ok([[:p, 't1'], [:ul, [:li, 't2']]], "t1\n- t2")
303
+
304
+ # test_qwik_text
305
+ ok([[:ul, [:li, 't']]], '- t')
306
+ ok([[:ul, [:li, 's'], [:ul, [:li, 't']]]], "- s\n-- t")
307
+ ok([[:ol, [:li, 't']]], "+ t")
308
+
309
+ # test_ul
310
+ ok([[:ul, [:li, 't1']], ["\n"], [:ul, [:li, 't2']]], "- t1\n\n- t2")
311
+ end
312
+
313
+ def test_format
314
+ # test_inline
315
+ ok([[:p, [:em, 't']]], "''t''")
316
+ ok([[:p, [:a, {:href=>'t.html'}, 't']]], "[[t]]")
317
+ ok([[:p, [:a, {:href=>'1.html'}, '1']]], "[[1]]")
318
+ ok([[:p, [:plugin, {:method=>'interwiki', :param=>'Test:t'}, 'Test:t']]],
319
+ "[[Test:t]]")
320
+ ok([[:plugin, {:method=>'t', :param=>''}]], "{{t}}")
321
+ ok([[:p, 'a', [:plugin, {:method=>'t', :param=>''}, ''], 'b']], "a{{t}}b")
322
+ ok([[:p, [:a, {:href=>'http://e.com/'}, 'http://e.com/']]],
323
+ 'http://e.com/')
324
+ ok([[:p, 'a ', [:a, {:href=>'http://e.com/'}, 'http://e.com/'], ' b']],
325
+ 'a http://e.com/ b')
326
+
327
+ # test_escape
328
+ ok([[:h2, "'"]], "*'")
329
+ ok([[:h2, "<"]], "*<")
330
+
331
+ # test_sjis
332
+ ok([[:h2, "\202\240"]], "* あ")
333
+ ok([[:h3, "\202\240"]], "** あ")
334
+ ok([[:h3, "\212\277\216\232"]], "** 漢字")
335
+ ok([[:h3, "\221\322"]], "** 待")
336
+
337
+ # test ?
338
+ ok([[:h2, [:a, {:href=>'t.html'}, 't']]], "*[[t]]")
339
+ ok([[:h2, [:a, {:href=>'t.html'}, 't']]], "* [[t]]")
340
+ ok([[:h2, [:a, {:href=>'t.html'}, 't']]], "* [[t]] ")
341
+ ok([[:h2, [:a, {:href=>'t.html'}, 't'], ' a']], "* [[t]] a")
342
+ ok([[:h2, [:a, {:href=>'t.html'}, 't'], ' a']], "* [[t]] a")
343
+
344
+ # test_format
345
+ ok([[:h2, "<"]], "*<")
346
+ ok([[:p, [:strong, '']]], "''''''")
347
+ end
348
+ end
349
+ end
@@ -0,0 +1,183 @@
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
+ require 'qwik/util-string'
8
+ require 'qwik/server-memory'
9
+
10
+ module Qwik
11
+ class ServerMemory
12
+ # password
13
+ def passgen
14
+ @passgen = PasswordGenerator.new(@config) unless defined? @passgen
15
+ return @passgen
16
+ end
17
+ end
18
+
19
+ class PasswordGenerator
20
+ DEFAULT_SITE_PASSWORD = ''
21
+ PASSWORD_FILE = 'password.txt'
22
+ GENERATION_FILE = 'generation.txt'
23
+
24
+ def initialize(config)
25
+ etc_path = config.etc_dir.path
26
+ @site_password_file = etc_path + PASSWORD_FILE
27
+ @site_password = DEFAULT_SITE_PASSWORD
28
+ if @site_password_file.exist?
29
+ @site_password = @site_password_file.read.to_s.chomp
30
+ end
31
+ @generation_file = etc_path + GENERATION_FILE
32
+ @generation = PasswordGenerator.generation_get(@generation_file)
33
+ end
34
+
35
+ def generate(user)
36
+ generation = 0
37
+ generation = @generation[user] if @generation[user]
38
+ return PasswordGenerator.generate_md5hex(@site_password,
39
+ user, generation).hex.to_s[-8, 8]
40
+ end
41
+
42
+ def generate_hex(user)
43
+ generation = 0
44
+ generation = @generation[user] if @generation[user]
45
+ return PasswordGenerator.generate_md5hex(@site_password,
46
+ user, generation).upcase[0, 8]
47
+ end
48
+
49
+ def match?(user, pass)
50
+ return false if user.nil? || user.empty?
51
+ return false if pass.nil? || pass.empty?
52
+
53
+ pa = generate(user)
54
+ return true if pa == pass
55
+ pa = generate_hex(user)
56
+ return true if pa == pass
57
+ return true if pa == pass.upcase
58
+ return false
59
+ end
60
+
61
+ def generation_inc(user)
62
+ generation = PasswordGenerator.generation_get(@generation_file)
63
+ gen = 0
64
+ gen = generation[user] if generation[user]
65
+ gen += 1 # Increment the generation of the user.
66
+ PasswordGenerator.generation_add(@generation_file, user, gen)
67
+ @generation = PasswordGenerator.generation_get(@generation_file)
68
+ return gen
69
+ end
70
+
71
+ def generation_store
72
+ PasswordGenerator.generation_store(@generation_file, @generation)
73
+ return nil
74
+ end
75
+
76
+ private
77
+
78
+ def self.generation_get(file)
79
+ file.write('') if ! file.exist?
80
+ str = file.read
81
+ generation = {}
82
+ str.each {|line|
83
+ next unless line[0] == ?,
84
+ dummy, user, gen = line.chomp.split(',')
85
+ generation[user] = gen.to_i
86
+ }
87
+ return generation
88
+ end
89
+
90
+ def self.generate_md5hex(site_password, user, generation=0)
91
+ return "#{user}:#{site_password}:#{generation}".md5hex
92
+ end
93
+
94
+ def self.generation_add(file, user, gen)
95
+ file.add(",#{user},#{gen}\n")
96
+ end
97
+
98
+ def self.generation_store(file, generation)
99
+ str = generation.map {|user, gen|
100
+ [user, gen]
101
+ }.sort.map {|user, gen|
102
+ ",#{user},#{gen}\n"
103
+ }.join
104
+ file.write(str)
105
+ end
106
+ end
107
+ end
108
+
109
+ if $0 == __FILE__
110
+ require 'qwik/testunit'
111
+ require 'qwik/config'
112
+ $test = true
113
+ end
114
+
115
+ if defined?($test) && $test
116
+ class TestPasswordGenerator < Test::Unit::TestCase
117
+ def test_all
118
+ config = Qwik::Config.new
119
+ config.update Qwik::Config::DebugConfig
120
+ config.update Qwik::Config::TestConfig
121
+ generation_file = config.etc_dir.path +
122
+ Qwik::PasswordGenerator::GENERATION_FILE
123
+ generation_file.write('')
124
+
125
+ gen = Qwik::PasswordGenerator.new(config)
126
+
127
+ # test_generate
128
+ assert_equal '95988593', gen.generate('user@e.com')
129
+
130
+ # test_generate_hex
131
+ assert_equal '68246775', gen.generate_hex('user@e.com')
132
+
133
+ # test_match?
134
+ assert_equal true, gen.match?('user@e.com', '95988593')
135
+ # generation 0
136
+ assert_equal false, gen.match?('user@e.com', '64006086')
137
+ assert_equal true, gen.match?('user@e.com', '68246775')
138
+
139
+ # test_generation_inc
140
+ gen.generation_inc('user@e.com')
141
+ assert_equal ",user@e.com,1\n", generation_file.read
142
+ assert_equal false, gen.match?('user@e.com', '95988593') # Changed.
143
+ assert_equal '85127862', gen.generate('user@e.com') # generation 1
144
+ assert_equal true, gen.match?('user@e.com', '85127862')
145
+
146
+ # test_generation_inc, again
147
+ gen.generation_inc('user@e.com')
148
+ assert_equal ",user@e.com,1\n,user@e.com,2\n", generation_file.read
149
+ assert_equal '78735937', gen.generate('user@e.com')
150
+
151
+ # test_store
152
+ gen.generation_store
153
+ assert_equal ",user@e.com,2\n", generation_file.read
154
+
155
+ # test_another_user
156
+ gen.generation_inc('another@e.com')
157
+ assert_equal ",user@e.com,2\n,another@e.com,1\n", generation_file.read
158
+ gen.generation_store
159
+ assert_equal ",another@e.com,1\n,user@e.com,2\n", generation_file.read
160
+
161
+ # teardown
162
+ generation_file.unlink
163
+ end
164
+
165
+ def test_password_file
166
+ config = Qwik::Config.new
167
+ config.update Qwik::Config::DebugConfig
168
+ config.update Qwik::Config::TestConfig
169
+ password_file = config.etc_dir.path+Qwik::PasswordGenerator::PASSWORD_FILE
170
+ password_file.write('')
171
+
172
+ gen = Qwik::PasswordGenerator.new(config)
173
+ assert_equal '95988593', gen.generate('user@e.com')
174
+
175
+ password_file.write('t')
176
+ gen = Qwik::PasswordGenerator.new(config)
177
+ assert_equal '57318391', gen.generate('user@e.com')
178
+
179
+ # teardown
180
+ password_file.unlink
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,79 @@
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/config'
7
+ require 'qwik/site-report'
8
+
9
+ module Qwik
10
+ class PeriodicThread
11
+ def initialize(config, memory, time)
12
+ @config, @memory = config, memory
13
+ @logger = @memory[:logger]
14
+ @time = time
15
+ end
16
+
17
+ def start
18
+ loop {
19
+ begin
20
+ process
21
+ rescue Exception => e
22
+ pp e
23
+ end
24
+ sleep @time
25
+ }
26
+ end
27
+
28
+ def process # abstract method
29
+ end
30
+ end
31
+
32
+ class SweepThread < PeriodicThread
33
+ def initialize(config, memory)
34
+ super(config, memory, 60*60) # 1hour
35
+ end
36
+
37
+ def process
38
+ sleep 30*60 # 30min
39
+ farm = @memory.farm
40
+ farm.sweep
41
+ end
42
+ end
43
+ end
44
+
45
+ if $0 == __FILE__
46
+ require 'qwik/test-common'
47
+ $test = true
48
+ end
49
+
50
+ if defined?($test) && $test
51
+ class TestPeriodic < Test::Unit::TestCase
52
+ include TestSession
53
+
54
+ def test_dummy
55
+ end
56
+
57
+ def nu_test_all
58
+ @periodic = Qwik::Periodic.new(@config, @memory)
59
+ # @periodic.time = 1 # for test, do it on every second.
60
+ @periodic.time = 1000 # for test, do it on every second.
61
+
62
+ t = Thread.new { @periodic.start }
63
+ t.abort_on_exception = true
64
+
65
+ @farm = @memory.farm
66
+ @site = @farm.get_site('test')
67
+ ok_eq(false, @site.inactive?)
68
+ page = @site['_SiteConfig']
69
+ page.store(':ml_life_time:0') # die soon.
70
+
71
+ sleep 2 # will run sweep
72
+
73
+ @site = @farm.get_site('test')
74
+ ok_eq(nil, @site)
75
+
76
+ t.kill
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,56 @@
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
+ module QP
6
+ def caller_msg(ca)
7
+ file, linenum, msg = ca.first.split(/:([0-9]+):/)
8
+ msg = $1 if /\Ain \`(.+)\'\z/ =~ msg
9
+ File.basename(file)+':'+linenum.to_s+':'+msg.to_s
10
+ end
11
+
12
+ def ar_inspect(ar)
13
+ '['+ar.map {|arg| arg.inspect }.join(', ')+']'
14
+ end
15
+
16
+ def runtime
17
+ $__qp_t__ = Time.now unless defined? $__qp_t__
18
+ sprintf('%.1f', Time.now - $__qp_t__)
19
+ end
20
+
21
+ def qp(ca, *args)
22
+ QP.caller_msg(ca)+"\t"+QP.ar_inspect(args)
23
+ end
24
+
25
+ def tp(ca, *args)
26
+ QP.runtime+':'+QP.qp(ca, *args)
27
+ end
28
+
29
+ module_function :caller_msg, :ar_inspect, :runtime, :qp, :tp
30
+ end
31
+
32
+ def qp(*args)
33
+ $stdout.print QP.qp(caller(1), *args)+"\n"
34
+ end
35
+
36
+ def tp(*args)
37
+ print QP.tp(caller(1), *args)+"\n"
38
+ end
39
+
40
+ if $0 == __FILE__
41
+ $LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
42
+ $test = true
43
+ end
44
+
45
+ if defined?($test) && $test
46
+ require 'qwik/testunit'
47
+
48
+ class TestQP < Test::Unit::TestCase
49
+ def test_all
50
+ #assert_match(/testcase.rb:\d\d:_*send_*/, QP.caller_msg(caller(1)))
51
+ ok_eq("[1, \"a\"]", QP.ar_inspect([1, 'a']))
52
+ assert_match(/\d+\.\d/, QP.runtime)
53
+ #assert_match(/\d+\.\d:testcase.rb:\d\d:_*send_* \[1, 'a'\]/, QP.tp(caller(1), 1, 'a'))
54
+ end
55
+ end
56
+ end