mullen-wee 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/README.rdoc +127 -0
  2. data/Rakefile +25 -0
  3. data/aWee.gemspec +26 -0
  4. data/examples/ObjectSpaceBrowser.rb +191 -0
  5. data/examples/ajax.rb +73 -0
  6. data/examples/apotomo-webhunter/main.rb +75 -0
  7. data/examples/apotomo-webhunter/public/images/bear_trap_charged.png +0 -0
  8. data/examples/apotomo-webhunter/public/images/bear_trap_snapped.png +0 -0
  9. data/examples/apotomo-webhunter/public/images/cheese.png +0 -0
  10. data/examples/apotomo-webhunter/public/images/dark_forest.jpg +0 -0
  11. data/examples/apotomo-webhunter/public/images/mouse.png +0 -0
  12. data/examples/apotomo-webhunter/public/javascripts/jquery-1.3.2.min.js +19 -0
  13. data/examples/apotomo-webhunter/public/javascripts/wee-jquery.js +19 -0
  14. data/examples/apotomo-webhunter/public/stylesheets/forest.css +33 -0
  15. data/examples/arc_challenge.rb +42 -0
  16. data/examples/arc_challenge2.rb +46 -0
  17. data/examples/cheese_task.rb +27 -0
  18. data/examples/continuations.rb +28 -0
  19. data/examples/demo.rb +135 -0
  20. data/examples/demo/calculator.rb +63 -0
  21. data/examples/demo/calendar.rb +333 -0
  22. data/examples/demo/counter.rb +38 -0
  23. data/examples/demo/editable_counter.rb +36 -0
  24. data/examples/demo/example.rb +142 -0
  25. data/examples/demo/file_upload.rb +19 -0
  26. data/examples/demo/messagebox.rb +15 -0
  27. data/examples/demo/radio.rb +33 -0
  28. data/examples/demo/window.rb +71 -0
  29. data/examples/hw.rb +11 -0
  30. data/examples/i18n/app.rb +16 -0
  31. data/examples/i18n/locale/de/app.po +25 -0
  32. data/examples/i18n/locale/en/app.po +25 -0
  33. data/examples/pager.rb +102 -0
  34. data/lib/wee.rb +109 -0
  35. data/lib/wee/application.rb +89 -0
  36. data/lib/wee/callback.rb +109 -0
  37. data/lib/wee/component.rb +363 -0
  38. data/lib/wee/decoration.rb +251 -0
  39. data/lib/wee/dialog.rb +171 -0
  40. data/lib/wee/external_resource.rb +39 -0
  41. data/lib/wee/html_brushes.rb +795 -0
  42. data/lib/wee/html_canvas.rb +254 -0
  43. data/lib/wee/html_document.rb +52 -0
  44. data/lib/wee/html_writer.rb +71 -0
  45. data/lib/wee/id_generator.rb +81 -0
  46. data/lib/wee/jquery.rb +11 -0
  47. data/lib/wee/jquery/jquery-1.3.2.min.js +19 -0
  48. data/lib/wee/jquery/wee-jquery.js +19 -0
  49. data/lib/wee/locale.rb +56 -0
  50. data/lib/wee/lru_cache.rb +91 -0
  51. data/lib/wee/presenter.rb +44 -0
  52. data/lib/wee/renderer.rb +72 -0
  53. data/lib/wee/request.rb +56 -0
  54. data/lib/wee/response.rb +68 -0
  55. data/lib/wee/rightjs.rb +11 -0
  56. data/lib/wee/rightjs/rightjs-1.5.2.min.js +9 -0
  57. data/lib/wee/rightjs/wee-rightjs.js +18 -0
  58. data/lib/wee/root_component.rb +45 -0
  59. data/lib/wee/session.rb +366 -0
  60. data/lib/wee/state.rb +102 -0
  61. data/lib/wee/task.rb +16 -0
  62. data/test/bm_render.rb +34 -0
  63. data/test/component_spec.rb +40 -0
  64. data/test/stress/plotter.rb +84 -0
  65. data/test/stress/stress_client.rb +51 -0
  66. data/test/stress/stress_local.rb +86 -0
  67. data/test/stress/stress_server.rb +83 -0
  68. data/test/test_component.rb +106 -0
  69. data/test/test_html_canvas.rb +25 -0
  70. data/test/test_html_writer.rb +32 -0
  71. data/test/test_lru_cache.rb +51 -0
  72. data/test/test_request.rb +42 -0
  73. metadata +185 -0
@@ -0,0 +1,106 @@
1
+ require 'test/unit'
2
+ module Wee; end
3
+ require 'wee/core'
4
+
5
+ class Test_Component < Test::Unit::TestCase
6
+ def test_add_remove_one_decoration
7
+ c = Wee::Component.new
8
+ d = Wee::Decoration.new
9
+
10
+ assert_same c, c.decoration
11
+ assert_nil d.owner
12
+
13
+ c.add_decoration(d)
14
+
15
+ assert_same d, c.decoration
16
+ assert_same c, d.owner
17
+ assert_same d, d.owner.decoration
18
+
19
+ assert_same d, c.remove_decoration(d)
20
+
21
+ assert_same c, c.decoration
22
+ assert_nil d.owner
23
+ end
24
+
25
+ def test_add_remove_multiple_decorations
26
+ c = Wee::Component.new
27
+ d1 = Wee::Decoration.new
28
+ d2 = Wee::Decoration.new
29
+ d3 = Wee::Decoration.new
30
+
31
+ c.add_decoration(d1)
32
+ c.add_decoration(d2)
33
+ c.add_decoration(d3)
34
+
35
+ assert_same d3, c.decoration
36
+ assert_same d2, d3.owner
37
+ assert_same d1, d2.owner
38
+ assert_same c, d1.owner
39
+
40
+ assert_same d2, c.remove_decoration(d2)
41
+
42
+ assert_same d3, c.decoration
43
+ assert_same d1, d3.owner
44
+ assert_nil d2.owner
45
+ assert_same c, d1.owner
46
+
47
+ assert_same d1, c.remove_decoration(d1)
48
+ assert_same d3, c.decoration
49
+ assert_same c, d3.owner
50
+ assert_nil d1.owner
51
+
52
+ # try to remove an already removed decoration
53
+ assert_nil c.remove_decoration(d2)
54
+ assert_nil c.remove_decoration(d1)
55
+
56
+ assert_same d3, c.remove_decoration(d3)
57
+ assert_same c, c.decoration
58
+ assert_nil d3.owner
59
+ end
60
+
61
+ def test_each_decoration
62
+ require 'enumerator'
63
+ c = Wee::Component.new
64
+ d1 = Wee::Decoration.new
65
+ d2 = Wee::Decoration.new
66
+ d3 = Wee::Decoration.new
67
+
68
+ c.add_decoration(d1)
69
+ c.add_decoration(d2)
70
+ c.add_decoration(d3)
71
+
72
+ assert_equal [d3, d2, d1], c.to_enum(:each_decoration).to_a
73
+ end
74
+
75
+ def test_remove_decoration_if
76
+ c = Wee::Component.new
77
+ d1 = Wee::Decoration.new
78
+ d2 = Wee::Decoration.new
79
+ d3 = Wee::Decoration.new
80
+ d4 = Wee::Decoration.new
81
+
82
+ c.add_decoration(d1)
83
+ c.add_decoration(d2)
84
+ c.add_decoration(d3)
85
+ c.add_decoration(d4)
86
+
87
+ def d1.a() end
88
+ def d3.a() end
89
+ c.remove_decoration_if {|d| d.respond_to?(:a)}
90
+ assert_equal [d4, d2], c.to_enum(:each_decoration).to_a
91
+
92
+ def d4.a() end
93
+ c.remove_decoration_if {|d| d.respond_to?(:a)}
94
+ assert_equal [d2], c.to_enum(:each_decoration).to_a
95
+
96
+ c.remove_decoration_if {|d| d.respond_to?(:a)}
97
+ assert_equal [d2], c.to_enum(:each_decoration).to_a
98
+
99
+ def d2.a() end
100
+ c.remove_decoration_if {|d| d.respond_to?(:a)}
101
+ assert_equal [], c.to_enum(:each_decoration).to_a
102
+
103
+ assert_equal c, c.decoration
104
+ end
105
+
106
+ end
@@ -0,0 +1,25 @@
1
+ require 'test/unit'
2
+ module Wee; end
3
+ require 'wee/renderer/html/writer'
4
+ require 'wee/renderer/html/brushes'
5
+ require 'wee/renderer/html/canvas'
6
+ require 'wee/context'
7
+
8
+ class Test_HtmlCanvas < Test::Unit::TestCase
9
+ def test_simple
10
+ rctx = Wee::RenderingContext.new
11
+ rctx.document = Wee::HtmlWriter.new(doc='')
12
+
13
+ c = Wee::HtmlCanvas.new(rctx)
14
+ c.form.action("foo").with {
15
+ c.table {
16
+ c.table_row.id("myrow").with {
17
+ c.table_data.align_top.with("Hello world")
18
+ }
19
+ }
20
+ c.space
21
+ }
22
+
23
+ assert_equal %[<form action="foo" method="POST"><table><tr id="myrow"><td align="top">Hello world</td></tr></table>&nbsp;</form>], doc
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ require 'test/unit'
2
+ module Wee; end
3
+ require 'wee/renderer/html/writer'
4
+
5
+ class Test_HtmlWriter < Test::Unit::TestCase
6
+ def test_document
7
+ w = Wee::HtmlWriter.new(doc='')
8
+ w.start_tag('html')
9
+ w.start_tag('body')
10
+ w.start_tag('a', 'href' => 'http://...')
11
+ w.text('link')
12
+ w.end_tag('a')
13
+ w.end_tag('body')
14
+ w.end_tag('html')
15
+
16
+ assert_equal '<html><body><a href="http://...">link</a></body></html>', doc
17
+ end
18
+
19
+ def test_start_end_tag
20
+ w = Wee::HtmlWriter.new(doc='')
21
+ w.start_tag('a', 'href' => '')
22
+ w.end_tag('a')
23
+ assert_equal '<a href=""></a>', doc
24
+ end
25
+
26
+ def test_single_tag
27
+ w = Wee::HtmlWriter.new(doc='')
28
+ w.single_tag('a', 'href' => '')
29
+ assert_equal '<a href="" />', doc
30
+ end
31
+
32
+ end
@@ -0,0 +1,51 @@
1
+ require 'test/unit'
2
+ require 'wee/lru_cache'
3
+
4
+ class I
5
+ include Wee::LRUCache::Item
6
+
7
+ attr_accessor :id
8
+
9
+ def initialize(id)
10
+ @id = id
11
+ end
12
+ end
13
+
14
+ class Test_LRUCache < Test::Unit::TestCase
15
+ def test_replacement
16
+ cache = Wee::LRUCache.new(2)
17
+ def cache.purge(item) @purged = item end
18
+ def cache.purged() @purged end
19
+
20
+ a = I.new("a")
21
+ b = I.new("b")
22
+ c = I.new("c")
23
+
24
+ assert_nil cache.purged
25
+
26
+ cache.store(a.id, a)
27
+ assert_nil cache.purged
28
+
29
+ cache.store(b.id, b)
30
+ assert_nil cache.purged
31
+
32
+ cache.store(c.id, c)
33
+ assert_same a, cache.purged
34
+
35
+ cache.store(a.id, a)
36
+ assert_same b, cache.purged
37
+
38
+ cache.store(b.id, b)
39
+ assert_same c, cache.purged
40
+
41
+ #
42
+ # Reads also modify LRU
43
+ #
44
+ assert_same a, cache.fetch(a.id)
45
+ assert_same b, cache.fetch(b.id)
46
+ assert_same a, cache.fetch(a.id)
47
+
48
+ cache.store(c.id, c)
49
+ assert_same b, cache.purged
50
+ end
51
+ end
@@ -0,0 +1,42 @@
1
+ require 'test/unit'
2
+ module Wee; end
3
+ require 'wee/request'
4
+
5
+ class Test_Request < Test::Unit::TestCase
6
+ def test_parse
7
+ d = Wee::Request::DELIM
8
+ req = Wee::Request.new('/app', "/app/info#{d}req_handler_id/page_id", nil, nil, nil)
9
+ assert_equal 'info', req.info
10
+ assert_equal 'req_handler_id', req.request_handler_id
11
+ assert_equal 'page_id', req.page_id
12
+ end
13
+
14
+ def test_fields
15
+ fields = {
16
+ 'a' => 1,
17
+ 'b' => 2,
18
+ 'a.x' => 3,
19
+ 'a.y' => 4,
20
+ }
21
+
22
+ parsed = {
23
+ 'a' => {nil => 1, 'x' => 3, 'y' => 4},
24
+ 'b' => 2
25
+ }
26
+
27
+ req = Wee::Request.new('/app', "/app", nil, fields, nil)
28
+ assert_equal parsed, req.fields
29
+ end
30
+
31
+ def test_build_url
32
+ d = Wee::Request::DELIM
33
+ req = Wee::Request.new('/app', "/app/info#{d}req_handler_id/page_id", nil, nil, nil)
34
+
35
+ assert_equal "/app/info#{d}req_handler_id/page_id?c", req.build_url(:callback_id => 'c')
36
+
37
+ assert_equal "/app/info#{d}a/b?c", req.build_url(:request_handler_id => 'a', :page_id => 'b', :callback_id => 'c')
38
+ assert_equal "/app/info#{d}req_handler_id/b", req.build_url(:request_handler_id => 'req_handler_id', :page_id => 'b')
39
+
40
+ assert_equal "/app/info", req.build_url(:request_handler_id => nil, :page_id => nil)
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mullen-wee
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 2
9
+ - 0
10
+ version: 2.2.0
11
+ platform: ruby
12
+ authors:
13
+ - Michael Neumann
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-09 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rack
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 0
34
+ version: 1.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: mspec
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 17
46
+ segments:
47
+ - 1
48
+ - 5
49
+ - 9
50
+ version: 1.5.9
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: fast_gettext
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 45
62
+ segments:
63
+ - 0
64
+ - 4
65
+ - 17
66
+ version: 0.4.17
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ description: "Wee is a stateful component-orient web framework which supports "
70
+ email: mneumann@ntecs.de
71
+ executables: []
72
+
73
+ extensions: []
74
+
75
+ extra_rdoc_files: []
76
+
77
+ files:
78
+ - examples/hw.rb
79
+ - examples/demo/counter.rb
80
+ - examples/demo/example.rb
81
+ - examples/demo/file_upload.rb
82
+ - examples/demo/editable_counter.rb
83
+ - examples/demo/window.rb
84
+ - examples/demo/calendar.rb
85
+ - examples/demo/messagebox.rb
86
+ - examples/demo/calculator.rb
87
+ - examples/demo/radio.rb
88
+ - examples/arc_challenge2.rb
89
+ - examples/apotomo-webhunter/public/images/bear_trap_charged.png
90
+ - examples/apotomo-webhunter/public/images/dark_forest.jpg
91
+ - examples/apotomo-webhunter/public/images/mouse.png
92
+ - examples/apotomo-webhunter/public/images/cheese.png
93
+ - examples/apotomo-webhunter/public/images/bear_trap_snapped.png
94
+ - examples/apotomo-webhunter/public/javascripts/jquery-1.3.2.min.js
95
+ - examples/apotomo-webhunter/public/javascripts/wee-jquery.js
96
+ - examples/apotomo-webhunter/public/stylesheets/forest.css
97
+ - examples/apotomo-webhunter/main.rb
98
+ - examples/ajax.rb
99
+ - examples/demo.rb
100
+ - examples/continuations.rb
101
+ - examples/arc_challenge.rb
102
+ - examples/cheese_task.rb
103
+ - examples/i18n/app.rb
104
+ - examples/i18n/locale/en/app.po
105
+ - examples/i18n/locale/de/app.po
106
+ - examples/pager.rb
107
+ - examples/ObjectSpaceBrowser.rb
108
+ - lib/wee.rb
109
+ - lib/wee/presenter.rb
110
+ - lib/wee/session.rb
111
+ - lib/wee/callback.rb
112
+ - lib/wee/dialog.rb
113
+ - lib/wee/external_resource.rb
114
+ - lib/wee/rightjs/rightjs-1.5.2.min.js
115
+ - lib/wee/rightjs/wee-rightjs.js
116
+ - lib/wee/html_brushes.rb
117
+ - lib/wee/html_canvas.rb
118
+ - lib/wee/rightjs.rb
119
+ - lib/wee/task.rb
120
+ - lib/wee/application.rb
121
+ - lib/wee/jquery.rb
122
+ - lib/wee/response.rb
123
+ - lib/wee/state.rb
124
+ - lib/wee/component.rb
125
+ - lib/wee/locale.rb
126
+ - lib/wee/lru_cache.rb
127
+ - lib/wee/html_document.rb
128
+ - lib/wee/jquery/jquery-1.3.2.min.js
129
+ - lib/wee/jquery/wee-jquery.js
130
+ - lib/wee/html_writer.rb
131
+ - lib/wee/root_component.rb
132
+ - lib/wee/renderer.rb
133
+ - lib/wee/request.rb
134
+ - lib/wee/decoration.rb
135
+ - lib/wee/id_generator.rb
136
+ - aWee.gemspec
137
+ - README.rdoc
138
+ - test/test_lru_cache.rb
139
+ - test/test_html_canvas.rb
140
+ - test/test_html_writer.rb
141
+ - test/test_component.rb
142
+ - test/test_request.rb
143
+ - test/component_spec.rb
144
+ - test/bm_render.rb
145
+ - test/stress/plotter.rb
146
+ - test/stress/stress_local.rb
147
+ - test/stress/stress_server.rb
148
+ - test/stress/stress_client.rb
149
+ - Rakefile
150
+ has_rdoc: true
151
+ homepage: http://rubyforge.org/projects/wee
152
+ licenses: []
153
+
154
+ post_install_message:
155
+ rdoc_options: []
156
+
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ hash: 3
165
+ segments:
166
+ - 0
167
+ version: "0"
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ hash: 3
174
+ segments:
175
+ - 0
176
+ version: "0"
177
+ requirements: []
178
+
179
+ rubyforge_project: wee
180
+ rubygems_version: 1.3.7
181
+ signing_key:
182
+ specification_version: 3
183
+ summary: Wee is a framework for building highly dynamic web applications.
184
+ test_files: []
185
+