manveru-ramaze 2008.07 → 2008.08

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.
Files changed (51) hide show
  1. data/Rakefile +31 -2
  2. data/doc/meta/announcement.txt +16 -32
  3. data/examples/app/rapaste/controller/paste.rb +7 -0
  4. data/examples/app/sourceview/public/sourceview.js +2 -2
  5. data/lib/proto/view/error.xhtml +3 -3
  6. data/lib/ramaze/action.rb +2 -2
  7. data/lib/ramaze/adapter/base.rb +10 -19
  8. data/lib/ramaze/cache/memcached.rb +3 -5
  9. data/lib/ramaze/controller/resolve.rb +14 -4
  10. data/lib/ramaze/controller.rb +15 -11
  11. data/lib/ramaze/current/request.rb +6 -3
  12. data/lib/ramaze/current/session/flash.rb +8 -0
  13. data/lib/ramaze/dispatcher/error.rb +3 -3
  14. data/lib/ramaze/dispatcher.rb +5 -5
  15. data/lib/ramaze/gestalt.rb +8 -8
  16. data/lib/ramaze/helper/cgi.rb +1 -1
  17. data/lib/ramaze/helper/formatting.rb +8 -1
  18. data/lib/ramaze/helper/thread.rb +17 -0
  19. data/lib/ramaze/helper/ultraviolet.rb +44 -0
  20. data/lib/ramaze/helper/user.rb +4 -9
  21. data/lib/ramaze/option/holder.rb +1 -11
  22. data/lib/ramaze/option.rb +3 -3
  23. data/lib/ramaze/reloader.rb +186 -0
  24. data/lib/ramaze/setup.rb +1 -1
  25. data/lib/ramaze/snippets/dictionary.rb +2 -2
  26. data/lib/ramaze/snippets/fiber.rb +63 -0
  27. data/lib/ramaze/snippets/numeric/time.rb +10 -10
  28. data/lib/ramaze/snippets/ramaze/deprecated.rb +4 -2
  29. data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
  30. data/lib/ramaze/snippets/ramaze/state.rb +86 -0
  31. data/lib/ramaze/sourcereload.rb +1 -0
  32. data/lib/ramaze/template/maruku.rb +34 -0
  33. data/lib/ramaze/template.rb +4 -1
  34. data/lib/ramaze/tool/mime.rb +11 -1
  35. data/lib/ramaze/trinity.rb +4 -1
  36. data/lib/ramaze/version.rb +1 -1
  37. data/lib/ramaze.rb +2 -2
  38. data/rake_tasks/gem.rake +6 -0
  39. data/ramaze.gemspec +11 -5
  40. data/spec/ramaze/action/file_cache.rb +22 -0
  41. data/spec/ramaze/controller/actionless_templates.rb +1 -1
  42. data/spec/ramaze/controller/subclass.rb +15 -0
  43. data/spec/ramaze/controller/template_resolving.rb +1 -1
  44. data/spec/ramaze/controller/view/bar.xhtml +1 -0
  45. data/spec/ramaze/controller/view/base/another.xhtml +1 -0
  46. data/spec/ramaze/helper/aspect.rb +26 -17
  47. data/spec/ramaze/route.rb +1 -1
  48. data/spec/ramaze/template/tagz.rb +1 -1
  49. metadata +11 -5
  50. data/lib/ramaze/snippets/object/thread_accessor.rb +0 -5
  51. data/lib/ramaze/snippets/ramaze/thread_accessor.rb +0 -58
data/ramaze.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ramaze"
3
- s.version = "2008.07"
3
+ s.version = "2008.08"
4
4
 
5
5
  s.summary = "Ramaze is a simple and modular web framework"
6
6
  s.description = "Ramaze is a simple and modular web framework"
@@ -38,7 +38,6 @@ Gem::Specification.new do |s|
38
38
  "benchmark/test.rb",
39
39
  "bin",
40
40
  "bin/ramaze",
41
- "cache.yaml",
42
41
  "doc",
43
42
  "doc/AUTHORS",
44
43
  "doc/CHANGELOG",
@@ -416,6 +415,8 @@ Gem::Specification.new do |s|
416
415
  "lib/ramaze/helper/simple_captcha.rb",
417
416
  "lib/ramaze/helper/stack.rb",
418
417
  "lib/ramaze/helper/tagz.rb",
418
+ "lib/ramaze/helper/thread.rb",
419
+ "lib/ramaze/helper/ultraviolet.rb",
419
420
  "lib/ramaze/helper/user.rb",
420
421
  "lib/ramaze/helper/xhtml.rb",
421
422
  "lib/ramaze/helper.rb",
@@ -435,6 +436,7 @@ Gem::Specification.new do |s|
435
436
  "lib/ramaze/option/holder.rb",
436
437
  "lib/ramaze/option/merger.rb",
437
438
  "lib/ramaze/option.rb",
439
+ "lib/ramaze/reloader.rb",
438
440
  "lib/ramaze/route.rb",
439
441
  "lib/ramaze/setup.rb",
440
442
  "lib/ramaze/snippets",
@@ -445,6 +447,7 @@ Gem::Specification.new do |s|
445
447
  "lib/ramaze/snippets/blankslate.rb",
446
448
  "lib/ramaze/snippets/dictionary.rb",
447
449
  "lib/ramaze/snippets/divide.rb",
450
+ "lib/ramaze/snippets/fiber.rb",
448
451
  "lib/ramaze/snippets/kernel",
449
452
  "lib/ramaze/snippets/kernel/__dir__.rb",
450
453
  "lib/ramaze/snippets/kernel/acquire.rb",
@@ -458,7 +461,6 @@ Gem::Specification.new do |s|
458
461
  "lib/ramaze/snippets/object/instance_variable_defined.rb",
459
462
  "lib/ramaze/snippets/object/pretty.rb",
460
463
  "lib/ramaze/snippets/object/scope.rb",
461
- "lib/ramaze/snippets/object/thread_accessor.rb",
462
464
  "lib/ramaze/snippets/object/traits.rb",
463
465
  "lib/ramaze/snippets/ordered_set.rb",
464
466
  "lib/ramaze/snippets/proc",
@@ -467,7 +469,8 @@ Gem::Specification.new do |s|
467
469
  "lib/ramaze/snippets/ramaze/caller_info.rb",
468
470
  "lib/ramaze/snippets/ramaze/caller_lines.rb",
469
471
  "lib/ramaze/snippets/ramaze/deprecated.rb",
470
- "lib/ramaze/snippets/ramaze/thread_accessor.rb",
472
+ "lib/ramaze/snippets/ramaze/fiber.rb",
473
+ "lib/ramaze/snippets/ramaze/state.rb",
471
474
  "lib/ramaze/snippets/string",
472
475
  "lib/ramaze/snippets/string/camel_case.rb",
473
476
  "lib/ramaze/snippets/string/color.rb",
@@ -513,6 +516,7 @@ Gem::Specification.new do |s|
513
516
  "lib/ramaze/template/haml.rb",
514
517
  "lib/ramaze/template/liquid.rb",
515
518
  "lib/ramaze/template/markaby.rb",
519
+ "lib/ramaze/template/maruku.rb",
516
520
  "lib/ramaze/template/nagoro.rb",
517
521
  "lib/ramaze/template/none.rb",
518
522
  "lib/ramaze/template/redcloth.rb",
@@ -535,7 +539,6 @@ Gem::Specification.new do |s|
535
539
  "lib/ramaze.rb",
536
540
  "lib/vendor",
537
541
  "lib/vendor/bacon.rb",
538
- "pkg",
539
542
  "rake_tasks",
540
543
  "rake_tasks/conf.rake",
541
544
  "rake_tasks/coverage.rake",
@@ -601,6 +604,9 @@ Gem::Specification.new do |s|
601
604
  "spec/ramaze/controller/subclass.rb",
602
605
  "spec/ramaze/controller/template_resolving.rb",
603
606
  "spec/ramaze/controller/view",
607
+ "spec/ramaze/controller/view/bar.xhtml",
608
+ "spec/ramaze/controller/view/base",
609
+ "spec/ramaze/controller/view/base/another.xhtml",
604
610
  "spec/ramaze/controller/view/greet.xhtml",
605
611
  "spec/ramaze/controller/view/list.xhtml",
606
612
  "spec/ramaze/controller/view/other",
@@ -22,6 +22,18 @@ class TCOtherCache < Ramaze::Controller
22
22
  cache :index
23
23
  end
24
24
 
25
+ class TCIndexCache < Ramaze::Controller
26
+ map '/withparams'
27
+ helper :cache
28
+
29
+ def index(somearg = nil)
30
+ rand + somearg.to_f
31
+ end
32
+ alias :nonindex :index
33
+
34
+ cache :index, :nonindex
35
+ end
36
+
25
37
  describe 'Action rendering' do
26
38
  behaves_like 'http'
27
39
 
@@ -44,5 +56,15 @@ describe 'Action rendering' do
44
56
  File.file?(public_root/'other/index').should == true
45
57
  end
46
58
 
59
+ should 'cache action with params' do
60
+ lambda{ req('/withparams/nonindex/42') }.should.not.change{ req('/withparams/nonindex/42') }
61
+ File.file?(public_root/'withparams/nonindex/42').should == true
62
+ end
63
+
64
+ should 'cache index action with params' do
65
+ lambda{ req('/withparams/42') }.should.not.change{ req('/withparams/42') }
66
+ File.file?(public_root/'withparams/42').should == true
67
+ end
68
+
47
69
  FileUtils.rm_rf public_root
48
70
  end
@@ -19,7 +19,7 @@ end
19
19
  describe "Testing Actionless Templates" do
20
20
  behaves_like 'http'
21
21
  ramaze :actionless_templates => false,
22
- :view_root => __DIR__/:view
22
+ :view_root => __DIR__/:view, :error_page => true
23
23
 
24
24
  it "should not find template file for non existant method" do
25
25
  get('/non_existant_method').status.should == 404
@@ -4,6 +4,9 @@
4
4
  require 'spec/helper'
5
5
 
6
6
  class BaseController < Ramaze::Controller
7
+ template :foo, :bar
8
+ template :one, self, :another
9
+
7
10
  def test() 'test' end
8
11
  end
9
12
 
@@ -18,4 +21,16 @@ describe 'Controller' do
18
21
  it 'should allow sub-classing MainController' do
19
22
  get('/test').body.should == 'test'
20
23
  end
24
+
25
+ it 'should respect template mappings set in superclass, with no explicit controller' do
26
+ # The template file it should use is view/bar.xhtml, as the template mapping doesn't
27
+ # specify a controller, so it will be implicitly relative to MainController.
28
+ get('/foo').body.should == 'bar'
29
+ end
30
+
31
+ it 'should respect template mappings set in superclass, with an explicit controller' do
32
+ # Note that the template file it should use is view/base/another.xhtml, because
33
+ # BaseController explicitly specifies the template mapping in relation to self.
34
+ get('/one').body.should == 'another'
35
+ end
21
36
  end
@@ -44,7 +44,7 @@ class OtherController < MainController
44
44
 
45
45
  end
46
46
 
47
- class AnotherController < Ramaze::Controller
47
+ class AnotherController < MainController
48
48
  Root = __DIR__/:view
49
49
  Absolute = lambda{|path| File.join Root, path}
50
50
  Relative = lambda{|path| path}
@@ -0,0 +1 @@
1
+ bar
@@ -0,0 +1 @@
1
+ another
@@ -8,14 +8,14 @@ class TCAspectController < Ramaze::Controller
8
8
  trait :foo => :bar
9
9
  helper :aspect
10
10
 
11
- def test_before() request[:before] += 2 end
12
- before(:test_before){ request[:before] = 40 }
11
+ def test_before() $helper_aspect_spec_test_before += 2 end
12
+ before(:test_before){ $helper_aspect_spec_test_before = 40 }
13
13
 
14
- def test_after() request[:after] = 40 end
15
- after(:test_after){ request[:after] += 2 }
14
+ def test_after() $helper_aspect_spec_test_after = 40 end
15
+ after(:test_after){ $helper_aspect_spec_test_after += 2 }
16
16
 
17
17
  def test_wrap() end
18
- wrap(:test_wrap){ request[:wrap] ||= 0; request[:wrap] += 21 }
18
+ wrap(:test_wrap){ $helper_aspect_spec_test_wrap ||= 0; $helper_aspect_spec_test_wrap += 21 }
19
19
 
20
20
  wrap(:test_template) { '<aspect>' }
21
21
  end
@@ -29,8 +29,8 @@ class TCAspectAllController < Ramaze::Controller
29
29
  def test_all_first() 'first' end
30
30
  def test_all_second() 'second' end
31
31
 
32
- before_all{ request[:all] = 40 }
33
- after_all{ request[:all] += 2 }
32
+ before_all{ $helper_aspect_spec_all = 40 }
33
+ after_all{ $helper_aspect_spec_all += 2 }
34
34
 
35
35
  def test_all_after() 'after' end
36
36
 
@@ -42,51 +42,60 @@ end
42
42
  describe "AspectHelper" do
43
43
  behaves_like 'http'
44
44
  ramaze :error_page => false
45
- extend Ramaze::Trinity
46
45
 
47
46
  it "shouldn't overwrite traits on inclusion" do
48
47
  TCAspectController.trait[:foo].should == :bar
49
48
  end
50
49
 
51
50
  it 'should use before' do
51
+ $helper_aspect_spec_test_before = nil
52
52
  get('/test_before')
53
- request[:before].should == 42
53
+ $helper_aspect_spec_test_before.should == 42
54
54
  end
55
55
 
56
56
  it 'should use after' do
57
+ $helper_aspect_spec_test_after = nil
57
58
  get('/test_after')
58
- request[:after].should == 42
59
+ $helper_aspect_spec_test_after.should == 42
59
60
  end
60
61
 
61
62
  it 'should use wrap' do
63
+ $helper_aspect_spec_test_wrap = nil
62
64
  get('/test_wrap')
63
- request[:wrap].should == 42
65
+ $helper_aspect_spec_test_wrap.should == 42
64
66
  end
65
67
 
66
68
  it 'should before_all and after_all' do
69
+ $helper_aspect_spec_all = nil
67
70
  get('/all/test_all_first')
68
- request[:all].should == 42
71
+ $helper_aspect_spec_all.should == 42
72
+
73
+ $helper_aspect_spec_all = nil
69
74
  get('/all/test_all_second')
70
- request[:all].should == 42
75
+ $helper_aspect_spec_all.should == 42
71
76
  end
72
77
 
73
78
  it 'should before_all and after_all for templates' do
79
+ $helper_aspect_spec_all = nil
74
80
  get('/all/test_template')
75
- request[:all].should == 42
81
+ $helper_aspect_spec_all.should == 42
76
82
  end
77
83
 
78
84
  it 'should before_all and after_all for all defined actions' do
85
+ $helper_aspect_spec_all = nil
79
86
  get('/all/test_all_after')
80
- request[:all].should == 42
87
+ $helper_aspect_spec_all.should == 42
81
88
  end
82
89
 
83
90
  it 'should not apply aspects to render_template' do
91
+ $helper_aspect_spec_all = nil
84
92
  get('/all/loop').body.gsub(/\s/,'').should == '12345'
85
- request[:all].should == 42
93
+ $helper_aspect_spec_all.should == 42
86
94
  end
87
95
 
88
96
  it 'should not apply aspects to layouts' do
97
+ $helper_aspect_spec_all = nil
89
98
  get('/all/loop_with_layout').body.gsub(/\s/,'').should == '<div>12345</div>'
90
- request[:all].should == 42
99
+ $helper_aspect_spec_all.should == 42
91
100
  end
92
101
  end
data/spec/ramaze/route.rb CHANGED
@@ -126,6 +126,6 @@ describe 'Route' do
126
126
  it 'should not recurse given a bad route' do
127
127
  Ramaze::Route[ %r!^/good/(.+)$! ] = "/bad/%s"
128
128
  r = get('/good/hi')
129
- r.status.should == 404
129
+ r.status.should == 500
130
130
  end
131
131
  end
@@ -57,6 +57,6 @@ describe "Tagz" do
57
57
 
58
58
  it "should not respond to tagz" do
59
59
  response = get('/tagz')
60
- response.status.should == 404
60
+ response.status.should == 500
61
61
  end
62
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manveru-ramaze
3
3
  version: !ruby/object:Gem::Version
4
- version: "2008.07"
4
+ version: "2008.08"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael 'manveru' Fellinger
@@ -52,7 +52,6 @@ files:
52
52
  - benchmark/test.rb
53
53
  - bin
54
54
  - bin/ramaze
55
- - cache.yaml
56
55
  - doc
57
56
  - doc/AUTHORS
58
57
  - doc/CHANGELOG
@@ -430,6 +429,8 @@ files:
430
429
  - lib/ramaze/helper/simple_captcha.rb
431
430
  - lib/ramaze/helper/stack.rb
432
431
  - lib/ramaze/helper/tagz.rb
432
+ - lib/ramaze/helper/thread.rb
433
+ - lib/ramaze/helper/ultraviolet.rb
433
434
  - lib/ramaze/helper/user.rb
434
435
  - lib/ramaze/helper/xhtml.rb
435
436
  - lib/ramaze/helper.rb
@@ -449,6 +450,7 @@ files:
449
450
  - lib/ramaze/option/holder.rb
450
451
  - lib/ramaze/option/merger.rb
451
452
  - lib/ramaze/option.rb
453
+ - lib/ramaze/reloader.rb
452
454
  - lib/ramaze/route.rb
453
455
  - lib/ramaze/setup.rb
454
456
  - lib/ramaze/snippets
@@ -459,6 +461,7 @@ files:
459
461
  - lib/ramaze/snippets/blankslate.rb
460
462
  - lib/ramaze/snippets/dictionary.rb
461
463
  - lib/ramaze/snippets/divide.rb
464
+ - lib/ramaze/snippets/fiber.rb
462
465
  - lib/ramaze/snippets/kernel
463
466
  - lib/ramaze/snippets/kernel/__dir__.rb
464
467
  - lib/ramaze/snippets/kernel/acquire.rb
@@ -472,7 +475,6 @@ files:
472
475
  - lib/ramaze/snippets/object/instance_variable_defined.rb
473
476
  - lib/ramaze/snippets/object/pretty.rb
474
477
  - lib/ramaze/snippets/object/scope.rb
475
- - lib/ramaze/snippets/object/thread_accessor.rb
476
478
  - lib/ramaze/snippets/object/traits.rb
477
479
  - lib/ramaze/snippets/ordered_set.rb
478
480
  - lib/ramaze/snippets/proc
@@ -481,7 +483,8 @@ files:
481
483
  - lib/ramaze/snippets/ramaze/caller_info.rb
482
484
  - lib/ramaze/snippets/ramaze/caller_lines.rb
483
485
  - lib/ramaze/snippets/ramaze/deprecated.rb
484
- - lib/ramaze/snippets/ramaze/thread_accessor.rb
486
+ - lib/ramaze/snippets/ramaze/fiber.rb
487
+ - lib/ramaze/snippets/ramaze/state.rb
485
488
  - lib/ramaze/snippets/string
486
489
  - lib/ramaze/snippets/string/camel_case.rb
487
490
  - lib/ramaze/snippets/string/color.rb
@@ -527,6 +530,7 @@ files:
527
530
  - lib/ramaze/template/haml.rb
528
531
  - lib/ramaze/template/liquid.rb
529
532
  - lib/ramaze/template/markaby.rb
533
+ - lib/ramaze/template/maruku.rb
530
534
  - lib/ramaze/template/nagoro.rb
531
535
  - lib/ramaze/template/none.rb
532
536
  - lib/ramaze/template/redcloth.rb
@@ -549,7 +553,6 @@ files:
549
553
  - lib/ramaze.rb
550
554
  - lib/vendor
551
555
  - lib/vendor/bacon.rb
552
- - pkg
553
556
  - rake_tasks
554
557
  - rake_tasks/conf.rake
555
558
  - rake_tasks/coverage.rake
@@ -615,6 +618,9 @@ files:
615
618
  - spec/ramaze/controller/subclass.rb
616
619
  - spec/ramaze/controller/template_resolving.rb
617
620
  - spec/ramaze/controller/view
621
+ - spec/ramaze/controller/view/bar.xhtml
622
+ - spec/ramaze/controller/view/base
623
+ - spec/ramaze/controller/view/base/another.xhtml
618
624
  - spec/ramaze/controller/view/greet.xhtml
619
625
  - spec/ramaze/controller/view/list.xhtml
620
626
  - spec/ramaze/controller/view/other
@@ -1,5 +0,0 @@
1
- require(File.expand_path(File.join(File.dirname(__FILE__), '../ramaze/thread_accessor')))
2
-
3
- class Object
4
- include Ramaze::ThreadAccessor
5
- end
@@ -1,58 +0,0 @@
1
- module Ramaze
2
-
3
- # A alike of attr_accessor and friends, but for thread variables in
4
- # Thread::current
5
- module ThreadAccessor
6
-
7
- # Iterate over the names and yield accordingly.
8
- # names are either objects responding to #to_sym or hashes.
9
- #
10
- # It's only used within this module for abstractin-purposes.
11
- # Usage below.
12
- def self.each(*names)
13
- names.each do |name|
14
- if name.respond_to?(:to_hash)
15
- name.to_hash.each do |key, meth|
16
- key, meth = key.to_sym, meth.to_sym
17
- yield key, meth
18
- end
19
- else
20
- key = meth = name.to_sym
21
- yield key, meth
22
- end
23
- end
24
- end
25
-
26
- # thread_writer and thread_reader, initializer is a block that may be given
27
- # and its result will be the new value in case the reader was never called
28
- # before or the value wasn't set before.
29
- def thread_accessor(*names, &initializer)
30
- thread_writer(*names)
31
- thread_reader(*names, &initializer)
32
- end
33
-
34
- # Simple writer accessor to Thread::current[key]=
35
- def thread_writer(*names)
36
- ThreadAccessor.each(*names) do |key, meth|
37
- define_method("#{meth}="){|obj| Thread.current[key] = obj }
38
- end
39
- end
40
-
41
- # Reader accessor for Thread::current[key]
42
- def thread_reader(*names, &initializer)
43
- ThreadAccessor.each(*names) do |key, meth|
44
- if initializer
45
- define_method(meth) do
46
- unless Thread.current.key?(key)
47
- Thread.current[key] = instance_eval(&initializer)
48
- else
49
- Thread.current[key]
50
- end
51
- end
52
- else
53
- define_method(meth){ Thread.current[key] }
54
- end
55
- end
56
- end
57
- end
58
- end