ramaze 2008.06 → 2008.11
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/README.markdown +6 -6
- data/Rakefile +33 -3
- data/bin/ramaze +18 -0
- data/doc/CHANGELOG +960 -0
- data/doc/LEGAL +5 -1
- data/doc/meta/announcement.txt +20 -36
- data/doc/tutorial/todolist.html +421 -313
- data/doc/tutorial/todolist.mkd +33 -16
- data/examples/app/blog/spec/blog.rb +3 -3
- data/examples/app/rapaste/controller/paste.rb +8 -1
- data/examples/app/rapaste/model/paste.rb +3 -0
- data/examples/app/rapaste/spec/rapaste.rb +3 -1
- data/examples/app/rapaste/start.rb +3 -2
- data/examples/app/sourceview/public/sourceview.js +2 -2
- data/examples/app/todolist/spec/todolist.rb +6 -6
- data/examples/app/todolist/template/index.xhtml +1 -1
- data/examples/app/whywiki/spec/whywiki.rb +2 -2
- data/examples/app/wikore/spec/wikore.rb +2 -2
- data/examples/app/wikore/src/model.rb +4 -3
- data/examples/app/wiktacular/spec/wiktacular.rb +7 -7
- data/examples/basic/simple.rb +2 -2
- data/examples/helpers/paginate.rb +71 -0
- data/examples/misc/simple_auth.rb +20 -8
- data/lib/proto/controller/init.rb +10 -0
- data/lib/proto/controller/main.rb +1 -3
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/dispatch.fcgi +1 -1
- data/lib/proto/spec/main.rb +2 -1
- data/lib/proto/start.rb +3 -3
- data/lib/proto/start.ru +1 -1
- data/lib/proto/view/error.xhtml +4 -4
- data/lib/ramaze.rb +8 -3
- data/lib/ramaze/action.rb +6 -6
- data/lib/ramaze/adapter.rb +1 -6
- data/lib/ramaze/adapter/base.rb +30 -27
- data/lib/ramaze/adapter/cgi.rb +1 -0
- data/lib/ramaze/cache.rb +1 -3
- data/lib/ramaze/cache/memcached.rb +3 -5
- data/lib/ramaze/contrib/auto_params.rb +2 -2
- data/lib/ramaze/contrib/auto_params/get_args.rb +2 -1
- data/lib/ramaze/contrib/gems.rb +17 -18
- data/lib/ramaze/contrib/gzip_filter.rb +22 -9
- data/lib/ramaze/contrib/maruku_uv.rb +59 -0
- data/lib/ramaze/contrib/profiling.rb +1 -1
- data/lib/ramaze/contrib/rest.rb +16 -13
- data/lib/ramaze/contrib/sequel/create_join.rb +25 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +129 -0
- data/lib/ramaze/contrib/sequel/image.rb +198 -0
- data/lib/ramaze/contrib/sequel/relation.rb +82 -0
- data/lib/ramaze/controller.rb +33 -34
- data/lib/ramaze/controller/resolve.rb +29 -9
- data/lib/ramaze/current.rb +60 -20
- data/lib/ramaze/current/request.rb +8 -7
- data/lib/ramaze/current/response.rb +15 -3
- data/lib/ramaze/current/session/flash.rb +8 -0
- data/lib/ramaze/dispatcher.rb +17 -9
- data/lib/ramaze/dispatcher/action.rb +4 -5
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +4 -4
- data/lib/ramaze/dispatcher/file.rb +4 -4
- data/lib/ramaze/gestalt.rb +15 -20
- data/lib/ramaze/helper/cgi.rb +7 -15
- data/lib/ramaze/helper/formatting.rb +41 -1
- data/lib/ramaze/helper/httpdigest.rb +20 -7
- data/lib/ramaze/helper/link.rb +4 -6
- data/lib/ramaze/helper/paginate.rb +233 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/helper/rest.rb +1 -1
- data/lib/ramaze/helper/thread.rb +17 -0
- data/lib/ramaze/helper/ultraviolet.rb +44 -0
- data/lib/ramaze/helper/user.rb +4 -9
- data/lib/ramaze/log.rb +2 -2
- data/lib/ramaze/log/analogger.rb +21 -23
- data/lib/ramaze/log/growl.rb +21 -23
- data/lib/ramaze/log/hub.rb +1 -1
- data/lib/ramaze/log/informer.rb +97 -99
- data/lib/ramaze/log/knotify.rb +14 -16
- data/lib/ramaze/log/logger.rb +11 -13
- data/lib/ramaze/log/logging.rb +61 -63
- data/lib/ramaze/log/rotatinginformer.rb +168 -0
- data/lib/ramaze/log/syslog.rb +41 -31
- data/lib/ramaze/log/xosd.rb +70 -72
- data/lib/ramaze/option.rb +9 -6
- data/lib/ramaze/option/holder.rb +5 -27
- data/lib/ramaze/reloader.rb +186 -0
- data/lib/ramaze/setup.rb +1 -1
- data/lib/ramaze/snippets.rb +13 -0
- data/lib/ramaze/snippets/array/put_within.rb +31 -24
- data/lib/ramaze/snippets/binding/locals.rb +23 -11
- data/lib/ramaze/snippets/dictionary.rb +2 -2
- data/lib/ramaze/snippets/fiber.rb +63 -0
- data/lib/ramaze/snippets/kernel/constant.rb +36 -21
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +12 -6
- data/lib/ramaze/snippets/numeric/filesize_format.rb +24 -17
- data/lib/ramaze/snippets/numeric/time.rb +63 -0
- data/lib/ramaze/snippets/object/__dir__.rb +29 -0
- data/lib/ramaze/snippets/object/acquire.rb +40 -0
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +16 -5
- data/lib/ramaze/snippets/object/pretty.rb +14 -4
- data/lib/ramaze/snippets/object/scope.rb +14 -7
- data/lib/ramaze/snippets/ordered_set.rb +25 -14
- data/lib/ramaze/snippets/proc/locals.rb +17 -9
- data/lib/ramaze/snippets/ramaze/deprecated.rb +13 -0
- data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
- data/lib/ramaze/snippets/ramaze/state.rb +86 -0
- data/lib/ramaze/snippets/ramaze/struct.rb +45 -0
- data/lib/ramaze/snippets/string/camel_case.rb +13 -8
- data/lib/ramaze/snippets/string/color.rb +24 -20
- data/lib/ramaze/snippets/string/each.rb +14 -3
- data/lib/ramaze/snippets/string/end_with.rb +20 -0
- data/lib/ramaze/snippets/string/esc.rb +26 -21
- data/lib/ramaze/snippets/string/ord.rb +12 -6
- data/lib/ramaze/snippets/string/snake_case.rb +13 -7
- data/lib/ramaze/snippets/string/start_with.rb +16 -5
- data/lib/ramaze/snippets/string/unindent.rb +23 -15
- data/lib/ramaze/snippets/thread/into.rb +3 -3
- data/lib/ramaze/spec/helper/bacon.rb +5 -5
- data/lib/ramaze/spec/helper/mock_http.rb +1 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +2 -2
- data/lib/ramaze/spec/helper/snippets.rb +8 -0
- data/lib/ramaze/template.rb +4 -1
- data/lib/ramaze/template/ezamar/textpow.syntax +34 -0
- data/lib/ramaze/template/maruku.rb +34 -0
- data/lib/ramaze/template/tagz.rb +2 -2
- data/lib/ramaze/template/xslt.rb +2 -2
- data/lib/ramaze/tool/create.rb +27 -53
- data/lib/ramaze/tool/localize.rb +8 -4
- data/lib/ramaze/tool/mime.rb +11 -1
- data/lib/ramaze/tool/project_creator.rb +110 -0
- data/lib/ramaze/trinity.rb +4 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/vendor/bacon.rb +323 -0
- data/rake_tasks/gem.rake +10 -1
- data/rake_tasks/maintenance.rake +40 -2
- data/rake_tasks/metric.rake +24 -0
- data/rake_tasks/release.rake +17 -4
- data/rake_tasks/spec.rake +1 -2
- data/ramaze.gemspec +549 -495
- data/spec/contrib/auto_params.rb +3 -3
- data/spec/contrib/profiling.rb +2 -2
- data/spec/examples/simple_auth.rb +2 -2
- data/spec/examples/templates/template_haml.rb +0 -2
- data/spec/ramaze/action/file_cache.rb +22 -0
- data/spec/ramaze/adapter.rb +2 -2
- data/spec/ramaze/controller/actionless_templates.rb +1 -1
- data/spec/ramaze/controller/subclass.rb +15 -0
- data/spec/ramaze/controller/template_resolving.rb +1 -1
- data/spec/ramaze/controller/view/bar.xhtml +1 -0
- data/spec/ramaze/controller/view/base/another.xhtml +1 -0
- data/spec/ramaze/current/session.rb +1 -1
- data/spec/ramaze/dispatcher/file.rb +2 -2
- data/spec/ramaze/helper/aspect.rb +26 -17
- data/spec/ramaze/helper/formatting.rb +13 -0
- data/spec/ramaze/log/informer.rb +10 -10
- data/spec/ramaze/log/syslog.rb +67 -4
- data/spec/ramaze/rewrite.rb +1 -1
- data/spec/ramaze/route.rb +1 -1
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/tagz.rb +1 -1
- data/spec/snippets/binding/locals.rb +9 -0
- data/spec/snippets/numeric/time.rb +12 -0
- data/spec/snippets/{kernel → object}/__dir__.rb +0 -0
- data/spec/snippets/{kernel → object}/acquire.rb +0 -0
- metadata +90 -81
- data/cache.yaml +0 -7
- data/examples/app/rammit/spec/rammit.rb +0 -31
- data/examples/app/rammit/src/controller/main.rb +0 -3
- data/examples/app/rammit/src/controller/page.rb +0 -16
- data/examples/app/rammit/src/model.rb +0 -33
- data/examples/app/rammit/start.rb +0 -8
- data/examples/app/rammit/template/index.xhtml +0 -14
- data/examples/app/rammit/template/page/view.xhtml +0 -4
- data/lib/ramaze/snippets/kernel/__dir__.rb +0 -23
- data/lib/ramaze/snippets/kernel/acquire.rb +0 -34
- data/lib/ramaze/snippets/object/thread_accessor.rb +0 -5
- data/lib/ramaze/snippets/ramaze/thread_accessor.rb +0 -58
- data/lib/ramaze/snippets/struct/fill.rb +0 -23
- data/lib/ramaze/snippets/struct/values_at.rb +0 -39
- data/lib/ramaze/snippets/symbol/to_proc.rb +0 -24
- data/lib/ramaze/sourcereload.rb +0 -176
- data/spec/snippets/struct/fill.rb +0 -26
- data/spec/snippets/struct/values_at.rb +0 -52
- data/spec/snippets/symbol/to_proc.rb +0 -13
data/spec/contrib/auto_params.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'spec/helper'
|
2
|
-
spec_require 'ruby2ruby'
|
2
|
+
spec_require 'parse_tree', 'ruby2ruby'
|
3
3
|
|
4
4
|
Ramaze.contrib :auto_params
|
5
5
|
|
@@ -100,7 +100,7 @@ describe 'Parameterized actions' do
|
|
100
100
|
end if method(:puts).respond_to? :get_args
|
101
101
|
|
102
102
|
describe 'Normal behavior' do
|
103
|
-
|
103
|
+
behaves_like 'http'
|
104
104
|
ramaze
|
105
105
|
|
106
106
|
it 'should work with no arguments' do
|
@@ -108,7 +108,7 @@ describe 'Normal behavior' do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'should raise no action' do
|
111
|
-
get('/none').body.should =~
|
111
|
+
get('/none').body.should =~ /No Action found/
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'should work with included actions' do
|
data/spec/contrib/profiling.rb
CHANGED
@@ -11,7 +11,7 @@ class MainController < Ramaze::Controller
|
|
11
11
|
end
|
12
12
|
|
13
13
|
output = StringIO.new
|
14
|
-
Ramaze::Log.loggers << Ramaze::
|
14
|
+
Ramaze::Log.loggers << Ramaze::Logger::Informer.new(output)
|
15
15
|
|
16
16
|
describe 'Profiling' do
|
17
17
|
behaves_like "http"
|
@@ -19,7 +19,7 @@ describe 'Profiling' do
|
|
19
19
|
|
20
20
|
it "should profile" do
|
21
21
|
output = StringIO.new
|
22
|
-
Ramaze::Log.loggers << Ramaze::
|
22
|
+
Ramaze::Log.loggers << Ramaze::Logger::Informer.new(output)
|
23
23
|
|
24
24
|
get('/')
|
25
25
|
output.string.should =~ /Thread ID:\s\d+/
|
@@ -7,12 +7,12 @@ describe "SimpleAuth" do
|
|
7
7
|
|
8
8
|
it 'should show start page' do
|
9
9
|
Browser.new do
|
10
|
-
http.basic_authentication "
|
10
|
+
http.basic_authentication "jill", "password1"
|
11
11
|
get('/').should == "Secret Info"
|
12
12
|
end
|
13
13
|
|
14
14
|
Browser.new do
|
15
|
-
http.basic_authentication "
|
15
|
+
http.basic_authentication "jack", "password2"
|
16
16
|
get('/').should == "Secret Info"
|
17
17
|
end
|
18
18
|
end
|
@@ -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
|
data/spec/ramaze/adapter.rb
CHANGED
@@ -12,7 +12,7 @@ class TCAdapterController < Ramaze::Controller
|
|
12
12
|
end
|
13
13
|
|
14
14
|
$output = StringIO.new
|
15
|
-
Ramaze::Log.loggers << Ramaze::
|
15
|
+
Ramaze::Log.loggers << Ramaze::Logger::Informer.new($output)
|
16
16
|
|
17
17
|
describe "Adapter" do
|
18
18
|
ramaze ramaze_options ||= {}
|
@@ -46,4 +46,4 @@ describe "Adapter" do
|
|
46
46
|
ret.status.should == 200
|
47
47
|
ret.body.should == 'i am before'
|
48
48
|
end
|
49
|
-
end
|
49
|
+
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
|
@@ -0,0 +1 @@
|
|
1
|
+
bar
|
@@ -0,0 +1 @@
|
|
1
|
+
another
|
@@ -37,7 +37,7 @@ describe 'Dispatcher::File' do
|
|
37
37
|
it 'should send Last-Modified' do
|
38
38
|
res = get '/test_download.css'
|
39
39
|
res.headers['Last-Modified'].should.not.be == nil
|
40
|
-
res.headers['Last-Modified'].should == File.
|
40
|
+
res.headers['Last-Modified'].should == File.mtime(@public_root/'test_download.css').httpdate
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should respect ETag with IF_NONE_MATCHES' do
|
@@ -57,4 +57,4 @@ describe 'Dispatcher::File' do
|
|
57
57
|
res.status.should == 304
|
58
58
|
res.body.should == ''
|
59
59
|
end
|
60
|
-
end
|
60
|
+
end
|
@@ -8,14 +8,14 @@ class TCAspectController < Ramaze::Controller
|
|
8
8
|
trait :foo => :bar
|
9
9
|
helper :aspect
|
10
10
|
|
11
|
-
def test_before()
|
12
|
-
before(:test_before){
|
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()
|
15
|
-
after(:test_after){
|
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){
|
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{
|
33
|
-
after_all{
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
71
|
+
$helper_aspect_spec_all.should == 42
|
72
|
+
|
73
|
+
$helper_aspect_spec_all = nil
|
69
74
|
get('/all/test_all_second')
|
70
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
99
|
+
$helper_aspect_spec_all.should == 42
|
91
100
|
end
|
92
101
|
end
|
@@ -26,6 +26,11 @@ describe 'Helper::Formatting' do
|
|
26
26
|
"<a href=\"http://ramaze.net\" target='_blank'>http://ramaze.net</a>"
|
27
27
|
end
|
28
28
|
|
29
|
+
it 'should auto_link urls, setting the result of the given block as the link text' do
|
30
|
+
auto_link('http://ramaze.net rocks, so does http://rubyonrails.org.') { |url| url.sub!(%r{http://}, '') }.should ==
|
31
|
+
'<a href="http://ramaze.net">ramaze.net</a> rocks, so does <a href="http://rubyonrails.org">rubyonrails.org</a>.'
|
32
|
+
end
|
33
|
+
|
29
34
|
should 'ordinalize numbers' do
|
30
35
|
ordinal(1).should == '1st'
|
31
36
|
ordinal(2).should == '2nd'
|
@@ -38,4 +43,12 @@ describe 'Helper::Formatting' do
|
|
38
43
|
ordinal(100).should == '100th'
|
39
44
|
ordinal(133).should == '133rd'
|
40
45
|
end
|
46
|
+
|
47
|
+
should 'generate tagclouds' do
|
48
|
+
tags = %w[ruby ruby code ramaze]
|
49
|
+
tagcloud(tags).should ==
|
50
|
+
{"code"=>0.75, "ramaze"=>0.75, "ruby"=>1.0}
|
51
|
+
tagcloud(tags, 0.5, 2.0).should ==
|
52
|
+
{"code"=>0.875, "ramaze"=>0.875, "ruby"=>1.25}
|
53
|
+
end
|
41
54
|
end
|
data/spec/ramaze/log/informer.rb
CHANGED
@@ -4,8 +4,8 @@ describe 'Informer' do
|
|
4
4
|
before do
|
5
5
|
@out = []
|
6
6
|
def @out.puts(*args) push(*args) end
|
7
|
-
Ramaze::
|
8
|
-
@inform = Ramaze::
|
7
|
+
Ramaze::Logger::Informer.trait[:colorize] = false
|
8
|
+
@inform = Ramaze::Logger::Informer.new(@out)
|
9
9
|
end
|
10
10
|
|
11
11
|
def format(tag, string)
|
@@ -39,27 +39,27 @@ describe 'Informer' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should choose stdout on init(stdout,:stdout,STDOUT)' do
|
42
|
-
a = Ramaze::
|
43
|
-
b = Ramaze::
|
44
|
-
c = Ramaze::
|
42
|
+
a = Ramaze::Logger::Informer.new(STDOUT)
|
43
|
+
b = Ramaze::Logger::Informer.new(:stdout)
|
44
|
+
c = Ramaze::Logger::Informer.new('stdout')
|
45
45
|
[a,b,c].each { |x| x.out.should == $stdout}
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should choose stderr on init(stderr,:stderr,STDERR)' do
|
49
|
-
a = Ramaze::
|
50
|
-
b = Ramaze::
|
51
|
-
c = Ramaze::
|
49
|
+
a = Ramaze::Logger::Informer.new(STDERR)
|
50
|
+
b = Ramaze::Logger::Informer.new(:stderr)
|
51
|
+
c = Ramaze::Logger::Informer.new('stderr')
|
52
52
|
[a,b,c].each { |x| x.out.should == $stderr}
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should use IO when supplied' do
|
56
|
-
i = Ramaze::
|
56
|
+
i = Ramaze::Logger::Informer.new(s = StringIO.new)
|
57
57
|
i.out.should == s
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should open file otherwise' do
|
61
61
|
begin
|
62
|
-
i = Ramaze::
|
62
|
+
i = Ramaze::Logger::Informer.new('tmp.dummy')
|
63
63
|
out = i.out
|
64
64
|
out.should.be.instance_of(File)
|
65
65
|
out.path.should == 'tmp.dummy'
|
data/spec/ramaze/log/syslog.rb
CHANGED
@@ -1,10 +1,73 @@
|
|
1
|
+
# Copyright (c) 2008 rob@rebeltechnologies.nl
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
1
4
|
require 'spec/helper'
|
2
5
|
|
3
6
|
require 'ramaze/log/syslog'
|
4
7
|
|
5
8
|
describe 'Syslog' do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
|
10
|
+
# close the syslog, if it was open for some reason before we
|
11
|
+
# start a test.
|
12
|
+
before do
|
13
|
+
if ( Syslog.opened? )
|
14
|
+
::Syslog.close
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should default initialize correctly' do
|
19
|
+
syslog = Ramaze::Logger::Syslog.new
|
20
|
+
::Syslog.opened?.should == true
|
21
|
+
::Syslog.ident.should == $0
|
22
|
+
::Syslog.options.should == ( ::Syslog::LOG_PID | ::Syslog::LOG_CONS )
|
23
|
+
::Syslog.facility.should == ::Syslog::LOG_USER
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should handle non default initialization' do
|
27
|
+
syslog = Ramaze::Logger::Syslog.new( 'ramaze_syslog_test',
|
28
|
+
::Syslog::LOG_NDELAY | ::Syslog::LOG_NOWAIT,
|
29
|
+
::Syslog::LOG_DAEMON )
|
30
|
+
::Syslog.opened?.should == true
|
31
|
+
::Syslog.ident.should == 'ramaze_syslog_test'
|
32
|
+
::Syslog.options.should == ( ::Syslog::LOG_NDELAY | ::Syslog::LOG_NOWAIT )
|
33
|
+
::Syslog.facility.should == ::Syslog::LOG_DAEMON
|
34
|
+
end
|
35
|
+
|
36
|
+
# We test the actual logging using a trick found in te test code of the
|
37
|
+
# syslog module. We create a pipe, fork a child, reroute the childs
|
38
|
+
# stderr to the pipe. Then we open the logging using LOG_PERROR, so all
|
39
|
+
# log messages are written to stderror. In the parent we read the messages
|
40
|
+
# from the pipe and compare them to what we expected.
|
41
|
+
def test_log_msg( type, priority, msg )
|
42
|
+
logpipe = IO::pipe
|
43
|
+
child = fork {
|
44
|
+
logpipe[0].close
|
45
|
+
STDERR.reopen(logpipe[1])
|
46
|
+
syslog = Ramaze::Logger::Syslog.new( 'ramaze_syslog_test',
|
47
|
+
::Syslog::LOG_PID | ::Syslog::LOG_NDELAY | ::Syslog::LOG_PERROR,
|
48
|
+
::Syslog::LOG_USER )
|
49
|
+
syslog.send priority, msg
|
50
|
+
Process.exit!( 0 )
|
51
|
+
}
|
52
|
+
logpipe[1].close
|
53
|
+
Process.waitpid(child)
|
54
|
+
|
55
|
+
logpipe[0].gets.should == "ramaze_syslog_test[#{child}]: #{msg}\n"
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should handle debug' do
|
59
|
+
test_log_msg :direct, :debug, "Hello Debug World"
|
60
|
+
end
|
61
|
+
it 'should handle dev' do
|
62
|
+
test_log_msg :direct, :dev, "Hello Dev World"
|
63
|
+
end
|
64
|
+
it 'should handle info' do
|
65
|
+
test_log_msg :direct, :info, 'Hello Info World!'
|
66
|
+
end
|
67
|
+
it 'should handle warn' do
|
68
|
+
test_log_msg :direct, :warn, 'Hello Warn World!'
|
69
|
+
end
|
70
|
+
it 'should handle error' do
|
71
|
+
test_log_msg :direct, :error, 'Hello Error World!'
|
72
|
+
end
|
10
73
|
end
|
data/spec/ramaze/rewrite.rb
CHANGED