wee 0.1.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +7 -0
- data/README +268 -0
- data/Rakefile +26 -0
- data/TODO +116 -0
- data/benchmark/Centrino1300/result.2000.counter.action +45 -0
- data/benchmark/Centrino1300/result.2000.counter.render +43 -0
- data/benchmark/Centrino1300/result.2000.filehandler +43 -0
- data/benchmark/Centrino600/result.2000.counter.action +47 -0
- data/benchmark/Centrino600/result.2000.counter.render +45 -0
- data/benchmark/Centrino600/result.2000.filehandler +43 -0
- data/benchmark/Makefile +48 -0
- data/benchmark/bench.sh +24 -0
- data/benchmark/counter.rb +96 -0
- data/benchmark/filehandler.rb +6 -0
- data/doc/rdoc/classes/Array.html +172 -0
- data/doc/rdoc/classes/Cache.html +126 -0
- data/doc/rdoc/classes/Cache/StorageCache.html +320 -0
- data/doc/rdoc/classes/Cache/Strategy.html +128 -0
- data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +269 -0
- data/doc/rdoc/classes/Cache/Strategy/LFU.html +238 -0
- data/doc/rdoc/classes/Cache/Strategy/LFU/Item.html +111 -0
- data/doc/rdoc/classes/Cache/Strategy/LRU.html +238 -0
- data/doc/rdoc/classes/Cache/Strategy/LRU/Item.html +111 -0
- data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +225 -0
- data/doc/rdoc/classes/Cache/Strategy/Unbounded/Item.html +111 -0
- data/doc/rdoc/classes/Enumerable.html +146 -0
- data/doc/rdoc/classes/LiteralMethod.html +196 -0
- data/doc/rdoc/classes/Object.html +178 -0
- data/doc/rdoc/classes/String.html +172 -0
- data/doc/rdoc/classes/Struct.html +174 -0
- data/doc/rdoc/classes/Wee.html +160 -0
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +182 -0
- data/doc/rdoc/classes/Wee/Application.html +337 -0
- data/doc/rdoc/classes/Wee/Brush.html +245 -0
- data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +149 -0
- data/doc/rdoc/classes/Wee/Brush/ActionMixin.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +157 -0
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +210 -0
- data/doc/rdoc/classes/Wee/Brush/AssignMixin.html +141 -0
- data/doc/rdoc/classes/Wee/Brush/CallbackMixin.html +141 -0
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +225 -0
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +176 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +283 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +176 -0
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +195 -0
- data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +149 -0
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +172 -0
- data/doc/rdoc/classes/Wee/Brush/Page.html +193 -0
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +267 -0
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +177 -0
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +154 -0
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +173 -0
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +277 -0
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +229 -0
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +154 -0
- data/doc/rdoc/classes/Wee/Callback.html +231 -0
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +308 -0
- data/doc/rdoc/classes/Wee/CallbackStream.html +227 -0
- data/doc/rdoc/classes/Wee/Canvas.html +235 -0
- data/doc/rdoc/classes/Wee/Component.html +933 -0
- data/doc/rdoc/classes/Wee/Context.html +111 -0
- data/doc/rdoc/classes/Wee/Decoration.html +338 -0
- data/doc/rdoc/classes/Wee/Delegate.html +247 -0
- data/doc/rdoc/classes/Wee/ErrorPage.html +175 -0
- data/doc/rdoc/classes/Wee/ErrorResponse.html +180 -0
- data/doc/rdoc/classes/Wee/GenericResponse.html +162 -0
- data/doc/rdoc/classes/Wee/HtmlCanvas.html +751 -0
- data/doc/rdoc/classes/Wee/HtmlWriter.html +351 -0
- data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +180 -0
- data/doc/rdoc/classes/Wee/MethodCallback.html +193 -0
- data/doc/rdoc/classes/Wee/Page.html +111 -0
- data/doc/rdoc/classes/Wee/Presenter.html +521 -0
- data/doc/rdoc/classes/Wee/RedirectResponse.html +150 -0
- data/doc/rdoc/classes/Wee/RefreshResponse.html +157 -0
- data/doc/rdoc/classes/Wee/RenderingContext.html +111 -0
- data/doc/rdoc/classes/Wee/Request.html +268 -0
- data/doc/rdoc/classes/Wee/RequestHandler.html +336 -0
- data/doc/rdoc/classes/Wee/Response.html +260 -0
- data/doc/rdoc/classes/Wee/Session.html +469 -0
- data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +198 -0
- data/doc/rdoc/classes/Wee/Snapshot.html +211 -0
- data/doc/rdoc/classes/Wee/StateHolder.html +149 -0
- data/doc/rdoc/classes/Wee/StateRegistry.html +434 -0
- data/doc/rdoc/classes/Wee/StateRegistry/Snapshot.html +320 -0
- data/doc/rdoc/classes/Wee/StateRegistry/WithObject.html +153 -0
- data/doc/rdoc/classes/Wee/Utils.html +111 -0
- data/doc/rdoc/classes/Wee/Utils/LRUCache.html +148 -0
- data/doc/rdoc/classes/Wee/ValueHolder.html +220 -0
- data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +330 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/INSTALL.html +118 -0
- data/doc/rdoc/files/README.html +466 -0
- data/doc/rdoc/files/lib/cache/cache_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/application_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/callback_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/component_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/component_rb.html +109 -0
- data/doc/rdoc/files/lib/wee/context_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/core/callback_rb.html +115 -0
- data/doc/rdoc/files/lib/wee/core/component_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/core/decoration_rb.html +133 -0
- data/doc/rdoc/files/lib/wee/core/presenter_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +113 -0
- data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/core_rb.html +131 -0
- data/doc/rdoc/files/lib/wee/decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/holder_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/html_canvas_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/html_writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/idgen_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/page_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/presenter_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/rendering/html/brushes_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/rendering/html/canvas_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/rendering/html/writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/request_rb.html +113 -0
- data/doc/rdoc/files/lib/wee/requesthandler_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/response_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/session_rb.html +109 -0
- data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/snapshot_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/state_registry_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/stuff_rb.html +144 -0
- data/doc/rdoc/files/lib/wee/utils/cache_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/webrick_rb.html +108 -0
- data/doc/rdoc/files/lib/wee_rb.html +132 -0
- data/doc/rdoc/fr_class_index.html +93 -0
- data/doc/rdoc/fr_file_index.html +51 -0
- data/doc/rdoc/fr_method_index.html +242 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/ObjectSpaceBrowser.rb +199 -0
- data/examples/calendar.rb +366 -0
- data/examples/cc.rb +94 -0
- data/examples/draw.rb +91 -0
- data/examples/example.rb +223 -0
- data/examples/test.rb +66 -0
- data/examples/window.rb +53 -0
- data/lib/cache/cache.rb +9 -0
- data/lib/wee.rb +18 -8
- data/lib/wee/adaptors/webrick.rb +73 -0
- data/lib/wee/application.rb +69 -71
- data/lib/wee/context.rb +2 -12
- data/lib/wee/core.rb +15 -0
- data/lib/wee/core/callback.rb +108 -0
- data/lib/wee/core/component.rb +314 -0
- data/lib/wee/core/decoration.rb +129 -0
- data/lib/wee/core/presenter.rb +132 -0
- data/lib/wee/core/snapshot.rb +21 -0
- data/lib/wee/core/valueholder.rb +19 -0
- data/lib/wee/idgen.rb +13 -0
- data/lib/wee/page.rb +1 -1
- data/lib/wee/renderer/html/brushes.rb +435 -0
- data/lib/wee/renderer/html/canvas.rb +148 -0
- data/lib/wee/{html_writer.rb → renderer/html/writer.rb} +31 -16
- data/lib/wee/request.rb +57 -0
- data/lib/wee/requesthandler.rb +77 -0
- data/lib/wee/response.rb +77 -0
- data/lib/wee/session.rb +70 -64
- data/lib/wee/{snapshot.rb → snapshot_ext.rb} +4 -4
- data/test/components/calltest.rb +16 -0
- data/test/components/counter.rb +17 -0
- data/test/components/messagebox.rb +15 -0
- data/test/components/page.rb +14 -0
- data/test/components/page_decoration.rb +7 -0
- data/test/stress.rb +64 -0
- data/test/test_component.rb +106 -0
- data/test/test_html_canvas.rb +25 -0
- data/test/test_html_writer.rb +27 -0
- data/test/test_request.rb +13 -0
- data/test/utils/cross.rb +65 -0
- data/test/utils/generic_plotter.rb +28 -0
- data/test/utils/gnuplot.rb +31 -0
- data/test/utils/measure_memory.rb +9 -0
- data/test/utils/memory_plotter.rb +10 -0
- data/test/utils/object_plotter.rb +10 -0
- data/test/utils/webrick_background.rb +31 -0
- data/wee.gemspec +22 -0
- metadata +222 -18
- data/lib/wee/component.rb +0 -126
- data/lib/wee/delegate_decoration.rb +0 -22
- data/lib/wee/handler_registry.rb +0 -89
- data/lib/wee/holder.rb +0 -14
- data/lib/wee/html_canvas.rb +0 -379
- data/lib/wee/state_registry.rb +0 -173
- data/lib/wee/stuff.rb +0 -29
- data/lib/wee/webrick.rb +0 -15
data/lib/wee/state_registry.rb
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
require 'set'
|
3
|
-
require 'wee/snapshot'
|
4
|
-
|
5
|
-
class Wee::StateRegistry
|
6
|
-
def initialize
|
7
|
-
@registered_objects = Hash.new # { oid => Set:{snap_oid1, snap_oid2}
|
8
|
-
@snap_to_oid_map = Hash.new # { snap_oid => Set:{oid1, oid2} }
|
9
|
-
|
10
|
-
@finalizer_snap = proc {|snap_oid|
|
11
|
-
Thread.exclusive do
|
12
|
-
@snap_to_oid_map[snap_oid].each do |oid|
|
13
|
-
if r = @registered_objects[oid]
|
14
|
-
r.delete(snap_oid)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
@snap_to_oid_map.delete(snap_oid)
|
18
|
-
end
|
19
|
-
}
|
20
|
-
|
21
|
-
@finalizer_obj = proc {|oid|
|
22
|
-
Thread.exclusive do
|
23
|
-
(@registered_objects.delete(oid) || []).each do |snap_oid|
|
24
|
-
with_object(snap_oid) { |snap|
|
25
|
-
snap.delete(oid)
|
26
|
-
@snap_to_oid_map[snap_oid].delete(oid)
|
27
|
-
}
|
28
|
-
end
|
29
|
-
end
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def marshal_load(dump)
|
34
|
-
initialize
|
35
|
-
objs, snaps = dump
|
36
|
-
|
37
|
-
objs.each do |obj|
|
38
|
-
register(obj)
|
39
|
-
end
|
40
|
-
|
41
|
-
snaps.each do |snap|
|
42
|
-
set = (@snap_to_oid_map[snap.object_id] ||= Set.new)
|
43
|
-
|
44
|
-
snap.each do |oid, hash|
|
45
|
-
set.add(oid)
|
46
|
-
@registered_objects[oid].add(snap.object_id)
|
47
|
-
end
|
48
|
-
|
49
|
-
ObjectSpace.define_finalizer(snap, @finalizer_snap)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# TODO: should do a GC before marshalling?!
|
54
|
-
# NOTE: we have to marshal the @registered_objects too, as we might have not
|
55
|
-
# yet taken any snapshot
|
56
|
-
def marshal_dump
|
57
|
-
objs = []
|
58
|
-
snaps = []
|
59
|
-
|
60
|
-
each_object {|obj| objs << obj}
|
61
|
-
each_snapshot { |snap| snaps << snap }
|
62
|
-
|
63
|
-
[objs, snaps]
|
64
|
-
end
|
65
|
-
|
66
|
-
def snapshot
|
67
|
-
snap = Snapshot.new
|
68
|
-
set = (@snap_to_oid_map[snap.object_id] ||= Set.new)
|
69
|
-
|
70
|
-
each_object do |obj|
|
71
|
-
snap.add_object(obj)
|
72
|
-
set.add(obj.object_id)
|
73
|
-
@registered_objects[obj.object_id].add(snap.object_id)
|
74
|
-
end
|
75
|
-
|
76
|
-
ObjectSpace.define_finalizer(snap, @finalizer_snap)
|
77
|
-
|
78
|
-
return snap
|
79
|
-
end
|
80
|
-
|
81
|
-
def register(obj)
|
82
|
-
@registered_objects[obj.object_id] ||= Set.new
|
83
|
-
ObjectSpace.define_finalizer(obj, @finalizer_obj)
|
84
|
-
end
|
85
|
-
|
86
|
-
alias << register
|
87
|
-
|
88
|
-
def each_object(&block)
|
89
|
-
Thread.exclusive do
|
90
|
-
@registered_objects.each_key do |oid|
|
91
|
-
with_object(oid, &block)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def each_snapshot(&block)
|
97
|
-
Thread.exclusive do
|
98
|
-
@snap_to_oid_map.each_key do |oid|
|
99
|
-
with_object(oid, &block)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
private
|
105
|
-
|
106
|
-
def with_object(oid, &block)
|
107
|
-
begin
|
108
|
-
obj = ObjectSpace._id2ref(oid)
|
109
|
-
rescue RangeError
|
110
|
-
return
|
111
|
-
end
|
112
|
-
block.call(obj) if block
|
113
|
-
end
|
114
|
-
|
115
|
-
class Snapshot
|
116
|
-
def initialize
|
117
|
-
@data = Hash.new
|
118
|
-
end
|
119
|
-
|
120
|
-
def delete(key)
|
121
|
-
@data.delete(key)
|
122
|
-
end
|
123
|
-
|
124
|
-
def each(&block)
|
125
|
-
Thread.exclusive do
|
126
|
-
@data.each(&block)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def add_object(obj)
|
131
|
-
@data[obj.object_id] = obj.take_snapshot
|
132
|
-
end
|
133
|
-
|
134
|
-
def apply
|
135
|
-
each do |oid, snap|
|
136
|
-
with_object(oid) {|obj|
|
137
|
-
obj.apply_snapshot(snap)
|
138
|
-
}
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def marshal_dump
|
143
|
-
# generates a { obj => {instance variables} } hash
|
144
|
-
dump = Hash.new
|
145
|
-
|
146
|
-
each do |oid, hash|
|
147
|
-
with_object(oid) {|obj| dump[obj] = hash }
|
148
|
-
end
|
149
|
-
|
150
|
-
dump
|
151
|
-
end
|
152
|
-
|
153
|
-
def marshal_load(dump)
|
154
|
-
initialize
|
155
|
-
dump.each do |obj, hash|
|
156
|
-
@data[obj.object_id] = hash
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
private
|
161
|
-
|
162
|
-
def with_object(oid, &block)
|
163
|
-
begin
|
164
|
-
obj = ObjectSpace._id2ref(oid)
|
165
|
-
rescue RangeError
|
166
|
-
return
|
167
|
-
end
|
168
|
-
block.call(obj) if block
|
169
|
-
end
|
170
|
-
|
171
|
-
end # class Snapshot
|
172
|
-
|
173
|
-
end
|
data/lib/wee/stuff.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
class Wee::ErrorPage < Wee::Component
|
2
|
-
def initialize(msg)
|
3
|
-
@msg = msg
|
4
|
-
super()
|
5
|
-
end
|
6
|
-
|
7
|
-
def render_content_on(r)
|
8
|
-
r << "<html><head><title>Error: #{@msg}</title><head><body>Error: #{@msg}</body></html>"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def parse_url(request)
|
13
|
-
hash = {}
|
14
|
-
request.path_info.split('/').each do |part|
|
15
|
-
# we are only interested in "k:v" parts
|
16
|
-
next unless part.include?(':')
|
17
|
-
|
18
|
-
k, v = part.split(/:/, 2)
|
19
|
-
hash[k] = v
|
20
|
-
end
|
21
|
-
hash
|
22
|
-
end
|
23
|
-
|
24
|
-
# for Ruby 1.8
|
25
|
-
module Enumerable
|
26
|
-
def min_by(&block)
|
27
|
-
min {|i,j| block.call(i) <=> block.call(j) }
|
28
|
-
end
|
29
|
-
end
|
data/lib/wee/webrick.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'webrick'
|
2
|
-
class Wee::Application
|
3
|
-
def start(hash=nil)
|
4
|
-
hash = {:Port => 2000}.update(hash||{})
|
5
|
-
server = WEBrick::HTTPServer.new(hash)
|
6
|
-
server.mount_proc(hash[:mount_path] || self.path) {|req, res| self.handle_request(req, res)}
|
7
|
-
trap("INT") {
|
8
|
-
trap("INT", "IGNORE")
|
9
|
-
self.shutdown
|
10
|
-
server.shutdown
|
11
|
-
exit
|
12
|
-
}
|
13
|
-
server.start
|
14
|
-
end
|
15
|
-
end
|