ramaze 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/Rakefile +14 -29
  2. data/bin/ramaze +2 -3
  3. data/doc/AUTHORS +5 -2
  4. data/doc/CHANGELOG +262 -9
  5. data/doc/FAQ +6 -6
  6. data/doc/meta/announcement.txt +5 -19
  7. data/doc/tutorial/todolist.html +47 -57
  8. data/doc/tutorial/todolist.mkd +47 -55
  9. data/examples/memleak_detector.rb +31 -0
  10. data/examples/todolist/src/controller/main.rb +14 -13
  11. data/examples/todolist/src/element/page.rb +2 -2
  12. data/examples/todolist/src/model.rb +2 -2
  13. data/examples/todolist/todolist.db +0 -4
  14. data/examples/whywiki/main.rb +2 -2
  15. data/examples/whywiki/template/edit.xhtml +1 -1
  16. data/examples/whywiki/template/show.xhtml +3 -3
  17. data/lib/proto/src/controller/main.rb +18 -1
  18. data/lib/proto/template/index.xhtml +11 -2
  19. data/lib/ramaze.rb +1 -1
  20. data/lib/ramaze/action.rb +104 -5
  21. data/lib/ramaze/action/render.rb +54 -0
  22. data/lib/ramaze/adapter.rb +2 -1
  23. data/lib/ramaze/adapter/mongrel.rb +13 -4
  24. data/lib/ramaze/cache.rb +17 -8
  25. data/lib/ramaze/cache/memcached.rb +1 -5
  26. data/lib/ramaze/controller.rb +51 -18
  27. data/lib/ramaze/controller/resolve.rb +19 -14
  28. data/lib/ramaze/dispatcher.rb +13 -16
  29. data/lib/ramaze/dispatcher/action.rb +2 -3
  30. data/lib/ramaze/dispatcher/error.rb +8 -3
  31. data/lib/ramaze/dispatcher/file.rb +1 -4
  32. data/lib/ramaze/error.rb +5 -5
  33. data/lib/ramaze/global.rb +7 -1
  34. data/lib/ramaze/global/globalstruct.rb +1 -3
  35. data/lib/ramaze/helper/aspect.rb +8 -10
  36. data/lib/ramaze/helper/cgi.rb +21 -3
  37. data/lib/ramaze/helper/identity.rb +4 -6
  38. data/lib/ramaze/helper/link.rb +4 -4
  39. data/lib/ramaze/helper/pager.rb +316 -0
  40. data/lib/ramaze/helper/partial.rb +37 -0
  41. data/lib/ramaze/helper/stack.rb +1 -1
  42. data/lib/ramaze/inform.rb +9 -0
  43. data/lib/ramaze/inform/hub.rb +5 -0
  44. data/lib/ramaze/inform/informer.rb +12 -6
  45. data/lib/ramaze/inform/informing.rb +32 -7
  46. data/lib/ramaze/inform/knotify.rb +21 -0
  47. data/lib/ramaze/inform/xosd.rb +58 -24
  48. data/lib/ramaze/sourcereload.rb +30 -1
  49. data/lib/ramaze/template.rb +33 -12
  50. data/lib/ramaze/template/amrita2.rb +21 -20
  51. data/lib/ramaze/template/erubis.rb +18 -14
  52. data/lib/ramaze/template/ezamar.rb +15 -26
  53. data/lib/ramaze/template/ezamar/element.rb +1 -1
  54. data/lib/ramaze/template/ezamar/engine.rb +45 -36
  55. data/lib/ramaze/template/ezamar/morpher.rb +3 -3
  56. data/lib/ramaze/template/ezamar/render_partial.rb +26 -0
  57. data/lib/ramaze/template/haml.rb +23 -18
  58. data/lib/ramaze/template/liquid.rb +5 -3
  59. data/lib/ramaze/template/markaby.rb +14 -11
  60. data/lib/ramaze/template/remarkably.rb +11 -5
  61. data/lib/ramaze/tool/localize.rb +12 -4
  62. data/lib/ramaze/tool/tidy.rb +26 -23
  63. data/lib/ramaze/trinity/request.rb +11 -7
  64. data/lib/ramaze/trinity/session.rb +24 -8
  65. data/lib/ramaze/version.rb +1 -1
  66. data/rake_tasks/maintaince.rake +136 -11
  67. data/spec/examples/templates/template_liquid.rb +6 -3
  68. data/spec/examples/todolist.rb +1 -2
  69. data/spec/helper/minimal.rb +7 -7
  70. data/spec/ramaze/action/basics.rb +19 -0
  71. data/spec/ramaze/action/render.rb +18 -0
  72. data/spec/ramaze/controller.rb +1 -1
  73. data/spec/ramaze/controller/template_resolving.rb +1 -1
  74. data/spec/ramaze/dispatcher/file.rb +24 -0
  75. data/spec/ramaze/error.rb +28 -29
  76. data/spec/ramaze/helper/cgi.rb +43 -0
  77. data/spec/ramaze/helper/pager.rb +27 -0
  78. data/spec/ramaze/helper/partial.rb +38 -0
  79. data/spec/ramaze/helper/template/partial.xhtml +1 -0
  80. data/spec/ramaze/inform/informer.rb +1 -1
  81. data/spec/ramaze/localize.rb +1 -1
  82. data/spec/ramaze/morpher.rb +3 -3
  83. data/spec/ramaze/request.rb +1 -3
  84. data/spec/ramaze/template.rb +9 -7
  85. data/spec/ramaze/template/haml.rb +2 -1
  86. metadata +21 -7
  87. data/examples/todolist/public/404.jpg +0 -0
  88. data/examples/todolist/public/error.xhtml +0 -74
  89. data/lib/ramaze/controller/render.rb +0 -90
@@ -0,0 +1,19 @@
1
+ require 'spec/helper'
2
+
3
+ describe 'Action() basics' do
4
+ it 'should have useful defaults' do
5
+ action = Ramaze::Action()
6
+
7
+ action.params.should == []
8
+ action.method.should be_nil
9
+ action.template.should be_nil
10
+ end
11
+
12
+ it 'should sanitize parameters' do
13
+ action = Ramaze::Action :params => [[1],[2],nil,'%20'],
14
+ :method => :foo
15
+
16
+ action.params.should == ['1', '2', ' ']
17
+ action.method.should == 'foo'
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec/helper'
2
+
3
+ class TCActionOne < Ramaze::Controller
4
+ def index
5
+ 'Hello, World!'
6
+ end
7
+ end
8
+
9
+ describe 'Action rendering' do
10
+ before :all do
11
+ ramaze
12
+ end
13
+
14
+ it 'should render' do
15
+ action = Ramaze::Action(:method => :index, :controller => TCActionOne)
16
+ action.render.should == 'Hello, World!'
17
+ end
18
+ end
@@ -37,7 +37,7 @@ describe "Controller" do
37
37
  end
38
38
 
39
39
  def values(*url)
40
- resolve(*url).last.values_at(:method, :params, :template)
40
+ resolve(*url).values_at(:method, :params, :template)
41
41
  end
42
42
 
43
43
  before :all do
@@ -11,7 +11,7 @@ class MainController < Ramaze::Controller
11
11
  end
12
12
 
13
13
  def list
14
- @obj = @action.method
14
+ @obj = Ramaze::Action.current.method
15
15
  end
16
16
  alias_method :index, :list
17
17
  template :index, 'list'
@@ -0,0 +1,24 @@
1
+ require 'spec/helper'
2
+
3
+ describe 'Dispatcher::File' do
4
+ before :all do
5
+ ramaze
6
+ end
7
+
8
+ it 'should serve from proto/public' do
9
+ end
10
+
11
+ it 'should serve from Global.public_root' do
12
+ dir = Ramaze::Global.public_root = 'spec/ramaze/public'
13
+ css = File.read(dir/'test_download.css')
14
+ re_css = get('/test_download.css')
15
+ re_css.body.should == css
16
+ re_css.status.should == 200
17
+ end
18
+
19
+ it 'should serve from Global.public_proto' do
20
+ file = (Ramaze::Global.public_proto/'error.zmr')
21
+ original = File.read(file)
22
+ get('/error.zmr').body.should == original
23
+ end
24
+ end
@@ -6,7 +6,6 @@ require 'open-uri'
6
6
 
7
7
  class TCErrorController < Ramaze::Controller
8
8
  map :/
9
- public_root 'spec/ramaze/public'
10
9
 
11
10
  def index
12
11
  self.class.name
@@ -18,46 +17,46 @@ class TCErrorController < Ramaze::Controller
18
17
  end
19
18
 
20
19
  describe "Error" do
21
- ramaze :error_page => true
20
+ ramaze :error_page => true, :public_root => 'spec/ramaze/public'
22
21
 
23
- describe "Throwing Error" do
24
- it 'erroring' do
25
- response = get('/erroring')
26
- response.status.should == 500
27
- regex = %r(undefined local variable or method `blah' for .*?TCErrorController)
28
- response.body.should =~ regex
29
- end
22
+ before :all do
23
+ require 'ramaze/dispatcher/error'
24
+ @handle_error = Ramaze::Dispatcher::Error::HANDLE_ERROR
30
25
  end
31
26
 
32
- describe "No Action" do
33
- it 'default' do
34
- response = get('/foobar')
35
- response.status.should == 404
36
- response.body.should =~ %r(No Action found for `/foobar' on TCErrorController)
37
- end
27
+ it 'should throw errors from rendering' do
28
+ response = get('/erroring')
29
+ response.status.should == 500
30
+ regex = %r(undefined local variable or method `blah' for .*?TCErrorController)
31
+ response.body.should =~ regex
32
+ end
33
+
34
+ it 'should give 404 when no action is found' do
35
+ response = get('/illegal')
36
+ response.status.should == 404
37
+ response.body.should =~ %r(No Action found for `/foobar' on TCErrorController)
38
+ end
38
39
 
39
- it "No Action custom" do
40
- Ramaze::Dispatcher.trait[:handle_error] = { Exception => [500, '/error'] }
40
+ it "should give custom status when no action is found" do
41
+ @handle_error.should_receive(:[]).twice.
42
+ with(Ramaze::Error::NoAction).and_return{ [707, '/error'] }
41
43
 
42
- response = get('/illegal')
43
- response.status.should == 500
44
- response.body.should =~ %r(No Action found for `/illegal' on TCErrorController)
45
- end
44
+ response = get('/illegal')
45
+ response.status.should == 707
46
+ response.body.should =~ %r(No Action found for `/illegal' on TCErrorController)
46
47
  end
47
48
 
48
- it "No Controller" do
49
- Ramaze::Global.should_receive(:mapping).twice.and_return{ {} }
50
- Ramaze::Dispatcher.trait[:handle_error].should_receive(:[]).twice.
51
- with(Ramaze::Error::NoController).and_return{ [500, '/error'] }
49
+ it "should give 404 when no controller is found" do
50
+ Ramaze::Global.should_receive(:mapping).once.and_return{ {} }
52
51
  response = get('/illegal')
53
- response.status.should == 500
52
+ response.status.should == 404
54
53
  response.body.should =~ %r(No Controller found for `/error')
55
54
  end
56
55
 
57
- it "Custom Static" do
58
- Ramaze::Dispatcher.trait[:handle_error].should_receive(:[]).twice.
56
+ it "should return custom error page" do
57
+ @handle_error.should_receive(:[]).twice.
59
58
  with(Ramaze::Error::NoAction).and_return{ [404, '/error404'] }
60
- response = get('/foo')
59
+ response = get('/illegal')
61
60
  response.status.should == 404
62
61
  response.body.should == '404 - not found'
63
62
  end
@@ -0,0 +1,43 @@
1
+ # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require 'spec/helper'
5
+ require 'ramaze/helper/cgi'
6
+
7
+ class TCLink < Ramaze::Controller
8
+ map '/'
9
+ end
10
+
11
+ describe "url encode" do
12
+ include Ramaze::CgiHelper
13
+
14
+ it 'should url_encode strings' do
15
+ # ok, I believe that the web is dumb for this
16
+ # but this probably is a SHOULD thingy in the HTTP RFC
17
+ url_encode('title with spaces').should == 'title+with+spaces'
18
+ url_encode('[foo]').should == '%5Bfoo%5D'
19
+ u('//').should == '%2F%2F'
20
+ end
21
+ it 'should url_decode strings' do
22
+ url_decode('title%20with%20spaces').should == 'title with spaces'
23
+ url_decode('title+with+spaces').should == 'title with spaces'
24
+ end
25
+ it 'should be reversible' do
26
+ url_decode(u('../ etc/passwd')).should == '../ etc/passwd'
27
+ end
28
+ end
29
+
30
+ describe 'html escape' do
31
+ include Ramaze::CgiHelper
32
+
33
+ it 'should escape html' do
34
+ html_escape('& < >').should == '&amp; &lt; &gt;'
35
+ h('<&>').should == '&lt;&amp;&gt;'
36
+ end
37
+ it 'should unescape html' do
38
+ html_unescape('&lt; &amp; &gt;').should == '< & >'
39
+ end
40
+ it 'should be reversible' do
41
+ html_unescape(html_escape('2 > b && b <= 0')).should == '2 > b && b <= 0'
42
+ end
43
+ end
@@ -0,0 +1,27 @@
1
+ # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require 'spec/helper'
5
+
6
+ class TC_PagerController < Ramaze::Controller
7
+ map '/'
8
+ helper :pager
9
+
10
+ def page
11
+ stuff = [1, 2, 3, 4, 5, 6, 7, 8, 9]
12
+
13
+ items, pager = paginate(stuff, :limit => 2)
14
+
15
+ items.inspect
16
+ end
17
+
18
+ end
19
+
20
+ describe "StackHelper" do
21
+ before(:all){ ramaze }
22
+
23
+ it "conventional login" do
24
+ get('/page').body.should == '[1, 2]'
25
+ get("/page", Ramaze::Pager.trait[:key] => '2').body.should == '[3, 4]'
26
+ end
27
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require 'spec/helper'
5
+
6
+ class TCPartialHelperController < Ramaze::Controller
7
+ map '/'
8
+ helper :partial
9
+ template_root(File.dirname(__FILE__)/:template)
10
+
11
+ def index
12
+ '<http><head><title>#{render_partial("/title")}</title></head></http>'
13
+ end
14
+
15
+ def title
16
+ "Title"
17
+ end
18
+
19
+ def composed
20
+ @here = 'there'
21
+ 'From Action | ' +
22
+ render_template("partial.xhtml")
23
+ end
24
+ end
25
+
26
+ describe "PartialHelper" do
27
+ before :all do
28
+ ramaze
29
+ end
30
+
31
+ it "should render partials" do
32
+ get('/').body.should == '<http><head><title>Title</title></head></http>'
33
+ end
34
+
35
+ it 'should be able to render a template in the current scope' do
36
+ get('/composed').body.should == 'From Action | From Partial there'
37
+ end
38
+ end
@@ -0,0 +1 @@
1
+ From Partial #@here
@@ -4,8 +4,8 @@ describe 'Informer' do
4
4
  before(:each) do
5
5
  @out = []
6
6
  def @out.puts(*args) push(*args) end
7
+ Ramaze::Informer.trait[:colorize] = false
7
8
  @inform = Ramaze::Informer.new(@out)
8
- @inform.colorize = false
9
9
  end
10
10
 
11
11
  def format(tag, string)
@@ -9,7 +9,7 @@ Ramaze::Tool::Localize.trait :enable => true,
9
9
  :file => 'spec/ramaze/conf/locale_%s.yaml'.freeze,
10
10
  :languages => %w[en de]
11
11
 
12
- Ramaze::Dispatcher::Action.trait[:filter] << Ramaze::Tool::Localize
12
+ Ramaze::Dispatcher::Action::FILTER << Ramaze::Tool::Localize
13
13
 
14
14
  class TCLocalize < Ramaze::Controller
15
15
  map '/'
@@ -53,9 +53,9 @@ end
53
53
  describe "Morpher" do
54
54
  before :all do
55
55
  ramaze
56
- Ramaze::Template::Ezamar.trait[:transform_pipeline] = [
57
- Ezamar::Element, Ezamar::Morpher, Ezamar::Template
58
- ]
56
+ pipeline = Ramaze::Template::Ezamar::TRANSFORM_PIPELINE
57
+ pipeline.clear
58
+ pipeline.push(Ezamar::Element, Ezamar::Morpher)
59
59
  end
60
60
 
61
61
  def clean_get(*url)
@@ -6,8 +6,6 @@ require 'spec/helper'
6
6
  class TCRequestController < Ramaze::Controller
7
7
  map '/'
8
8
 
9
- trait :public => 'spec/ramaze/public'
10
-
11
9
  def is_post() request.post?.to_s end
12
10
  def is_get() request.get?.to_s end
13
11
  def is_put() request.put?.to_s end
@@ -50,7 +48,7 @@ end
50
48
 
51
49
  describe "Request" do
52
50
  options = ramaze_options rescue {}
53
- ramaze options.merge(:mapping => {'/' => TCRequestController})
51
+ ramaze options.merge(:public_root => 'spec/ramaze/public')
54
52
 
55
53
  describe "POST" do
56
54
  it "give me the result of request.post?" do
@@ -4,13 +4,15 @@
4
4
  require 'spec/helper'
5
5
  require 'ramaze/template'
6
6
 
7
- module Ramaze::Template
8
- class TestTemplate < Template
9
- Ramaze::Controller.register_engine self, %w[ test ]
10
-
11
- class << self
12
- def transform action
13
- action.values_at(:method, :params, :template).to_yaml
7
+ module Ramaze
8
+ module Template
9
+ class TestTemplate < Template
10
+ ENGINES[self] = %w[ test ]
11
+
12
+ class << self
13
+ def transform action
14
+ action.values_at(:method, :params, :template).to_yaml
15
+ end
14
16
  end
15
17
  end
16
18
  end
@@ -6,6 +6,7 @@ require 'spec/helper'
6
6
  testcase_requires 'ramaze/template/haml'
7
7
 
8
8
  class TCTemplateHamlController < Ramaze::Controller
9
+ map '/'
9
10
  template_root 'spec/ramaze/template/haml/'
10
11
  trait :engine => Ramaze::Template::Haml
11
12
 
@@ -20,7 +21,7 @@ class TCTemplateHamlController < Ramaze::Controller
20
21
  end
21
22
 
22
23
  describe "Simply calling" do
23
- ramaze(:mapping => {'/' => TCTemplateHamlController})
24
+ ramaze(:compile => true)
24
25
 
25
26
  it "index" do
26
27
  get('/').body.strip.should ==
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.3
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ramaze
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2007-05-27 00:00:00 +09:00
6
+ version: 0.1.2
7
+ date: 2007-06-17 00:00:00 +09:00
8
8
  summary: Ramaze tries to be a very simple Webframework without the voodoo
9
9
  require_paths:
10
10
  - lib
@@ -35,7 +35,7 @@ post_install_message: |-
35
35
  ramaze --create yourproject
36
36
 
37
37
  * Browse and try the Examples in
38
- /usr/lib/ruby/gems/1.8/gems/ramaze-0.1.1/examples
38
+ /usr/lib/ruby/gems/1.8/gems/ramaze-0.1.2/examples
39
39
 
40
40
  ============================================================
41
41
  authors:
@@ -62,6 +62,7 @@ files:
62
62
  - examples/blog/public/styles/blog.css
63
63
  - examples/nitro_form.rb
64
64
  - examples/caching.rb
65
+ - examples/memleak_detector.rb
65
66
  - examples/todolist
66
67
  - examples/todolist/src
67
68
  - examples/todolist/src/element
@@ -80,8 +81,6 @@ files:
80
81
  - examples/todolist/public/css
81
82
  - examples/todolist/public/favicon.ico
82
83
  - examples/todolist/public/ramaze.png
83
- - examples/todolist/public/error.xhtml
84
- - examples/todolist/public/404.jpg
85
84
  - examples/identity.rb
86
85
  - examples/element.rb
87
86
  - examples/simple.rb
@@ -189,13 +188,21 @@ files:
189
188
  - spec/ramaze/template/amrita2/data.amrita
190
189
  - spec/ramaze/template/amrita2.rb
191
190
  - spec/ramaze/cache.rb
191
+ - spec/ramaze/action
192
+ - spec/ramaze/action/basics.rb
193
+ - spec/ramaze/action/render.rb
192
194
  - spec/ramaze/template.rb
193
195
  - spec/ramaze/tidy.rb
194
196
  - spec/ramaze/helper
197
+ - spec/ramaze/helper/pager.rb
195
198
  - spec/ramaze/helper/link.rb
199
+ - spec/ramaze/helper/template
200
+ - spec/ramaze/helper/template/partial.xhtml
196
201
  - spec/ramaze/helper/cache.rb
202
+ - spec/ramaze/helper/partial.rb
197
203
  - spec/ramaze/helper/feed.rb
198
204
  - spec/ramaze/helper/file.rb
205
+ - spec/ramaze/helper/cgi.rb
199
206
  - spec/ramaze/helper/redirect.rb
200
207
  - spec/ramaze/helper/form.rb
201
208
  - spec/ramaze/helper/flash.rb
@@ -226,6 +233,8 @@ files:
226
233
  - spec/ramaze/public/ramaze.png
227
234
  - spec/ramaze/public/test_download.css
228
235
  - spec/ramaze/public/error404.xhtml
236
+ - spec/ramaze/dispatcher
237
+ - spec/ramaze/dispatcher/file.rb
229
238
  - spec/ramaze/gestalt.rb
230
239
  - spec/ramaze/session.rb
231
240
  - spec/ramaze/element.rb
@@ -291,6 +300,7 @@ files:
291
300
  - lib/ramaze/template/liquid.rb
292
301
  - lib/ramaze/template/remarkably.rb
293
302
  - lib/ramaze/template/ezamar
303
+ - lib/ramaze/template/ezamar/render_partial.rb
294
304
  - lib/ramaze/template/ezamar/engine.rb
295
305
  - lib/ramaze/template/ezamar/element.rb
296
306
  - lib/ramaze/template/ezamar/morpher.rb
@@ -298,14 +308,18 @@ files:
298
308
  - lib/ramaze/template/amrita2.rb
299
309
  - lib/ramaze/cache.rb
300
310
  - lib/ramaze/snippets.rb
311
+ - lib/ramaze/action
312
+ - lib/ramaze/action/render.rb
301
313
  - lib/ramaze/template.rb
302
314
  - lib/ramaze/global
303
315
  - lib/ramaze/global/globalstruct.rb
304
316
  - lib/ramaze/global/dsl.rb
305
317
  - lib/ramaze/helper
306
318
  - lib/ramaze/helper/markaby.rb
319
+ - lib/ramaze/helper/pager.rb
307
320
  - lib/ramaze/helper/link.rb
308
321
  - lib/ramaze/helper/cache.rb
322
+ - lib/ramaze/helper/partial.rb
309
323
  - lib/ramaze/helper/feed.rb
310
324
  - lib/ramaze/helper/file.rb
311
325
  - lib/ramaze/helper/cgi.rb
@@ -324,6 +338,7 @@ files:
324
338
  - lib/ramaze/inform/xosd.rb
325
339
  - lib/ramaze/inform/syslog.rb
326
340
  - lib/ramaze/inform/growl.rb
341
+ - lib/ramaze/inform/knotify.rb
327
342
  - lib/ramaze/inform/hub.rb
328
343
  - lib/ramaze/inform/informing.rb
329
344
  - lib/ramaze/inform/analogger.rb
@@ -340,7 +355,6 @@ files:
340
355
  - lib/ramaze/controller
341
356
  - lib/ramaze/controller/resolve.rb
342
357
  - lib/ramaze/controller/error.rb
343
- - lib/ramaze/controller/render.rb
344
358
  - lib/ramaze/controller.rb
345
359
  - lib/ramaze/sourcereload.rb
346
360
  - lib/ramaze/dispatcher.rb