qwikdoc 0.0.1
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.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/CHANGES +3 -0
- data/COPYING +340 -0
- data/Gemfile +3 -0
- data/README.md +10 -0
- data/Rakefile +10 -0
- data/TextFormattingRules +137 -0
- data/TextFormattingRules.ja +143 -0
- data/bin/qwikdoc +34 -0
- data/lib/qwik_doc.rb +15 -0
- data/lib/qwik_doc/hack.rb +184 -0
- data/qwikdoc.gemspec +26 -0
- data/spec/qwik_doc_spec.rb +305 -0
- data/spec/spec_helper.rb +12 -0
- data/vendor/qwik/Makefile +63 -0
- data/vendor/qwik/Rakefile +17 -0
- data/vendor/qwik/act-aa.rb +83 -0
- data/vendor/qwik/act-archive.rb +386 -0
- data/vendor/qwik/act-attach.rb +304 -0
- data/vendor/qwik/act-backup.rb +236 -0
- data/vendor/qwik/act-basic.rb +325 -0
- data/vendor/qwik/act-book.rb +161 -0
- data/vendor/qwik/act-calc.rb +371 -0
- data/vendor/qwik/act-charset.rb +251 -0
- data/vendor/qwik/act-christel.rb +112 -0
- data/vendor/qwik/act-chronology.rb +149 -0
- data/vendor/qwik/act-code.rb +155 -0
- data/vendor/qwik/act-comment.rb +554 -0
- data/vendor/qwik/act-config.rb +49 -0
- data/vendor/qwik/act-counter.rb +125 -0
- data/vendor/qwik/act-day.rb +96 -0
- data/vendor/qwik/act-describe.rb +135 -0
- data/vendor/qwik/act-diary.rb +109 -0
- data/vendor/qwik/act-edit.rb +317 -0
- data/vendor/qwik/act-embed-html.rb +296 -0
- data/vendor/qwik/act-emode.rb +150 -0
- data/vendor/qwik/act-event.rb +187 -0
- data/vendor/qwik/act-file.rb +303 -0
- data/vendor/qwik/act-files.rb +771 -0
- data/vendor/qwik/act-getpass.rb +295 -0
- data/vendor/qwik/act-history.rb +136 -0
- data/vendor/qwik/act-html.rb +204 -0
- data/vendor/qwik/act-httpauth.rb +147 -0
- data/vendor/qwik/act-include.rb +142 -0
- data/vendor/qwik/act-interwiki.rb +189 -0
- data/vendor/qwik/act-isearch.rb +109 -0
- data/vendor/qwik/act-keywords.rb +137 -0
- data/vendor/qwik/act-lang.rb +81 -0
- data/vendor/qwik/act-license.rb +63 -0
- data/vendor/qwik/act-list.rb +287 -0
- data/vendor/qwik/act-login.rb +410 -0
- data/vendor/qwik/act-logout.rb +60 -0
- data/vendor/qwik/act-mail.rb +159 -0
- data/vendor/qwik/act-map.rb +292 -0
- data/vendor/qwik/act-md5.rb +42 -0
- data/vendor/qwik/act-mdlb.rb +741 -0
- data/vendor/qwik/act-media.rb +416 -0
- data/vendor/qwik/act-member.rb +157 -0
- data/vendor/qwik/act-menu.rb +142 -0
- data/vendor/qwik/act-metadata.rb +323 -0
- data/vendor/qwik/act-mlsubmitform.rb +49 -0
- data/vendor/qwik/act-monitor.rb +167 -0
- data/vendor/qwik/act-new.rb +418 -0
- data/vendor/qwik/act-pagelist.rb +248 -0
- data/vendor/qwik/act-password.rb +145 -0
- data/vendor/qwik/act-plan.rb +210 -0
- data/vendor/qwik/act-povray.rb +230 -0
- data/vendor/qwik/act-presen.rb +380 -0
- data/vendor/qwik/act-redirect.rb +133 -0
- data/vendor/qwik/act-ring.rb +1071 -0
- data/vendor/qwik/act-rrefs.rb +255 -0
- data/vendor/qwik/act-ruby.rb +116 -0
- data/vendor/qwik/act-sample.rb +170 -0
- data/vendor/qwik/act-save.rb +295 -0
- data/vendor/qwik/act-schedule.rb +374 -0
- data/vendor/qwik/act-search.rb +180 -0
- data/vendor/qwik/act-searchwords.rb +51 -0
- data/vendor/qwik/act-sendpass.rb +83 -0
- data/vendor/qwik/act-site.rb +89 -0
- data/vendor/qwik/act-sitebackup.rb +419 -0
- data/vendor/qwik/act-sitelog.rb +118 -0
- data/vendor/qwik/act-smil.rb +299 -0
- data/vendor/qwik/act-status.rb +220 -0
- data/vendor/qwik/act-style.rb +608 -0
- data/vendor/qwik/act-table.rb +263 -0
- data/vendor/qwik/act-tableform.rb +241 -0
- data/vendor/qwik/act-tag.rb +103 -0
- data/vendor/qwik/act-text.rb +70 -0
- data/vendor/qwik/act-textarea.rb +164 -0
- data/vendor/qwik/act-theme.rb +346 -0
- data/vendor/qwik/act-toc.rb +112 -0
- data/vendor/qwik/act-typekey.rb +198 -0
- data/vendor/qwik/act-under-const.rb +94 -0
- data/vendor/qwik/act-webservice.rb +321 -0
- data/vendor/qwik/act-wema.rb +558 -0
- data/vendor/qwik/act-wysiwyg.rb +238 -0
- data/vendor/qwik/action.rb +325 -0
- data/vendor/qwik/autoreload.rb +98 -0
- data/vendor/qwik/bench-bench.rb +28 -0
- data/vendor/qwik/bench-emode.rb +47 -0
- data/vendor/qwik/bench-format-xml.rb +70 -0
- data/vendor/qwik/bench-large-table.rb +62 -0
- data/vendor/qwik/bench-md5.rb +14 -0
- data/vendor/qwik/bench-module-session.rb +19 -0
- data/vendor/qwik/bench-page.rb +50 -0
- data/vendor/qwik/bench-s-md5.rb +28 -0
- data/vendor/qwik/bench-session.rb +25 -0
- data/vendor/qwik/bench-textformat.rb +31 -0
- data/vendor/qwik/catalog-factory.rb +91 -0
- data/vendor/qwik/catalog-ja.rb +479 -0
- data/vendor/qwik/catalog-ml-ja.rb +145 -0
- data/vendor/qwik/check-act-monitor.rb +112 -0
- data/vendor/qwik/check-act-monitor2.rb +46 -0
- data/vendor/qwik/check-act-theme.rb +27 -0
- data/vendor/qwik/check-event.rb +112 -0
- data/vendor/qwik/check-event2.rb +55 -0
- data/vendor/qwik/check-htree-rexml.rb +77 -0
- data/vendor/qwik/check-htree.rb +51 -0
- data/vendor/qwik/check-libxml.rb +135 -0
- data/vendor/qwik/check-many-pages.rb +47 -0
- data/vendor/qwik/check-monitor.rb +33 -0
- data/vendor/qwik/check-observer.rb +67 -0
- data/vendor/qwik/check-server.rb +61 -0
- data/vendor/qwik/check-uuencode.rb +33 -0
- data/vendor/qwik/check-webdav.rb +65 -0
- data/vendor/qwik/check-xml-xpath.rb +27 -0
- data/vendor/qwik/common-backtrace.rb +94 -0
- data/vendor/qwik/common-basic.rb +111 -0
- data/vendor/qwik/common-condition.rb +142 -0
- data/vendor/qwik/common-error.rb +48 -0
- data/vendor/qwik/common-gettext.rb +50 -0
- data/vendor/qwik/common-javascript.rb +45 -0
- data/vendor/qwik/common-notice.rb +132 -0
- data/vendor/qwik/common-plain.rb +105 -0
- data/vendor/qwik/common-plugin.rb +111 -0
- data/vendor/qwik/common-res.rb +76 -0
- data/vendor/qwik/common-resolve.rb +92 -0
- data/vendor/qwik/common-send.rb +171 -0
- data/vendor/qwik/common-session.rb +139 -0
- data/vendor/qwik/common-surface.rb +261 -0
- data/vendor/qwik/common-url.rb +90 -0
- data/vendor/qwik/compat/Makefile +12 -0
- data/vendor/qwik/compat/add_load_path.rb +1 -0
- data/vendor/qwik/config.rb +299 -0
- data/vendor/qwik/db-b-backup.rb +142 -0
- data/vendor/qwik/db-backup.rb +184 -0
- data/vendor/qwik/db-berkeley.rb +306 -0
- data/vendor/qwik/db-filesystem.rb +305 -0
- data/vendor/qwik/db-indexer.rb +154 -0
- data/vendor/qwik/db-searchwords.rb +238 -0
- data/vendor/qwik/description-ja.rb +267 -0
- data/vendor/qwik/description.rb +256 -0
- data/vendor/qwik/dev-add-copyright.rb +23 -0
- data/vendor/qwik/dev-backup.rb +24 -0
- data/vendor/qwik/dev-bench.rb +175 -0
- data/vendor/qwik/dev-calctime.rb +52 -0
- data/vendor/qwik/dev-css-compressor.rb +60 -0
- data/vendor/qwik/dev-extract-catalog.rb +102 -0
- data/vendor/qwik/dev-js-compressor.rb +73 -0
- data/vendor/qwik/dev-release.rb +235 -0
- data/vendor/qwik/dev-replace.rb +353 -0
- data/vendor/qwik/dev-sendmail.rb +25 -0
- data/vendor/qwik/farm.rb +283 -0
- data/vendor/qwik/gettext.rb +56 -0
- data/vendor/qwik/group-cond.rb +157 -0
- data/vendor/qwik/group-config.rb +247 -0
- data/vendor/qwik/group-confirm.rb +147 -0
- data/vendor/qwik/group-db.rb +326 -0
- data/vendor/qwik/group-mail.rb +195 -0
- data/vendor/qwik/group-member.rb +307 -0
- data/vendor/qwik/group-sendmail.rb +231 -0
- data/vendor/qwik/group-site.rb +374 -0
- data/vendor/qwik/group-sweep.rb +63 -0
- data/vendor/qwik/group.rb +157 -0
- data/vendor/qwik/helper.rb +6 -0
- data/vendor/qwik/html-generator.rb +104 -0
- data/vendor/qwik/html-to-wabisabi.rb +149 -0
- data/vendor/qwik/htree-diff.rb +87 -0
- data/vendor/qwik/htree-format-xml.rb +57 -0
- data/vendor/qwik/htree-generator.rb +144 -0
- data/vendor/qwik/htree-get.rb +251 -0
- data/vendor/qwik/htree-html-generator.rb +179 -0
- data/vendor/qwik/htree-template.rb +263 -0
- data/vendor/qwik/htree-to-wabisabi.rb +171 -0
- data/vendor/qwik/loadlib.rb +79 -0
- data/vendor/qwik/logger.rb +115 -0
- data/vendor/qwik/mail-body.rb +171 -0
- data/vendor/qwik/mail-header.rb +474 -0
- data/vendor/qwik/mail-multipart.rb +193 -0
- data/vendor/qwik/mail-parse.rb +147 -0
- data/vendor/qwik/mail.rb +341 -0
- data/vendor/qwik/mailaddress.rb +83 -0
- data/vendor/qwik/mdlb-model.rb +81 -0
- data/vendor/qwik/mdlb-sample.rb +324 -0
- data/vendor/qwik/ml-catalog-factory.rb +27 -0
- data/vendor/qwik/ml-exception.rb +15 -0
- data/vendor/qwik/ml-generator.rb +28 -0
- data/vendor/qwik/ml-gettext.rb +137 -0
- data/vendor/qwik/ml-logger.rb +82 -0
- data/vendor/qwik/ml-memory.rb +65 -0
- data/vendor/qwik/ml-msg-validator.rb +86 -0
- data/vendor/qwik/ml-processor.rb +609 -0
- data/vendor/qwik/ml-quickml-server.rb +122 -0
- data/vendor/qwik/ml-sendmail.rb +0 -0
- data/vendor/qwik/ml-server.rb +107 -0
- data/vendor/qwik/ml-session.rb +348 -0
- data/vendor/qwik/ml-sweeper.rb +101 -0
- data/vendor/qwik/mock-logger.rb +65 -0
- data/vendor/qwik/mock-sendmail.rb +78 -0
- data/vendor/qwik/mock-socket.rb +82 -0
- data/vendor/qwik/modulobe.rb +406 -0
- data/vendor/qwik/mongrel-server.rb +72 -0
- data/vendor/qwik/page-files.rb +249 -0
- data/vendor/qwik/page-generate.rb +82 -0
- data/vendor/qwik/page-get.rb +262 -0
- data/vendor/qwik/page-images.rb +168 -0
- data/vendor/qwik/page-put.rb +128 -0
- data/vendor/qwik/page-rrefs.rb +154 -0
- data/vendor/qwik/page-title.rb +0 -0
- data/vendor/qwik/page-wikidb.rb +234 -0
- data/vendor/qwik/page.rb +67 -0
- data/vendor/qwik/pages.rb +444 -0
- data/vendor/qwik/parse-plugin.rb +249 -0
- data/vendor/qwik/parser-emode.rb +116 -0
- data/vendor/qwik/parser-inline.rb +273 -0
- data/vendor/qwik/parser.rb +350 -0
- data/vendor/qwik/password.rb +183 -0
- data/vendor/qwik/periodic.rb +79 -0
- data/vendor/qwik/qp.rb +56 -0
- data/vendor/qwik/qwik-service.rb +341 -0
- data/vendor/qwik/qwik.rb +5 -0
- data/vendor/qwik/qwikweb-adduser.rb +34 -0
- data/vendor/qwik/qwikweb-catalog-validator.rb +110 -0
- data/vendor/qwik/qwikweb-incgen.rb +28 -0
- data/vendor/qwik/qwikweb-makesite.rb +41 -0
- data/vendor/qwik/qwikweb-server.rb +44 -0
- data/vendor/qwik/qwikweb-showpassword.rb +26 -0
- data/vendor/qwik/qwikweb-watchlog.rb +67 -0
- data/vendor/qwik/request-path.rb +304 -0
- data/vendor/qwik/request-ua.rb +76 -0
- data/vendor/qwik/request-webrick.rb +81 -0
- data/vendor/qwik/request.rb +91 -0
- data/vendor/qwik/resolve-tdiary.rb +292 -0
- data/vendor/qwik/resolve.rb +121 -0
- data/vendor/qwik/response.rb +228 -0
- data/vendor/qwik/server-memory.rb +57 -0
- data/vendor/qwik/server-webrick.rb +102 -0
- data/vendor/qwik/server.rb +252 -0
- data/vendor/qwik/site-config.rb +149 -0
- data/vendor/qwik/site-db.rb +136 -0
- data/vendor/qwik/site-event.rb +162 -0
- data/vendor/qwik/site-files.rb +86 -0
- data/vendor/qwik/site-group.rb +103 -0
- data/vendor/qwik/site-index.rb +47 -0
- data/vendor/qwik/site-log.rb +64 -0
- data/vendor/qwik/site-member.rb +230 -0
- data/vendor/qwik/site-monitor.rb +97 -0
- data/vendor/qwik/site-pages.rb +62 -0
- data/vendor/qwik/site-plan.rb +139 -0
- data/vendor/qwik/site-report.rb +282 -0
- data/vendor/qwik/site-resolve.rb +230 -0
- data/vendor/qwik/site-rrefs.rb +18 -0
- data/vendor/qwik/site-search.rb +180 -0
- data/vendor/qwik/site-timeline.rb +153 -0
- data/vendor/qwik/site-url.rb +189 -0
- data/vendor/qwik/site.rb +76 -0
- data/vendor/qwik/smil-time.rb +105 -0
- data/vendor/qwik/smtp-session.rb +331 -0
- data/vendor/qwik/template-generator.rb +149 -0
- data/vendor/qwik/template.rb +85 -0
- data/vendor/qwik/test-common.rb +10 -0
- data/vendor/qwik/test-ml-info.rb +225 -0
- data/vendor/qwik/test-module-ml.rb +142 -0
- data/vendor/qwik/test-module-path.rb +110 -0
- data/vendor/qwik/test-module-public.rb +70 -0
- data/vendor/qwik/test-module-server.rb +98 -0
- data/vendor/qwik/test-module-session.rb +264 -0
- data/vendor/qwik/test-module-suite.rb +91 -0
- data/vendor/qwik/test-ms-applemail.rb +59 -0
- data/vendor/qwik/test-ms-attach.rb +174 -0
- data/vendor/qwik/test-ms-basic.rb +40 -0
- data/vendor/qwik/test-ms-close.rb +35 -0
- data/vendor/qwik/test-ms-confirm.rb +75 -0
- data/vendor/qwik/test-ms-ignore-spam.rb +57 -0
- data/vendor/qwik/test-ms-japanese.rb +97 -0
- data/vendor/qwik/test-ms-jfilename.rb +82 -0
- data/vendor/qwik/test-ms-large.rb +58 -0
- data/vendor/qwik/test-ms-member.rb +103 -0
- data/vendor/qwik/test-ms-multipart.rb +84 -0
- data/vendor/qwik/test-ms-org.rb +129 -0
- data/vendor/qwik/test-ms-plan.rb +130 -0
- data/vendor/qwik/test-ms-post.rb +53 -0
- data/vendor/qwik/test-ms-quopri.rb +76 -0
- data/vendor/qwik/test-sub-quopri.rb +45 -0
- data/vendor/qwik/test-submit-base64.rb +59 -0
- data/vendor/qwik/test-submit-forward.rb +61 -0
- data/vendor/qwik/test-submit-html-mail.rb +52 -0
- data/vendor/qwik/test-submit-japanese.rb +135 -0
- data/vendor/qwik/test-submit-jfilename.rb +144 -0
- data/vendor/qwik/test-submit-uuencode.rb +71 -0
- data/vendor/qwik/test-suite-all.rb +8 -0
- data/vendor/qwik/test-suite-basic.rb +9 -0
- data/vendor/qwik/test-suite-ml.rb +9 -0
- data/vendor/qwik/test-typekey.rb +64 -0
- data/vendor/qwik/testunit.rb +45 -0
- data/vendor/qwik/tokenizer-inline.rb +294 -0
- data/vendor/qwik/tokenizer.rb +332 -0
- data/vendor/qwik/typekey.rb +160 -0
- data/vendor/qwik/util-basic.rb +135 -0
- data/vendor/qwik/util-charset.rb +332 -0
- data/vendor/qwik/util-css.rb +56 -0
- data/vendor/qwik/util-csv-tokenizer.rb +113 -0
- data/vendor/qwik/util-filename.rb +112 -0
- data/vendor/qwik/util-pathname.rb +202 -0
- data/vendor/qwik/util-pid.rb +58 -0
- data/vendor/qwik/util-safe.rb +67 -0
- data/vendor/qwik/util-sendmail.rb +273 -0
- data/vendor/qwik/util-string.rb +203 -0
- data/vendor/qwik/util-time.rb +125 -0
- data/vendor/qwik/util-webrick.rb +176 -0
- data/vendor/qwik/version.rb +11 -0
- data/vendor/qwik/wabisabi-basic.rb +163 -0
- data/vendor/qwik/wabisabi-diff.rb +130 -0
- data/vendor/qwik/wabisabi-format-xml.rb +310 -0
- data/vendor/qwik/wabisabi-generator.rb +262 -0
- data/vendor/qwik/wabisabi-index.rb +174 -0
- data/vendor/qwik/wabisabi-table.rb +212 -0
- data/vendor/qwik/wabisabi-template.rb +295 -0
- data/vendor/qwik/wabisabi-to-htree.rb +111 -0
- data/vendor/qwik/wabisabi-to-wiki.rb +690 -0
- data/vendor/qwik/wabisabi-traverse.rb +207 -0
- data/vendor/qwik/wabisabi-validator.rb +116 -0
- data/vendor/qwik/wabisabi.rb +5 -0
- metadata +416 -0
|
@@ -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
|
data/vendor/qwik/qp.rb
ADDED
|
@@ -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
|
|
@@ -0,0 +1,341 @@
|
|
|
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 'optparse'
|
|
6
|
+
|
|
7
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
8
|
+
require 'qwik/config'
|
|
9
|
+
require 'qwik/version'
|
|
10
|
+
require 'qwik/util-pathname'
|
|
11
|
+
require 'qwik/mailaddress'
|
|
12
|
+
require 'pp'
|
|
13
|
+
require 'qwik/qp'
|
|
14
|
+
|
|
15
|
+
module Qwik
|
|
16
|
+
class QwikService
|
|
17
|
+
QWIKWEB_SERVER = '/usr/bin/qwikweb-server'
|
|
18
|
+
QWIKWEB_PID = '/var/run/qwik/qwikweb.pid'
|
|
19
|
+
QUICKML_SERVER = '/usr/bin/quickml-server'
|
|
20
|
+
QUICKML_PID = '/var/run/qwik/quickml.pid'
|
|
21
|
+
|
|
22
|
+
def self.main(args)
|
|
23
|
+
self.new.run(args)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def run(args)
|
|
27
|
+
@config = Config.new
|
|
28
|
+
args_conf, cmd = QwikService.parse_args('qwik-service', args)
|
|
29
|
+
@config.update(args_conf) # config file is specified by args
|
|
30
|
+
file_conf = Config.load_config_file(@config[:config_file])
|
|
31
|
+
@config.update(file_conf)
|
|
32
|
+
@config.update(args_conf) # Set args again to override.
|
|
33
|
+
|
|
34
|
+
cmd, cmd_args = cmd
|
|
35
|
+
|
|
36
|
+
if self.respond_to?(cmd)
|
|
37
|
+
return self.send(cmd) if cmd_args.nil?
|
|
38
|
+
return self.send(cmd, cmd_args)
|
|
39
|
+
end
|
|
40
|
+
warn "Error: unknown cmd [#{cmd}]"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.parse_args(myprog, args)
|
|
44
|
+
config = {}
|
|
45
|
+
cmd = []
|
|
46
|
+
optionparser = OptionParser.new {|opts|
|
|
47
|
+
opts.banner = "Usage: #{myprog} [options]"
|
|
48
|
+
opts.separator ''
|
|
49
|
+
opts.separator 'Specific options:'
|
|
50
|
+
opts.on('-c', '--config file', 'Specify config file.') {|a|
|
|
51
|
+
config[:config_file] = a
|
|
52
|
+
}
|
|
53
|
+
opts.on('-d', '--[no-]debug', 'Run in debug mode.') {|a|
|
|
54
|
+
config[:debug] = a
|
|
55
|
+
}
|
|
56
|
+
opts.on('--start', 'Start qwikWeb and QuickML services.') {|a|
|
|
57
|
+
cmd = [:start]
|
|
58
|
+
}
|
|
59
|
+
opts.on('--stop', 'Stop qwikWeb and QuickML services.') {|a|
|
|
60
|
+
cmd = [:stop]
|
|
61
|
+
}
|
|
62
|
+
opts.on('--restart', 'Restart qwikWeb and QuickML services.') {|a|
|
|
63
|
+
cmd = [:restart]
|
|
64
|
+
}
|
|
65
|
+
opts.on('--web-start', 'Start qwikWeb services.') {|a|
|
|
66
|
+
cmd = [:web_start]
|
|
67
|
+
}
|
|
68
|
+
opts.on('--web-stop', 'Stop qwikWeb services.') {|a|
|
|
69
|
+
cmd = [:web_stop]
|
|
70
|
+
}
|
|
71
|
+
opts.on('--web-restart', 'Restart qwikWeb services.') {|a|
|
|
72
|
+
cmd = [:web_restart]
|
|
73
|
+
}
|
|
74
|
+
opts.on('--ml-start', 'Start QuickML services.') {|a|
|
|
75
|
+
cmd = [:ml_start]
|
|
76
|
+
}
|
|
77
|
+
opts.on('--ml-stop', 'Stop QuickML services.') {|a|
|
|
78
|
+
cmd = [:ml_stop]
|
|
79
|
+
}
|
|
80
|
+
opts.on('--ml-restart', 'Restart QuickML services.') {|a|
|
|
81
|
+
cmd = [:ml_restart]
|
|
82
|
+
}
|
|
83
|
+
opts.on('--watchlog', 'Watch log continuously.') {|a|
|
|
84
|
+
cmd = [:watchlog]
|
|
85
|
+
}
|
|
86
|
+
opts.on('--makesite sitename,mailaddr', 'Make a new site.') {|a|
|
|
87
|
+
cmd = [:makesite, a]
|
|
88
|
+
}
|
|
89
|
+
opts.on('--adduser sitename,mailaddr', 'Add a user.') {|a|
|
|
90
|
+
cmd = [:adduser, a]
|
|
91
|
+
}
|
|
92
|
+
opts.on('--showpassword mailaddress', 'Show password.') {|a|
|
|
93
|
+
cmd = [:showpassword, a]
|
|
94
|
+
}
|
|
95
|
+
opts.on('--incgen mailaddress', 'Increment a generation.') {|a|
|
|
96
|
+
cmd = [:incgen, a]
|
|
97
|
+
}
|
|
98
|
+
opts.separator ''
|
|
99
|
+
opts.separator 'Debug options:'
|
|
100
|
+
opts.on('--showinactive', 'Show inactive sites.') {|a|
|
|
101
|
+
cmd = [:showinactive, a]
|
|
102
|
+
}
|
|
103
|
+
opts.separator ''
|
|
104
|
+
opts.separator 'Common options:'
|
|
105
|
+
opts.on_tail('-h', '--help', 'Show this message.') {
|
|
106
|
+
puts opts
|
|
107
|
+
exit
|
|
108
|
+
}
|
|
109
|
+
opts.on_tail('-v', '--version', 'Show version.') {
|
|
110
|
+
puts VERSION
|
|
111
|
+
exit
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
begin
|
|
117
|
+
optionparser.parse!(args)
|
|
118
|
+
rescue OptionParser::ParseError => err
|
|
119
|
+
puts err.message
|
|
120
|
+
puts optionparser.to_s
|
|
121
|
+
exit
|
|
122
|
+
end
|
|
123
|
+
if cmd.empty?
|
|
124
|
+
puts optionparser.to_s
|
|
125
|
+
exit
|
|
126
|
+
end
|
|
127
|
+
return config, cmd
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def start
|
|
131
|
+
web_start
|
|
132
|
+
ml_start
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def stop
|
|
136
|
+
web_stop
|
|
137
|
+
ml_stop
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def restart
|
|
141
|
+
stop
|
|
142
|
+
sleep 1
|
|
143
|
+
start
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def web_start
|
|
147
|
+
start_cmd('Starting qwikWeb services: ',
|
|
148
|
+
"#{QWIKWEB_SERVER} -c #{@config[:config_file]}")
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def web_stop
|
|
152
|
+
pidfile = @config[:web_pid_file] || QWIKWEB_PID
|
|
153
|
+
pidfile += '-d' if @config[:debug]
|
|
154
|
+
stop_cmd('Stopping qwikWeb services: ', pidfile)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def web_restart
|
|
158
|
+
web_stop
|
|
159
|
+
sleep 1
|
|
160
|
+
web_start
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def ml_start
|
|
164
|
+
start_cmd('Starting QuickML services: ',
|
|
165
|
+
"#{QUICKML_SERVER} -c #{@config[:config_file]}")
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def ml_stop
|
|
169
|
+
pidfile = @config[:ml_pid_file] || QUICKML_PID
|
|
170
|
+
stop_cmd('Stopping QuickML services: ', pidfile)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def ml_restart
|
|
174
|
+
ml_stop
|
|
175
|
+
sleep 1
|
|
176
|
+
ml_start
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def watchlog
|
|
180
|
+
require 'qwik/qwikweb-watchlog'
|
|
181
|
+
WatchLog.new(@config).run
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def makesite(args)
|
|
185
|
+
require 'qwik/farm'
|
|
186
|
+
require 'qwik/mailaddress'
|
|
187
|
+
|
|
188
|
+
def usage
|
|
189
|
+
warn 'Usage: qwik-service --makesite sitename,yourmailaddress'
|
|
190
|
+
exit
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
sitename, mail = args.split(/,/, 2)
|
|
194
|
+
return usage if sitename.nil? || sitename.empty?
|
|
195
|
+
return usage if mail.nil? || mail.empty?
|
|
196
|
+
if ! MailAddress.valid?(mail)
|
|
197
|
+
warn "Error: invalid mail form [#{mail}]"
|
|
198
|
+
return usage
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
memory = ServerMemory.new(@config)
|
|
202
|
+
farm = Farm.new(@config, memory)
|
|
203
|
+
|
|
204
|
+
site = nil
|
|
205
|
+
begin
|
|
206
|
+
site = farm.make_site(sitename)
|
|
207
|
+
rescue Errno::EACCES => e
|
|
208
|
+
error e.to_s
|
|
209
|
+
rescue => e
|
|
210
|
+
error "The site [#{sitename}] is already exist."
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
site = farm.get_site(sitename)
|
|
214
|
+
site.member.add(mail)
|
|
215
|
+
|
|
216
|
+
puts "Creating a new site [#{sitename}] and
|
|
217
|
+
adding an initial user [#{mail}] is completed."
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def adduser(args)
|
|
221
|
+
require 'qwik/farm'
|
|
222
|
+
require 'qwik/mailaddress'
|
|
223
|
+
|
|
224
|
+
def usage
|
|
225
|
+
die 'Usage: qwik-service --adduser sitename,mailaddress'
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
sitename, mail = args.split(/,/, 2)
|
|
229
|
+
return usage if sitename.nil? || sitename.empty?
|
|
230
|
+
return usage if mail.nil? || mail.empty?
|
|
231
|
+
if ! MailAddress.valid?(mail)
|
|
232
|
+
warn "Error: invalid mail form [#{mail}]"
|
|
233
|
+
return usage
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
memory = ServerMemory.new(@config)
|
|
237
|
+
farm = Farm.new(@config, memory)
|
|
238
|
+
|
|
239
|
+
site = farm.get_site(sitename)
|
|
240
|
+
if site.nil?
|
|
241
|
+
error "The site [#{sitename}] does not exist."
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
if site.member.exist?(mail)
|
|
245
|
+
error "A user [#{mail}] is already exist."
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
site.member.add(mail)
|
|
249
|
+
puts "Adding a new user [#{mail}] to site [#{sitename}] is completed."
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def showpassword(mail)
|
|
253
|
+
require 'qwik/password'
|
|
254
|
+
require 'qwik/mailaddress'
|
|
255
|
+
|
|
256
|
+
def usage
|
|
257
|
+
die 'Usage: qwik-service --showpassword mailaddress'
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
return usage if mail.nil? || mail.empty?
|
|
261
|
+
if ! MailAddress.valid?(mail)
|
|
262
|
+
warn "Error: invalid mail form [#{mail}]"
|
|
263
|
+
return usage
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
gen = PasswordGenerator.new(@config)
|
|
267
|
+
puts "mail: #{mail}"
|
|
268
|
+
puts "pass: #{gen.generate(mail)}"
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def incgen(mail)
|
|
272
|
+
require 'qwik/password'
|
|
273
|
+
|
|
274
|
+
def usage
|
|
275
|
+
die 'Usage: qwik-service --showpassword mailaddress'
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
return usage if mail.nil? || mail.empty?
|
|
279
|
+
if ! MailAddress.valid?(mail)
|
|
280
|
+
warn "Error: invalid mail form [#{mail}]"
|
|
281
|
+
return usage
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
gen = PasswordGenerator.new(@config)
|
|
285
|
+
g = gen.generation_inc(mail)
|
|
286
|
+
puts "mail: #{mail}"
|
|
287
|
+
puts "generation: #{g}"
|
|
288
|
+
puts "increment generation done."
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def showinactive(*a)
|
|
292
|
+
require 'qwik/farm'
|
|
293
|
+
|
|
294
|
+
memory = ServerMemory.new(@config)
|
|
295
|
+
farm = Farm.new(@config, memory)
|
|
296
|
+
inactive_sites = farm.check_inactive_sites
|
|
297
|
+
p inactive_sites
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
private
|
|
301
|
+
|
|
302
|
+
def die(msg)
|
|
303
|
+
warn msg
|
|
304
|
+
exit
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def error(msg)
|
|
308
|
+
warn "Error: " + msg
|
|
309
|
+
exit 1
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def start_cmd(msg, cmd)
|
|
313
|
+
print msg
|
|
314
|
+
system cmd
|
|
315
|
+
puts
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def stop_cmd(msg, pid_file)
|
|
319
|
+
print msg
|
|
320
|
+
pid = pid_file.path.read.to_i
|
|
321
|
+
Process.kill(:KILL, pid)
|
|
322
|
+
puts
|
|
323
|
+
|
|
324
|
+
# pid = `cat /usr/local/qwik/log/qwikweb.pid`
|
|
325
|
+
# pid = `cat /var/run/qwik/qwikweb.pid`
|
|
326
|
+
# process = `ps ho%c -p $pid`
|
|
327
|
+
# if [ $process = "qwikweb-server" ] ; then
|
|
328
|
+
# kill $pid
|
|
329
|
+
# echo
|
|
330
|
+
# else
|
|
331
|
+
# echo "Stopping failed."
|
|
332
|
+
# fi
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
if $0 == __FILE__
|
|
338
|
+
args = ARGV
|
|
339
|
+
#args << '-d' # force debug mode
|
|
340
|
+
Qwik::QwikService.main(args)
|
|
341
|
+
end
|