wee 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +75 -0
- data/README +17 -9
- data/Rakefile +2 -2
- data/TODO +20 -0
- data/benchmark/Makefile +14 -9
- data/benchmark/counter.rb +11 -30
- data/benchmark/report_req.rb +12 -0
- data/doc/rdoc/classes/Array.html +12 -12
- data/doc/rdoc/classes/Cache/StorageCache.html +38 -38
- data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +30 -30
- data/doc/rdoc/classes/Cache/Strategy/LFU.html +24 -24
- data/doc/rdoc/classes/Cache/Strategy/LRU.html +24 -24
- data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +24 -24
- data/doc/rdoc/classes/Enumerable.html +6 -6
- data/doc/rdoc/classes/Object.html +12 -12
- data/doc/rdoc/classes/OgApplication.html +126 -0
- data/doc/rdoc/classes/OgScaffolder.html +401 -0
- data/doc/rdoc/classes/OgSession.html +172 -0
- data/doc/rdoc/classes/String.html +12 -12
- data/doc/rdoc/classes/Struct.html +12 -12
- data/doc/rdoc/classes/Wee.html +5 -62
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +9 -9
- data/doc/rdoc/classes/Wee/Application.html +107 -39
- data/doc/rdoc/classes/Wee/Brush.html +22 -18
- data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +17 -11
- data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +18 -10
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +30 -64
- data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +8 -10
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +27 -79
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +12 -12
- data/doc/rdoc/classes/Wee/Brush/GenericSingleTagBrush.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +179 -65
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +12 -12
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +16 -18
- data/doc/rdoc/classes/Wee/Brush/ImageTag.html +203 -0
- data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +17 -11
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +15 -15
- data/doc/rdoc/classes/Wee/Brush/JavascriptTag.html +147 -0
- data/doc/rdoc/classes/Wee/Brush/Page.html +17 -17
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +25 -50
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +7 -38
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +15 -16
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +65 -50
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +14 -64
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/ToCallback.html +146 -0
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +40 -40
- data/doc/rdoc/classes/Wee/CallbackStream.html +18 -18
- data/doc/rdoc/classes/Wee/Canvas.html +24 -24
- data/doc/rdoc/classes/Wee/Component.html +232 -149
- data/doc/rdoc/classes/Wee/Component/OnAnswer.html +153 -0
- data/doc/rdoc/classes/Wee/Decoration.html +42 -42
- data/doc/rdoc/classes/Wee/Delegate.html +27 -27
- data/doc/rdoc/classes/Wee/ErrorResponse.html +12 -12
- data/doc/rdoc/classes/Wee/FormDecoration.html +148 -0
- data/doc/rdoc/classes/Wee/GenericResponse.html +6 -6
- data/doc/rdoc/classes/Wee/HtmlCanvas.html +296 -215
- data/doc/rdoc/classes/Wee/HtmlWriter.html +83 -81
- data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +21 -16
- data/doc/rdoc/classes/Wee/MessageBox.html +180 -0
- data/doc/rdoc/classes/Wee/PageDecoration.html +30 -30
- data/doc/rdoc/classes/Wee/Presenter.html +237 -69
- data/doc/rdoc/classes/Wee/RedirectResponse.html +6 -6
- data/doc/rdoc/classes/Wee/RefreshResponse.html +6 -6
- data/doc/rdoc/classes/Wee/Request.html +18 -18
- data/doc/rdoc/classes/Wee/RequestHandler.html +43 -39
- data/doc/rdoc/classes/Wee/Response.html +24 -24
- data/doc/rdoc/classes/Wee/Session.html +746 -72
- data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +18 -18
- data/doc/rdoc/classes/Wee/Snapshot.html +19 -19
- data/doc/rdoc/classes/Wee/Utils.html +138 -2
- data/doc/rdoc/classes/Wee/Utils/LRUCache.html +7 -7
- data/doc/rdoc/classes/Wee/ValueHolder.html +18 -18
- data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +43 -68
- data/doc/rdoc/classes/Wee/WrapperDecoration.html +150 -0
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +29 -15
- data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/application_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components/form_decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/components/messagebox_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/components/page_decoration_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components/wrapper_decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/components_rb.html +4 -1
- data/doc/rdoc/files/lib/wee/continuation/core/component_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/continuation/session_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/continuation_rb.html +116 -0
- data/doc/rdoc/files/lib/wee/core/callback_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/component_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/presenter_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core_rb.html +3 -3
- data/doc/rdoc/files/lib/wee/databases/og_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/requesthandler_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/session_rb.html +1 -2
- data/doc/rdoc/files/lib/wee/utils/autoreload_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/utils/cache_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/utils/helper_rb.html +1 -8
- data/doc/rdoc/files/lib/wee/utils_rb.html +110 -0
- data/doc/rdoc/files/lib/wee_rb.html +1 -1
- data/doc/rdoc/fr_class_index.html +11 -1
- data/doc/rdoc/fr_file_index.html +8 -0
- data/doc/rdoc/fr_method_index.html +269 -228
- data/examples/calculator.rb +69 -0
- data/examples/calendar.rb +5 -17
- data/examples/example.rb +2 -2
- data/examples/hw.rb +17 -0
- data/examples/live-update.rb +45 -0
- data/examples/og-test.rb +51 -0
- data/lib/wee.rb +1 -1
- data/lib/wee/adaptors/webrick.rb +2 -0
- data/lib/wee/application.rb +16 -0
- data/lib/wee/components.rb +3 -0
- data/lib/wee/components/form_decoration.rb +7 -0
- data/{test → lib/wee}/components/messagebox.rb +1 -1
- data/lib/wee/components/page_decoration.rb +5 -5
- data/lib/wee/components/wrapper_decoration.rb +7 -0
- data/lib/wee/continuation.rb +5 -0
- data/lib/wee/continuation/core/component.rb +55 -0
- data/lib/wee/continuation/session.rb +217 -0
- data/lib/wee/core/callback.rb +11 -6
- data/lib/wee/core/component.rb +45 -33
- data/lib/wee/core/presenter.rb +68 -0
- data/lib/wee/databases/og.rb +114 -0
- data/lib/wee/renderer/html/brushes.rb +179 -98
- data/lib/wee/renderer/html/canvas.rb +37 -13
- data/lib/wee/renderer/html/writer.rb +34 -32
- data/lib/wee/requesthandler.rb +6 -3
- data/lib/wee/session.rb +73 -54
- data/lib/wee/utils.rb +5 -0
- data/lib/wee/utils/autoreload.rb +1 -1
- data/lib/wee/utils/cache.rb +0 -2
- data/lib/wee/utils/helper.rb +40 -8
- data/test/components/calltest-cont.rb +16 -0
- data/test/components/calltest.rb +15 -10
- data/test/stress.rb +31 -28
- data/test/stress_and_measure.rb +53 -0
- data/test/stressed_application.rb +15 -0
- data/test/test_html_writer.rb +9 -4
- metadata +236 -195
- data/benchmark/bench.sh +0 -24
data/ChangeLog
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Wed Jan 26 20:22:55 CET 2005 Michael Neumann <mneumann@ntecs.de>
|
|
2
|
+
|
|
3
|
+
* Raised version up to 0.5.0 (nearing a release)
|
|
4
|
+
|
|
5
|
+
* Fixed test cases.
|
|
6
|
+
|
|
7
|
+
Wed Jan 26 18:19:39 CET 2005 Michael Neumann <mneumann@ntecs.de>
|
|
8
|
+
|
|
9
|
+
* updated docs
|
|
10
|
+
|
|
11
|
+
* made Component#call's marshallable by using an object of class
|
|
12
|
+
Wee::Component::OnAnswer instead of a Proc.
|
|
13
|
+
|
|
14
|
+
* Moved all continuation-dependent code into directory
|
|
15
|
+
wee/continuation. By default Wee uses no continuations, you have to
|
|
16
|
+
require 'wee/continuation' to enable them.
|
|
17
|
+
|
|
18
|
+
Wed Jan 26 13:51:22 CET 2005 Michael Neumann <mneumann@ntecs.de>
|
|
19
|
+
|
|
20
|
+
* If you pass nil to an attribute method of a Brush, e.g.
|
|
21
|
+
|
|
22
|
+
r.table_data.width(nil)
|
|
23
|
+
|
|
24
|
+
This will remove the 'width' attribute from the tag.
|
|
25
|
+
|
|
26
|
+
* Method HtmlCanvas#javascript added:
|
|
27
|
+
|
|
28
|
+
# external javascript resource
|
|
29
|
+
r.javascript.src('/test.js')
|
|
30
|
+
|
|
31
|
+
# internal javascript
|
|
32
|
+
r.javascript.with('function js() { ... }')
|
|
33
|
+
|
|
34
|
+
* Method Presenter.uses_property added. Used to declare required
|
|
35
|
+
properties. This has actually no effect. It's sole purpose is to
|
|
36
|
+
describe the dependencies.
|
|
37
|
+
|
|
38
|
+
NO DATE AVAILABLE Michael Neumann <mneumann@ntecs.de>
|
|
39
|
+
|
|
40
|
+
* Enable Socket.do_not_reverse_lookup in WEBrickAdaptor by default, as
|
|
41
|
+
this has been the reason for much slowliness
|
|
42
|
+
|
|
43
|
+
* Method Component#add_child returns the child so that the following
|
|
44
|
+
code becomes possible:
|
|
45
|
+
|
|
46
|
+
@pager = add_child Pager.new(...)
|
|
47
|
+
|
|
48
|
+
* Added experimental property system.
|
|
49
|
+
|
|
50
|
+
* Added methods GenericTagBrush#onclick_callback, HtmlCanvas#link_css,
|
|
51
|
+
lots of refactoring
|
|
52
|
+
|
|
53
|
+
* New examples: hw.rb, live-update.rb, calculator.rb
|
|
54
|
+
|
|
55
|
+
* Wee::Brush::InputTag: methods #disabled and #readonly added
|
|
56
|
+
|
|
57
|
+
* Wee::Utils.app_for takes now (optionally) a block.
|
|
58
|
+
|
|
59
|
+
* Wee::MessageBox, Wee::WrapperDecoration, Wee::FromDecoration added
|
|
60
|
+
|
|
61
|
+
* Wee::Session#current_page, #current_context methods added
|
|
62
|
+
|
|
63
|
+
* added ground-work for live-updates (see examples/live-update.rb)
|
|
64
|
+
|
|
65
|
+
* added wee/databases/og.rb, which defines OgApplication and
|
|
66
|
+
OgSession, as well as a generic (but still very limited)
|
|
67
|
+
OgScaffolder.
|
|
68
|
+
|
|
69
|
+
* Methods Wee::Session#sleep and #awake added, which are called before and
|
|
70
|
+
after the request is handled. They can be used for example to setup
|
|
71
|
+
and release a database connection.
|
|
72
|
+
|
|
73
|
+
* Wee::Helper.app_for is now Wee::Utils.app_for
|
|
74
|
+
|
|
75
|
+
* require 'wee/utils' will load all utility methods.
|
data/README
CHANGED
|
@@ -10,12 +10,15 @@ different terms.
|
|
|
10
10
|
|
|
11
11
|
== Status and Bugs
|
|
12
12
|
|
|
13
|
-
Wee is
|
|
14
|
-
|
|
13
|
+
Wee is now considered pretty stable (if you don't use continuations).
|
|
14
|
+
Nevertheless I wouldn't use it yet for mission-critical applications ;-)
|
|
15
15
|
|
|
16
16
|
Known Bugs:
|
|
17
17
|
|
|
18
|
-
*
|
|
18
|
+
* Using continuations might leak memory, at least they did in the past. The
|
|
19
|
+
latest memory stress-test has not showed up any memory problems, but since I
|
|
20
|
+
haven't changed anything at the continuation implementation, I can't say for
|
|
21
|
+
sure whether the problem has been fixed or not.
|
|
19
22
|
|
|
20
23
|
== Introduction
|
|
21
24
|
|
|
@@ -80,11 +83,12 @@ can be any object, e.g. whole components:
|
|
|
80
83
|
items = labels.collect {|m| MessageBox.new(m)}
|
|
81
84
|
r.select_list(items).labels(labels).callback {|choosen| call choosen.first}
|
|
82
85
|
|
|
83
|
-
===
|
|
86
|
+
=== Optional use of Continuations
|
|
84
87
|
|
|
85
|
-
<b>IMPORTANT:</b> <i>The current implementation of continuations in Ruby
|
|
86
|
-
to memory leaks, if you use continuations.
|
|
87
|
-
continuations, it's no longer possible to store the
|
|
88
|
+
<b>IMPORTANT:</b> <i>The current implementation of continuations in Ruby (or
|
|
89
|
+
their use in Wee) might lead to memory leaks, if you use continuations.
|
|
90
|
+
Furthermore, if you use continuations, it's no longer possible to store the
|
|
91
|
+
session state to disk.</i>
|
|
88
92
|
|
|
89
93
|
Continuation-based frameworks are also known as _modal_ frameworks. You can
|
|
90
94
|
write code like the one shown below (taken from one of Avi's emails) where each
|
|
@@ -104,6 +108,10 @@ method displays a new page:
|
|
|
104
108
|
Try to implement the same in a non-continuation based framework and show me
|
|
105
109
|
your code... ;-)
|
|
106
110
|
|
|
111
|
+
To enable continuations, you have to require:
|
|
112
|
+
|
|
113
|
+
require 'wee/continuation'
|
|
114
|
+
|
|
107
115
|
=== Fully Marshallable (drops Continuation support)
|
|
108
116
|
|
|
109
117
|
If you don't need continuations, Wee can be made fully marshallable. It is not
|
|
@@ -119,8 +127,8 @@ yet fully marshallable (it was in the past), but it can be made, if required.
|
|
|
119
127
|
DragonFly[www.dragonflybsd.org]. But with this approach it's still impossible
|
|
120
128
|
to store sessions _selectively_ to disk.
|
|
121
129
|
|
|
122
|
-
*
|
|
123
|
-
|
|
130
|
+
* When using continuations, each session runs in it's own (light-weigth)
|
|
131
|
+
thread. This is not the case if you don't use continuations.
|
|
124
132
|
|
|
125
133
|
* Only one action callback can be invoked per request (a former version of Wee
|
|
126
134
|
was able to invoke multiple callback, and answer even from multiple
|
data/Rakefile
CHANGED
|
@@ -22,8 +22,8 @@ task :package do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
task :local_install => [:package] do
|
|
25
|
-
sh 'gem uninstall wee || true'
|
|
26
|
-
sh 'gem install wee-*.gem'
|
|
25
|
+
sh '(yes | gem uninstall wee) || true'
|
|
26
|
+
sh 'gem install --no-rdoc wee-*.gem'
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
task :clean => [:clobber_rdoc]
|
data/TODO
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
* OgScaffolder: cache fields
|
|
2
|
+
|
|
3
|
+
* LiteralMethodCallback: use a simple symbol instead?
|
|
4
|
+
|
|
5
|
+
* brushes.rb: tags as constants
|
|
6
|
+
|
|
7
|
+
* Session.new(application)
|
|
8
|
+
|
|
9
|
+
* live updates
|
|
10
|
+
|
|
11
|
+
* transactions
|
|
12
|
+
|
|
13
|
+
* use it with databases
|
|
14
|
+
|
|
15
|
+
* diverting html-renderer
|
|
16
|
+
|
|
17
|
+
* Add unit-tests for new global/local decorations
|
|
18
|
+
|
|
19
|
+
* MessageBox: Buttons: OK_Cancel, YES_NO, Confirm
|
|
20
|
+
|
|
1
21
|
* req-handler gc interval
|
|
2
22
|
|
|
3
23
|
* use LiteralMethod object instead of block if callback(:method_name) is given
|
data/benchmark/Makefile
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
N=2000
|
|
2
|
+
PORT=2000
|
|
3
|
+
COUNTERS=10
|
|
2
4
|
|
|
3
5
|
RUBY=ruby
|
|
4
6
|
|
|
@@ -7,21 +9,24 @@ all: bench1 bench2
|
|
|
7
9
|
|
|
8
10
|
start_counter:
|
|
9
11
|
# start the counter app
|
|
10
|
-
$(RUBY) counter.rb
|
|
12
|
+
$(RUBY) counter.rb $(PORT) $(COUNTERS) > /dev/null 2> /dev/null &
|
|
11
13
|
sleep 3
|
|
12
14
|
|
|
13
15
|
stop_counter:
|
|
14
|
-
kill -9 `cat counter.
|
|
15
|
-
rm -f counter.
|
|
16
|
+
kill -9 `cat counter.$(PORT).pid`
|
|
17
|
+
rm -f counter.$(PORT).pid
|
|
16
18
|
rm -f dump
|
|
17
19
|
|
|
18
20
|
bench_counter:
|
|
19
21
|
# generate initial session and first page
|
|
20
|
-
fetch -o counter.html http://localhost
|
|
22
|
+
fetch -o counter.html http://localhost:$(PORT)/counter
|
|
21
23
|
|
|
22
24
|
# perform benchmark
|
|
23
|
-
ab -n ${N} http://localhost
|
|
24
|
-
ab -n ${N} http://localhost
|
|
25
|
+
ab -n ${N} http://localhost:$(PORT)/counter/@1/1 > result.${N}.counter.render
|
|
26
|
+
ab -n ${N} http://localhost:$(PORT)/counter/@1/1?4 > result.${N}.counter.action
|
|
27
|
+
|
|
28
|
+
report_counter:
|
|
29
|
+
$(RUBY) report_req.rb result.$(N).counter.render result.$(N).counter.action
|
|
25
30
|
|
|
26
31
|
start_filehandler:
|
|
27
32
|
# start the filehandler app
|
|
@@ -33,16 +38,16 @@ stop_filehandler:
|
|
|
33
38
|
rm -f filehandler.pid
|
|
34
39
|
|
|
35
40
|
bench_filehandler:
|
|
36
|
-
ab -n ${N} http://localhost
|
|
41
|
+
ab -n ${N} http://localhost:$(PORT)/counter.html > result.${N}.filehandler
|
|
37
42
|
|
|
38
43
|
clean:
|
|
39
|
-
rm -f counter.
|
|
44
|
+
rm -f counter.$(PORT).pid
|
|
40
45
|
rm -f filehandler.pid
|
|
41
46
|
rm -f dump
|
|
42
47
|
rm -f result.${N}.*
|
|
43
48
|
rm -f counter.html
|
|
44
49
|
|
|
45
|
-
bench1: start_counter bench_counter stop_counter
|
|
50
|
+
bench1: start_counter bench_counter stop_counter report_counter
|
|
46
51
|
bench2: start_filehandler bench_filehandler stop_filehandler
|
|
47
52
|
|
|
48
53
|
|
data/benchmark/counter.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$LOAD_PATH.unshift '../lib'
|
|
2
2
|
require 'wee'
|
|
3
|
-
require 'wee/webrick'
|
|
4
|
-
require 'wee/utils
|
|
3
|
+
require 'wee/adaptors/webrick'
|
|
4
|
+
require 'wee/utils'
|
|
5
5
|
|
|
6
6
|
class Counter < Wee::Component
|
|
7
7
|
def initialize(cnt)
|
|
@@ -24,18 +24,18 @@ class Counter < Wee::Component
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def render
|
|
27
|
-
r.form.
|
|
28
|
-
r.anchor.
|
|
27
|
+
r.form.callback(:submit).with do
|
|
28
|
+
r.anchor.callback(:dec).with("--")
|
|
29
29
|
r.space
|
|
30
30
|
|
|
31
31
|
if @show_edit_field
|
|
32
|
-
r.text_input.
|
|
32
|
+
r.text_input.callback(:cnt=).value(@cnt).size(6)
|
|
33
33
|
else
|
|
34
|
-
r.anchor.
|
|
34
|
+
r.anchor.callback(:submit).with(@cnt)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
r.space
|
|
38
|
-
r.anchor.
|
|
38
|
+
r.anchor.callback(:inc).with("++")
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -57,7 +57,7 @@ end
|
|
|
57
57
|
class Main < Wee::Component
|
|
58
58
|
def initialize
|
|
59
59
|
super()
|
|
60
|
-
@counters = (1..
|
|
60
|
+
@counters = (1..COUNTERS).map {|i| Counter.new(i)}
|
|
61
61
|
children.push(*@counters)
|
|
62
62
|
end
|
|
63
63
|
|
|
@@ -68,29 +68,10 @@ class Main < Wee::Component
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
class MySession < Wee::Session
|
|
72
|
-
def initialize
|
|
73
|
-
super do
|
|
74
|
-
self.root_component = Main.new
|
|
75
|
-
self.page_store = Wee::Utils::LRUCache.new(10) # backtrack up to 10 pages
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
class MyApplication < Wee::Application
|
|
81
|
-
def setup_session_id_generator
|
|
82
|
-
@session_cnt = 0
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
|
|
87
71
|
if __FILE__ == $0
|
|
88
72
|
PORT = (ARGV[0] || 2000).to_i
|
|
73
|
+
COUNTERS = (ARGV[1] || 20).to_i
|
|
89
74
|
File.open("counter.#{ PORT }.pid", 'w+') {|f| f.puts($$.to_s) }
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
app.path = '/counter'
|
|
93
|
-
app.session_class = MySession
|
|
94
|
-
app.session_store = Wee::Utils::LRUCache.new(100) # handle up to 100 sessions
|
|
95
|
-
}.start(:Port => PORT)
|
|
75
|
+
app = Wee::Utils.app_for(Main, :id_seed => 0, :page_cache_capacity => 10)
|
|
76
|
+
Wee::WEBrickAdaptor.register('/counter' => app).start(:Port => PORT)
|
|
96
77
|
end
|
data/doc/rdoc/classes/Array.html
CHANGED
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
<h3 class="section-bar">Methods</h3>
|
|
89
89
|
|
|
90
90
|
<div class="name-list">
|
|
91
|
-
<a href="#
|
|
92
|
-
<a href="#
|
|
91
|
+
<a href="#M000006">restore_snapshot</a>
|
|
92
|
+
<a href="#M000005">take_snapshot</a>
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
95
|
|
|
@@ -111,19 +111,19 @@
|
|
|
111
111
|
<div id="methods">
|
|
112
112
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
113
113
|
|
|
114
|
-
<div id="method-
|
|
115
|
-
<a name="
|
|
114
|
+
<div id="method-M000006" class="method-detail">
|
|
115
|
+
<a name="M000006"></a>
|
|
116
116
|
|
|
117
117
|
<div class="method-heading">
|
|
118
|
-
<a href="#
|
|
118
|
+
<a href="#M000006" class="method-signature">
|
|
119
119
|
<span class="method-name">restore_snapshot</span><span class="method-args">(snap)</span>
|
|
120
120
|
</a>
|
|
121
121
|
</div>
|
|
122
122
|
|
|
123
123
|
<div class="method-description">
|
|
124
124
|
<p><a class="source-toggle" href="#"
|
|
125
|
-
onclick="toggleCode('
|
|
126
|
-
<div class="method-source-code" id="
|
|
125
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
|
126
|
+
<div class="method-source-code" id="M000006-source">
|
|
127
127
|
<pre>
|
|
128
128
|
<span class="ruby-comment cmt"># File lib/wee/snapshot_ext.rb, line 22</span>
|
|
129
129
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restore_snapshot</span>(<span class="ruby-identifier">snap</span>)
|
|
@@ -134,19 +134,19 @@
|
|
|
134
134
|
</div>
|
|
135
135
|
</div>
|
|
136
136
|
|
|
137
|
-
<div id="method-
|
|
138
|
-
<a name="
|
|
137
|
+
<div id="method-M000005" class="method-detail">
|
|
138
|
+
<a name="M000005"></a>
|
|
139
139
|
|
|
140
140
|
<div class="method-heading">
|
|
141
|
-
<a href="#
|
|
141
|
+
<a href="#M000005" class="method-signature">
|
|
142
142
|
<span class="method-name">take_snapshot</span><span class="method-args">()</span>
|
|
143
143
|
</a>
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div class="method-description">
|
|
147
147
|
<p><a class="source-toggle" href="#"
|
|
148
|
-
onclick="toggleCode('
|
|
149
|
-
<div class="method-source-code" id="
|
|
148
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
|
149
|
+
<div class="method-source-code" id="M000005-source">
|
|
150
150
|
<pre>
|
|
151
151
|
<span class="ruby-comment cmt"># File lib/wee/snapshot_ext.rb, line 18</span>
|
|
152
152
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">take_snapshot</span>
|
|
@@ -101,13 +101,13 @@ protocol that the <em>store</em> must understand is:
|
|
|
101
101
|
<h3 class="section-bar">Methods</h3>
|
|
102
102
|
|
|
103
103
|
<div class="name-list">
|
|
104
|
-
<a href="#
|
|
105
|
-
<a href="#
|
|
106
|
-
<a href="#
|
|
107
|
-
<a href="#
|
|
108
|
-
<a href="#
|
|
109
|
-
<a href="#
|
|
110
|
-
<a href="#
|
|
104
|
+
<a href="#M000012">[]</a>
|
|
105
|
+
<a href="#M000013">[]=</a>
|
|
106
|
+
<a href="#M000009">delete</a>
|
|
107
|
+
<a href="#M000010">fetch</a>
|
|
108
|
+
<a href="#M000008">has_key?</a>
|
|
109
|
+
<a href="#M000007">new</a>
|
|
110
|
+
<a href="#M000011">store</a>
|
|
111
111
|
</div>
|
|
112
112
|
</div>
|
|
113
113
|
|
|
@@ -129,19 +129,19 @@ protocol that the <em>store</em> must understand is:
|
|
|
129
129
|
<div id="methods">
|
|
130
130
|
<h3 class="section-bar">Public Class methods</h3>
|
|
131
131
|
|
|
132
|
-
<div id="method-
|
|
133
|
-
<a name="
|
|
132
|
+
<div id="method-M000007" class="method-detail">
|
|
133
|
+
<a name="M000007"></a>
|
|
134
134
|
|
|
135
135
|
<div class="method-heading">
|
|
136
|
-
<a href="#
|
|
136
|
+
<a href="#M000007" class="method-signature">
|
|
137
137
|
<span class="method-name">new</span><span class="method-args">(strategy, store=Hash.new, store_on_update=false)</span>
|
|
138
138
|
</a>
|
|
139
139
|
</div>
|
|
140
140
|
|
|
141
141
|
<div class="method-description">
|
|
142
142
|
<p><a class="source-toggle" href="#"
|
|
143
|
-
onclick="toggleCode('
|
|
144
|
-
<div class="method-source-code" id="
|
|
143
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
|
144
|
+
<div class="method-source-code" id="M000007-source">
|
|
145
145
|
<pre>
|
|
146
146
|
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 114</span>
|
|
147
147
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">strategy</span>, <span class="ruby-identifier">store</span>=<span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>, <span class="ruby-identifier">store_on_update</span>=<span class="ruby-keyword kw">false</span>)
|
|
@@ -156,8 +156,8 @@ protocol that the <em>store</em> must understand is:
|
|
|
156
156
|
|
|
157
157
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
158
158
|
|
|
159
|
-
<div id="method-
|
|
160
|
-
<a name="
|
|
159
|
+
<div id="method-M000012" class="method-detail">
|
|
160
|
+
<a name="M000012"></a>
|
|
161
161
|
|
|
162
162
|
<div class="method-heading">
|
|
163
163
|
<span class="method-name">[]</span><span class="method-args">(key, default_value=nil)</span>
|
|
@@ -165,13 +165,13 @@ protocol that the <em>store</em> must understand is:
|
|
|
165
165
|
|
|
166
166
|
<div class="method-description">
|
|
167
167
|
<p>
|
|
168
|
-
Alias for <a href="StorageCache.html#
|
|
168
|
+
Alias for <a href="StorageCache.html#M000010">fetch</a>
|
|
169
169
|
</p>
|
|
170
170
|
</div>
|
|
171
171
|
</div>
|
|
172
172
|
|
|
173
|
-
<div id="method-
|
|
174
|
-
<a name="
|
|
173
|
+
<div id="method-M000013" class="method-detail">
|
|
174
|
+
<a name="M000013"></a>
|
|
175
175
|
|
|
176
176
|
<div class="method-heading">
|
|
177
177
|
<span class="method-name">[]=</span><span class="method-args">(key, value)</span>
|
|
@@ -179,24 +179,24 @@ Alias for <a href="StorageCache.html#M000008">fetch</a>
|
|
|
179
179
|
|
|
180
180
|
<div class="method-description">
|
|
181
181
|
<p>
|
|
182
|
-
Alias for <a href="StorageCache.html#
|
|
182
|
+
Alias for <a href="StorageCache.html#M000011">store</a>
|
|
183
183
|
</p>
|
|
184
184
|
</div>
|
|
185
185
|
</div>
|
|
186
186
|
|
|
187
|
-
<div id="method-
|
|
188
|
-
<a name="
|
|
187
|
+
<div id="method-M000009" class="method-detail">
|
|
188
|
+
<a name="M000009"></a>
|
|
189
189
|
|
|
190
190
|
<div class="method-heading">
|
|
191
|
-
<a href="#
|
|
191
|
+
<a href="#M000009" class="method-signature">
|
|
192
192
|
<span class="method-name">delete</span><span class="method-args">(key)</span>
|
|
193
193
|
</a>
|
|
194
194
|
</div>
|
|
195
195
|
|
|
196
196
|
<div class="method-description">
|
|
197
197
|
<p><a class="source-toggle" href="#"
|
|
198
|
-
onclick="toggleCode('
|
|
199
|
-
<div class="method-source-code" id="
|
|
198
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
|
199
|
+
<div class="method-source-code" id="M000009-source">
|
|
200
200
|
<pre>
|
|
201
201
|
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 124</span>
|
|
202
202
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
|
|
@@ -213,19 +213,19 @@ Alias for <a href="StorageCache.html#M000009">store</a>
|
|
|
213
213
|
</div>
|
|
214
214
|
</div>
|
|
215
215
|
|
|
216
|
-
<div id="method-
|
|
217
|
-
<a name="
|
|
216
|
+
<div id="method-M000010" class="method-detail">
|
|
217
|
+
<a name="M000010"></a>
|
|
218
218
|
|
|
219
219
|
<div class="method-heading">
|
|
220
|
-
<a href="#
|
|
220
|
+
<a href="#M000010" class="method-signature">
|
|
221
221
|
<span class="method-name">fetch</span><span class="method-args">(key, default_value=nil)</span>
|
|
222
222
|
</a>
|
|
223
223
|
</div>
|
|
224
224
|
|
|
225
225
|
<div class="method-description">
|
|
226
226
|
<p><a class="source-toggle" href="#"
|
|
227
|
-
onclick="toggleCode('
|
|
228
|
-
<div class="method-source-code" id="
|
|
227
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
|
228
|
+
<div class="method-source-code" id="M000010-source">
|
|
229
229
|
<pre>
|
|
230
230
|
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 134</span>
|
|
231
231
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">default_value</span>=<span class="ruby-keyword kw">nil</span>)
|
|
@@ -243,19 +243,19 @@ Alias for <a href="StorageCache.html#M000009">store</a>
|
|
|
243
243
|
</div>
|
|
244
244
|
</div>
|
|
245
245
|
|
|
246
|
-
<div id="method-
|
|
247
|
-
<a name="
|
|
246
|
+
<div id="method-M000008" class="method-detail">
|
|
247
|
+
<a name="M000008"></a>
|
|
248
248
|
|
|
249
249
|
<div class="method-heading">
|
|
250
|
-
<a href="#
|
|
250
|
+
<a href="#M000008" class="method-signature">
|
|
251
251
|
<span class="method-name">has_key?</span><span class="method-args">(key)</span>
|
|
252
252
|
</a>
|
|
253
253
|
</div>
|
|
254
254
|
|
|
255
255
|
<div class="method-description">
|
|
256
256
|
<p><a class="source-toggle" href="#"
|
|
257
|
-
onclick="toggleCode('
|
|
258
|
-
<div class="method-source-code" id="
|
|
257
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
|
258
|
+
<div class="method-source-code" id="M000008-source">
|
|
259
259
|
<pre>
|
|
260
260
|
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 120</span>
|
|
261
261
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">key</span>)
|
|
@@ -266,19 +266,19 @@ Alias for <a href="StorageCache.html#M000009">store</a>
|
|
|
266
266
|
</div>
|
|
267
267
|
</div>
|
|
268
268
|
|
|
269
|
-
<div id="method-
|
|
270
|
-
<a name="
|
|
269
|
+
<div id="method-M000011" class="method-detail">
|
|
270
|
+
<a name="M000011"></a>
|
|
271
271
|
|
|
272
272
|
<div class="method-heading">
|
|
273
|
-
<a href="#
|
|
273
|
+
<a href="#M000011" class="method-signature">
|
|
274
274
|
<span class="method-name">store</span><span class="method-args">(key, value)</span>
|
|
275
275
|
</a>
|
|
276
276
|
</div>
|
|
277
277
|
|
|
278
278
|
<div class="method-description">
|
|
279
279
|
<p><a class="source-toggle" href="#"
|
|
280
|
-
onclick="toggleCode('
|
|
281
|
-
<div class="method-source-code" id="
|
|
280
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
|
281
|
+
<div class="method-source-code" id="M000011-source">
|
|
282
282
|
<pre>
|
|
283
283
|
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 145</span>
|
|
284
284
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
|